Merge "DO NOT MERGE initial add sts to build" into nyc-dev am: b20486d397 am: 41a57745a4 am: 5a37ad8d6b am: cf5f702e19
am: 5da13164a3  -s ours

Change-Id: If732481d7a5f8122e5a75b1aa692f7065bc69b54
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..a1455d4
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,8 @@
+LOCAL_PATH := $(call my-dir)
+
+# We're relocating the build project to a subdirectory, then using symlinks
+# to expose the subdirectories where they used to be. If the manifest hasn't
+# been updated, we need to include all the subdirectories.
+ifeq ($(LOCAL_PATH),build)
+include $(call first-makefiles-under,$(LOCAL_PATH))
+endif
diff --git a/CleanSpec.mk b/CleanSpec.mk
index a97c71a..88f9172 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -378,6 +378,45 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/*)
 
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_packages.txt)
+
+$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES)/include)
+
+$(call add-clean-step, rm -rf $(HOST_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
+$(call add-clean-step, rm -rf $(HOST_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_gen_java_config.mk)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/current_gen_java_config.mk)
+
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*/package-res.apk)
+$(call add-clean-step, rm -rf $(TARGET_OUT_INTERMEDIATES)/APPS/*/package-res.apk)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
+$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
+
+$(call add-clean-step, rm -rf $(HOST_OUT_TESTCASES))
+$(call add-clean-step, rm -rf $(TARGET_OUT_TESTCASES))
+
+$(call add-clean-step, rm -rf $(TARGET_OUT_ETC)/init)
+
+# Libraries are moved from {system|vendor}/lib to ./lib/framework, ./lib/vndk, etc.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
+
+# Revert that move
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
+
+# Sanitized libraries now live in a different location.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/lib*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/vendor/lib*)
+
+# Soong module variant change, remove obsolete intermediates
+$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/buildspec.mk.default b/buildspec.mk.default
index d14208e..b31578a 100644
--- a/buildspec.mk.default
+++ b/buildspec.mk.default
@@ -36,6 +36,12 @@
 #TARGET_BUILD_VARIANT:=eng
 endif
 
+# Choose a targeted release.  If you don't pick one, the default is the
+# soonest future release.
+ifndef TARGET_PLATFORM_RELEASE
+#TARGET_PLATFORM_RELEASE:=OPR1
+endif
+
 # Choose additional targets to always install, even when building
 # minimal targets like "make droid".  This takes simple target names
 # like "Browser" or "MyApp", the names used by LOCAL_MODULE or
@@ -61,9 +67,6 @@
 # will be added to LOCAL_CFLAGS when building the module.
 #DEBUG_MODULE_ModuleName:=true
 
-# Specify an alternative tool chain prefix if needed.
-#TARGET_TOOLS_PREFIX:=
-
 # Specify the extra CFLAGS to use when building a module whose
 # DEBUG_MODULE_ variable is set.  Host and device flags are handled
 # separately.
@@ -108,4 +111,4 @@
 # variable will be changed.  After you have modified this file with the new
 # changes (see buildspec.mk.default), update this to the new value from
 # buildspec.mk.default.
-BUILD_ENV_SEQUENCE_NUMBER := 10
+BUILD_ENV_SEQUENCE_NUMBER := 13
diff --git a/core/Makefile b/core/Makefile
index cf39a8b..fc4f907 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -5,7 +5,7 @@
 LOCAL_PATH := $(BUILD_SYSTEM)
 
 # Pick a reasonable string to use to identify files.
-ifneq "" "$(filter eng.%,$(BUILD_NUMBER))"
+ifneq (,$(filter eng.%,$(BUILD_NUMBER)))
   # BUILD_NUMBER has a timestamp in it, which means that
   # it will change every time.  Pick a stable value.
   FILE_NAME_TAG := eng.$(USER)
@@ -71,25 +71,43 @@
 endif
 
 # -----------------------------------------------------------------
-# default.prop
+# property_overrides_split_enabled
+property_overrides_split_enabled :=
+ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
+  property_overrides_split_enabled := true
+endif
+
+# -----------------------------------------------------------------
+# prop.default
+ifdef property_overrides_split_enabled
+INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_OUT)/etc/prop.default
+INSTALLED_DEFAULT_PROP_OLD_TARGET := $(TARGET_ROOT_OUT)/default.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
+$(INSTALLED_DEFAULT_PROP_OLD_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
+else
+# legacy path
 INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop
+endif
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET)
-ADDITIONAL_DEFAULT_PROPERTIES := \
+FINAL_DEFAULT_PROPERTIES := \
     $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES))
-ADDITIONAL_DEFAULT_PROPERTIES += \
-    $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
-ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
-    $(ADDITIONAL_DEFAULT_PROPERTIES),=)
+ifndef property_overrides_split_enabled
+  FINAL_DEFAULT_PROPERTIES += \
+      $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+endif
+FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(FINAL_DEFAULT_PROPERTIES),=)
 
 intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
 
 $(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop)
 	@echo Target buildinfo: $@
 	@mkdir -p $(dir $@)
+	@rm -f $@
 	$(hide) echo "#" > $@; \
 	        echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \
 	        echo "#" >> $@;
-	$(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \
+	$(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \
 		echo "$(line)" >> $@;)
 	$(hide) echo "#" >> $@; \
 	        echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \
@@ -98,15 +116,43 @@
 	$(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
 	$(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
 	$(hide) build/tools/post_process_props.py $@
+ifdef property_overrides_split_enabled
+	$(hide) mkdir -p $(TARGET_ROOT_OUT)
+	$(hide) ln -sf system/etc/prop.default $(INSTALLED_DEFAULT_PROP_OLD_TARGET)
+endif
+
+# -----------------------------------------------------------------
+# vendor default.prop
+INSTALLED_VENDOR_DEFAULT_PROP_TARGET :=
+ifdef property_overrides_split_enabled
+INSTALLED_VENDOR_DEFAULT_PROP_TARGET := $(TARGET_OUT_VENDOR)/default.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET)
+
+FINAL_VENDOR_DEFAULT_PROPERTIES += \
+    $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+FINAL_VENDOR_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(FINAL_VENDOR_DEFAULT_PROPERTIES),=)
+
+$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET): $(INSTALLED_DEFAULT_PROP_TARGET)
+	@echo Target buildinfo: $@
+	@mkdir -p $(dir $@)
+	$(hide) echo "#" > $@; \
+	        echo "# ADDITIONAL VENDOR DEFAULT PROPERTIES" >> $@; \
+	        echo "#" >> $@;
+	$(hide) $(foreach line,$(FINAL_VENDOR_DEFAULT_PROPERTIES), \
+		echo "$(line)" >> $@;)
+	$(hide) build/tools/post_process_props.py $@
+
+endif  # property_overrides_split_enabled
 
 # -----------------------------------------------------------------
 # build.prop
 INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
-ADDITIONAL_BUILD_PROPERTIES := \
+FINAL_BUILD_PROPERTIES := \
     $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))
-ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
-    $(ADDITIONAL_BUILD_PROPERTIES),=)
+FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(FINAL_BUILD_PROPERTIES),=)
 
 # A list of arbitrary tags describing the build configuration.
 # Force ":=" so we can use +=
@@ -171,7 +217,7 @@
   # release build number or branch.buld_number non-release builds
 
   # Dev. branches should have DISPLAY_BUILD_NUMBER set
-  ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
+  ifeq (true,$(DISPLAY_BUILD_NUMBER))
     BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS)
   else
     BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS)
@@ -190,6 +236,7 @@
 endef
 
 BUILDINFO_SH := build/tools/buildinfo.sh
+VENDOR_BUILDINFO_SH := build/tools/vendor_buildinfo.sh
 
 # TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test harness to distinguish builds.
 TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
@@ -202,7 +249,7 @@
 else
 system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
 endif
-$(intermediate_system_build_prop): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET)
+$(intermediate_system_build_prop): $(VENDOR_BUILDINFO_SH) $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET)
 	@echo Target buildinfo: $@
 	@mkdir -p $(dir $@)
 	$(hide) echo > $@
@@ -237,10 +284,8 @@
 			PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \
 			PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \
 			BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
-			TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
 			BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \
 			$(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \
-			TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
 			TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \
 			TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \
 			TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \
@@ -248,6 +293,11 @@
 			TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \
 			TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \
 	        bash $(BUILDINFO_SH) >> $@
+ifndef property_overrides_split_enabled
+	$(hide) TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
+			TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
+	        bash $(VENDOR_BUILDINFO_SH) >> $@
+endif
 	$(hide) $(foreach file,$(system_prop_file), \
 		if [ -f "$(file)" ]; then \
 			echo "#" >> $@; \
@@ -256,12 +306,12 @@
 			echo "#" >> $@; \
 			cat $(file) >> $@; \
 		fi;)
-	$(if $(ADDITIONAL_BUILD_PROPERTIES), \
+	$(if $(FINAL_BUILD_PROPERTIES), \
 		$(hide) echo >> $@; \
 		        echo "#" >> $@; \
 		        echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \
 		        echo "#" >> $@; )
-	$(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \
+	$(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \
 		echo "$(line)" >> $@;)
 	$(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@
 	$(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST)
@@ -284,18 +334,37 @@
 # -----------------------------------------------------------------
 # vendor build.prop
 #
-# For verifying that the vendor build is what we thing it is
+# For verifying that the vendor build is what we think it is
 ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
 INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
 ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
-$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
+
+ifdef property_overrides_split_enabled
+FINAL_VENDOR_BUILD_PROPERTIES += \
+    $(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES))
+FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \
+    $(FINAL_VENDOR_BUILD_PROPERTIES),=)
+endif  # property_overrides_split_enabled
+
+$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(VENDOR_BUILDINFO_SH)
 	@echo Target vendor buildinfo: $@
 	@mkdir -p $(dir $@)
 	$(hide) echo > $@
 	$(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@
 	$(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@
 	$(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@
-endif
+ifdef property_overrides_split_enabled
+	$(hide) TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
+			TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
+	        bash $(VENDOR_BUILDINFO_SH) >> $@
+	$(hide) echo "#" >> $@; \
+	        echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
+	        echo "#" >> $@;
+	$(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
+		echo "$(line)" >> $@;)
+	$(hide) build/tools/post_process_props.py $@
+endif  # property_overrides_split_enabled
+endif  # BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
 
 # ----------------------------------------------------------------
 
@@ -386,7 +455,31 @@
 endif
 
 # -----------------------------------------------------------------
+# build system stats
+BUILD_SYSTEM_STATS := $(PRODUCT_OUT)/build_system_stats.txt
+$(BUILD_SYSTEM_STATS):
+	@rm -f $@
+	@$(foreach s,$(STATS.MODULE_TYPE),echo "modules_type_make,$(s),$(words $(STATS.MODULE_TYPE.$(s)))" >>$@;)
+	@$(foreach s,$(STATS.SOONG_MODULE_TYPE),echo "modules_type_soong,$(s),$(STATS.SOONG_MODULE_TYPE.$(s))" >>$@;)
+$(call dist-for-goals,droidcore,$(BUILD_SYSTEM_STATS))
 
+# -----------------------------------------------------------------
+# Modules ready to be converted to Soong, ordered by how many
+# modules depend on them.
+SOONG_CONV := $(sort $(SOONG_CONV))
+SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
+$(SOONG_CONV_DATA):
+	@rm -f $@
+	@$(foreach s,$(SOONG_CONV),echo "$(s),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS)))" >>$@;)
+
+SOONG_TO_CONVERT_SCRIPT := build/tools/soong_to_convert.py
+SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
+$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
+	@rm -f $@
+	$(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
+$(call dist-for-goals,droidcore,$(SOONG_TO_CONVERT))
+
+# -----------------------------------------------------------------
 # The dev key is used to sign this package, and as the key required
 # for future OTA packages installed by this system.  Actual product
 # deliverables will be re-signed by hand.  We expect this file to
@@ -420,9 +513,9 @@
 pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES)))
 
 $(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
-$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file)
+$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/tools/event_log_tags.py
 	$(hide) mkdir -p $(dir $@)
-	$(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES)
+	$(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
 
 # Include tags from all packages included in this product, plus all
 # tags that are part of the system (ie, not in a vendor/ or device/
@@ -436,9 +529,9 @@
 
 $(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file)
 $(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file)
-$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file)
+$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) $(MERGETAGS) build/tools/event_log_tags.py
 	$(hide) mkdir -p $(dir $@)
-	$(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
+	$(hide) $(MERGETAGS) -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES)
 
 event-log-tags: $(event_log_tags_file)
 
@@ -468,7 +561,6 @@
 # -----------------------------------------------------------------
 # the ramdisk
 INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
-	$(ALL_PREBUILT) \
 	$(ALL_GENERATED_SOURCES) \
 	$(ALL_DEFAULT_INSTALLED_MODULES))
 
@@ -499,12 +591,10 @@
 
 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
@@ -516,9 +606,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 := \
@@ -538,7 +628,31 @@
 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: $@")
@@ -585,6 +699,7 @@
 endif # BOARD_USES_RECOVERY_AS_BOOT
 
 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.
@@ -607,13 +722,14 @@
 
 .PHONY: notice_files
 
-# Create the rule to combine the files into text and html forms
-# $(1) - Plain text output file
-# $(2) - HTML output file
-# $(3) - File title
-# $(4) - Directory to use.  Notice files are all $(4)/src.  Other
+# Create the rule to combine the files into text and html/xml forms
+# $(1) - xml_excluded_vendor|xml_vendor|html
+# $(2) - Plain text output file
+# $(3) - HTML/XML output file
+# $(4) - File title
+# $(5) - Directory to use.  Notice files are all $(4)/src.  Other
 #		 directories in there will be used for scratch
-# $(5) - Dependencies for the output files
+# $(6) - Dependencies for the output files
 #
 # The algorithm here is that we go collect a hash for each of the notice
 # files and write the names of the files that match that hash.  Then
@@ -627,12 +743,16 @@
 # original notice files instead of making rules to copy them somwehere.
 # Then we could traverse that without quite as much bash drama.
 define combine-notice-files
-$(1) $(2): PRIVATE_MESSAGE := $(3)
-$(1) $(2): PRIVATE_DIR := $(4)
-$(1) : $(2)
-$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
-	build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src
-notice_files: $(1) $(2)
+$(2) $(3): PRIVATE_MESSAGE := $(4)
+$(2) $(3): PRIVATE_DIR := $(5)
+$(2) : $(3)
+$(3) : $(6) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py
+	build/tools/generate-notice-files.py --text-output $(2) \
+		$(if $(filter $(1),xml_excluded_vendor),-e vendor --xml-output, \
+		  $(if $(filter $(1),xml_vendor),-i vendor --xml-output, \
+		    --html-output)) $(3) \
+		-t $$(PRIVATE_MESSAGE) -s $$(PRIVATE_DIR)/src
+notice_files: $(2) $(3)
 endef
 
 # TODO These intermediate NOTICE.txt/NOTICE.html files should go into
@@ -640,43 +760,82 @@
 # the src subdirectory.
 
 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
-target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
-target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
+target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
+target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
+installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
 
+ifeq ($(PRODUCT_FULL_TREBLE),true)
+target_notice_file_html_or_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
+target_notice_file_html_or_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
+installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
+
+target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
+target_vendor_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml
+target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
+installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
+endif
+
 ifndef TARGET_BUILD_APPS
 kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
+winpthreads_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/winpthreads.txt
 pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES))
 
-$(eval $(call combine-notice-files, \
+ifdef target_vendor_notice_file_xml_gz
+$(eval $(call combine-notice-files, xml_excluded_vendor, \
 			$(target_notice_file_txt), \
-			$(target_notice_file_html), \
+			$(target_notice_file_html_or_xml), \
 			"Notices for files contained in the filesystem images in this directory:", \
 			$(TARGET_OUT_NOTICE_FILES), \
 			$(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
+$(eval $(call combine-notice-files, xml_vendor, \
+			$(target_vendor_notice_file_txt), \
+			$(target_vendor_notice_file_xml), \
+			"Notices for files contained in the vendor filesystem image in this directory:", \
+			$(TARGET_OUT_NOTICE_FILES), \
+			$(target_notice_file_html_or_xml)))
+else
+$(eval $(call combine-notice-files, html, \
+			$(target_notice_file_txt), \
+			$(target_notice_file_html_or_xml), \
+			"Notices for files contained in the filesystem images in this directory:", \
+			$(TARGET_OUT_NOTICE_FILES), \
+			$(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files)))
+endif
 
-$(eval $(call combine-notice-files, \
+$(eval $(call combine-notice-files, html, \
 			$(tools_notice_file_txt), \
 			$(tools_notice_file_html), \
 			"Notices for files contained in the tools directory:", \
 			$(HOST_OUT_NOTICE_FILES), \
-			$(ALL_DEFAULT_INSTALLED_MODULES)))
+			$(ALL_DEFAULT_INSTALLED_MODULES) \
+			$(winpthreads_notice_file)))
 
 # Install the html file at /system/etc/NOTICE.html.gz.
 # This is not ideal, but this is very late in the game, after a lot of
 # the module processing has already been done -- in fact, we used the
 # fact that all that has been done to get the list of modules that we
 # need notice files for.
-$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
+$(target_notice_file_html_or_xml_gz): $(target_notice_file_html_or_xml) | $(MINIGZIP)
 	$(hide) $(MINIGZIP) -9 < $< > $@
-installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
-$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
+$(installed_notice_html_or_xml_gz): $(target_notice_file_html_or_xml_gz)
 	$(copy-file-to-target)
 
+ifdef target_vendor_notice_file_xml_gz
+# Install the vendor html file at /vendor/etc/NOTICE.xml.gz.
+$(target_vendor_notice_file_xml_gz): $(target_vendor_notice_file_xml) | $(MINIGZIP)
+	$(hide) $(MINIGZIP) -9 < $< > $@
+$(installed_vendor_notice_xml_gz): $(target_vendor_notice_file_xml_gz)
+	$(copy-file-to-target)
+endif
+
 # if we've been run my mm, mmm, etc, don't reinstall this every time
 ifeq ($(ONE_SHOT_MAKEFILE),)
-ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
+  ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
+  ifdef target_vendor_notice_file_xml_gz
+    ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
+  endif
 endif
 endif  # TARGET_BUILD_APPS
 
@@ -690,6 +849,12 @@
 	$(hide) mkdir -p $(dir $@)
 	$(hide) $(ACP) $< $@
 
+$(winpthreads_notice_file): \
+	    $(BUILD_SYSTEM)/WINPTHREADS_COPYING \
+	    | $(ACP)
+	@echo Copying: $@
+	$(hide) mkdir -p $(dir $@)
+	$(hide) $(ACP) $< $@
 
 # -----------------------------------------------------------------
 # Build a keystore with the authorized keys in it, used to verify the
@@ -781,14 +946,23 @@
 endif
 endif
 
-SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts.bin
+SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
 INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
 
 INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS)
 
+INTERNAL_USERIMAGES_DEPS += \
+    $(ALL_MODULES.fs_config_dirs.INSTALLED) \
+    $(ALL_MODULES.fs_config_files.INSTALLED) \
+
+ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true)
+INTERNAL_USERIMAGES_DEPS += $(MKE2FS_CONF)
+endif
+
 # $(1): the path of the output dictionary file
 # $(2): additional "key=value" pairs to append to the dictionary file.
 define generate-userimage-prop-dictionary
+$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
 $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1))
 $(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
 $(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
@@ -803,6 +977,8 @@
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM)" >> $(1))
 $(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
 $(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
+$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
+$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
 $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
 $(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
 $(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
@@ -832,6 +1008,12 @@
 $(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=$(notdir $(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 $(BOARD_AVB_ENABLE),$(hide) echo "vendor_avb_enable=$(BOARD_AVB_ENABLE)" >> $(1))
+$(if $(BOARD_AVB_ENABLE),$(hide) echo "vendor_avb_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_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)),\
@@ -850,10 +1032,22 @@
     $(ALL_DEFAULT_INSTALLED_MODULES))
 
 recovery_initrc := $(call include-path-for, recovery)/etc/init.rc
-recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery
+recovery_sepolicy := \
+    $(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
+    $(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
+    $(TARGET_RECOVERY_ROOT_OUT)/nonplat_file_contexts \
+    $(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
+    $(TARGET_RECOVERY_ROOT_OUT)/nonplat_property_contexts
+# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
+# SELinux files
+IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
+
 recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
-recovery_build_prop := $(intermediate_system_build_prop)
+recovery_build_props := $(intermediate_system_build_prop)
+ifdef property_overrides_split_enabled
+recovery_build_props += $(INSTALLED_VENDOR_BUILD_PROP_TARGET)
+endif
 recovery_resources_common := $(call include-path-for, recovery)/res
 
 # Set recovery_density to the density bucket of the device.
@@ -932,13 +1126,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
@@ -962,18 +1155,36 @@
 	java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
 
 RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id
+
+# $(1): modules list
+# $(2): output dir
+# $(3): mount point
+# $(4): staging dir
+# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
+define build-image-kernel-modules
+    $(hide) rm -rf $(2)/lib/modules
+    $(hide) mkdir -p $(2)/lib/modules
+    $(hide) cp $(1) $(2)/lib/modules/
+    $(hide) rm -rf $(4)
+    $(hide) mkdir -p $(4)/lib/modules/0.0/$(3)lib/modules
+    $(hide) cp $(1) $(4)/lib/modules/0.0/$(3)lib/modules
+    $(hide) $(DEPMOD) -b $(4) 0.0
+    $(hide) sed -e 's/\(.*modules.*\):/\/\1:/g' -e 's/ \([^ ]*modules[^ ]*\)/ \/\1/g' $(4)/lib/modules/0.0/modules.dep > $(2)/lib/modules/modules.dep
+endef
+
 # $(1): output file
 define build-recoveryimage-target
   @echo ----- Making recovery image ------
   $(hide) mkdir -p $(TARGET_RECOVERY_OUT)
   $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
   @echo Copying baseline ramdisk...
-  $(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac.
+  # Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
+  $(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
   @echo Modifying ramdisk contents...
+  $(if $(BOARD_RECOVERY_KERNEL_MODULES), \
+    $(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery)))
   $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
   $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
-  $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
-  $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy
   $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist.
   $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
   $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
@@ -986,8 +1197,14 @@
   $(if $(strip $(recovery_wipe)), \
     $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe)
   $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
-  $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
-          > $(TARGET_RECOVERY_ROOT_OUT)/default.prop
+  $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) \
+          > $(TARGET_RECOVERY_ROOT_OUT)/prop.default
+  $(if $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET), \
+    $(hide) cat $(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
+            >> $(TARGET_RECOVERY_ROOT_OUT)/prop.default)
+  $(hide) cat $(recovery_build_props) \
+          >> $(TARGET_RECOVERY_ROOT_OUT)/prop.default
+  $(hide) ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
   $(BOARD_RECOVERY_IMAGE_PREPARE)
   $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \
     $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \
@@ -1005,6 +1222,12 @@
   )
   $(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)))
@@ -1023,9 +1246,12 @@
 		$(INTERNAL_RECOVERYIMAGE_FILES) \
 		$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
 		$(INSTALLED_2NDBOOTLOADER_TARGET) \
-		$(recovery_build_prop) $(recovery_resource_deps) \
+		$(recovery_build_props) $(recovery_resource_deps) \
 		$(recovery_fstab) \
-		$(RECOVERY_INSTALL_OTA_KEYS)
+		$(RECOVERY_INSTALL_OTA_KEYS) \
+		$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
+		$(BOARD_RECOVERY_KERNEL_MODULES) \
+		$(DEPMOD)
 		$(call pretty,"Target boot image from recovery: $@")
 		$(call build-recoveryimage-target, $@)
 endif
@@ -1036,9 +1262,12 @@
 		$(INTERNAL_RECOVERYIMAGE_FILES) \
 		$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
 		$(INSTALLED_2NDBOOTLOADER_TARGET) \
-		$(recovery_build_prop) $(recovery_resource_deps) \
+		$(recovery_build_props) $(recovery_resource_deps) \
 		$(recovery_fstab) \
-		$(RECOVERY_INSTALL_OTA_KEYS)
+		$(RECOVERY_INSTALL_OTA_KEYS) \
+		$(INSTALLED_VENDOR_DEFAULT_PROP_TARGET) \
+		$(BOARD_RECOVERY_KERNEL_MODULES) \
+		$(DEPMOD)
 		$(call build-recoveryimage-target, $@)
 
 ifdef RECOVERY_RESOURCE_ZIP
@@ -1077,7 +1306,6 @@
         $(ALL_PDK_FUSION_FILES))
 
 INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \
-    $(ALL_PREBUILT) \
     $(ALL_GENERATED_SOURCES) \
     $(ALL_DEFAULT_INSTALLED_MODULES) \
     $(PDK_FUSION_SYSIMG_FILES) \
@@ -1085,6 +1313,15 @@
 
 
 FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
+
+# ASAN libraries in the system image - add dependency.
+ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
+ifneq (,$(SANITIZE_TARGET))
+  ifeq (true,$(SANITIZE_TARGET_SYSTEM))
+    FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
+  endif
+endif
+
 # -----------------------------------------------------------------
 # installed file list
 # Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
@@ -1092,11 +1329,11 @@
 # so that we can get the size stat even if the build fails due to too large
 # system image.
 INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
-$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS)
+$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST)
 	@echo Installed file list: $@
 	@mkdir -p $(dir $@)
 	@rm -f $@
-	$(hide) build/tools/fileslist.py $(TARGET_OUT) > $(@:.txt=.json)
+	$(hide) $(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
 	$(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
 
 .PHONY: installed-file-list
@@ -1148,7 +1385,7 @@
            exit 1 )
 endef
 
-$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
+$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
 	$(call build-systemimage-target,$@)
 
 INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img
@@ -1176,7 +1413,7 @@
 endif
 
 
-$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP)
+$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH)
 	@echo "Install system fs image: $@"
 	$(copy-file-to-target)
 	$(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
@@ -1260,7 +1497,7 @@
 	  $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\
-	  $(hide) echo "PDK.DEXPREOPT.$(m).PROPRIETARY_MODULE:=$(DEXPREOPT.$(m).PROPRIETARY_MODULE)" >> $@$(newline)\
+	  $(hide) echo "PDK.DEXPREOPT.$(m).VENDOR_MODULE:=$(DEXPREOPT.$(m).VENDOR_MODULE)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\
 	  $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\
 	  )
@@ -1308,7 +1545,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)
@@ -1361,8 +1598,11 @@
 
 # We just build this directly to the install location.
 INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
-$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \
-                                   $(INTERNAL_USERDATAIMAGE_FILES)
+INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
+    $(INTERNAL_USERIMAGES_DEPS) \
+    $(INTERNAL_USERDATAIMAGE_FILES) \
+    $(BUILD_IMAGE_SRCS)
+$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
 	$(build-userdataimage-target)
 
 .PHONY: userdataimage-nodeps
@@ -1372,6 +1612,19 @@
 endif # not skip_userdata.img
 skip_userdata.img :=
 
+# ASAN libraries in the system image - build rule.
+ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
+  $(TARGET_OUT_SHARED_LIBRARIES) \
+  $(2ND_TARGET_OUT_SHARED_LIBRARIES) \
+  $(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
+  $(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
+# Extra options: Enforce the system user for the files to avoid having to change ownership.
+ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
+# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
+#       enough space.
+$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
+	tar cfj $(ASAN_IN_SYSTEM_INSTALLED) $(ASAN_SYSTEM_INSTALL_OPTIONS) -C $(TARGET_OUT_DATA)/.. $(ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL) >/dev/null
+
 #######
 ## data partition tarball
 define build-userdatatarball-target
@@ -1396,6 +1649,40 @@
 
 
 # -----------------------------------------------------------------
+# partition table image
+ifdef BOARD_BPT_INPUT_FILES
+
+BUILT_BPTIMAGE_TARGET := $(PRODUCT_OUT)/partition-table.img
+BUILT_BPTJSON_TARGET := $(PRODUCT_OUT)/partition-table.bpt
+
+INTERNAL_BVBTOOL_MAKE_TABLE_ARGS := \
+	--output_gpt $(BUILT_BPTIMAGE_TARGET) \
+	--output_json $(BUILT_BPTJSON_TARGET) \
+	$(foreach file, $(BOARD_BPT_INPUT_FILES), --input $(file))
+
+ifdef BOARD_BPT_DISK_SIZE
+INTERNAL_BVBTOOL_MAKE_TABLE_ARGS += --disk_size $(BOARD_BPT_DISK_SIZE)
+endif
+
+define build-bptimage-target
+  $(call pretty,"Target partition table image: $(INSTALLED_BPTIMAGE_TARGET)")
+  $(hide) $(BPTTOOL) make_table $(INTERNAL_BVBTOOL_MAKE_TABLE_ARGS) $(BOARD_BPT_MAKE_TABLE_ARGS)
+endef
+
+INSTALLED_BPTIMAGE_TARGET := $(BUILT_BPTIMAGE_TARGET)
+$(BUILT_BPTJSON_TARGET): $(INSTALLED_BPTIMAGE_TARGET)
+	$(hide) touch -c $(BUILT_BPTJSON_TARGET)
+
+$(INSTALLED_BPTIMAGE_TARGET): $(BPTTOOL) $(BOARD_BPT_INPUT_FILES)
+	$(build-bptimage-target)
+
+.PHONY: bptimage-nodeps
+bptimage-nodeps:
+	$(build-bptimage-target)
+
+endif # BOARD_BPT_INPUT_FILES
+
+# -----------------------------------------------------------------
 # cache partition image
 ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
 INTERNAL_CACHEIMAGE_FILES := \
@@ -1418,7 +1705,7 @@
 
 # We just build this directly to the install location.
 INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
-$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES)
+$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) $(BUILD_IMAGE_SRCS)
 	$(build-cacheimage-target)
 
 .PHONY: cacheimage-nodeps
@@ -1430,7 +1717,6 @@
 IGNORE_CACHE_LINK := --exclude=cache
 endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
 
-
 # -----------------------------------------------------------------
 # system_other partition image
 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
@@ -1450,11 +1736,12 @@
       $(ALL_PDK_FUSION_FILES))
 
 INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
-$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
+$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST)
 	@echo Installed file list: $@
 	@mkdir -p $(dir $@)
 	@rm -f $@
-	$(hide) build/tools/fileslist.py $(TARGET_OUT_SYSTEM_OTHER) > $@
+	$(hide) $(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
+	$(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
 
 systemotherimage_intermediates := \
     $(call intermediates-dir-for,PACKAGING,system_other)
@@ -1496,22 +1783,23 @@
 $(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES)
 
 INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
-$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES)
+$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST)
 	@echo Installed file list: $@
 	@mkdir -p $(dir $@)
 	@rm -f $@
-	$(hide) build/tools/fileslist.py $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
+	$(hide) $(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
 	$(hide) build/tools/fileslist_util.py -c $(@:.txt=.json) > $@
 
 vendorimage_intermediates := \
     $(call intermediates-dir-for,PACKAGING,vendor)
 BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
-
 define build-vendorimage-target
   $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
   @mkdir -p $(TARGET_OUT_VENDOR)
   @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
   $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true)
+  $(if $(BOARD_VENDOR_KERNEL_MODULES), \
+    $(call build-image-kernel-modules,$(BOARD_VENDOR_KERNEL_MODULES),$(TARGET_OUT_VENDOR),vendor/,$(call intermediates-dir-for,PACKAGING,depmod_vendor)))
   $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
       ./build/tools/releasetools/build_image.py \
       $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
@@ -1520,11 +1808,11 @@
 
 # We just build this directly to the install location.
 INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
-$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR)
+$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR) $(BUILD_IMAGE_SRCS) $(DEPMOD) $(BOARD_VENDOR_KERNEL_MODULES)
 	$(build-vendorimage-target)
 
-.PHONY: vendorimage-nodeps
-vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS)
+.PHONY: vendorimage-nodeps vnod
+vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(DEPMOD)
 	$(build-vendorimage-target)
 
 else ifdef BOARD_PREBUILT_VENDORIMAGE
@@ -1533,6 +1821,94 @@
 endif
 
 # -----------------------------------------------------------------
+# dtbo image
+ifdef BOARD_PREBUILT_DTBOIMAGE
+INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
+
+ifeq ($(BOARD_AVB_ENABLE),true)
+$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL)
+	cp $(BOARD_PREBUILT_DTBOIMAGE) $@
+	$(AVBTOOL) add_hash_footer \
+		--image $@ \
+		--partition_size $(BOARD_DTBOIMG_PARTITION_SIZE) \
+		--partition_name dtbo $(INTERNAL_AVB_SIGNING_ARGS) \
+		$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
+else
+$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
+	cp $(BOARD_PREBUILT_DTBOIMAGE) $@
+endif
+
+endif
+
+# -----------------------------------------------------------------
+# 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) \
+
+ifdef INSTALLED_VENDORIMAGE_TARGET
+INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
+    --include_descriptors_from_image $(INSTALLED_VENDORIMAGE_TARGET)
+endif
+
+ifdef INSTALLED_DTBOIMAGE_TARGET
+INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
+		--include_descriptors_from_image $(INSTALLED_DTBOIMAGE_TARGET)
+endif
+
+ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
+INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += --setup_rootfs_from_kernel $(BUILT_SYSTEMIMAGE)
+endif
+
+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) $(INSTALLED_VENDORIMAGE_TARGET) $(INSTALLED_DTBOIMAGE_TARGET)
+	$(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
+
+# -----------------------------------------------------------------
 # bring in the installer image generation defines if necessary
 ifeq ($(TARGET_USE_DISKINSTALLER),true)
 include bootable/diskinstaller/config.mk
@@ -1579,8 +1955,11 @@
   $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
   $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
   $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
-  $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
   $(HOST_OUT_EXECUTABLES)/make_ext4fs \
+  $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
+  $(HOST_OUT_EXECUTABLES)/mke2fs \
+  $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh \
+  $(HOST_OUT_EXECUTABLES)/e2fsdroid \
   $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \
   $(HOST_OUT_EXECUTABLES)/mksquashfs \
   $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \
@@ -1605,6 +1984,12 @@
   $(VBOOT_SIGNER)
 endif
 
+ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
+OTATOOLS += \
+  $(FUTILITY) \
+  $(VBOOT_SIGNER)
+endif
+
 # Shared libraries.
 OTATOOLS += \
   $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
@@ -1612,26 +1997,26 @@
   $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \
-  $(HOST_LIBRARY_PATH)/libdivsufsort$(HOST_SHLIB_SUFFIX) \
-  $(HOST_LIBRARY_PATH)/libdivsufsort64$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libext2_misc$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \
-  $(HOST_LIBRARY_PATH)/libbrillo-http$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \
   $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \
-  $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX)
+  $(HOST_LIBRARY_PATH)/libsparse-host$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libpcre2$(HOST_SHLIB_SUFFIX)
 
 .PHONY: otatools
 otatools: $(OTATOOLS)
@@ -1642,10 +2027,11 @@
 $(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) | $(ACP)
 	@echo "Package OTA tools: $@"
 	$(hide) rm -rf $@ $(zip_root)
-	$(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity
+	$(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity $(zip_root)/system/extras/ext4_utils
 	$(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
 	$(hide) $(ACP) $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar $(zip_root)/framework/
 	$(hide) $(ACP) -p system/extras/verity/build_verity_metadata.py $(zip_root)/system/extras/verity/
+	$(hide) $(ACP) -p system/extras/ext4_utils/mke2fs.conf $(zip_root)/system/extras/ext4_utils/
 	$(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools
 ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT))
 	$(hide) mkdir -p $(zip_root)/external/vboot_reference/tests/devkeys
@@ -1703,15 +2089,23 @@
 
 ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
 # default to common dir for device vendor
-$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common
+tool_extensions := $(TARGET_DEVICE_DIR)/../common
 else
-$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
+tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
 endif
+tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
+$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSIONS := $(tool_extensions)
+$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
 
+ifeq ($(AB_OTA_UPDATER),true)
+# Build zlib fingerprint if using the AB Updater.
+updater_dep := $(TARGET_OUT_COMMON_GEN)/zlib_fingerprint
+updater_dep += system/update_engine/update_engine.conf
+else
 # Build OTA tools if not using the AB Updater.
-ifneq ($(AB_OTA_UPDATER),true)
-$(BUILT_TARGET_FILES_PACKAGE): $(built_ota_tools)
+updater_dep := $(built_ota_tools)
 endif
+$(BUILT_TARGET_FILES_PACKAGE): $(updater_dep)
 
 # If we are using recovery as boot, output recovery files to BOOT/.
 ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
@@ -1720,24 +2114,55 @@
 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY
 endif
 
+ifeq ($(AB_OTA_UPDATER),true)
+  ifdef BRILLO_VENDOR_PARTITIONS
+    $(BUILT_TARGET_FILES_PACKAGE): $(foreach p,$(BRILLO_VENDOR_PARTITIONS),\
+                                     $(call word-colon,1,$(p))/$(call word-colon,2,$(p)))
+  endif
+  ifdef OSRELEASED_DIRECTORY
+    $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
+    $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
+    $(BUILT_TARGET_FILES_PACKAGE): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
+  endif
+endif
+
+# Run fs_config while creating the target files package
+# $1: root directory
+# $2: add prefix
+define fs_config
+(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC)
+endef
+
 # Depending on the various images guarantees that the underlying
 # directories are up-to-date.
 $(BUILT_TARGET_FILES_PACKAGE): \
 		$(INSTALLED_BOOTIMAGE_TARGET) \
 		$(INSTALLED_RADIOIMAGE_TARGET) \
 		$(INSTALLED_RECOVERYIMAGE_TARGET) \
-		$(INSTALLED_SYSTEMIMAGE) \
+		$(FULL_SYSTEMIMAGE_DEPS) \
 		$(INSTALLED_USERDATAIMAGE_TARGET) \
 		$(INSTALLED_CACHEIMAGE_TARGET) \
 		$(INSTALLED_VENDORIMAGE_TARGET) \
-		$(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
+		$(INSTALLED_DTBOIMAGE_TARGET) \
+		$(INTERNAL_SYSTEMOTHERIMAGE_FILES) \
 		$(INSTALLED_ANDROID_INFO_TXT_TARGET) \
+		$(INSTALLED_KERNEL_TARGET) \
+		$(INSTALLED_2NDBOOTLOADER_TARGET) \
+		$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
+		$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
 		$(SELINUX_FC) \
 		$(APKCERTS_FILE) \
+		$(SOONG_ZIP) \
 		$(HOST_OUT_EXECUTABLES)/fs_config \
+		$(HOST_OUT_EXECUTABLES)/imgdiff \
+		$(HOST_OUT_EXECUTABLES)/bsdiff \
+		$(BUILD_IMAGE_SRCS) \
+		$(INSTALLED_VENDOR_MANIFEST) \
+		$(INSTALLED_VENDOR_MATRIX) \
 		| $(ACP)
 	@echo "Package target files: $@"
-	$(hide) rm -rf $@ $(zip_root)
+	$(call create-system-vendor-symlink)
+	$(hide) rm -rf $@ [email protected] $(zip_root)
 	$(hide) mkdir -p $(dir $@) $(zip_root)
 ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
 	@# Components of the recovery image
@@ -1745,14 +2170,13 @@
 	$(hide) $(call package_files-copy-root, \
 		$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
 ifdef INSTALLED_KERNEL_TARGET
-	$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
+	$(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
 endif
 ifdef INSTALLED_2NDBOOTLOADER_TARGET
-	$(hide) $(ACP) \
-		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
+	$(hide) cp $(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
@@ -1774,14 +2198,13 @@
 	@# If we are using recovery as boot, this is already done when processing recovery.
 ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
 ifdef INSTALLED_KERNEL_TARGET
-	$(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
+	$(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel
 endif
 ifdef INSTALLED_2NDBOOTLOADER_TARGET
-	$(hide) $(ACP) \
-		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
+	$(hide) cp $(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
@@ -1792,7 +2215,7 @@
 endif # BOARD_USES_RECOVERY_AS_BOOT
 	$(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
 	            mkdir -p $(zip_root)/RADIO; \
-	            $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));)
+	            cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
 	@# Contents of the system image
 	$(hide) $(call package_files-copy-root, \
 		$(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
@@ -1811,20 +2234,22 @@
 endif
 	@# Extra contents of the OTA package
 	$(hide) mkdir -p $(zip_root)/OTA
-	$(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
+	$(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
 ifneq ($(AB_OTA_UPDATER),true)
 ifneq ($(built_ota_tools),)
 	$(hide) mkdir -p $(zip_root)/OTA/bin
-	$(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
+	$(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
 endif
 endif
 	@# Files that do not end up in any images, but are necessary to
 	@# build them.
 	$(hide) mkdir -p $(zip_root)/META
-	$(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
-	$(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi
+	$(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
+ifneq ($(tool_extension),)
+	$(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
+endif
 	$(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
-	$(hide) $(ACP) $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
+	$(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
 	$(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt
 	$(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt
 ifdef BOARD_FLASH_BLOCK_SIZE
@@ -1851,27 +2276,25 @@
 else
 	$(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt
 endif
-	$(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "tool_extensions=$(PRIVATE_TOOL_EXTENSIONS)" >> $(zip_root)/META/misc_info.txt
 	$(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt
 ifdef PRODUCT_EXTRA_RECOVERY_KEYS
 	$(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt
 endif
 	$(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt
 	$(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
 	$(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "blockimgdiff_versions=1,2,3,4" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "blockimgdiff_versions=3,4" >> $(zip_root)/META/misc_info.txt
 ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
 	# OTA scripts are only interested in fingerprint related properties
 	$(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
 endif
 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),)
-	$(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
+	$(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \
 	  $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH))
 endif
 ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),)
-	$(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
+	$(hide) cp $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \
 	  $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH))
 endif
 ifneq ($(strip $(SANITIZE_TARGET)),)
@@ -1881,6 +2304,23 @@
 ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
 	$(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
 endif
+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
+	$(hide) echo "board_bpt_make_table_args=$(BOARD_BPT_MAKE_TABLE_ARGS)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_bpt_input_files=$(BOARD_BPT_INPUT_FILES)" >> $(zip_root)/META/misc_info.txt
+endif
+ifdef BOARD_BPT_DISK_SIZE
+	$(hide) echo "board_bpt_disk_size=$(BOARD_BPT_DISK_SIZE)" >> $(zip_root)/META/misc_info.txt
+endif
 	$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
 ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
 	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
@@ -1888,7 +2328,8 @@
 endif
 ifeq ($(AB_OTA_UPDATER),true)
 	@# When using the A/B updater, include the updater config files in the zip.
-	$(hide) $(ACP) $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
+	$(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
+	$(hide) cp $(TARGET_OUT_COMMON_GEN)/zlib_fingerprint $(zip_root)/META/zlib_fingerprint.txt
 	$(hide) for part in $(AB_OTA_PARTITIONS); do \
 	  echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
 	done
@@ -1898,9 +2339,21 @@
 	@# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
 	$(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt
 	$(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt
+ifdef BRILLO_VENDOR_PARTITIONS
+	$(hide) mkdir -p $(zip_root)/VENDOR_IMAGES
+	$(hide) for f in $(BRILLO_VENDOR_PARTITIONS); do \
+	  pair1="$$(echo $$f | awk -F':' '{print $$1}')"; \
+	  pair2="$$(echo $$f | awk -F':' '{print $$2}')"; \
+	  src=$${pair1}/$${pair2}; \
+	  dest=$(zip_root)/VENDOR_IMAGES/$${pair2}; \
+	  mkdir -p $$(dirname "$${dest}"); \
+	  cp $${src} $${dest}; \
+	done;
+endif
 ifdef OSRELEASED_DIRECTORY
-	$(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
-	$(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
+	$(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
+	$(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
+	$(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
 endif
 endif
 ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
@@ -1911,28 +2364,42 @@
 	$(hide) mkdir -p $(zip_root)/IMAGES
 	$(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
 endif
-	@# Zip everything up, preserving symlinks and placing META/ files first to
-	@# help early validation of the .zip file while uploading it.
-	$(hide) (cd $(zip_root) && \
-	        zip -qryX ../$(notdir $@) ./META && \
-	        zip -qryXu ../$(notdir $@) .)
 	@# Run fs_config on all the system, vendor, boot ramdisk,
 	@# and recovery ramdisk files in the zip, and save the output
-	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
-	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
-ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
-	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="ROOT/" } /^ROOT\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/root_filesystem_config.txt
+	$(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+	$(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
 endif
-	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
+ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
+	$(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
+endif
+	$(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
 ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
-	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
+	$(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
 endif
 ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET
-	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM_OTHER/" } /^SYSTEM_OTHER\// { print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/system_other_filesystem_config.txt
+	$(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
 endif
-	$(hide) (cd $(zip_root) && zip -qX ../$(notdir $@) META/*filesystem_config.txt)
+
+ifeq ($(PRODUCT_FULL_TREBLE),true)
+	@# Metadata for compatibility verification.
+	$(hide) cp $(BUILT_SYSTEM_MANIFEST) $(zip_root)/META/system_manifest.xml
+	$(hide) cp $(BUILT_SYSTEM_COMPATIBILITY_MATRIX) $(zip_root)/META/system_compatibility_matrix.xml
+ifdef BUILT_VENDOR_MANIFEST
+	$(hide) cp $(BUILT_VENDOR_MANIFEST) $(zip_root)/META/vendor_manifest.xml
+endif
+ifdef BUILT_VENDOR_MATRIX
+	$(hide) cp $(BUILT_VENDOR_MATRIX) $(zip_root)/META/vendor_matrix.xml
+endif
+endif
+
 	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
-	    ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $@
+	    ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $(zip_root)
+	@# Zip everything up, preserving symlinks and placing META/ files first to
+	@# help early validation of the .zip file while uploading it.
+	$(hide) find $(zip_root)/META | sort >[email protected]
+	$(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>[email protected]
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -l [email protected]
 
 .PHONY: target-files-package
 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
@@ -1941,6 +2408,15 @@
 $(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
 endif
 
+# -----------------------------------------------------------------
+# NDK Sysroot Package
+NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
+$(NDK_SYSROOT_TARGET): ndk
+	@echo Package NDK sysroot...
+	$(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
+
+$(call dist-for-goals,sdk,$(NDK_SYSROOT_TARGET))
+
 ifeq ($(build_ota_package),true)
 # -----------------------------------------------------------------
 # OTA update package
@@ -1955,11 +2431,13 @@
 
 $(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
 
-$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE)
+$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) \
+		build/tools/releasetools/ota_from_target_files
 	@echo "Package OTA: $@"
 	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
 	   ./build/tools/releasetools/ota_from_target_files -v \
 	   --block \
+	   --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \
 	   -p $(HOST_OUT) \
 	   -k $(KEY_CERT_PAIR) \
 	   $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \
@@ -1981,12 +2459,10 @@
 
 INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
 
-$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE)
+$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(ZIP2ZIP)
 	@echo "Package: $@"
-	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
-	   ./build/tools/releasetools/img_from_target_files -v \
-	   -p $(HOST_OUT) \
-	   $(BUILT_TARGET_FILES_PACKAGE) $@
+	$(hide) $(ZIP2ZIP) -i $(BUILT_TARGET_FILES_PACKAGE) -o $@ \
+	   OTA/android-info.txt:android-info.txt "IMAGES/*.img:."
 
 .PHONY: updatepackage
 updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
@@ -2004,13 +2480,41 @@
 SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip
 # For apps_only build we'll establish the dependency later in build/core/main.mk.
 ifndef TARGET_BUILD_APPS
-$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET)
+$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) \
+		$(INSTALLED_BOOTIMAGE_TARGET) \
+		$(INSTALLED_USERDATAIMAGE_TARGET) \
+		$(INSTALLED_VENDORIMAGE_TARGET) \
+		$(updater_dep)
 endif
-$(SYMBOLS_ZIP):
+$(SYMBOLS_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,symbols)/filelist
+$(SYMBOLS_ZIP): $(SOONG_ZIP)
 	@echo "Package symbols: $@"
-	$(hide) rm -rf $@
-	$(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED)
-	$(hide) zip -qrX $@ $(TARGET_OUT_UNSTRIPPED)
+	$(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
+	$(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) $(dir $(PRIVATE_LIST_FILE))
+	$(hide) find $(TARGET_OUT_UNSTRIPPED) | sort >$(PRIVATE_LIST_FILE)
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(OUT_DIR)/.. -l $(PRIVATE_LIST_FILE)
+# -----------------------------------------------------------------
+# A zip of the coverage directory.
+#
+name := $(TARGET_PRODUCT)
+ifeq ($(TARGET_BUILD_TYPE),debug)
+name := $(name)_debug
+endif
+name := $(name)-coverage-$(FILE_NAME_TAG)
+COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
+ifndef TARGET_BUILD_APPS
+$(COVERAGE_ZIP): $(INSTALLED_SYSTEMIMAGE) \
+		$(INSTALLED_BOOTIMAGE_TARGET) \
+		$(INSTALLED_USERDATAIMAGE_TARGET) \
+		$(INSTALLED_VENDORIMAGE_TARGET)
+endif
+$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
+$(COVERAGE_ZIP): $(SOONG_ZIP)
+	@echo "Package coverage: $@"
+	$(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
+	$(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
+	$(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
 
 # -----------------------------------------------------------------
 # A zip of the Android Apps. Not keeping full path so that we don't
@@ -2135,7 +2639,6 @@
 # if we don't have a real list, then use "everything"
 ifeq ($(strip $(ATREE_FILES)),)
 ATREE_FILES := \
-	$(ALL_PREBUILT) \
 	$(ALL_DEFAULT_INSTALLED_MODULES) \
 	$(INSTALLED_RAMDISK_TARGET) \
 	$(ALL_DOCS) \
@@ -2170,6 +2673,7 @@
 	$(tools_notice_file_txt) \
 	$(OUT_DOCS)/offline-sdk-timestamp \
 	$(SYMBOLS_ZIP) \
+	$(COVERAGE_ZIP) \
 	$(INSTALLED_SYSTEMIMAGE) \
 	$(INSTALLED_USERDATAIMAGE_TARGET) \
 	$(INSTALLED_RAMDISK_TARGET) \
@@ -2267,6 +2771,9 @@
 -include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
 -include $(sort $(wildcard device/*/*/build/tasks/*.mk))
 -include $(sort $(wildcard product/*/*/build/tasks/*.mk))
+# Also add test specifc tasks
+include $(sort $(wildcard platform_testing/build/tasks/*.mk))
+include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
 endif
 
 include $(BUILD_SYSTEM)/product-graph.mk
diff --git a/core/WINPTHREADS_COPYING b/core/WINPTHREADS_COPYING
new file mode 100644
index 0000000..3507701
--- /dev/null
+++ b/core/WINPTHREADS_COPYING
@@ -0,0 +1,57 @@
+Copyright (c) 2011 mingw-w64 project
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+
+/*
+ * Parts of this library are derived by:
+ *
+ * Posix Threads library for Microsoft Windows
+ *
+ * Use at own risk, there is no implied warranty to this code.
+ * It uses undocumented features of Microsoft Windows that can change
+ * at any time in the future.
+ *
+ * (C) 2010 Lockless Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *  * Neither the name of Lockless Inc. nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AN
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff --git a/core/aapt2.mk b/core/aapt2.mk
index ccc4535..a10af67 100644
--- a/core/aapt2.mk
+++ b/core/aapt2.mk
@@ -1,20 +1,27 @@
 ######################################
 # Compile resource with AAPT2
 # Input variables:
-# full_android_manifest,
-# my_res_resources, my_overlay_resources,
-# my_compiled_res_base_dir, my_res_package,
-# R_file_stamp, proguard_options_file
-# my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2.
-# my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs.
+# - full_android_manifest
+# - my_res_resources
+# - my_overlay_resources
+# - my_compiled_res_base_dir
+# - my_asset_dirs
+# - my_full_asset_paths
+# - my_res_package
+# - R_file_stamp
+# - proguard_options_file
+# - my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2.
+# - my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs.
+# - my_apk_split_configs: The configurations for which to generate splits.
+# - built_apk_splits: The paths where AAPT should generate the splits.
 #
 # Output variables:
-# my_res_resources_flat, my_overlay_resources_flat,
-# my_generated_resources_flata
+# - my_res_resources_flat
+# - my_overlay_resources_flat
+# - my_generated_resources_flata
 #
 ######################################
 
-
 # Compile all the resource files.
 my_res_resources_flat := \
   $(foreach r, $(my_res_resources),\
@@ -52,12 +59,19 @@
 $(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay
 endif
 
+ifneq ($(my_apk_split_configs),)
+# Join the Split APK paths with their configuration, separated by a ':'.
+$(my_res_package): PRIVATE_AAPT_FLAGS += $(addprefix --split ,$(join $(built_apk_splits),$(addprefix :,$(my_apk_split_configs))))
+endif
+
 $(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat)
 $(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_generated_resources_flata) $(my_overlay_resources_flat)
 $(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources)
 $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
-$(my_res_package) : $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
-$(my_res_package) : $(my_res_resources_flat) $(my_overlay_resources_flat) \
+$(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs)
+$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
+$(my_res_package): $(my_full_asset_paths)
+$(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \
   $(my_generated_resources_flata) $(my_static_library_resources) \
   $(AAPT2)
 	@echo "AAPT2 link $@"
diff --git a/core/aux_config.mk b/core/aux_config.mk
new file mode 100644
index 0000000..c40b8cc
--- /dev/null
+++ b/core/aux_config.mk
@@ -0,0 +1,187 @@
+variant_list := $(filter AUX-%,$(MAKECMDGOALS))
+
+ifdef variant_list
+AUX_OS_VARIANT_LIST := $(patsubst AUX-%,%,$(variant_list))
+else
+AUX_OS_VARIANT_LIST := $(TARGET_AUX_OS_VARIANT_LIST)
+endif
+
+# exclude AUX targets from build
+ifeq ($(AUX_OS_VARIANT_LIST),none)
+AUX_OS_VARIANT_LIST :=
+endif
+
+# temporary workaround to support external toolchain
+ifeq ($(NANOHUB_TOOLCHAIN),)
+AUX_OS_VARIANT_LIST :=
+endif
+
+# setup toolchain paths for various CPU architectures
+# this one will come from android prebuilts eventually
+AUX_TOOLCHAIN_cortexm4 := $(NANOHUB_TOOLCHAIN)
+ifeq ($(wildcard $(AUX_TOOLCHAIN_cortexm4)gcc),)
+AUX_TOOLCHAIN_cortexm4:=
+endif
+
+# there is no MAKE var that defines path to HOST toolchain
+# all the interesting paths are hardcoded in soong, and are not available from here
+# There is no other way but to hardcode them again, as we may need host x86 toolcain for AUX
+ifeq ($(HOST_OS),linux)
+AUX_TOOLCHAIN_x86 := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
+endif
+
+# setup AUX globals
+AUX_SHLIB_SUFFIX := .so
+AUX_GLOBAL_ARFLAGS := crsPD
+AUX_STATIC_LIB_SUFFIX := .a
+
+# Load ever-lasting "indexed" version of AUX variant environment; it is treated as READ-ONLY from this
+# moment on.
+#
+# $(1) - variant
+# no return value
+define aux-variant-setup-paths
+$(eval AUX_OUT_ROOT_$(1) := $(PRODUCT_OUT)/aux/$(1)) \
+$(eval AUX_COMMON_OUT_ROOT_$(1) := $(AUX_OUT_ROOT_$(1))/common) \
+$(eval AUX_OUT_$(1) := $(AUX_OUT_ROOT_$(1))/$(AUX_OS_$(1))-$(AUX_ARCH_$(1))-$(AUX_CPU_$(1))) \
+$(eval AUX_OUT_INTERMEDIATES_$(1) := $(AUX_OUT_$(1))/obj) \
+$(eval AUX_OUT_COMMON_INTERMEDIATES_$(1) := $(AUX_COMMON_OUT_ROOT_$(1))/obj) \
+$(eval AUX_OUT_HEADERS_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/include) \
+$(eval AUX_OUT_INTERMEDIATE_LIBRARIES_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/lib) \
+$(eval AUX_OUT_NOTICE_FILES_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/NOTICE_FILES) \
+$(eval AUX_OUT_FAKE_$(1) := $(AUX_OUT_$(1))/fake_packages) \
+$(eval AUX_OUT_GEN_$(1) := $(AUX_OUT_$(1))/gen) \
+$(eval AUX_OUT_COMMON_GEN_$(1) := $(AUX_COMMON_OUT_ROOT_$(1))/gen) \
+$(eval AUX_OUT_EXECUTABLES_$(1) := $(AUX_OUT_$(1))/bin) \
+$(eval AUX_OUT_UNSTRIPPED_$(1) := $(AUX_OUT_$(1))/symbols)
+endef
+
+# Copy "indexed" AUX environment for given VARIANT into
+# volatile not-indexed set of variables for simplicity of access.
+# Injection of index support throughout the build system is suboptimal
+# hence volatile environment is constructed
+# Unlike HOST*, TARGET* variables, AUX* variables are NOT read-only, but their
+# indexed versions are.
+#
+# $(1) - variant
+# no return value
+define aux-variant-load-env
+$(eval AUX_OS_VARIANT:=$(1)) \
+$(eval AUX_OS:=$(AUX_OS_$(1))) \
+$(eval AUX_ARCH:=$(AUX_ARCH_$(1))) \
+$(eval AUX_SUBARCH:=$(AUX_SUBARCH_$(1))) \
+$(eval AUX_CPU:=$(AUX_CPU_$(1))) \
+$(eval AUX_OS_PATH:=$(AUX_OS_PATH_$(1))) \
+$(eval AUX_OUT_ROOT := $(AUX_OUT_ROOT_$(1))) \
+$(eval AUX_COMMON_OUT_ROOT := $(AUX_COMMON_OUT_ROOT_$(1))) \
+$(eval AUX_OUT := $(AUX_OUT_$(1))) \
+$(eval AUX_OUT_INTERMEDIATES := $(AUX_OUT_INTERMEDIATES_$(1))) \
+$(eval AUX_OUT_COMMON_INTERMEDIATES := $(AUX_OUT_COMMON_INTERMEDIATES_$(1))) \
+$(eval AUX_OUT_HEADERS := $(AUX_OUT_HEADERS_$(1))) \
+$(eval AUX_OUT_INTERMEDIATE_LIBRARIES := $(AUX_OUT_INTERMEDIATE_LIBRARIES_$(1))) \
+$(eval AUX_OUT_NOTICE_FILES := $(AUX_OUT_NOTICE_FILES_$(1))) \
+$(eval AUX_OUT_FAKE := $(AUX_OUT_FAKE_$(1))) \
+$(eval AUX_OUT_GEN := $(AUX_OUT_GEN_$(1))) \
+$(eval AUX_OUT_COMMON_GEN := $(AUX_OUT_COMMON_GEN_$(1))) \
+$(eval AUX_OUT_EXECUTABLES := $(AUX_OUT_EXECUTABLES_$(1))) \
+$(eval AUX_OUT_UNSTRIPPED := $(AUX_OUT_UNSTRIPPED_$(1)))
+endef
+
+# given a variant:path pair, load the variant conviguration with aux-variant-setup-paths from file
+# this is a build system extension mechainsm, since configuration typically resides in non-build
+# project space
+#
+# $(1) - variant:path pair
+# $(2) - file suffix
+# no return value
+define aux-variant-import-from-pair
+$(eval _pair := $(subst :, ,$(1))) \
+$(eval _name:=$(word 1,$(_pair))) \
+$(eval _path:=$(word 2,$(_pair))) \
+$(eval include $(_path)/$(_name)$(2)) \
+$(eval AUX_OS_VARIANT_LIST_$(AUX_OS_$(1)):=) \
+$(call aux-variant-setup-paths,$(_name)) \
+$(eval AUX_ALL_VARIANTS += $(_name)) \
+$(eval AUX_ALL_OSES := $(filterout $(AUX_OS_$(_name)),$(AUX_ALL_OSES)) $(AUX_OS_$(_name))) \
+$(eval AUX_ALL_CPUS := $(filterout $(AUX_CPU_$(_name)),$(AUX_ALL_CPUS)) $(AUX_CPU_$(_name))) \
+$(eval AUX_ALL_ARCHS := $(filterout $(AUX_ARCH_$(_name)),$(AUX_ALL_ARCHS)) $(AUX_ARCH_$(_name))) \
+$(eval AUX_ALL_SUBARCHS := $(filterout $(AUX_SUBARCH_$(_name)),$(AUX_ALL_SUBARCHS)) $(AUX_SUBARCH_$(_name)))
+endef
+
+# Load system configuration referenced by AUX variant config;
+# this is a build extension mechanism; typically system config
+# resides in a non-build projects;
+# system config may define new rules and globally visible BUILD*
+# includes to support project-specific build steps and toolchains
+# MAintains list of valiants that reference this os config in OS "indexed" var
+# this facilitates multivariant build of the OS (or whataver it is the name of common component these variants share)
+#
+# $(1) - variant
+# no return value
+define aux-import-os-config
+$(eval _aioc_os := $(AUX_OS_$(1))) \
+$(eval AUX_OS_PATH_$(1) := $(patsubst $(_aioc_os):%,%,$(filter $(_aioc_os):%,$(AUX_ALL_OS_PATHS)))) \
+$(eval _aioc_os_cfg := $(AUX_OS_PATH_$(1))/$(_aioc_os)$(os_sfx)) \
+$(if $(wildcard $(_aioc_os_cfg)),,$(error AUX '$(_aioc_os)' OS config file [$(notdir $(_aioc_os_cfg))] required by AUX variant '$(1)' does not exist)) \
+$(if $(filter $(_aioc_os),$(_os_list)),,$(eval include $(_aioc_os_cfg))) \
+$(eval AUX_OS_VARIANT_LIST_$(_aioc_os) += $(1)) \
+$(eval _os_list += $(_aioc_os))
+endef
+
+# make sure that AUX config variables are minimally sane;
+# as a bare minimum they must contain the vars described by aux_env
+# Generate error if requirement is not met.
+#
+#$(1) - variant
+# no return value
+define aux-variant-validate
+$(eval _all:=) \
+$(eval _req:=$(addsuffix _$(1),$(aux_env))) \
+$(foreach var,$(_req),$(eval _all += $(var))) \
+$(eval _missing := $(filterout $(_all),$(_req))) \
+$(if $(_missing),$(error AUX variant $(1) must define vars: $(_missing)))
+endef
+
+AUX_ALL_VARIANTS :=
+AUX_ALL_OSES :=
+AUX_ALL_CPUS :=
+AUX_ALL_ARCHS :=
+AUX_ALL_SUBARCHS :=
+
+variant_sfx :=_aux_variant_config.mk
+os_sfx :=_aux_os_config.mk
+
+config_roots := $(wildcard device vendor)
+all_configs :=
+ifdef config_roots
+all_configs := $(shell find $(config_roots) -maxdepth 4 -name '*$(variant_sfx)' -o -name '*$(os_sfx)' | sort)
+endif
+all_os_configs := $(filter %$(os_sfx),$(all_configs))
+all_variant_configs := $(filter %$(variant_sfx),$(all_configs))
+
+AUX_ALL_OS_PATHS := $(foreach f,$(all_os_configs),$(patsubst %$(os_sfx),%,$(notdir $(f))):$(patsubst %/,%,$(dir $(f))))
+AUX_ALL_OS_VARIANT_PATHS := $(foreach f,$(all_variant_configs),$(patsubst %$(variant_sfx),%,$(notdir $(f))):$(patsubst %/,%,$(dir $(f))))
+
+my_variant_pairs := $(foreach v,$(AUX_OS_VARIANT_LIST),$(filter $(v):%,$(AUX_ALL_OS_VARIANT_PATHS)))
+my_missing_variants := $(foreach v,$(AUX_OS_VARIANT_LIST),$(if $(filter $(v):%,$(AUX_ALL_OS_VARIANT_PATHS)),,$(v)))
+
+ifneq ($(strip $(my_missing_variants)),)
+$(error Don't know how to build variant(s): $(my_missing_variants))
+endif
+
+# mandatory variables
+aux_env := AUX_OS AUX_ARCH AUX_SUBARCH AUX_CPU
+
+$(foreach v,$(my_variant_pairs),$(if $(filter $(v),$(AUX_ALL_VARIANTS)),,$(call aux-variant-import-from-pair,$(v),$(variant_sfx))))
+
+ifdef AUX_ALL_VARIANTS
+_os_list :=
+$(foreach v,$(AUX_ALL_VARIANTS),\
+  $(call aux-import-os-config,$(v)) \
+  $(call aux-variant-validate,$(v)) \
+)
+endif
+
+INSTALLED_AUX_TARGETS :=
+
+droidcore: auxiliary
diff --git a/core/aux_executable.mk b/core/aux_executable.mk
new file mode 100644
index 0000000..daf30e7
--- /dev/null
+++ b/core/aux_executable.mk
@@ -0,0 +1,96 @@
+# caller might have included aux_toolchain, e.g. if custom build steps are defined
+ifeq ($(LOCAL_IS_AUX_MODULE),)
+include $(BUILD_SYSTEM)/aux_toolchain.mk
+endif
+
+ifeq ($(AUX_BUILD_NOT_COMPATIBLE),)
+
+###########################################################
+## Standard rules for building an executable file.
+##
+## Additional inputs from base_rules.make:
+## None.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := EXECUTABLES
+endif
+
+$(call $(aux-executable-hook))
+
+###########################################################
+## Standard rules for building any target-side binaries
+## with dynamic linkage (dynamic libraries or executables
+## that link with dynamic libraries)
+##
+## Files including this file must define a rule to build
+## the target $(linked_module).
+###########################################################
+
+# The name of the target file, without any path prepended.
+# This duplicates logic from base_rules.mk because we need to
+# know its results before base_rules.mk is included.
+include $(BUILD_SYSTEM)/configure_module_stem.mk
+
+intermediates := $(call local-intermediates-dir)
+
+# Define the target that is the unmodified output of the linker.
+# The basename of this target must be the same as the final output
+# binary name, because it's used to set the "soname" in the binary.
+# The includer of this file will define a rule to build this target.
+linked_module := $(intermediates)/LINKED/$(my_built_module_stem)
+
+ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
+
+# Because AUX_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
+# the linked_module rules won't necessarily inherit the PRIVATE_
+# variables from LOCAL_BUILT_MODULE.  This tells binary.make to explicitly
+# define the PRIVATE_ variables for linked_module as well as for
+# LOCAL_BUILT_MODULE.
+LOCAL_INTERMEDIATE_TARGETS += $(linked_module)
+
+###################################
+include $(BUILD_SYSTEM)/binary.mk
+###################################
+
+aux_output := $(linked_module)
+
+ifneq ($(LOCAL_CUSTOM_BUILD_STEP_INPUT),)
+ifneq ($(LOCAL_CUSTOM_BUILD_STEP_OUTPUT),)
+
+# injecting custom build steps
+$(LOCAL_CUSTOM_BUILD_STEP_INPUT): $(aux_output)
+	@echo "$(AUX_DISPLAY) custom copy: $(PRIVATE_MODULE) ($@)"
+	@mkdir -p $(dir $@)
+	$(hide) $(copy-file-to-target)
+
+aux_output := $(LOCAL_CUSTOM_BUILD_STEP_OUTPUT)
+
+endif
+endif
+
+$(LOCAL_BUILT_MODULE): $(aux_output)
+	@echo "$(AUX_DISPLAY) final copy: $(PRIVATE_MODULE) ($@)"
+	@mkdir -p $(dir $@)
+	$(hide) $(copy-file-to-target)
+
+INSTALLED_AUX_TARGETS += $(LOCAL_INSTALLED_MODULE)
+
+$(cleantarget): PRIVATE_CLEAN_FILES += \
+    $(linked_module) \
+
+# Define PRIVATE_ variables from global vars
+$(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $(AUX_OUT_INTERMEDIATE_LIBRARIES)
+$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
+
+ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+$(linked_module): $(all_objects) $(all_libraries) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+	$(transform-o-to-aux-static-executable)
+	$(PRIVATE_POST_LINK_CMD)
+else
+$(linked_module): $(all_objects) $(all_libraries) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+	$(transform-o-to-aux-executable)
+	$(PRIVATE_POST_LINK_CMD)
+endif
+
+endif # AUX_BUILD_NOT_COMPATIBLE
diff --git a/core/aux_static_library.mk b/core/aux_static_library.mk
new file mode 100644
index 0000000..d88478d
--- /dev/null
+++ b/core/aux_static_library.mk
@@ -0,0 +1,27 @@
+ifeq ($(LOCAL_IS_AUX_MODULE),)
+include $(BUILD_SYSTEM)/aux_toolchain.mk
+endif
+
+ifeq ($(AUX_BUILD_NOT_COMPATIBLE),)
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := .a
+endif
+
+LOCAL_UNINSTALLABLE_MODULE := true
+
+ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
+$(error $(LOCAL_PATH): Cannot set module stem for a library)
+endif
+
+include $(BUILD_SYSTEM)/binary.mk
+
+$(LOCAL_BUILT_MODULE) : PRIVATE_AR := $(AUX_AR)
+$(LOCAL_BUILT_MODULE) : $(built_whole_libraries)
+$(LOCAL_BUILT_MODULE) : $(all_objects)
+	$(transform-o-to-aux-static-lib)
+
+endif # AUX_BUILD_NOT_COMPATIBLE
diff --git a/core/aux_toolchain.mk b/core/aux_toolchain.mk
new file mode 100644
index 0000000..de0b139
--- /dev/null
+++ b/core/aux_toolchain.mk
@@ -0,0 +1,53 @@
+###########################################################
+# takes form LOCAL_AUX_TOOLCHAIN_$(LOCAL_AUX_CPU)
+###########################################################
+
+###############################
+# setup AUX environment
+###############################
+
+# shortcuts for targets with a single instance of OS, ARCH, VARIANT, CPU
+AUX_TOOLCHAIN := $(if $(LOCAL_AUX_TOOLCHAIN),$(LOCAL_AUX_TOOLCHAIN),$(AUX_TOOLCHAIN_$(AUX_CPU)))
+AUX_BUILD_NOT_COMPATIBLE:=
+ifeq ($(strip $(AUX_TOOLCHAIN)),)
+  ifeq ($(strip $(AUX_CPU)),)
+    $(warning $(LOCAL_PATH): $(LOCAL_MODULE): Undefined CPU for AUX toolchain)
+    AUX_BUILD_NOT_COMPATIBLE += TOOLCHAIN
+  else
+    $(warning $(LOCAL_PATH): $(LOCAL_MODULE): Undefined AUX toolchain for CPU=$(AUX_CPU))
+    AUX_BUILD_NOT_COMPATIBLE += TOOLCHAIN
+  endif
+endif
+
+AUX_BUILD_NOT_COMPATIBLE += $(foreach var,OS ARCH SUBARCH CPU OS_VARIANT,$(if $(LOCAL_AUX_$(var)),$(if \
+    $(filter $(LOCAL_AUX_$(var)),$(AUX_$(var))),,$(var))))
+
+AUX_BUILD_NOT_COMPATIBLE := $(strip $(AUX_BUILD_NOT_COMPATIBLE))
+
+ifneq ($(AUX_BUILD_NOT_COMPATIBLE),)
+$(info $(LOCAL_PATH): $(LOCAL_MODULE): not compatible: "$(AUX_BUILD_NOT_COMPATIBLE)" with)
+$(info ====> OS=$(AUX_OS) CPU=$(AUX_CPU) ARCH=$(AUX_ARCH) SUBARCH=$(AUX_SUBARCH) OS_VARIANT=$(AUX_OS_VARIANT))
+$(info ====> TOOLCHAIN=$(AUX_TOOLCHAIN))
+endif
+
+AUX_AR := $(AUX_TOOLCHAIN)ar
+AUX_AS := $(AUX_TOOLCHAIN)gcc
+AUX_CC := $(AUX_TOOLCHAIN)gcc
+AUX_CXX := $(AUX_TOOLCHAIN)g++
+AUX_LINKER := $(AUX_TOOLCHAIN)ld
+AUX_OBJCOPY := $(AUX_TOOLCHAIN)objcopy
+AUX_OBJDUMP := $(AUX_TOOLCHAIN)objdump
+
+###############################
+# setup Android environment
+###############################
+
+LOCAL_IS_AUX_MODULE := true
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+LOCAL_CC := $(AUX_CC)
+LOCAL_CXX := $(AUX_CXX)
+LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
+LOCAL_SYSTEM_SHARED_LIBRARIES :=
+LOCAL_CXX_STL := none
+LOCAL_NO_PIC := true
+LOCAL_NO_LIBCOMPILER_RT := true
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 6fc2935..92e69bb 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -14,6 +14,9 @@
 # limitations under the License.
 #
 
+# Catch users that directly include base_rules.mk
+$(call record-module-type,base_rules)
+
 # Users can define base-rules-hook in their buildspec.mk to perform
 # arbitrary operations as each module is included.
 ifdef base-rules-hook
@@ -30,6 +33,7 @@
 endif
 
 LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
+LOCAL_IS_AUX_MODULE := $(strip $(LOCAL_IS_AUX_MODULE))
 ifdef LOCAL_IS_HOST_MODULE
   ifneq ($(LOCAL_IS_HOST_MODULE),true)
     $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
@@ -40,8 +44,18 @@
     my_prefix := $(LOCAL_HOST_PREFIX)
   endif
   my_host := host-
+  my_kind := HOST
 else
-  my_prefix := TARGET_
+  ifdef LOCAL_IS_AUX_MODULE
+    ifneq ($(LOCAL_IS_AUX_MODULE),true)
+      $(error $(LOCAL_PATH): LOCAL_IS_AUX_MODULE must be "true" or empty, not "$(LOCAL_IS_AUX_MODULE)")
+    endif
+    my_prefix := AUX_
+    my_kind := AUX
+  else
+    my_prefix := TARGET_
+    my_kind :=
+  endif
   my_host :=
 endif
 
@@ -51,12 +65,29 @@
   my_host_cross :=
 endif
 
+ifndef LOCAL_PROPRIETARY_MODULE
+  LOCAL_PROPRIETARY_MODULE := $(LOCAL_VENDOR_MODULE)
+endif
+ifndef LOCAL_VENDOR_MODULE
+  LOCAL_VENDOR_MODULE := $(LOCAL_PROPRIETARY_MODULE)
+endif
+ifneq ($(filter-out $(LOCAL_PROPRIETARY_MODULE),$(LOCAL_VENDOR_MODULE))$(filter-out $(LOCAL_VENDOR_MODULE),$(LOCAL_PROPRIETARY_MODULE)),)
+$(call pretty-error,Only one of LOCAL_PROPRIETARY_MODULE[$(LOCAL_PROPRIETARY_MODULE)] and LOCAL_VENDOR_MODULE[$(LOCAL_VENDOR_MODULE)] may be set, or they must be equal)
+endif
+
+include $(BUILD_SYSTEM)/local_vndk.mk
+
 my_module_tags := $(LOCAL_MODULE_TAGS)
 ifeq ($(my_host_cross),true)
   my_module_tags :=
 endif
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+ifdef LOCAL_2ND_ARCH_VAR_PREFIX
+# Don't pull in modules by tags if this is for translation TARGET_2ND_ARCH.
+  my_module_tags :=
+endif
+endif
 
-ifdef BUILDING_WITH_NINJA
 # Ninja has an implicit dependency on the command being run, and kati will
 # regenerate the ninja manifest if any read makefile changes, so there is no
 # need to have dependencies on makefiles.
@@ -64,7 +95,6 @@
 # a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
 # base_rules.mk, but it will fix the most common ones.
 LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
-endif
 
 ###########################################################
 ## Validate and define fallbacks for input LOCAL_* variables.
@@ -101,7 +131,7 @@
 # makefiles. Anything else is either a typo or a source of unexpected
 # behaviors.
 ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
-$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH))
+$(call pretty-warning,unusual tags $(my_module_tags))
 endif
 
 # Add implicit tags.
@@ -125,29 +155,42 @@
 my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
 
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+# When in TARGET_TRANSLATE_2ND_ARCH both TARGET_ARCH and TARGET_2ND_ARCH are 32-bit,
+# to avoid path conflict we force using LOCAL_MODULE_PATH_64 for the first arch.
+ifdef LOCAL_2ND_ARCH_VAR_PREFIX
+my_multilib_module_path := $(LOCAL_MODULE_PATH_32)
+else  # ! LOCAL_2ND_ARCH_VAR_PREFIX
+my_multilib_module_path := $(LOCAL_MODULE_PATH_64)
+endif  # ! LOCAL_2ND_ARCH_VAR_PREFIX
+else  # ! TARGET_TRANSLATE_2ND_ARCH
 my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
+endif # ! TARGET_TRANSLATE_2ND_ARCH
 ifdef my_multilib_module_path
 my_module_path := $(my_multilib_module_path)
 else
 my_module_path := $(strip $(LOCAL_MODULE_PATH))
 endif
+my_module_path := $(patsubst %/,%,$(my_module_path))
 my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
+ifdef LOCAL_IS_HOST_MODULE
+  partition_tag :=
+else
+ifeq (true,$(LOCAL_VENDOR_MODULE))
+  partition_tag := _VENDOR
+else ifeq (true,$(LOCAL_OEM_MODULE))
+  partition_tag := _OEM
+else ifeq (true,$(LOCAL_ODM_MODULE))
+  partition_tag := _ODM
+else ifeq (NATIVE_TESTS,$(LOCAL_MODULE_CLASS))
+  partition_tag := _DATA
+else
+  # The definition of should-install-to-system will be different depending
+  # on which goal (e.g., sdk or just droid) is being built.
+  partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
+endif
+endif
 ifeq ($(my_module_path),)
-  ifdef LOCAL_IS_HOST_MODULE
-    partition_tag :=
-  else
-  ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
-    partition_tag := _VENDOR
-  else ifeq (true,$(LOCAL_OEM_MODULE))
-    partition_tag := _OEM
-  else ifeq (true,$(LOCAL_ODM_MODULE))
-    partition_tag := _ODM
-  else
-    # The definition of should-install-to-system will be different depending
-    # on which goal (e.g., sdk or just droid) is being built.
-    partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA)
-  endif
-  endif
   install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
   ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
     install_path_var := $(install_path_var)_PRIVILEGED
@@ -176,9 +219,21 @@
 my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
 endif
 endif
+
+ifeq ($(my_host_cross),true)
+  my_all_targets := host_cross_$(my_register_name)_all_targets
+else ifneq ($(LOCAL_IS_HOST_MODULE),)
+  my_all_targets := host_$(my_register_name)_all_targets
+else
+  my_all_targets := device_$(my_register_name)_all_targets
+endif
+
+# variant is enough to make nano class unique; it serves as a key to lookup (OS,ARCH) tuple
+aux_class := $($(my_prefix)OS_VARIANT)
 # Make sure that this IS_HOST/CLASS/MODULE combination is unique.
 module_id := MODULE.$(if \
-    $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name)
+    $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),$(if \
+    $(LOCAL_IS_AUX_MODULE),$(aux_class),TARGET)).$(LOCAL_MODULE_CLASS).$(my_register_name)
 ifdef $(module_id)
 $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
 endif
@@ -230,9 +285,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)
@@ -242,15 +294,14 @@
 # Kati adds restat=1 to ninja. GNU make does nothing for this.
 .KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
 # Build .toc file when using mm, mma, or make $(my_register_name)
-$(my_register_name): $(LOCAL_BUILT_MODULE).toc
-endif
+$(my_all_targets): $(LOCAL_BUILT_MODULE).toc
 endif
 
 ###########################################################
 ## logtags: Add .logtags files to global list
 ###########################################################
 
-logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
+logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES)
 
 ifneq ($(strip $(logtags_sources)),)
 event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
@@ -276,6 +327,7 @@
 ###########################################################
 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
+$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_AUX_MODULE := $(LOCAL_IS_AUX_MODULE)
 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)
 
@@ -288,8 +340,17 @@
 # Provide a short-hand for building this module.
 # We name both BUILT and INSTALLED in case
 # LOCAL_UNINSTALLABLE_MODULE is set.
+.PHONY: $(my_all_targets)
+$(my_all_targets): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
+
 .PHONY: $(my_register_name)
-$(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
+$(my_register_name): $(my_all_targets)
+
+ifneq ($(my_register_name),$(LOCAL_MODULE))
+# $(LOCAL_MODULE) covers all the multilib targets.
+.PHONY: $(LOCAL_MODULE)
+$(LOCAL_MODULE) : $(my_all_targets)
+endif
 
 # Set up phony targets that covers all modules under the given paths.
 # This allows us to build everything in given paths by running mmma/mma.
@@ -298,51 +359,46 @@
 $(foreach c, $(my_path_components),\
   $(eval my_path_prefix := $(my_path_prefix)-$(c))\
   $(eval .PHONY : $(my_path_prefix))\
-  $(eval $(my_path_prefix) : $(my_register_name)))
+  $(eval $(my_path_prefix) : $(my_all_targets)))
 
 ###########################################################
 ## Module installation rule
 ###########################################################
 
-# Some hosts do not have ACP; override the LOCAL version if that's the case.
-ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
-  LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
-endif
-
+my_init_rc_installed :=
+my_init_rc_pairs :=
+my_installed_symlinks :=
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
-  # Define a copy rule to install the module.
-  # acp and libraries that it uses can't use acp for
-  # installation;  hence, LOCAL_ACP_UNAVAILABLE.
 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
-ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
-$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
+$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
 	@echo "Install: $@"
 	$(copy-file-to-new-target)
 	$(PRIVATE_POST_INSTALL_CMD)
-else
-$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
-	@echo "Install: $@"
-	$(copy-file-to-target-with-cp)
-endif
 
+ifndef LOCAL_IS_HOST_MODULE
 # Rule to install the module's companion init.rc.
-my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix))
-my_init_rc_src :=
-my_init_rc_installed :=
-ifndef my_init_rc
-my_init_rc := $(LOCAL_INIT_RC)
-# Make sure we don't define the rule twice in multilib module.
-LOCAL_INIT_RC :=
-endif
-ifdef my_init_rc
-my_init_rc_src := $(LOCAL_PATH)/$(my_init_rc)
-my_init_rc_installed := $(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(my_init_rc_src))
-$(my_init_rc_installed) : $(my_init_rc_src) | $(ACP)
-	@echo "Install: $@"
-	$(copy-file-to-new-target)
+my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC)
+ifneq ($(strip $(my_init_rc)),)
+my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(LOCAL_PATH)/$(rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(rc)))
+my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc)))
 
-$(my_register_name) : $(my_init_rc_installed)
+# Make sure we only set up the copy rules once, even if another arch variant
+# shares a common LOCAL_INIT_RC.
+my_init_rc_new_pairs := $(filter-out $(ALL_INIT_RC_INSTALLED_PAIRS),$(my_init_rc_pairs))
+my_init_rc_new_installed := $(call copy-many-files,$(my_init_rc_new_pairs))
+ALL_INIT_RC_INSTALLED_PAIRS += $(my_init_rc_new_pairs)
+
+$(my_all_targets) : $(my_init_rc_installed)
 endif # my_init_rc
+endif # !LOCAL_IS_HOST_MODULE
+
+# Rule to install the module's companion symlinks
+my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
+$(foreach symlink,$(my_installed_symlinks),\
+    $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink)))
+
+$(my_all_targets) : | $(my_installed_symlinks)
+
 endif # !LOCAL_UNINSTALLABLE_MODULE
 
 ###########################################################
@@ -371,50 +427,74 @@
 endif
 
 ###########################################################
-## Compatibiliy suite files.
+## Compatibility suite files.
 ###########################################################
 ifdef LOCAL_COMPATIBILITY_SUITE
-ifneq ($(words $(LOCAL_COMPATIBILITY_SUITE)),1)
-$(error $(LOCAL_PATH):$(LOCAL_MODULE) LOCAL_COMPATIBILITY_SUITE can be only one name)
-endif
 
 # The module itself.
-my_compat_dist := \
-  $(LOCAL_BUILT_MODULE):$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(my_installed_module_stem)
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
+    $(LOCAL_BUILT_MODULE):$(dir)/$(my_installed_module_stem))))
 
 # Make sure we only add the files once for multilib modules.
 ifndef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
 $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true
 
 # LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of <src>[:<dest>].
-my_compat_dist += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES),\
-  $(eval p := $(subst :,$(space),$(f)))\
-  $(eval s := $(word 1,$(p)))\
-  $(eval d := $(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(or $(word 2,$(p)),$(notdir $(word 1,$(p)))))\
-  $(s):$(d))
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_dist_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \
+    $(eval p := $(subst :,$(space),$(f))) \
+    $(eval s := $(word 1,$(p))) \
+    $(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \
+    $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
+      $(s):$(dir)/$(n)))))
+
 
 ifneq (,$(wildcard $(LOCAL_PATH)/AndroidTest.xml))
-my_compat_dist += \
-  $(LOCAL_PATH)/AndroidTest.xml:$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE).config
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
+    $(LOCAL_PATH)/AndroidTest.xml:$(dir)/$(LOCAL_MODULE).config)))
 endif
 
 ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml))
-my_compat_dist += \
-  $(LOCAL_PATH)/DynamicConfig.xml:$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE).dynamic
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
+    $(LOCAL_PATH)/DynamicConfig.xml:$(dir)/$(LOCAL_MODULE).dynamic)))
 endif
 endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
 
-my_compat_files := $(call copy-many-files, $(my_compat_dist))
+$(call create-suite-dependencies)
 
-COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES := \
-  $(COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES) \
-  $(my_compat_files)
-
-# Copy over the compatibility files when user runs mm/mmm.
-$(my_register_name) : $(my_compat_files)
 endif  # LOCAL_COMPATIBILITY_SUITE
 
 ###########################################################
+## Test Data
+###########################################################
+my_test_data_pairs :=
+my_installed_test_data :=
+
+ifneq ($(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
+ifneq ($(strip $(LOCAL_TEST_DATA)),)
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+
+my_test_data_pairs := $(strip $(foreach td,$(LOCAL_TEST_DATA), \
+    $(eval _file := $(call word-colon,2,$(td))) \
+    $(if $(_file), \
+      $(eval _base := $(call word-colon,1,$(td))), \
+      $(eval _base := $(LOCAL_PATH)) \
+        $(eval _file := $(call word-colon,1,$(td)))) \
+    $(if $(findstring ..,$(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include '..': $(_file))) \
+    $(if $(filter /%,$(_base) $(_file)),$(error $(LOCAL_MODULE_MAKEFILE): LOCAL_TEST_DATA may not include absolute paths: $(_base) $(_file))) \
+    $(call append-path,$(_base),$(_file)):$(call append-path,$(my_module_path),$(_file))))
+
+my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs))
+$(LOCAL_INSTALLED_MODULE): $(my_installed_test_data)
+
+endif
+endif
+endif
+
+###########################################################
 ## Register with ALL_MODULES
 ###########################################################
 
@@ -435,11 +515,12 @@
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
 ALL_MODULES.$(my_register_name).INSTALLED := \
     $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
-    $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed))
+    $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed) $(my_installed_symlinks) \
+    $(my_installed_test_data))
 ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
     $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
     $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \
-    $(addprefix $(my_init_rc_src):,$(my_init_rc_installed)))
+    $(my_init_rc_pairs) $(my_test_data_pairs))
 endif
 ifdef LOCAL_PICKUP_FILES
 # Files or directories ready to pick up by the build system
@@ -454,6 +535,9 @@
 endif
 ALL_MODULES.$(my_register_name).REQUIRED := \
     $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules))
+ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED := \
+    $(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED)\
+        $(my_required_modules))
 ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
     $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
 ALL_MODULES.$(my_register_name).MAKEFILE := \
@@ -478,6 +562,7 @@
   $(LOCAL_STATIC_LIBRARIES) \
   $(LOCAL_WHOLE_STATIC_LIBRARIES) \
   $(LOCAL_SHARED_LIBRARIES) \
+  $(LOCAL_HEADER_LIBRARIES) \
   $(LOCAL_STATIC_JAVA_LIBRARIES) \
   $(LOCAL_JAVA_LIBRARIES)\
   $(LOCAL_JNI_SHARED_LIBRARIES))
@@ -499,7 +584,7 @@
 ## umbrella targets used to verify builds
 ###########################################################
 j_or_n :=
-ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
+ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES HEADER_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)))
 j_or_n := native
 else
 ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
@@ -508,15 +593,26 @@
 endif
 ifdef LOCAL_IS_HOST_MODULE
 h_or_t := host
+ifeq ($(my_host_cross),true)
+h_or_hc_or_t := host-cross
 else
+h_or_hc_or_t := host
+endif
+else
+h_or_hc_or_t := target
 h_or_t := target
 endif
 
+
 ifdef j_or_n
 $(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module)
 ifneq (,$(filter $(my_module_tags),tests))
 $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module)
 endif
+$(LOCAL_MODULE)-$(h_or_hc_or_t) : $(my_all_targets)
+ifeq ($(j_or_n),native)
+$(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets)
+endif
 endif
 
 ###########################################################
diff --git a/core/binary.mk b/core/binary.mk
index 7b22903..589c462 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -30,6 +30,8 @@
   endif
 endif
 
+my_soong_problems :=
+
 # The following LOCAL_ variables will be modified in this file.
 # Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
 # we can't modify them in place.
@@ -38,6 +40,7 @@
 my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
 my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
+my_header_libraries := $(LOCAL_HEADER_LIBRARIES)
 my_cflags := $(LOCAL_CFLAGS)
 my_conlyflags := $(LOCAL_CONLYFLAGS)
 my_cppflags := $(LOCAL_CPPFLAGS)
@@ -52,29 +55,90 @@
 my_cxx_wrapper := $(CXX_WRAPPER)
 my_c_includes := $(LOCAL_C_INCLUDES)
 my_generated_sources := $(LOCAL_GENERATED_SOURCES)
-my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
-my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+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)
+my_arflags :=
 
+ifneq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH)))))
+ifeq (,$(strip $(foreach dir,$(subst $(comma),$(space),$(COVERAGE_EXCLUDE_PATHS)),$(filter $(dir)%,$(LOCAL_PATH)))))
+  my_native_coverage := true
+else
+  my_native_coverage := false
+endif
+else
+  my_native_coverage := false
+endif
+
+my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
+ifdef SANITIZE_HOST
 ifdef LOCAL_IS_HOST_MODULE
 my_allow_undefined_symbols := true
-else
-my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
+endif
 endif
 
 my_ndk_sysroot :=
 my_ndk_sysroot_include :=
 my_ndk_sysroot_lib :=
-ifdef LOCAL_SDK_VERSION
-  ifdef LOCAL_NDK_VERSION
-    $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.)
-  endif
+ifneq ($(LOCAL_SDK_VERSION),)
   ifdef LOCAL_IS_HOST_MODULE
     $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
   endif
-  my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources
-  my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
-  my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include
+
+  # Make sure we've built the NDK.
+  my_additional_dependencies += $(SOONG_OUT_DIR)/ndk.timestamp
+
+  # mips32r6 is not supported by the NDK. No released NDK contains these
+  # libraries, but the r10 in prebuilts/ndk had a local hack to add them :(
+  #
+  # We need to find a real solution to this problem, but until we do just drop
+  # mips32r6 things back to r10 to get the tree building again.
+  ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
+    ifeq ($(LOCAL_NDK_VERSION), current)
+      LOCAL_NDK_VERSION := r10
+    endif
+  endif
+
+  my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
+  ifneq (,$(filter arm64 mips64 x86_64,$(my_arch)))
+    my_min_sdk_version := 21
+  else
+    my_min_sdk_version := 9
+  endif
+
+  # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map
+  # 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 := $(LOCAL_SDK_VERSION)
+  ifneq ($(my_ndk_api),current)
+    my_ndk_api := $(call math_max,$(my_ndk_api),$(my_min_sdk_version))
+  endif
+
+  my_ndk_api_def := $(my_ndk_api)
+  my_ndk_hist_api := $(my_ndk_api)
+  ifeq ($(my_ndk_api),current)
+    my_ndk_api_def := __ANDROID_API_FUTURE__
+    # The last API level supported by the old prebuilt NDKs.
+    my_ndk_hist_api := 24
+  endif
+
+
+  # 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
+  # per-API level copies of that header now.
+  my_cflags += -D__ANDROID_API__=$(my_ndk_api_def)
+
+  my_ndk_source_root := \
+      $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources
+  my_ndk_sysroot := \
+    $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_hist_api)/arch-$(my_arch)
+  my_built_ndk := $(SOONG_OUT_DIR)/ndk
+  my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE)
+  my_ndk_sysroot_include := \
+      $(my_built_ndk)/sysroot/usr/include \
+      $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \
+      $(my_ndk_sysroot)/usr/include \
 
   # x86_64 and and mips64 are both multilib toolchains, so their libraries are
   # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib
@@ -83,14 +147,19 @@
   # Mips32r6 is yet another variation, with libraries installed in libr6.
   #
   # For the rest, the libraries are installed simply to /usr/lib.
-  ifneq (,$(filter x86_64 mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
-    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
+  ifneq (,$(filter x86_64 mips64,$(my_arch)))
+    my_ndk_libdir_name := lib64
   else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
-    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6
+    my_ndk_libdir_name := libr6
   else
-    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
+    my_ndk_libdir_name := lib
   endif
 
+  my_ndk_platform_dir := \
+      $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch)
+  my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name)
+  my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name)
+
   # The bionic linker now has support for packed relocations and gnu style
   # hashes (which are much faster!), but shipping to older devices requires
   # the old style hash. Fortunately, we can build with both and it'll work
@@ -108,9 +177,8 @@
   # See ndk/docs/CPLUSPLUS-SUPPORT.html
   my_ndk_stl_include_path :=
   my_ndk_stl_shared_lib_fullpath :=
-  my_ndk_stl_shared_lib :=
   my_ndk_stl_static_lib :=
-  my_ndk_stl_cppflags :=
+  my_ndk_cpp_std_version :=
   my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
   ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
     my_cpu_variant := mips32r6
@@ -131,22 +199,62 @@
     my_system_shared_libraries += libstdc++
     ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
       my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a
+      my_ldlibs += -ldl
     else
       my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so
-      my_ndk_stl_shared_lib := -lstlport_shared
     endif
   else # LOCAL_NDK_STL_VARIANT is not stlport_* either
   ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
-    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \
-                               $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \
-                               $(my_ndk_source_root)/android/support/include
-    ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
-      my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_static.a
+    # Pre-r11 NDKs used libgabi++ for libc++'s C++ ABI, but r11 and later use
+    # libc++abi.
+    #
+    # r13 no longer has the inner directory as a side effect of just using
+    # external/libcxx.
+    ifeq (r10,$(LOCAL_NDK_VERSION))
+      my_ndk_stl_include_path := \
+        $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include
+      my_ndk_stl_include_path += \
+        $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include
+    else ifeq (r11,$(LOCAL_NDK_VERSION))
+      my_ndk_stl_include_path := \
+        $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include
+      my_ndk_stl_include_path += \
+        $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/libcxxabi/include
     else
-      my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_shared.so
-      my_ndk_stl_shared_lib := -lc++_shared
+      my_ndk_stl_include_path := \
+        $(my_ndk_source_root)/cxx-stl/llvm-libc++/include
+      my_ndk_stl_include_path += \
+        $(my_ndk_source_root)/cxx-stl/llvm-libc++abi/include
     endif
-    my_ndk_stl_cppflags := -std=c++11
+    my_ndk_stl_include_path += $(my_ndk_source_root)/android/support/include
+
+    my_libcxx_libdir := \
+      $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)
+
+    ifneq (,$(filter r10 r11,$(LOCAL_NDK_VERSION)))
+      ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
+        my_ndk_stl_static_lib := $(my_libcxx_libdir)/libc++_static.a
+      else
+        my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
+      endif
+    else
+      ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
+        my_ndk_stl_static_lib := \
+          $(my_libcxx_libdir)/libc++_static.a \
+          $(my_libcxx_libdir)/libc++abi.a
+      else
+        my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
+      endif
+
+      my_ndk_stl_static_lib += $(my_libcxx_libdir)/libandroid_support.a
+      ifneq (,$(filter armeabi armeabi-v7a,$(my_cpu_variant)))
+        my_ndk_stl_static_lib += $(my_libcxx_libdir)/libunwind.a
+      endif
+    endif
+
+    my_ldlibs += -ldl
+
+    my_ndk_cpp_std_version := c++11
   else # LOCAL_NDK_STL_VARIANT is not c++_* either
   ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT)))
     my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \
@@ -160,21 +268,59 @@
   endif
 endif
 
+ifneq ($(LOCAL_USE_VNDK),)
+  my_cflags += -D__ANDROID_API__=__ANDROID_API_FUTURE__
+endif
+
+ifndef LOCAL_IS_HOST_MODULE
+# For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We
+# no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're
+# linking my_shared_libraries by full path now.
+my_allowed_ldlibs :=
+
+# Sort ldlibs and ldflags between -l and other linker flags
+# We'll do this again later, since there are still changes happening, but that's fine.
+my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
+my_ldlibs := $(filter -l%,$(my_ldlib_flags))
+my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
+my_ldlib_flags :=
+
+# Move other ldlibs back to shared libraries
+my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs)))
+my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
+endif
+
+ifneq ($(LOCAL_SDK_VERSION),)
+  my_all_ndk_libraries := \
+      $(NDK_MIGRATED_LIBS) $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES))
+  my_ndk_shared_libraries := \
+      $(filter $(my_all_ndk_libraries),\
+        $(my_shared_libraries) $(my_system_shared_libraries))
+
+  my_shared_libraries := \
+      $(filter-out $(my_all_ndk_libraries),$(my_shared_libraries))
+  my_system_shared_libraries := \
+      $(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries))
+endif
+
 # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
 # all code is position independent, and then those warnings get promoted to
 # errors.
+ifneq ($(LOCAL_NO_PIC),true)
 ifneq ($($(my_prefix)OS),windows)
-ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
 my_cflags += -fpie
 else
 my_cflags += -fPIC
 endif
 endif
+endif
 
 ifdef LOCAL_IS_HOST_MODULE
 my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
 my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS))
 my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS))
+my_header_libraries += $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)OS))
 my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS))
 my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS))
 my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS))
@@ -201,6 +347,10 @@
 endif
 my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files))
 
+# Strip '/' from the beginning of each src file. This helps the ../ detection in case
+# the source file is in the form of /../file
+my_src_files := $(patsubst /%,%,$(my_src_files))
+
 my_clang := $(strip $(LOCAL_CLANG))
 ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
 my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
@@ -209,13 +359,32 @@
 my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
 endif
 
+# if custom toolchain is in use, default is not to use clang, if not explicitly required
+ifneq ($(my_cc)$(my_cxx),)
+    ifeq ($(my_clang),)
+        my_clang := false
+    endif
+endif
+# Issue warning if LOCAL_CLANG* is set to false and the local makefile is not found
+# in the exception project list.
+ifeq ($(my_clang),false)
+    ifeq ($(call find_in_local_clang_exception_projects,$(LOCAL_MODULE_MAKEFILE))$(LOCAL_IS_AUX_MODULE),)
+        $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_CLANG is set to false)
+    endif
+endif
+
 # clang is enabled by default for host builds
 # enable it unless we've specifically disabled clang above
 ifdef LOCAL_IS_HOST_MODULE
-    ifneq ($($(my_prefix)OS),windows)
-    ifeq ($(my_clang),)
-        my_clang := true
-    endif
+    ifeq ($($(my_prefix)OS),windows)
+        ifeq ($(my_clang),true)
+            $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Clang is not yet supported for windows binaries)
+        endif
+        my_clang := false
+    else
+        ifeq ($(my_clang),)
+            my_clang := true
+        endif
     endif
 # Add option to make gcc the default for device build
 else ifeq ($(USE_CLANG_PLATFORM_BUILD),false)
@@ -226,34 +395,56 @@
     my_clang := true
 endif
 
-my_cpp_std_version := -std=gnu++14
+ifeq ($(LOCAL_C_STD),)
+    my_c_std_version := $(DEFAULT_C_STD_VERSION)
+else ifeq ($(LOCAL_C_STD),experimental)
+    my_c_std_version := $(EXPERIMENTAL_C_STD_VERSION)
+else
+    my_c_std_version := $(LOCAL_C_STD)
+endif
+
+ifeq ($(LOCAL_CPP_STD),)
+    my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION)
+else ifeq ($(LOCAL_CPP_STD),experimental)
+    my_cpp_std_version := $(EXPERIMENTAL_CPP_STD_VERSION)
+else
+    my_cpp_std_version := $(LOCAL_CPP_STD)
+endif
 
 ifneq ($(my_clang),true)
     # GCC uses an invalid C++14 ABI (emits calls to
     # __cxa_throw_bad_array_length, which is not a valid C++ RT ABI).
     # http://b/25022512
-    my_cpp_std_version := -std=gnu++11
+    my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION)
 endif
 
 ifdef LOCAL_SDK_VERSION
     # The NDK handles this itself.
-    my_cpp_std_version :=
+    my_cpp_std_version := $(my_ndk_cpp_std_version)
 endif
 
 ifdef LOCAL_IS_HOST_MODULE
     ifneq ($(my_clang),true)
         # The host GCC doesn't support C++14 (and is deprecated, so likely
         # never will). Build these modules with C++11.
-        my_cpp_std_version := -std=gnu++11
+        my_cpp_std_version := $(DEFAULT_GCC_CPP_STD_VERSION)
     endif
 endif
 
-my_cppflags := $(my_cpp_std_version) $(my_cppflags)
+my_c_std_conlyflags :=
+my_cpp_std_cppflags :=
+ifneq (,$(my_c_std_version))
+    my_c_std_conlyflags := -std=$(my_c_std_version)
+endif
 
+ifneq (,$(my_cpp_std_version))
+   my_cpp_std_cppflags := -std=$(my_cpp_std_version)
+endif
 
 # arch-specific static libraries go first so that generic ones can depend on them
 my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
+my_header_libraries := $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_HEADER_LIBRARIES_$(my_32_64_bit_suffix)) $(my_header_libraries)
 
 include $(BUILD_SYSTEM)/cxx_stl_setup.mk
 
@@ -269,15 +460,32 @@
 ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),)
   my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)
 else
-  my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LINKER)
+  my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER)
 endif
 
 include $(BUILD_SYSTEM)/config_sanitizers.mk
 
+ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true)
 # Add in libcompiler_rt for all regular device builds
-ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT))
+ifeq (,$(WITHOUT_LIBCOMPILER_RT))
   my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
+endif
+
+# Statically link libwinpthread when cross compiling win32.
+ifeq ($($(my_prefix)OS),windows)
+  my_static_libraries += libwinpthread
+endif
+
+ifneq ($(filter ../%,$(my_src_files)),)
+my_soong_problems += dotdot_srcs
+endif
+ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),)
+my_soong_problems += dotdot_incs
+endif
+ifneq ($(filter %.arm,$(my_src_files)),)
+my_soong_problems += srcs_dotarm
+endif
 
 ####################################################
 ## Add FDO flags if FDO is turned on and supported
@@ -306,35 +514,79 @@
 ###########################################################
 my_asflags += -D__ASSEMBLY__
 
+###########################################################
+## When compiling against the VNDK, use LL-NDK libraries
+###########################################################
+ifneq ($(LOCAL_USE_VNDK),)
+  ####################################################
+  ## Soong modules may be built twice, once for /system
+  ## and once for /vendor. If we're using the VNDK,
+  ## switch all soong libraries over to the /vendor
+  ## variant.
+  ####################################################
+  ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+    # Soong-built libraries should always use the .vendor variant
+    my_whole_static_libraries := $(addsuffix .vendor,$(my_whole_static_libraries))
+    my_static_libraries := $(addsuffix .vendor,$(my_static_libraries))
+    my_shared_libraries := $(addsuffix .vendor,$(my_shared_libraries))
+    my_system_shared_libraries := $(addsuffix .vendor,$(my_system_shared_libraries))
+    my_header_libraries := $(addsuffix .vendor,$(my_header_libraries))
+  else
+    my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
+      $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
+    my_static_libraries := $(foreach l,$(my_static_libraries),\
+      $(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
+    my_shared_libraries := $(foreach l,$(my_shared_libraries),\
+      $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
+    my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
+      $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
+    my_header_libraries := $(foreach l,$(my_header_libraries),\
+      $(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l)))
+  endif
+endif
 
 ###########################################################
 ## Define PRIVATE_ variables from global vars
 ###########################################################
 ifndef LOCAL_IS_HOST_MODULE
-ifdef LOCAL_SDK_VERSION
-my_target_project_includes :=
-my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
-my_target_global_cppflags := $(my_ndk_stl_cppflags)
+ifdef LOCAL_USE_VNDK
+my_target_global_c_includes := \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES)
+my_target_global_c_system_includes := \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES)
+else ifdef LOCAL_SDK_VERSION
+my_target_global_c_includes :=
+my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include)
+else ifdef BOARD_VNDK_VERSION
+my_target_global_c_includes := $(SRC_HEADERS) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
+my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
 else
-my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES)
-my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
-my_target_global_cppflags :=
-endif # LOCAL_SDK_VERSION
+my_target_global_c_includes := $(SRC_HEADERS) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
+my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) $(TARGET_OUT_HEADERS) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
+endif
 
 ifeq ($(my_clang),true)
-my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS)
-my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CONLYFLAGS)
-my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS)
-my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS)
+my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
+my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
+my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
 else
-my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS)
-my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CONLYFLAGS)
-my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS)
-my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS)
+my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
+my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
+my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
 endif # my_clang
 
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
@@ -342,21 +594,25 @@
 
 else # LOCAL_IS_HOST_MODULE
 
+my_host_global_c_includes := $(SRC_HEADERS) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
+my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
+    $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
+
 ifeq ($(my_clang),true)
 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
-my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS)
-my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS)
+my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
-my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
 else
 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
-my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS)
-my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS)
+my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
+my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
-my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
 endif # my_clang
 
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
@@ -378,28 +634,25 @@
         my_cflags += --coverage -O0
         my_ldflags += --coverage
     endif
+
+    ifeq ($(my_clang),true)
+        my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
+    else
+        my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,$(filter AUX,$(my_kind)),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a
+    endif
+
+    $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
+    $(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib)
 else
     my_native_coverage := false
 endif
 
-ifeq ($(my_clang),true)
-    my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT)
-else
-    my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV)
-endif
-
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
-
 ###########################################################
 ## Define PRIVATE_ variables used by multiple module types
 ###########################################################
 $(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
@@ -413,7 +666,7 @@
 ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
   my_syntax_arch := host
 else
-  my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
+  my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
 endif
 
 ifeq ($(strip $(my_cc)),)
@@ -428,10 +681,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)
@@ -448,10 +697,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)
@@ -467,9 +712,18 @@
 # Certain modules like libdl have to have symbols resolved at runtime and blow
 # up if --no-undefined is passed to the linker.
 ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
-ifeq ($(my_allow_undefined_symbols),)
-  my_ldflags +=  $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
-endif
+  ifeq ($(my_allow_undefined_symbols),)
+    ifneq ($(HOST_OS),darwin)
+      my_ldflags += -Wl,--no-undefined
+    endif
+  else
+    ifdef LOCAL_IS_HOST_MODULE
+      ifeq ($(HOST_OS),darwin)
+        # darwin defaults to treating undefined symbols as errors
+        my_ldflags += -Wl,-undefined,dynamic_lookup
+      endif
+    endif
+  endif
 endif
 
 ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
@@ -492,8 +746,8 @@
 arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
 normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
 ifeq ($(my_clang),true)
-arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
-normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
+arm_objects_cflags := $(call convert-to-clang-flags,$(arm_objects_cflags))
+normal_objects_cflags := $(call convert-to-clang-flags,$(normal_objects_cflags))
 endif
 
 else
@@ -530,7 +784,7 @@
 
 my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
 
-$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP)
+$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/%
 	@echo "Copy: $@"
 	$(copy-file-to-target)
 
@@ -551,6 +805,7 @@
 renderscript_sources := $(filter %.rs %.fs,$(my_src_files))
 
 ifneq (,$(renderscript_sources))
+my_soong_problems += rs
 
 renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
 RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
@@ -583,7 +838,7 @@
 
 renderscript_includes := \
     $(TOPDIR)external/clang/lib/Headers \
-    $(TOPDIR)frameworks/rs/scriptc \
+    $(TOPDIR)frameworks/rs/script_api/include \
     $(LOCAL_RENDERSCRIPT_INCLUDES)
 
 ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
@@ -603,8 +858,8 @@
 $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
 	$(transform-renderscripts-to-cpp-and-bc)
 
-# include the dependency files (.d/.P) generated by llvm-rs-cc.
-$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp))
+# include the dependency files (.d) generated by llvm-rs-cc.
+$(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp))
 
 LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
 
@@ -631,6 +886,7 @@
 proto_sources := $(filter %.proto,$(my_src_files))
 ifneq ($(proto_sources),)
 proto_gen_dir := $(generated_sources_dir)/proto
+proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
 
 my_rename_cpp_ext :=
 ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE)))
@@ -638,6 +894,7 @@
 my_proto_c_includes := external/nanopb-c
 my_protoc_flags := --nanopb_out=$(proto_gen_dir) \
     --plugin=external/nanopb-c/generator/protoc-gen-nanopb
+my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options)
 else
 my_proto_source_suffix := $(LOCAL_CPP_EXTENSION)
 ifneq ($(my_proto_source_suffix),.cc)
@@ -648,10 +905,10 @@
 my_proto_c_includes := external/protobuf/src
 my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
 my_protoc_flags := --cpp_out=$(proto_gen_dir)
+my_protoc_deps :=
 endif
 my_proto_c_includes += $(proto_gen_dir)
 
-proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
 proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \
     $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
 
@@ -671,7 +928,7 @@
 proto_intermediate_dir := $(intermediates)/proto
 proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\
     $(proto_generated_cpps))
-$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/% | $(ACP)
+$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/%
 	@echo "Copy: $@"
 	$(copy-file-to-target)
 	$(hide) cp $(basename $<).h $(basename $@).h
@@ -693,6 +950,8 @@
     else
         my_shared_libraries += libprotobuf-cpp-full
     endif
+else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static)
+    my_static_libraries += libprotobuf-cpp-lite
 else
     ifdef LOCAL_SDK_VERSION
         my_static_libraries += libprotobuf-cpp-lite-ndk
@@ -703,61 +962,6 @@
 endif  # $(proto_sources) non-empty
 
 ###########################################################
-## Compile the .dbus-xml files to c++ headers
-###########################################################
-dbus_definitions := $(filter %.dbus-xml,$(my_src_files))
-dbus_generated_headers :=
-ifneq ($(dbus_definitions),)
-
-dbus_definition_paths := $(addprefix $(LOCAL_PATH)/,$(dbus_definitions))
-dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files))
-dbus_service_config_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config))
-
-# Mark these source files as not producing objects
-$(call track-src-file-obj,$(dbus_definitions) $(dbus_service_config),)
-
-dbus_gen_dir := $(generated_sources_dir)/dbus_bindings
-
-ifdef LOCAL_DBUS_PROXY_PREFIX
-dbus_header_dir := $(dbus_gen_dir)/include/$(LOCAL_DBUS_PROXY_PREFIX)
-dbus_headers := dbus-proxies.h
-else
-dbus_header_dir := $(dbus_gen_dir)
-dbus_headers := $(patsubst %.dbus-xml,%.h,$(dbus_definitions))
-endif
-dbus_generated_headers := $(addprefix $(dbus_header_dir)/,$(dbus_headers))
-
-# Ensure that we only define build rules once in multilib builds.
-ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
-$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true
-
-$(dbus_generated_headers): PRIVATE_MODULE := $(LOCAL_MODULE)
-$(dbus_generated_headers): PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_path)
-$(dbus_generated_headers) : $(dbus_service_config_path) $(DBUS_GENERATOR)
-ifdef LOCAL_DBUS_PROXY_PREFIX
-$(dbus_generated_headers) : $(dbus_definition_paths)
-	$(generate-dbus-proxies)
-else
-$(dbus_generated_headers) : $(dbus_header_dir)/%.h : $(LOCAL_PATH)/%.dbus-xml
-	$(generate-dbus-adaptors)
-endif  # $(LOCAL_DBUS_PROXY_PREFIX)
-endif  # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
-
-ifdef LOCAL_DBUS_PROXY_PREFIX
-# Auto-export the generated dbus proxy directory.
-my_export_c_include_dirs += $(dbus_gen_dir)/include
-my_c_includes += $(dbus_gen_dir)/include
-else
-my_export_c_include_dirs += $(dbus_header_dir)
-my_c_includes += $(dbus_header_dir)
-endif  # $(LOCAL_DBUS_PROXY_PREFIX)
-
-my_generated_sources += $(dbus_generated_headers)
-
-endif  # $(dbus_definitions) non-empty
-
-
-###########################################################
 ## AIDL: Compile .aidl files to .cpp and .h files
 ###########################################################
 aidl_src := $(strip $(filter %.aidl,$(my_src_files)))
@@ -773,7 +977,7 @@
 $(foreach s,$(aidl_src),\
     $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
 $(foreach cpp,$(aidl_gen_cpp), \
-    $(call include-depfile,$(addsuffix .aidl.P,$(basename $(cpp))),$(cpp)))
+    $(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp)))
 $(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp))
 
 $(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
@@ -795,6 +999,7 @@
 vts_src := $(strip $(filter %.vts,$(my_src_files)))
 vts_gen_cpp :=
 ifneq ($(vts_src),)
+my_soong_problems += vts
 
 # Use the intermediates directory to avoid writing our own .cpp -> .o rules.
 vts_gen_cpp_root := $(intermediates)/vts-generated/src
@@ -810,7 +1015,7 @@
 
 $(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
 $(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root)
-$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES))
+$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) $(addprefix -m,$(LOCAL_VTS_MODE))
 
 # Add generated headers to include paths.
 my_c_includes += $(vts_gen_include_root)
@@ -829,7 +1034,7 @@
     $(intermediates)/,$(y_yacc_sources:.y=.c))
 ifneq ($(y_yacc_cs),)
 $(y_yacc_cs): $(intermediates)/%.c: \
-    $(TOPDIR)$(LOCAL_PATH)/%.y \
+    $(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) \
     $(my_additional_dependencies)
 	$(call transform-y-to-c-or-cpp)
 $(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs))
@@ -842,7 +1047,7 @@
     $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
 ifneq ($(yy_yacc_cpps),)
 $(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
-    $(TOPDIR)$(LOCAL_PATH)/%.yy \
+    $(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) \
     $(my_additional_dependencies)
 	$(call transform-y-to-c-or-cpp)
 $(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps))
@@ -970,7 +1175,7 @@
 ifneq ($(strip $(gen_s_objects)),)
 $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
     $(my_additional_dependencies)
-	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
+	$(transform-$(PRIVATE_HOST)s-to-o)
 endif
 
 gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
@@ -1057,6 +1262,7 @@
 $(call track-src-file-obj,$(objc_sources),$(objc_objects))
 
 ifneq ($(strip $(objc_objects)),)
+my_soong_problems += objc
 $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \
     $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)m-to-o)
@@ -1118,7 +1324,7 @@
 ifneq ($(strip $(asm_objects_s)),)
 $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
     $(my_additional_dependencies)
-	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
+	$(transform-$(PRIVATE_HOST)s-to-o)
 endif
 
 asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
@@ -1144,7 +1350,7 @@
 ## they may cusomize their install path with LOCAL_MODULE_PATH
 ##########################################################
 # Get the list of INSTALLED libraries as module names.
-ifdef LOCAL_SDK_VERSION
+ifneq ($(LOCAL_SDK_VERSION),)
   installed_shared_library_module_names := \
       $(my_shared_libraries)
 else
@@ -1168,11 +1374,13 @@
 import_includes := $(intermediates)/import_includes
 import_includes_deps := $(strip \
     $(foreach l, $(installed_shared_library_module_names), \
-      $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \
+      $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \
     $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
-      $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+      $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \
+    $(foreach l, $(my_header_libraries), \
+      $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
 $(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
-$(import_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(import_includes_deps)
+$(import_includes) : $(import_includes_deps)
 	@echo Import includes file: $@
 	$(hide) mkdir -p $(dir $@) && rm -f $@
 ifdef import_includes_deps
@@ -1183,13 +1391,52 @@
 	$(hide) touch $@
 endif
 
+####################################################
+## Verify that NDK-built libraries only link against
+## other NDK-built libraries
+####################################################
+
+my_link_type := $(intermediates)/link_type
+all_link_types: $(my_link_type)
+ifdef LOCAL_SDK_VERSION
+$(my_link_type): PRIVATE_LINK_TYPE := native:ndk
+$(my_link_type): PRIVATE_WARN_TYPES :=
+$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk
+else ifdef LOCAL_USE_VNDK
+$(my_link_type): PRIVATE_LINK_TYPE := native:vendor
+$(my_link_type): PRIVATE_WARN_TYPES :=
+$(my_link_type): PRIVATE_ALLOWED_TYPES := native:vendor
+else
+$(my_link_type): PRIVATE_LINK_TYPE := native:platform
+$(my_link_type): PRIVATE_WARN_TYPES :=
+$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk native:platform
+endif
+$(eval $(call link-type-partitions,$(my_link_type)))
+my_link_type_deps := $(strip \
+   $(foreach l,$(my_whole_static_libraries) $(my_static_libraries), \
+     $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
+ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
+ifneq ($(LOCAL_MODULE_CLASS),HEADER_LIBRARIES)
+my_link_type_deps += $(strip \
+   $(foreach l,$(my_shared_libraries), \
+     $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
+endif
+endif
+$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
+$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
+$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
+	@echo Check module type: $@
+	$(check-link-type)
+
+
 ###########################################################
 ## Common object handling.
 ###########################################################
 
 my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files))
 ifneq ($(my_unused_src_files),)
-  $(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files))
+  $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files))
 endif
 
 # some rules depend on asm_objects being first.  If your code depends on
@@ -1233,16 +1480,17 @@
   my_c_includes += $(JNI_H_INCLUDE)
 endif
 
+my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes)))
+ifneq ($(my_outside_includes),)
+$(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): C_INCLUDES must be under the source or output directories: $(my_outside_includes))
+endif
+
 # all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
 # use normal_objects here to avoid creating circular dependencies. This assumes
 # that custom build rules which generate .o files don't consume other generated
 # sources as input (or if they do they take care of that dependency themselves).
 $(normal_objects) : | $(my_generated_sources)
-ifeq ($(BUILDING_WITH_NINJA),true)
 $(all_objects) : $(import_includes)
-else
-$(all_objects) : | $(import_includes)
-endif
 ALL_C_CPP_ETC_OBJECTS += $(all_objects)
 
 
@@ -1279,7 +1527,7 @@
 so_suffix := $($(my_prefix)SHLIB_SUFFIX)
 a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
 
-ifdef LOCAL_SDK_VERSION
+ifneq ($(LOCAL_SDK_VERSION),)
 built_shared_libraries := \
     $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
       $(addsuffix $(so_suffix), \
@@ -1292,26 +1540,32 @@
     $(addprefix $(my_ndk_sysroot_lib)/, \
         $(addsuffix $(so_suffix), $(my_system_shared_libraries)))
 
-built_shared_libraries += $(my_system_shared_libraries_fullpath)
+# We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of
+# whether the libs are generated or prebuilt, so we simply can't split into two
+# lists and use addprefix.
+my_ndk_shared_libraries_fullpath := \
+    $(foreach _lib,$(my_ndk_shared_libraries),\
+        $(if $(filter $(NDK_MIGRATED_LIBS),$(_lib)),\
+            $(my_built_ndk_libs)/$(_lib)$(so_suffix),\
+            $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix)))
+
+built_shared_libraries += \
+    $(my_ndk_shared_libraries_fullpath) \
+    $(my_system_shared_libraries_fullpath) \
+
 else
 built_shared_libraries := \
     $(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
 
 built_static_libraries := \
     $(foreach lib,$(my_static_libraries), \
       $(call intermediates-dir-for, \
-        STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
+        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
 
 ifdef LOCAL_SDK_VERSION
 built_static_libraries += $(my_ndk_stl_static_lib)
@@ -1320,7 +1574,7 @@
 built_whole_libraries := \
     $(foreach lib,$(my_whole_static_libraries), \
       $(call intermediates-dir-for, \
-        STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
+        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
 
 # We don't care about installed static libraries, since the
 # libraries have already been linked into the module at that point.
@@ -1353,10 +1607,14 @@
 my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
 my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
 my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
-my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags))
-my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags))
-my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags))
-my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags))
+my_cflags := $(call convert-to-clang-flags,$(my_cflags))
+my_cppflags := $(call convert-to-clang-flags,$(my_cppflags))
+my_asflags := $(call convert-to-clang-flags,$(my_asflags))
+my_ldflags := $(call convert-to-clang-flags,$(my_ldflags))
+else
+# gcc does not handle hidden functions in a manner compatible with LLVM libcxx
+# see b/27908145
+my_cflags += -Wno-attributes
 endif
 
 ifeq ($(my_fdo_build), true)
@@ -1374,6 +1632,97 @@
 my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
 my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
 
+# We can enforce some rules more strictly in the code we own. my_strict
+# indicates if this is code that we can be stricter with. If we have rules that
+# we want to apply to *our* code (but maybe can't for vendor/device specific
+# things), we could extend this to be a ternary value.
+my_strict := true
+ifneq ($(filter external/%,$(LOCAL_PATH)),)
+    my_strict := false
+endif
+
+# Can be used to make some annotations stricter for code we can fix (such as
+# when we mark functions as deprecated).
+ifeq ($(my_strict),true)
+    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
+else
+  # If LOCAL_TIDY is not defined, use global WITH_TIDY
+  my_tidy_enabled := $(LOCAL_TIDY)
+  ifeq ($(my_tidy_enabled),)
+    my_tidy_enabled := $(WITH_TIDY)
+  endif
+endif
+
+# my_tidy_checks is empty if clang-tidy is disabled.
+my_tidy_checks :=
+my_tidy_flags :=
+ifneq (,$(filter 1 true,$(my_tidy_enabled)))
+  ifneq ($(my_clang),true)
+    # Disable clang-tidy if clang is disabled.
+    my_tidy_enabled := false
+  else
+    tidy_only: $(cpp_objects) $(c_objects)
+    # Set up global default checks
+    my_tidy_checks := $(WITH_TIDY_CHECKS)
+    ifeq ($(my_tidy_checks),)
+      my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH))
+    endif
+    # Append local clang-tidy checks.
+    ifneq ($(LOCAL_TIDY_CHECKS),)
+      my_tidy_checks := $(my_tidy_checks),$(LOCAL_TIDY_CHECKS)
+    endif
+    # Set up global default clang-tidy flags, which is none.
+    my_tidy_flags := $(WITH_TIDY_FLAGS)
+    # Use local clang-tidy flags if specified.
+    ifneq ($(LOCAL_TIDY_FLAGS),)
+      my_tidy_flags := $(LOCAL_TIDY_FLAGS)
+    endif
+    # If tidy flags are not specified, default to check all header files.
+    ifeq ($(my_tidy_flags),)
+      my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH))
+    endif
+  endif
+endif
+
+my_tidy_checks := $(subst $(space),,$(my_tidy_checks))
+
+# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
+my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
+my_ldlibs := $(filter -l%,$(my_ldlib_flags))
+my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
+
+# One last verification check for ldlibs
+ifndef LOCAL_IS_HOST_MODULE
+my_allowed_ldlibs :=
+ifneq ($(LOCAL_SDK_VERSION),)
+  my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES))
+endif
+
+my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs))
+ifneq ($(my_bad_ldlibs),)
+  $(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs))
+endif
+endif
+
+# my_cxx_ldlibs may contain linker flags need to wrap certain libraries
+# (start-group/end-group), so append after the check above.
+my_ldlibs += $(my_cxx_ldlibs)
+
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
@@ -1387,13 +1736,16 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags)
 
 # this is really the way to get the files onto the command line instead
 # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
 
 ###########################################################
 # Define library dependencies.
@@ -1414,31 +1766,85 @@
 # Export includes
 ###########################################################
 export_includes := $(intermediates)/export_includes
-$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
+export_cflags := $(foreach d,$(my_export_c_include_dirs),-I $(d))
+# Soong exports cflags instead of include dirs, so that -isystem can be included.
+ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+export_cflags += $(LOCAL_EXPORT_CFLAGS)
+else ifdef LOCAL_EXPORT_CFLAGS
+$(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead)
+endif
+$(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags)
+# Headers exported by whole static libraries are also exported by this library.
+export_include_deps := $(strip \
+   $(foreach l,$(my_whole_static_libraries), \
+     $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+# Re-export requested headers from shared libraries.
+export_include_deps += $(strip \
+   $(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
+     $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+# Re-export requested headers from static libraries.
+export_include_deps += $(strip \
+   $(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
+     $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+# Re-export requested headers from header libraries.
+export_include_deps += $(strip \
+   $(foreach l,$(LOCAL_EXPORT_HEADER_LIBRARY_HEADERS), \
+     $(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
+$(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) $(LOCAL_EXPORT_C_INCLUDE_DEPS)
 	@echo Export includes file: $< -- $@
-	$(hide) mkdir -p $(dir $@) && rm -f [email protected]
-ifdef my_export_c_include_dirs
-	$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
-	        echo "-I $$d" >> [email protected]; \
-	        done
-else
-	$(hide) touch [email protected]
+	$(hide) mkdir -p $(dir $@) && rm -f [email protected] && touch [email protected]
+ifdef export_cflags
+	$(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >>[email protected]
 endif
-ifeq ($(BUILDING_WITH_NINJA),true)
+ifdef export_include_deps
+	$(hide) for f in $(PRIVATE_REEXPORTED_INCLUDES); do \
+		cat $$f >> [email protected]; \
+		done
+endif
 	$(hide) if cmp -s [email protected] $@ ; then \
 	  rm [email protected] ; \
 	else \
 	  mv [email protected] $@ ; \
 	fi
-else
-	mv [email protected] $@ ;
-endif
+export_cflags :=
 
 # Kati adds restat=1 to ninja. GNU make does nothing for this.
 .KATI_RESTAT: $(export_includes)
 
 # Make sure export_includes gets generated when you are running mm/mmm
-$(LOCAL_BUILT_MODULE) : | $(export_includes)
+$(LOCAL_BUILT_MODULE) : | $(export_includes) $(my_link_type)
+
+ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs)))
+my_soong_problems += non_local__export_c_include_dirs
+endif
+
+SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
+    $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems)
+SOONG_CONV.$(LOCAL_MODULE).DEPS := \
+    $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \
+    $(my_static_libraries) \
+    $(my_whole_static_libraries) \
+    $(my_shared_libraries) \
+    $(my_system_shared_libraries)
+SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
+endif
+
+###########################################################
+# Coverage packaging.
+###########################################################
+ifeq ($(my_native_coverage),true)
+my_gcno_objects := \
+    $(cpp_objects) \
+    $(gen_cpp_objects) \
+    $(c_objects) \
+    $(gen_c_objects) \
+    $(objc_objects) \
+    $(objcpp_objects)
+
+LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(my_gcno_objects))
+$(foreach f,$(my_gcno_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno))))
+endif
diff --git a/core/build-system.html b/core/build-system.html
index bddde6a..e72e141 100644
--- a/core/build-system.html
+++ b/core/build-system.html
@@ -438,7 +438,7 @@
 GEN := $(intermediates)/<font color=red>file.c</font>
 $(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/<font color=red>input.file</font>
 $(GEN): PRIVATE_CUSTOM_TOOL = <font color=red>cat $(PRIVATE_INPUT_FILE) &gt; $@</font>
-$(GEN): <font color=red>$(LOCAL_PATH)/file.c</font>
+$(GEN): <font color=red>$(LOCAL_PATH)/input.file</font>
 	$(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
 </pre>
@@ -707,6 +707,11 @@
 them here.  For example:</p>
 <p><code>LOCAL_JAVACFLAGS += -Xlint:deprecation</code></p>
 
+<h4>LOCAL_ERROR_PRONE_FLAGS</h4>
+<p>If you have additional flags to pass into the error prone compiler, add
+them here.  For example:</p>
+<p><code>LOCAL_ERROR_PRONE_FLAGS += -Xep:ClassCanBeStatic:ERROR</code></p>
+
 <h4>LOCAL_JAVA_LIBRARIES</h4>
 <p>When linking Java apps and libraries, <code>LOCAL_JAVA_LIBRARIES</code>
 specifies which sets of java classes to include.  Currently there are
diff --git a/core/build_id.mk b/core/build_id.mk
index 5a012b9..0690c04 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -18,4 +18,4 @@
 # (like "CRB01").  It must be a single word, and is
 # capitalized by convention.
 
-export BUILD_ID=NYC
+export BUILD_ID=OC
diff --git a/core/build_rro_package.mk b/core/build_rro_package.mk
index 9865b33..ffefb9c 100644
--- a/core/build_rro_package.mk
+++ b/core/build_rro_package.mk
@@ -15,7 +15,7 @@
   $(error runtime resource overlay package should not contain sources)
 endif
 
-ifeq (S(LOCAL_RRO_THEME),)
+ifeq ($(LOCAL_RRO_THEME),)
   LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/overlay
 else
   LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/overlay/$(LOCAL_RRO_THEME)
diff --git a/core/ccache.mk b/core/ccache.mk
index 5c2ae23..d67bce6 100644
--- a/core/ccache.mk
+++ b/core/ccache.mk
@@ -17,7 +17,7 @@
 ifneq ($(filter-out false,$(USE_CCACHE)),)
   # The default check uses size and modification time, causing false misses
   # since the mtime depends when the repo was checked out
-  export CCACHE_COMPILERCHECK := content
+  export CCACHE_COMPILERCHECK ?= content
 
   # See man page, optimizations to get more cache hits
   # implies that __DATE__ and __TIME__ are not critical for functionality.
diff --git a/core/clang/HOST_CROSS_x86.mk b/core/clang/HOST_CROSS_x86.mk
index b78a074..bf48f95 100644
--- a/core/clang/HOST_CROSS_x86.mk
+++ b/core/clang/HOST_CROSS_x86.mk
@@ -1,56 +1 @@
-
-include $(BUILD_SYSTEM)/clang/x86.mk
-
-CLANG_CONFIG_x86_HOST_CROSS_TRIPLE := i686-pc-mingw32
-
-CLANG_CONFIG_x86_HOST_CROSS_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE)
-
-CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CPPFLAGS) \
-  -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE)
-
-CLANG_CONFIG_x86_HOST_CROSS_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CONLYFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CONLYFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CPPFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CPPFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_LDFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_LDFLAGS)
-
 $(clang_2nd_arch_prefix)HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686.a
diff --git a/core/clang/HOST_CROSS_x86_64.mk b/core/clang/HOST_CROSS_x86_64.mk
index b6f2de9..f921a1c 100644
--- a/core/clang/HOST_CROSS_x86_64.mk
+++ b/core/clang/HOST_CROSS_x86_64.mk
@@ -1,56 +1 @@
-
-include $(BUILD_SYSTEM)/clang/x86_64.mk
-
-CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE := x86_64-pc-mingw32
-
-CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE)
-
-CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_CPPFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE)
-
-CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CONLYFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CONLYFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CPPFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CPPFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_LDFLAGS := \
-  $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_LDFLAGS)
-
 $(clang_2nd_arch_prefix)HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a
diff --git a/core/clang/HOST_x86.mk b/core/clang/HOST_x86.mk
index 0ec64ad..0722b2a 100644
--- a/core/clang/HOST_x86.mk
+++ b/core/clang/HOST_x86.mk
@@ -1,77 +1 @@
-
-include $(BUILD_SYSTEM)/clang/x86.mk
-include $(BUILD_SYSTEM)/clang/HOST_x86_common.mk
-
-ifeq ($(HOST_OS),linux)
-CLANG_CONFIG_x86_HOST_TRIPLE := i686-linux-gnu
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS)
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS)
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS)
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS)
-endif
-ifeq ($(HOST_OS),darwin)
-CLANG_CONFIG_x86_HOST_TRIPLE := i686-apple-darwin
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS)
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS)
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CPPFLAGS)
-CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_LDFLAGS)
-endif
-
-CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_x86_HOST_TRIPLE)
-
-CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_x86_HOST_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS) \
-  -target $(CLANG_CONFIG_x86_HOST_TRIPLE)
-
-CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_x86_HOST_TRIPLE)
-
-define $(clang_2nd_arch_prefix)convert-to-host-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-x86-flags,\
-  $(filter-out $(CLANG_CONFIG_x86_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CONLYFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_EXTRA_CONLYFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CPPFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_LDFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS)
-
 $(clang_2nd_arch_prefix)HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686.a
diff --git a/core/clang/HOST_x86_64.mk b/core/clang/HOST_x86_64.mk
index d46cb67..4fdffd8 100644
--- a/core/clang/HOST_x86_64.mk
+++ b/core/clang/HOST_x86_64.mk
@@ -1,77 +1 @@
-
-include $(BUILD_SYSTEM)/clang/x86_64.mk
-include $(BUILD_SYSTEM)/clang/HOST_x86_common.mk
-
-ifeq ($(HOST_OS),linux)
-CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-linux-gnu
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS)
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS)
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS)
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS)
-endif
-ifeq ($(HOST_OS),darwin)
-CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-apple-darwin
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS)
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS)
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CPPFLAGS)
-CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_LDFLAGS)
-endif
-
-CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
-
-CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_x86_64_HOST_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
-
-CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE)
-
-define convert-to-host-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-x86_64-flags,\
-  $(filter-out $(CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-CLANG_HOST_GLOBAL_CFLAGS := \
-  $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS)
-
-CLANG_HOST_GLOBAL_CONLYFLAGS := \
-  $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_EXTRA_CONLYFLAGS)
-
-CLANG_HOST_GLOBAL_CPPFLAGS := \
-  $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS)
-
-CLANG_HOST_GLOBAL_LDFLAGS := \
-  $(call convert-to-host-clang-flags,$(HOST_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS)
-
 HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a
diff --git a/core/clang/HOST_x86_common.mk b/core/clang/HOST_x86_common.mk
deleted file mode 100644
index 690c0f6..0000000
--- a/core/clang/HOST_x86_common.mk
+++ /dev/null
@@ -1,55 +0,0 @@
-# Shared by HOST_x86.mk and HOST_x86_64.mk.
-
-ifeq ($(HOST_OS),darwin)
-CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS := \
-  -integrated-as
-
-CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS := \
-  -integrated-as
-
-CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS += -fstack-protector-strong
-endif
-
-ifeq ($(HOST_OS),linux)
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
-  --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-  -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin
-
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)
-
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS += -fstack-protector-strong
-
-ifneq ($(strip $($(clang_2nd_arch_prefix)HOST_IS_64_BIT)),)
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
-  --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8 \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/x86_64-linux \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/backward
-
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
-  --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-  -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin \
-  -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib64/
-else
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
-  --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8 \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/x86_64-linux/32 \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/backward
-
-CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
-  --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \
-  -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin \
-  -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8/32 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8/32 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib32/
-endif
-endif  # Linux
diff --git a/core/clang/TARGET_arm.mk b/core/clang/TARGET_arm.mk
index 5c1bf6f..9c1a836 100644
--- a/core/clang/TARGET_arm.mk
+++ b/core/clang/TARGET_arm.mk
@@ -1,72 +1,8 @@
-
-include $(BUILD_SYSTEM)/clang/arm.mk
-
-CLANG_CONFIG_arm_TARGET_TRIPLE := arm-linux-androideabi
-CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \
-  $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm_TARGET_TRIPLE)/bin
-
-CLANG_CONFIG_arm_TARGET_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_arm_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX)
-
-CLANG_CONFIG_arm_TARGET_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_arm_EXTRA_CFLAGS) \
-  -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \
-  $(CLANG_CONFIG_arm_TARGET_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_arm_TARGET_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_arm_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_arm_EXTRA_CPPFLAGS) \
-  -target $(CLANG_CONFIG_arm_TARGET_TRIPLE)
-
-CLANG_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_arm_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX)
-
-
-define $(clang_2nd_arch_prefix)convert-to-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-arm-flags,\
-  $(filter-out $(CLANG_CONFIG_arm_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_arm_TARGET_EXTRA_CFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CONLYFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_arm_TARGET_EXTRA_CONLYFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_arm_TARGET_EXTRA_CPPFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_arm_TARGET_EXTRA_LDFLAGS)
-
-$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-linux-androideabi
+$(clang_2nd_arch_prefix)RS_TRIPLE := renderscript32-linux-androideabi
 $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS :=
 $(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi
 
 $(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-arm-android.a
 
 # Address sanitizer clang config
-$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-arm-android
 $(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan
diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk
index 15b0172..9a67b6b 100644
--- a/core/clang/TARGET_arm64.mk
+++ b/core/clang/TARGET_arm64.mk
@@ -1,70 +1,8 @@
-
-include $(BUILD_SYSTEM)/clang/arm64.mk
-
-CLANG_CONFIG_arm64_TARGET_TRIPLE := aarch64-linux-android
-CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX := \
-  $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm64_TARGET_TRIPLE)/bin
-
-CLANG_CONFIG_arm64_TARGET_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_arm64_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_arm64_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX)
-
-CLANG_CONFIG_arm64_TARGET_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_arm64_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_arm64_TARGET_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_arm64_TARGET_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_arm64_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_arm64_TARGET_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_arm64_EXTRA_CPPFLAGS) \
-
-CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_arm64_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_arm64_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX)
-
-
-define convert-to-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-arm64-flags,\
-  $(filter-out $(CLANG_CONFIG_arm64_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-CLANG_TARGET_GLOBAL_CFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_arm64_TARGET_EXTRA_CFLAGS)
-
-CLANG_TARGET_GLOBAL_CONLYFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_arm64_TARGET_EXTRA_CONLYFLAGS)
-
-CLANG_TARGET_GLOBAL_CPPFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_arm64_TARGET_EXTRA_CPPFLAGS)
-
-CLANG_TARGET_GLOBAL_LDFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS)
-
-RS_TRIPLE := aarch64-linux-android
+RS_TRIPLE := renderscript64-linux-android
 RS_TRIPLE_CFLAGS :=
 RS_COMPAT_TRIPLE := aarch64-linux-android
 
 TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a
 
 # Address sanitizer clang config
-ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-aarch64-android
 ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64
diff --git a/core/clang/TARGET_mips.mk b/core/clang/TARGET_mips.mk
index 1a0176a..dfd99b2 100644
--- a/core/clang/TARGET_mips.mk
+++ b/core/clang/TARGET_mips.mk
@@ -1,67 +1,8 @@
-
-include $(BUILD_SYSTEM)/clang/mips.mk
-
-CLANG_CONFIG_mips_TARGET_TRIPLE := mipsel-linux-android
-CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX := \
-  $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/mips64el-linux-android/bin
-
-CLANG_CONFIG_mips_TARGET_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_mips_EXTRA_ASFLAGS) \
-  -fPIC \
-  -target $(CLANG_CONFIG_mips_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX)
-
-CLANG_CONFIG_mips_TARGET_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_mips_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_mips_TARGET_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_mips_TARGET_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_mips_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_mips_TARGET_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_mips_EXTRA_CPPFLAGS) \
-
-CLANG_CONFIG_mips_TARGET_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_mips_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_mips_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX)
-
-
-define $(clang_2nd_arch_prefix)convert-to-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-mips-flags,\
-  $(filter-out $(CLANG_CONFIG_mips_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_mips_TARGET_EXTRA_CFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CONLYFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_mips_TARGET_EXTRA_CONLYFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_mips_TARGET_EXTRA_CPPFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_mips_TARGET_EXTRA_LDFLAGS)
-
-$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-linux-androideabi
+$(clang_2nd_arch_prefix)RS_TRIPLE := renderscript32-linux-androideabi
 $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS :=
 RS_COMPAT_TRIPLE := mipsel-linux-android
 
 $(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mipsel-android.a
+
+# Address sanitizer clang config
+$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan
diff --git a/core/clang/TARGET_mips64.mk b/core/clang/TARGET_mips64.mk
index 104fb70..a3684cc 100644
--- a/core/clang/TARGET_mips64.mk
+++ b/core/clang/TARGET_mips64.mk
@@ -1,66 +1,8 @@
-
-include $(BUILD_SYSTEM)/clang/mips64.mk
-
-CLANG_CONFIG_mips64_TARGET_TRIPLE := mips64el-linux-android
-CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX := \
-  $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_mips64_TARGET_TRIPLE)/bin
-
-CLANG_CONFIG_mips64_TARGET_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_mips64_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_mips64_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX)
-
-CLANG_CONFIG_mips64_TARGET_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_mips64_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_mips64_TARGET_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_mips64_TARGET_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_mips64_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_mips64_TARGET_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_mips64_EXTRA_CPPFLAGS) \
-
-CLANG_CONFIG_mips64_TARGET_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_mips64_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_mips64_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX)
-
-
-define convert-to-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-mips64-flags,\
-  $(filter-out $(CLANG_CONFIG_mips64_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-CLANG_TARGET_GLOBAL_CFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_mips64_TARGET_EXTRA_CFLAGS)
-
-CLANG_TARGET_GLOBAL_CONLYFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_mips64_TARGET_EXTRA_CONLYFLAGS)
-
-CLANG_TARGET_GLOBAL_CPPFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_mips64_TARGET_EXTRA_CPPFLAGS)
-
-CLANG_TARGET_GLOBAL_LDFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_mips64_TARGET_EXTRA_LDFLAGS)
-
-RS_TRIPLE := aarch64-linux-android
+RS_TRIPLE := renderscript64-linux-android
 RS_TRIPLE_CFLAGS :=
 RS_COMPAT_TRIPLE := mips64el-linux-android
 
 TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mips64el-android.a
+
+# Address sanitizer clang config
+$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64
diff --git a/core/clang/TARGET_x86.mk b/core/clang/TARGET_x86.mk
index 741768b..1b9c78c 100644
--- a/core/clang/TARGET_x86.mk
+++ b/core/clang/TARGET_x86.mk
@@ -1,77 +1,8 @@
-
-include $(BUILD_SYSTEM)/clang/x86.mk
-
-CLANG_CONFIG_x86_TARGET_TRIPLE := i686-linux-android
-# NOTE: There is no i686-linux-android prebuilt, so we must hardcode the
-# x86_64 target instead.
-CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX := \
-  $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin
-
-CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_x86_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX)
-
-CLANG_CONFIG_x86_TARGET_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS) \
-  -mstackrealign
-
-# -mstackrealign is needed to realign stack in native code
-# that could be called from JNI, so that movaps instruction
-# will work on assumed stack aligned local variables.
-
-CLANG_CONFIG_x86_TARGET_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_x86_TARGET_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \
-
-CLANG_CONFIG_x86_TARGET_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_x86_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX)
-
-
-define $(clang_2nd_arch_prefix)convert-to-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-x86-flags,\
-  $(filter-out $(CLANG_CONFIG_x86_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_x86_TARGET_EXTRA_CFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CONLYFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_x86_TARGET_EXTRA_CONLYFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_x86_TARGET_EXTRA_CPPFLAGS)
-
-$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \
-  $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_x86_TARGET_EXTRA_LDFLAGS)
-
-$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-linux-androideabi
+$(clang_2nd_arch_prefix)RS_TRIPLE := renderscript32-linux-androideabi
 $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := -D__i386__
 $(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := i686-linux-android
 
 $(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686-android.a
 
 # Address sanitizer clang config
-$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-i686-android
 $(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan
diff --git a/core/clang/TARGET_x86_64.mk b/core/clang/TARGET_x86_64.mk
index e44382d..0d3ee3f 100644
--- a/core/clang/TARGET_x86_64.mk
+++ b/core/clang/TARGET_x86_64.mk
@@ -1,65 +1,4 @@
-
-include $(BUILD_SYSTEM)/clang/x86_64.mk
-
-CLANG_CONFIG_x86_64_TARGET_TRIPLE := x86_64-linux-android
-CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX := \
-  $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_x86_64_TARGET_TRIPLE)/bin
-
-CLANG_CONFIG_x86_64_TARGET_EXTRA_ASFLAGS := \
-  $(CLANG_CONFIG_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX)
-
-CLANG_CONFIG_x86_64_TARGET_EXTRA_CFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_64_TARGET_EXTRA_ASFLAGS)
-
-CLANG_CONFIG_x86_64_TARGET_EXTRA_CONLYFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CONLYFLAGS)
-
-CLANG_CONFIG_x86_64_TARGET_EXTRA_CPPFLAGS := \
-  $(CLANG_CONFIG_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \
-
-CLANG_CONFIG_x86_64_TARGET_EXTRA_LDFLAGS := \
-  $(CLANG_CONFIG_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \
-  $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \
-  -target $(CLANG_CONFIG_x86_64_TARGET_TRIPLE) \
-  -B$(CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX)
-
-
-define convert-to-clang-flags
-  $(strip \
-  $(call subst-clang-incompatible-x86_64-flags,\
-  $(filter-out $(CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS),\
-  $(1))))
-endef
-
-CLANG_TARGET_GLOBAL_CFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \
-  $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CFLAGS)
-
-CLANG_TARGET_GLOBAL_CONLYFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CONLYFLAGS)) \
-  $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CONLYFLAGS)
-
-CLANG_TARGET_GLOBAL_CPPFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \
-  $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CPPFLAGS)
-
-CLANG_TARGET_GLOBAL_LDFLAGS := \
-  $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \
-  $(CLANG_CONFIG_x86_64_TARGET_EXTRA_LDFLAGS)
-
-RS_TRIPLE := aarch64-linux-android
+RS_TRIPLE := renderscript64-linux-android
 RS_TRIPLE_CFLAGS := -D__x86_64__
 RS_COMPAT_TRIPLE := x86_64-linux-android
 
diff --git a/core/clang/arm.mk b/core/clang/arm.mk
deleted file mode 100644
index 4053bb2..0000000
--- a/core/clang/arm.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# Clang flags for arm arch, target or host.
-
-CLANG_CONFIG_arm_EXTRA_ASFLAGS :=
-
-CLANG_CONFIG_arm_EXTRA_CFLAGS :=
-
-ifneq (,$(filter krait,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
-  # Android's clang support's krait as a CPU whereas GCC doesn't. Specify
-  # -mcpu here rather than the more normal core/combo/arch/arm/armv7-a-neon.mk.
-  CLANG_CONFIG_arm_EXTRA_CFLAGS += -mcpu=krait -mfpu=neon-vfpv4
-endif
-
-CLANG_CONFIG_arm_EXTRA_CPPFLAGS :=
-
-CLANG_CONFIG_arm_EXTRA_LDFLAGS :=
-
-# Include common unknown flags
-CLANG_CONFIG_arm_UNKNOWN_CFLAGS := \
-  $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
-  -mthumb-interwork \
-  -fgcse-after-reload \
-  -frerun-cse-after-loop \
-  -frename-registers \
-  -fno-align-jumps \
-  -fno-builtin-sin \
-  -fno-caller-saves \
-  -fno-early-inlining \
-  -fno-move-loop-invariants \
-  -fno-partial-inlining \
-  -fno-strict-volatile-bitfields \
-  -fno-tree-copy-prop \
-  -fno-tree-loop-optimize
-
-define subst-clang-incompatible-arm-flags
-  $(subst -march=armv5te,-march=armv5t,\
-  $(subst -march=armv5e,-march=armv5,\
-  $(1)))
-endef
diff --git a/core/clang/arm64.mk b/core/clang/arm64.mk
deleted file mode 100644
index cad7321..0000000
--- a/core/clang/arm64.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Clang flags for arm64 arch, target or host.
-
-CLANG_CONFIG_arm64_EXTRA_ASFLAGS :=
-
-CLANG_CONFIG_arm64_EXTRA_CFLAGS :=
-
-CLANG_CONFIG_arm64_EXTRA_LDFLAGS :=
-
-# Include common unknown flags
-CLANG_CONFIG_arm64_UNKNOWN_CFLAGS := \
-  $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
-  -fgcse-after-reload \
-  -frerun-cse-after-loop \
-  -frename-registers \
-  -fno-strict-volatile-bitfields \
-  -fno-align-jumps
-
-# We don't have any arm64 flags to substitute yet.
-define subst-clang-incompatible-arm64-flags
-  $(1)
-endef
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 6cc3446..0e59930 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -1,114 +1,13 @@
 ## Clang configurations.
 
-LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin
 LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/
 
-CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
-CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
-LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
-LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
-
 CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX)
 LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX)
 
-# RenderScript-specific tools
-# These are tied to the version of LLVM directly in external/, so they might
-# trail the host prebuilts being used for the rest of the build process.
-RS_LLVM_PREBUILTS_VERSION := clang-2690385
-RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host
-RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin
-RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
-RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX)
-RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX)
-
-# Clang flags for all host or target rules
-CLANG_CONFIG_EXTRA_ASFLAGS :=
-CLANG_CONFIG_EXTRA_CFLAGS :=
-CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99
-CLANG_CONFIG_EXTRA_CPPFLAGS :=
-CLANG_CONFIG_EXTRA_LDFLAGS :=
-
-CLANG_CONFIG_EXTRA_CFLAGS += \
-  -D__compiler_offsetof=__builtin_offsetof
-
-# Help catch common 32/64-bit errors.
-CLANG_CONFIG_EXTRA_CFLAGS += \
-  -Werror=int-conversion
-
-# Disable overly aggressive warning for macros defined with a leading underscore
-# This used to happen in AndroidConfig.h, which was included everywhere.
-# TODO: can we remove this now?
-CLANG_CONFIG_EXTRA_CFLAGS += \
-  -Wno-reserved-id-macro
-
-# Disable overly aggressive warning for format strings.
-# Bug: 20148343
-CLANG_CONFIG_EXTRA_CFLAGS += \
-  -Wno-format-pedantic
-
-# Workaround for ccache with clang.
-# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
-CLANG_CONFIG_EXTRA_CFLAGS += \
-  -Wno-unused-command-line-argument
-
-# Disable -Winconsistent-missing-override until we can clean up the existing
-# codebase for it.
-CLANG_CONFIG_EXTRA_CPPFLAGS += \
-  -Wno-inconsistent-missing-override
-
-# Force clang to always output color diagnostics.  Ninja will strip the ANSI
-# color codes if it is not running in a terminal.
-ifdef BUILDING_WITH_NINJA
-CLANG_CONFIG_EXTRA_CFLAGS += \
-  -fcolor-diagnostics
-endif
-
-CLANG_CONFIG_UNKNOWN_CFLAGS := \
-  -finline-functions \
-  -finline-limit=64 \
-  -fno-canonical-system-headers \
-  -Wno-clobbered \
-  -fno-devirtualize \
-  -fno-tree-sra \
-  -fprefetch-loop-arrays \
-  -funswitch-loops \
-  -Werror=unused-but-set-parameter \
-  -Werror=unused-but-set-variable \
-  -Wmaybe-uninitialized \
-  -Wno-error=clobbered \
-  -Wno-error=maybe-uninitialized \
-  -Wno-error=unused-but-set-parameter \
-  -Wno-error=unused-but-set-variable \
-  -Wno-free-nonheap-object \
-  -Wno-literal-suffix \
-  -Wno-maybe-uninitialized \
-  -Wno-old-style-declaration \
-  -Wno-psabi \
-  -Wno-unused-but-set-parameter \
-  -Wno-unused-but-set-variable \
-  -Wno-unused-local-typedefs \
-  -Wunused-but-set-parameter \
-  -Wunused-but-set-variable \
-  -fdiagnostics-color \
-  -fdebug-prefix-map=/proc/self/cwd=
-
-# Clang flags for all host rules
-CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
-CLANG_CONFIG_HOST_EXTRA_CFLAGS :=
-CLANG_CONFIG_HOST_EXTRA_CPPFLAGS :=
-CLANG_CONFIG_HOST_EXTRA_LDFLAGS :=
-
-# Clang flags for all host cross rules
-CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS :=
-CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS :=
-CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS :=
-CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS :=
-
-# Clang flags for all target rules
-CLANG_CONFIG_TARGET_EXTRA_ASFLAGS :=
-CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc
-CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
-CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
+define convert-to-clang-flags
+$(strip $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(1)))
+endef
 
 CLANG_DEFAULT_UB_CHECKS := \
   bool \
@@ -165,17 +64,31 @@
 include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
 endif
 
-ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
-ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
-
-ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES :=
-ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
-
 # This allows us to use the superset of functionality that compiler-rt
 # provides to Clang (for supporting features like -ftrapv).
 COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras
 
-ifeq ($(HOST_PREFER_32_BIT),true)
-# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source.
-FORCE_BUILD_LLVM_COMPONENTS := true
-endif
+# A list of projects that are allowed to set LOCAL_CLANG to false.
+# INTERNAL_LOCAL_CLANG_EXCEPTION_PROJECTS is defined later in other config.mk.
+LOCAL_CLANG_EXCEPTION_PROJECTS = \
+  bionic/tests/ \
+  device/huawei/angler/ \
+  device/lge/bullhead/ \
+  external/gentoo/integration/ \
+  hardware/qcom/ \
+  test/vts/hals/camera/bullhead/ \
+  test/vts/hals/etc/libqdutils/ \
+  vendor/huawei/angler/ \
+  vendor/lge/bullhead/ \
+  $(INTERNAL_LOCAL_CLANG_EXCEPTION_PROJECTS)
+
+# Find $1 in the exception project list.
+define find_in_local_clang_exception_projects
+$(subst $(space),, \
+  $(foreach project,$(LOCAL_CLANG_EXCEPTION_PROJECTS), \
+    $(if $(filter $(project)%,$(1)),$(project)) \
+  ) \
+)
+endef
+
+include $(BUILD_SYSTEM)/clang/tidy.mk
diff --git a/core/clang/mips.mk b/core/clang/mips.mk
deleted file mode 100644
index 4a8f812..0000000
--- a/core/clang/mips.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Clang flags for mips arch, target or host.
-
-CLANG_CONFIG_mips_EXTRA_ASFLAGS :=
-CLANG_CONFIG_mips_EXTRA_CFLAGS :=
-CLANG_CONFIG_mips_EXTRA_LDFLAGS :=
-
-# Include common unknown flags
-CLANG_CONFIG_mips_UNKNOWN_CFLAGS := \
-  $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
-  -fno-strict-volatile-bitfields \
-  -fgcse-after-reload \
-  -frerun-cse-after-loop \
-  -frename-registers \
-  -msynci \
-  -mno-synci \
-  -mno-fused-madd
-
-# Temporary workaround for Mips clang++ problem,  creates
-#   relocated ptrs in read-only pic .gcc_exception_table;
-#   permanent fix pending at http://reviews.llvm.org/D9669
-CLANG_CONFIG_mips_UNKNOWN_CFLAGS += -Wl,--warn-shared-textrel
-
-# We don't have any mips flags to substitute yet.
-define subst-clang-incompatible-mips-flags
-  $(1)
-endef
diff --git a/core/clang/mips64.mk b/core/clang/mips64.mk
deleted file mode 100644
index 1b72e05..0000000
--- a/core/clang/mips64.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-# Clang flags for mips64 arch, target or host.
-
-CLANG_CONFIG_mips64_EXTRA_ASFLAGS :=
-CLANG_CONFIG_mips64_EXTRA_CFLAGS :=
-CLANG_CONFIG_mips64_EXTRA_LDFLAGS :=
-
-# Include common unknown flags
-CLANG_CONFIG_mips64_UNKNOWN_CFLAGS := \
-  $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
-  -fno-strict-volatile-bitfields \
-  -fgcse-after-reload \
-  -frerun-cse-after-loop \
-  -frename-registers \
-  -msynci \
-  -mno-synci \
-  -mno-fused-madd
-
-# Temporary workaround for Mips clang++ problem creating
-#   relocated ptrs in read-only pic .gcc_exception_table;
-#   permanent fix pending at http://reviews.llvm.org/D9669
-CLANG_CONFIG_mips64_UNKNOWN_CFLAGS += -Wl,--warn-shared-textrel
-
-# We don't have any mips64 flags to substitute yet.
-define subst-clang-incompatible-mips64-flags
-  $(1)
-endef
diff --git a/core/clang/tidy.mk b/core/clang/tidy.mk
new file mode 100644
index 0000000..868f7bc
--- /dev/null
+++ b/core/clang/tidy.mk
@@ -0,0 +1,42 @@
+#
+# Copyright (C) 2016 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.
+#
+
+# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
+define find_default_local_tidy_check2
+$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
+endef
+
+# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
+define find_default_local_tidy_check
+$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
+endef
+
+# Returns the default tidy check list for local project path $(1).
+# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
+# most specific pattern.
+define default_global_tidy_checks
+$(lastword \
+  $(DEFAULT_GLOBAL_TIDY_CHECKS) \
+  $(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
+    $(call find_default_local_tidy_check,$(pattern),$(1)) \
+  ) \
+)
+endef
+
+# Default filter contains current directory $1 and DEFAULT_TIDY_HEADER_DIRS.
+define default_tidy_header_filter
+  -header-filter="($(subst $(space),,$1|$(DEFAULT_TIDY_HEADER_DIRS)))"
+endef
diff --git a/core/clang/versions.mk b/core/clang/versions.mk
index 81bd3b8..c5cc690 100644
--- a/core/clang/versions.mk
+++ b/core/clang/versions.mk
@@ -1,5 +1,4 @@
 ## Clang/LLVM release versions.
 
-LLVM_RELEASE_VERSION := 3.8
-LLVM_PREBUILTS_VERSION ?= clang-2690385
+LLVM_PREBUILTS_VERSION ?= clang-3859424
 LLVM_PREBUILTS_BASE ?= prebuilts/clang/host
diff --git a/core/clang/x86.mk b/core/clang/x86.mk
deleted file mode 100644
index 69c3fb2..0000000
--- a/core/clang/x86.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Clang flags for x86 arch, target or host.
-
-CLANG_CONFIG_x86_EXTRA_ASFLAGS := \
-  -msse3
-CLANG_CONFIG_x86_EXTRA_CFLAGS :=
-CLANG_CONFIG_x86_EXTRA_LDFLAGS :=
-
-# Include common unknown flags
-CLANG_CONFIG_x86_UNKNOWN_CFLAGS := \
-  $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
-  -finline-limit=300 \
-  -fno-inline-functions-called-once \
-  -mfpmath=sse \
-  -mbionic
-
-# We don't have any x86 flags to substitute yet.
-define subst-clang-incompatible-x86-flags
-  $(1)
-endef
diff --git a/core/clang/x86_64.mk b/core/clang/x86_64.mk
deleted file mode 100644
index cba10d4..0000000
--- a/core/clang/x86_64.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-# Clang flags for x86_64 arch, target or host.
-
-CLANG_CONFIG_x86_64_EXTRA_ASFLAGS :=
-CLANG_CONFIG_x86_64_EXTRA_CFLAGS :=
-CLANG_CONFIG_x86_64_EXTRA_LDFLAGS :=
-
-# Include common unknown flags
-CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS := \
-  $(CLANG_CONFIG_UNKNOWN_CFLAGS) \
-  -finline-limit=300 \
-  -fno-inline-functions-called-once \
-  -mfpmath=sse \
-  -mbionic
-
-# We don't have any x86_64 flags to substitute yet.
-define subst-clang-incompatible-x86_64-flags
-  $(1)
-endef
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index e46d934..fa89758 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -151,31 +151,21 @@
 # necessary to keep things consistent.
 
 previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk
-
-# A change in the list of aapt configs warrants an installclean, too.
-aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG) $(PRODUCT_AAPT_PREF_CONFIG))
+current_build_config_file := $(PRODUCT_OUT)/current_build_config.mk
 
 current_build_config := \
-    $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)-{$(aapt_config_list)}
-current_sanitize_target := $(strip $(SANITIZE_TARGET))
-ifeq (,$(current_sanitize_target))
-  current_sanitize_target := false
-endif
-aapt_config_list :=
+    $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)
 force_installclean := false
-force_objclean := false
 
 # Read the current state from the file, if present.
 # Will set PREVIOUS_BUILD_CONFIG.
 #
 PREVIOUS_BUILD_CONFIG :=
-PREVIOUS_SANITIZE_TARGET :=
 -include $(previous_build_config_file)
 PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG))
-PREVIOUS_SANITIZE_TARGET := $(strip $(PREVIOUS_SANITIZE_TARGET))
 
 ifdef PREVIOUS_BUILD_CONFIG
-  ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)"
+  ifneq ($(current_build_config),$(PREVIOUS_BUILD_CONFIG))
     $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)")
     ifneq ($(DISABLE_AUTO_INSTALLCLEAN),true)
       force_installclean := true
@@ -185,49 +175,52 @@
   endif
 endif  # else, this is the first build, so no need to clean.
 
-ifdef PREVIOUS_SANITIZE_TARGET
-  ifneq "$(current_sanitize_target)" "$(PREVIOUS_SANITIZE_TARGET)"
-    $(info *** SANITIZE_TARGET changed: "$(PREVIOUS_SANITIZE_TARGET)" -> "$(current_sanitize_target)")
-    force_objclean := true
-  endif
-endif  # else, this is the first build, so no need to clean.
-
 # Write the new state to the file.
 #
-ifneq ($(PREVIOUS_BUILD_CONFIG)-$(PREVIOUS_SANITIZE_TARGET),$(current_build_config)-$(current_sanitize_target))
 $(shell \
-  mkdir -p $(dir $(previous_build_config_file)) && \
+  mkdir -p $(dir $(current_build_config_file)) && \
   echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \
-      $(previous_build_config_file) && \
-  echo "PREVIOUS_SANITIZE_TARGET := $(current_sanitize_target)" >> \
-      $(previous_build_config_file) \
+      $(current_build_config_file) \
  )
-endif
+$(shell cmp $(current_build_config_file) $(previous_build_config_file) > /dev/null 2>&1 || \
+  mv -f $(current_build_config_file) $(previous_build_config_file))
+
 PREVIOUS_BUILD_CONFIG :=
-PREVIOUS_SANITIZE_TARGET :=
 previous_build_config_file :=
+current_build_config_file :=
 current_build_config :=
 
 #
 # installclean logic
 #
 
-# The files/dirs to delete during an installclean.  This includes the
-# non-common APPS directory, which may contain the wrong resources.
+# The files/dirs to delete during an installclean.
 #
-# Deletes all of the files that change between different build types,
-# like "make user" vs. "make sdk".  This lets you work with different
-# build types without having to do a full clean each time.  E.g.:
+# Deletes all of the installed files -- the intent is to remove files
+# that may no longer be installed, either because the user previously
+# installed them, or they were previously installed by default but no
+# longer are.
 #
-#     $ make -j8 all
-#     $ make installclean
-#     $ make -j8 user
-#     $ make installclean
-#     $ make -j8 sdk
+# This is faster than a full clean, since we're not deleting the
+# intermediates. Instead of recompiling, we can just copy the results.
 #
+# Host bin, frameworks, and lib* are intentionally omitted, since
+# otherwise we'd have to rebuild any generated files created with those
+# tools.
 installclean_files := \
 	$(HOST_OUT)/obj/NOTICE_FILES \
+	$(HOST_OUT)/obj/PACKAGING \
+	$(HOST_OUT)/coverage \
+	$(HOST_OUT)/cts \
+	$(HOST_OUT)/nativetest* \
 	$(HOST_OUT)/sdk \
+	$(HOST_OUT)/sdk_addon \
+	$(HOST_OUT)/testcases \
+	$(HOST_OUT)/vts \
+	$(HOST_CROSS_OUT)/bin \
+	$(HOST_CROSS_OUT)/coverage \
+	$(HOST_CROSS_OUT)/lib* \
+	$(HOST_CROSS_OUT)/nativetest* \
 	$(PRODUCT_OUT)/*.img \
 	$(PRODUCT_OUT)/*.ini \
 	$(PRODUCT_OUT)/*.txt \
@@ -236,7 +229,6 @@
 	$(PRODUCT_OUT)/kernel \
 	$(PRODUCT_OUT)/data \
 	$(PRODUCT_OUT)/skin \
-	$(PRODUCT_OUT)/obj/APPS \
 	$(PRODUCT_OUT)/obj/NOTICE_FILES \
 	$(PRODUCT_OUT)/obj/PACKAGING \
 	$(PRODUCT_OUT)/recovery \
@@ -245,17 +237,14 @@
 	$(PRODUCT_OUT)/system_other \
 	$(PRODUCT_OUT)/vendor \
 	$(PRODUCT_OUT)/oem \
-	$(PRODUCT_OUT)/dex_bootjars \
-	$(PRODUCT_OUT)/obj/JAVA_LIBRARIES \
 	$(PRODUCT_OUT)/obj/FAKE \
-	$(PRODUCT_OUT)/obj/EXECUTABLES/adbd_intermediates \
-	$(PRODUCT_OUT)/obj/EXECUTABLES/logd_intermediates \
-	$(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libfs_mgr_intermediates \
-	$(PRODUCT_OUT)/obj/EXECUTABLES/init_intermediates \
-	$(PRODUCT_OUT)/obj/ETC/mac_permissions.xml_intermediates \
-	$(PRODUCT_OUT)/obj/ETC/sepolicy_intermediates \
-	$(PRODUCT_OUT)/obj/ETC/sepolicy.recovery_intermediates \
-	$(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates
+	$(PRODUCT_OUT)/breakpad \
+	$(PRODUCT_OUT)/cache \
+	$(PRODUCT_OUT)/coverage \
+	$(PRODUCT_OUT)/installer \
+	$(PRODUCT_OUT)/odm \
+	$(PRODUCT_OUT)/sysloader \
+	$(PRODUCT_OUT)/testcases \
 
 # The files/dirs to delete during a dataclean, which removes any files
 # in the staging and emulator data partitions.
@@ -264,12 +253,6 @@
 	$(PRODUCT_OUT)/data-qemu/* \
 	$(PRODUCT_OUT)/userdata-qemu.img
 
-# The files/dirs to delete during an objclean, which removes any files
-# in the staging and emulator data partitions.
-objclean_files := \
-	$(TARGET_OUT_INTERMEDIATES) \
-	$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)
-
 # make sure *_OUT is set so that we won't result in deleting random parts
 # of the filesystem.
 ifneq (2,$(words $(HOST_OUT) $(PRODUCT_OUT)))
@@ -289,13 +272,7 @@
 	$(hide) rm -rf $(FILES)
 	@echo "Deleted images and staging directories."
 
-.PHONY: objclean
-objclean: FILES := $(objclean_files)
-objclean:
-	$(hide) rm -rf $(FILES)
-	@echo "Deleted images and staging directories."
-
-ifeq "$(force_installclean)" "true"
+ifeq ($(force_installclean),true)
   $(info *** Forcing "make installclean"...)
   $(info *** rm -rf $(dataclean_files) $(installclean_files))
   $(shell rm -rf $(dataclean_files) $(installclean_files))
@@ -303,14 +280,6 @@
 endif
 force_installclean :=
 
-ifeq "$(force_objclean)" "true"
-  $(info *** Forcing cleanup of intermediate files...)
-  $(info *** rm -rf $(objclean_files))
-  $(shell rm -rf $(objclean_files))
-  $(info *** Done with the cleaning, now starting the real build.)
-endif
-force_objclean :=
-
 ###########################################################
 
 .PHONY: clean-jack-files
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index f7567b4..91243c7 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -2,315 +2,357 @@
 ## Clear out values of all variables used by rule templates.
 ###########################################################
 
-LOCAL_MODULE:=
-LOCAL_MODULE_PATH:=
-LOCAL_MODULE_RELATIVE_PATH :=
-LOCAL_MODULE_STEM:=
-LOCAL_DONT_CHECK_MODULE:=
-LOCAL_CHECKED_MODULE:=
+# '',true
+LOCAL_32_BIT_ONLY:=
+LOCAL_AAPT_FLAGS:=
+LOCAL_AAPT_INCLUDE_ALL_RESOURCES:=
+LOCAL_ADDITIONAL_CERTIFICATES:=
+LOCAL_ADDITIONAL_DEPENDENCIES:=
+LOCAL_ADDITIONAL_HTML_DIR:=
+LOCAL_ADDITIONAL_JAVA_DIR:=
+LOCAL_AIDL_INCLUDES:=
+LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
+LOCAL_APK_LIBRARIES:=
+LOCAL_ARM_MODE:=
+LOCAL_ASFLAGS:=
+LOCAL_ASSET_DIR:=
 LOCAL_BUILT_MODULE:=
 LOCAL_BUILT_MODULE_STEM:=
-OVERRIDE_BUILT_MODULE_PATH:=
-LOCAL_INSTALLED_MODULE:=
-LOCAL_INSTALLED_MODULE_STEM:=
-LOCAL_PICKUP_FILES:=
-LOCAL_UNINSTALLABLE_MODULE:=
-LOCAL_INTERMEDIATE_TARGETS:=
-LOCAL_UNSTRIPPED_PATH:=
-LOCAL_MODULE_CLASS:=
-LOCAL_MODULE_SUFFIX:=
-LOCAL_PACKAGE_NAME:=
-LOCAL_OVERRIDES_PACKAGES:=
-LOCAL_EXPORT_PACKAGE_RESOURCES:=
-LOCAL_MANIFEST_PACKAGE_NAME:=
-LOCAL_PACKAGE_SPLITS:=
-LOCAL_REQUIRED_MODULES:=
-LOCAL_ACP_UNAVAILABLE:=
-LOCAL_MODULE_TAGS:=
-LOCAL_SRC_FILES:=
-LOCAL_SRC_FILES_EXCLUDE:=
-LOCAL_PREBUILT_OBJ_FILES:=
-LOCAL_STATIC_JAVA_LIBRARIES:=
-LOCAL_STATIC_JAVA_AAR_LIBRARIES:=
-LOCAL_STATIC_LIBRARIES:=
-# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.
-LOCAL_GROUP_STATIC_LIBRARIES:=
-LOCAL_WHOLE_STATIC_LIBRARIES:=
-LOCAL_SHARED_LIBRARIES:=
-LOCAL_IS_HOST_MODULE:=
 LOCAL_CC:=
-LOCAL_CXX:=
-LOCAL_CPP_EXTENSION:=
-LOCAL_NO_DEFAULT_COMPILER_FLAGS:=
-LOCAL_FDO_SUPPORT:=
-LOCAL_ARM_MODE:=
-LOCAL_YACCFLAGS:=
-LOCAL_ASFLAGS:=
+LOCAL_CERTIFICATE:=
 LOCAL_CFLAGS:=
-LOCAL_CPPFLAGS:=
+LOCAL_CHECKED_MODULE:=
+LOCAL_C_INCLUDES:=
+LOCAL_CLANG:=
 LOCAL_CLANG_ASFLAGS:=
 LOCAL_CLANG_CFLAGS:=
 LOCAL_CLANG_CONLYFLAGS:=
 LOCAL_CLANG_CPPFLAGS:=
-LOCAL_CONLYFLAGS:=
-LOCAL_RTTI_FLAG:=
-LOCAL_C_INCLUDES:=
-LOCAL_EXPORT_C_INCLUDE_DIRS:=
-LOCAL_LDFLAGS:=
 LOCAL_CLANG_LDFLAGS:=
-LOCAL_LDLIBS:=
-LOCAL_AAPT_FLAGS:=
-LOCAL_AAPT_INCLUDE_ALL_RESOURCES:=
-LOCAL_SYSTEM_SHARED_LIBRARIES:=none
-LOCAL_PREBUILT_LIBS:=
-LOCAL_PREBUILT_EXECUTABLES:=
-LOCAL_PREBUILT_JAVA_LIBRARIES:=
-LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=
-LOCAL_PREBUILT_STRIP_COMMENTS:=
-LOCAL_INTERMEDIATE_SOURCES:=
-LOCAL_INTERMEDIATE_SOURCE_DIR:=
-LOCAL_JAVACFLAGS:=
-LOCAL_JAVA_LIBRARIES:=
-LOCAL_JAVA_LAYERS_FILE:=
-LOCAL_NO_STANDARD_LIBRARIES:=
 LOCAL_CLASSPATH:=
-LOCAL_JACK_CLASSPATH:=
-LOCAL_DROIDDOC_USE_STANDARD_DOCLET:=
-LOCAL_DROIDDOC_SOURCE_PATH:=
-LOCAL_DROIDDOC_TEMPLATE_DIR:=
-LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=
+LOCAL_COMPATIBILITY_SUITE:=
+LOCAL_COMPATIBILITY_SUPPORT_FILES:=
+LOCAL_CONLYFLAGS:=
+LOCAL_COPY_HEADERS:=
+LOCAL_COPY_HEADERS_TO:=
+LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES:=
+LOCAL_CPP_EXTENSION:=
+LOCAL_CPPFLAGS:=
+LOCAL_CPP_STD:=
+LOCAL_C_STD:=
+LOCAL_CTS_TEST_PACKAGE:=
+LOCAL_CTS_TEST_RUNNER:=
+LOCAL_CXX:=
+LOCAL_CXX_STL := default
+LOCAL_DATA_BINDING:=
+LOCAL_DEX_PREOPT_APP_IMAGE:=
+LOCAL_DEX_PREOPT_FLAGS:=
+LOCAL_DEX_PREOPT_GENERATE_PROFILE:=
+LOCAL_DEX_PREOPT_IMAGE_LOCATION:=
+LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING:=
+LOCAL_DEX_PREOPT:= # '',true,false,nostripping
+LOCAL_DONT_CHECK_MODULE:=
+# Don't delete the META_INF dir when merging static Java libraries.
+LOCAL_DONT_DELETE_JAR_META_INF:=
+LOCAL_DPI_FILE_STEM:=
+LOCAL_DPI_VARIANTS:=
 LOCAL_DROIDDOC_ASSET_DIR:=
 LOCAL_DROIDDOC_CUSTOM_ASSET_DIR:=
-LOCAL_DROIDDOC_OPTIONS:=
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=
 LOCAL_DROIDDOC_HTML_DIR:=
+LOCAL_DROIDDOC_OPTIONS:=
+LOCAL_DROIDDOC_SOURCE_PATH:=
 LOCAL_DROIDDOC_STUB_OUT_DIR:=
-LOCAL_ADDITIONAL_HTML_DIR:=
-LOCAL_ASSET_DIR:=
-LOCAL_RESOURCE_DIR:=
+LOCAL_DROIDDOC_TEMPLATE_DIR:=
+LOCAL_DROIDDOC_USE_STANDARD_DOCLET:=
+LOCAL_DX_FLAGS:=
+LOCAL_EMMA_COVERAGE_FILTER:=
+LOCAL_EMMA_INSTRUMENT:=
+LOCAL_ERROR_PRONE_FLAGS:=
+LOCAL_EXPORT_CFLAGS:=
+LOCAL_EXPORT_C_INCLUDE_DEPS:=
+LOCAL_EXPORT_C_INCLUDE_DIRS:=
+LOCAL_EXPORT_HEADER_LIBRARY_HEADERS:=
+LOCAL_EXPORT_PACKAGE_RESOURCES:=
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS:=
+LOCAL_EXPORT_STATIC_LIBRARY_HEADERS:=
+LOCAL_EXTRACT_APK:=
+LOCAL_EXTRACT_DPI_APK:=
+LOCAL_FDO_SUPPORT:=
+LOCAL_FINDBUGS_FLAGS:=
+LOCAL_FORCE_STATIC_EXECUTABLE:=
+LOCAL_FULL_LIBS_MANIFEST_FILES:=
+LOCAL_FULL_MANIFEST_FILE:=
+LOCAL_GCNO_FILES:=
+LOCAL_GENERATED_SOURCES:=
+# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.
+LOCAL_GROUP_STATIC_LIBRARIES:=
+LOCAL_GTEST:=true
+LOCAL_HAL_STATIC_LIBRARIES:=
+LOCAL_HEADER_LIBRARIES:=
+LOCAL_INIT_RC:=
+LOCAL_INSTALLED_MODULE:=
+LOCAL_INSTALLED_MODULE_STEM:=
+LOCAL_INSTRUMENTATION_FOR:=
+LOCAL_INTERMEDIATE_SOURCE_DIR:=
+LOCAL_INTERMEDIATE_SOURCES:=
+LOCAL_INTERMEDIATE_TARGETS:=
+LOCAL_IS_HOST_MODULE:=
+LOCAL_IS_RUNTIME_RESOURCE_OVERLAY:=
+LOCAL_JACK_CLASSPATH:=
+LOCAL_JACK_COVERAGE_EXCLUDE_FILTER:=
+LOCAL_JACK_COVERAGE_INCLUDE_FILTER:=
+# '' (ie disabled), disabled, full, incremental, javac_frontend
+LOCAL_JACK_ENABLED:=$(DEFAULT_JACK_ENABLED)
+LOCAL_JACK_FLAGS:=
+LOCAL_JACK_PLUGIN:=
+LOCAL_JACK_PLUGIN_PATH:=
+LOCAL_JACK_PROGUARD_FLAGS:=
+LOCAL_JAR_EXCLUDE_FILES:=
+LOCAL_JAR_EXCLUDE_PACKAGES:=
+LOCAL_JARJAR_RULES:=
+LOCAL_JAR_MANIFEST:=
+LOCAL_JAR_PACKAGES:=
+LOCAL_JAVACFLAGS:=
+LOCAL_JAVA_LANGUAGE_VERSION:=
+LOCAL_JAVA_LAYERS_FILE:=
+LOCAL_JAVA_LIBRARIES:=
 LOCAL_JAVA_RESOURCE_DIRS:=
 LOCAL_JAVA_RESOURCE_FILES:=
-LOCAL_GENERATED_SOURCES:=
-LOCAL_COPY_HEADERS_TO:=
-LOCAL_COPY_HEADERS:=
-LOCAL_FORCE_STATIC_EXECUTABLE:=
-LOCAL_ADDITIONAL_DEPENDENCIES:=
-LOCAL_STRIP_MODULE:=
-LOCAL_PACK_MODULE_RELOCATIONS:=
 LOCAL_JNI_SHARED_LIBRARIES:=
 LOCAL_JNI_SHARED_LIBRARIES_ABI:=
-LOCAL_PREBUILT_JNI_LIBS:=
-LOCAL_JAR_MANIFEST:=
-LOCAL_INSTRUMENTATION_FOR:=
-LOCAL_APK_LIBRARIES:=
-LOCAL_RES_LIBRARIES:=
-LOCAL_MANIFEST_INSTRUMENTATION_FOR:=
-LOCAL_AIDL_INCLUDES:=
-LOCAL_VTS_INCLUDES:=
-LOCAL_JARJAR_RULES:=
-LOCAL_ADDITIONAL_JAVA_DIR:=
-LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
-LOCAL_DX_FLAGS:=
-LOCAL_JACK_ENABLED:=$(DEFAULT_JACK_ENABLED) # '' (ie disabled), disabled, full, incremental
-LOCAL_JACK_FLAGS:=
-LOCAL_JACK_COVERAGE_INCLUDE_FILTER:=
-LOCAL_JACK_COVERAGE_EXCLUDE_FILTER:=
-LOCAL_JILL_FLAGS:=
-LOCAL_CERTIFICATE:=
-LOCAL_SDK_VERSION:=
-LOCAL_MIN_SDK_VERSION:=
-LOCAL_SDK_RES_VERSION:=
-LOCAL_NDK_STL_VARIANT:=
-LOCAL_EMMA_INSTRUMENT:=
-LOCAL_PROGUARD_ENABLED:= # '',full,custom,nosystem,disabled,obfuscation,optimization
-LOCAL_PROGUARD_FLAGS:=
-LOCAL_JACK_PROGUARD_FLAGS:=
-LOCAL_PROGUARD_FLAG_FILES:=
-LOCAL_TEST_MODULE_TO_PROGUARD_WITH:=
-LOCAL_EMMA_COVERAGE_FILTER:=
-LOCAL_WARNINGS_ENABLE:=
-LOCAL_FULL_MANIFEST_FILE:=
+LOCAL_LDFLAGS:=
+LOCAL_LDLIBS:=
+LOCAL_LOGTAGS_FILES:=
 LOCAL_MANIFEST_FILE:=
-LOCAL_FULL_LIBS_MANIFEST_FILES:=
-LOCAL_RENDERSCRIPT_INCLUDES:=
-LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:=
+LOCAL_MANIFEST_INSTRUMENTATION_FOR:=
+LOCAL_MANIFEST_PACKAGE_NAME:=
+LOCAL_MIN_SDK_VERSION:=
+LOCAL_MODULE:=
+LOCAL_MODULE_CLASS:=
+LOCAL_MODULE_HOST_ARCH:=
+LOCAL_MODULE_HOST_ARCH_WARN:=
+LOCAL_MODULE_HOST_CROSS_ARCH:=
+LOCAL_MODULE_HOST_CROSS_ARCH_WARN:=
+LOCAL_MODULE_HOST_OS:=
+LOCAL_MODULE_OWNER:=
+LOCAL_MODULE_PATH:=
+LOCAL_MODULE_RELATIVE_PATH :=
+LOCAL_MODULE_STEM:=
+LOCAL_MODULE_SUFFIX:=
+LOCAL_MODULE_SYMLINKS:=
+LOCAL_MODULE_TAGS:=
+LOCAL_MODULE_TARGET_ARCH:=
+LOCAL_MODULE_TARGET_ARCH_WARN:=
+LOCAL_MODULE_UNSUPPORTED_HOST_ARCH:=
+LOCAL_MODULE_UNSUPPORTED_HOST_ARCH_WARN:=
+LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH:=
+LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH_WARN:=
+LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
+LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
+LOCAL_MULTILIB:=
+LOCAL_NDK_STL_VARIANT:=
+LOCAL_NDK_VERSION:=current
+LOCAL_NO_CRT:=
+LOCAL_NO_DEFAULT_COMPILER_FLAGS:=
+LOCAL_NO_FPIE :=
+LOCAL_NO_LIBCOMPILER_RT:=
+LOCAL_NO_LIBGCC:=
+LOCAL_NO_NOTICE_FILE:=
+LOCAL_NO_PIC:=
+LOCAL_NOSANITIZE:=
+LOCAL_NO_STANDARD_LIBRARIES:=
+LOCAL_NO_STATIC_ANALYZER:=
+LOCAL_NOTICE_FILE:=
+LOCAL_ODM_MODULE:=
+LOCAL_OEM_MODULE:=
+LOCAL_OVERRIDES_PACKAGES:=
+LOCAL_PACKAGE_NAME:=
+LOCAL_PACKAGE_SPLITS:=
+LOCAL_PACK_MODULE_RELOCATIONS:=
+LOCAL_PICKUP_FILES:=
+LOCAL_POST_INSTALL_CMD:=
+LOCAL_POST_LINK_CMD:=
+LOCAL_PREBUILT_COVERAGE_ARCHIVE:=
+LOCAL_PREBUILT_EXECUTABLES:=
+LOCAL_PREBUILT_JAVA_LIBRARIES:=
+LOCAL_PREBUILT_JNI_LIBS:=
+LOCAL_PREBUILT_LIBS:=
+LOCAL_PREBUILT_MODULE_FILE:=
+LOCAL_PREBUILT_OBJ_FILES:=
+LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=
+LOCAL_PREBUILT_STRIP_COMMENTS:=
+LOCAL_PRIVILEGED_MODULE:=
+# '',full,custom,nosystem,disabled,obfuscation,optimization
+LOCAL_PROGUARD_ENABLED:=
+LOCAL_PROGUARD_FLAG_FILES:=
+LOCAL_PROGUARD_FLAGS:=
+LOCAL_PROPRIETARY_MODULE:=
+LOCAL_PROTOC_FLAGS:=
+# lite(default),micro,nano,stream,full,nanopb-c,nanopb-c-enable_malloc
+LOCAL_PROTOC_OPTIMIZE_TYPE:=
+LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
+LOCAL_RECORDED_MODULE_TYPE:=
 LOCAL_RENDERSCRIPT_CC:=
 LOCAL_RENDERSCRIPT_COMPATIBILITY:=
 LOCAL_RENDERSCRIPT_FLAGS:=
+LOCAL_RENDERSCRIPT_INCLUDES:=
+LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:=
 LOCAL_RENDERSCRIPT_TARGET_API:=
-LOCAL_DEX_PREOPT:= # '',true,false,nostripping
-LOCAL_DEX_PREOPT_IMAGE_LOCATION:=
-LOCAL_DEX_PREOPT_FLAGS:=
-LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full,nanopb-c,nanopb-c-enable_malloc
-LOCAL_PROTOC_FLAGS:=
-LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
-LOCAL_VTSC_FLAGS:=
-LOCAL_NO_CRT:=
-LOCAL_NO_LIBGCC:=
-LOCAL_PROPRIETARY_MODULE:=
-LOCAL_OEM_MODULE:=
-LOCAL_ODM_MODULE:=
-LOCAL_PRIVILEGED_MODULE:=
-LOCAL_MODULE_OWNER:=
-LOCAL_COMPATIBILITY_SUITE:=
-LOCAL_COMPATIBILITY_SUPPORT_FILES:=
-LOCAL_CTS_TEST_PACKAGE:=
-LOCAL_CTS_TEST_RUNNER:=
-LOCAL_CLANG:=
-LOCAL_JAR_EXCLUDE_FILES:=
-LOCAL_JAR_PACKAGES:=
-LOCAL_JAR_EXCLUDE_PACKAGES:=
-LOCAL_SOURCE_FILES_ALL_GENERATED:= # '',true
-# Don't delete the META_INF dir when merging static Java libraries.
-LOCAL_DONT_DELETE_JAR_META_INF:=
-LOCAL_DONT_DELETE_JAR_DIRS:=
-LOCAL_ADDITIONAL_CERTIFICATES:=
-LOCAL_PREBUILT_MODULE_FILE:=
-LOCAL_POST_LINK_CMD:=
-LOCAL_POST_INSTALL_CMD:=
-LOCAL_HAL_STATIC_LIBRARIES:=
-LOCAL_RMTYPEDEFS:=
-LOCAL_NO_SYNTAX_CHECK:=
-LOCAL_NO_STATIC_ANALYZER:=
-LOCAL_32_BIT_ONLY:= # '',true
-LOCAL_MULTILIB:=
-LOCAL_MODULE_TARGET_ARCH:=
-LOCAL_MODULE_TARGET_ARCH_WARN:=
-LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
-LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
-LOCAL_MODULE_HOST_ARCH:=
-LOCAL_MODULE_HOST_ARCH_WARN:=
-LOCAL_MODULE_UNSUPPORTED_HOST_ARCH:=
-LOCAL_MODULE_UNSUPPORTED_HOST_ARCH_WARN:=
-LOCAL_MODULE_HOST_CROSS_ARCH:=
-LOCAL_MODULE_HOST_CROSS_ARCH_WARN:=
-LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH:=
-LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH_WARN:=
-LOCAL_NO_FPIE :=
-LOCAL_CXX_STL := default
-LOCAL_NATIVE_COVERAGE :=
-LOCAL_DPI_VARIANTS:=
-LOCAL_DPI_FILE_STEM:=
-LOCAL_SANITIZE:=
-LOCAL_SANITIZE_RECOVER:=
-LOCAL_DATA_BINDING:=
-LOCAL_DBUS_PROXY_PREFIX:=
-LOCAL_INIT_RC:=
-LOCAL_MODULE_HOST_OS:=
-LOCAL_FINDBUGS_FLAGS:=
-LOCAL_NOTICE_FILE:=
-LOCAL_USE_AAPT2:=$(USE_AAPT2)
-LOCAL_STATIC_ANDROID_LIBRARIES:=
-LOCAL_SHARED_ANDROID_LIBRARIES:=
 # Used to replace the installed file of a presigned prebuilt apk in PDK fusion build,
 # to avoid installing the presigned apks with classes.dex unstripped.
 LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=
-LOCAL_EXTRACT_APK:=
-LOCAL_EXTRACT_DPI_APK:=
+LOCAL_REQUIRED_MODULES:=
+LOCAL_RES_LIBRARIES:=
+LOCAL_RESOURCE_DIR:=
+LOCAL_RMTYPEDEFS:=
+LOCAL_RRO_THEME:=
+LOCAL_RTTI_FLAG:=
+LOCAL_SANITIZE:=
+LOCAL_SANITIZE_DIAG:=
+LOCAL_SANITIZE_RECOVER:=
+LOCAL_SDK_RES_VERSION:=
+LOCAL_SDK_VERSION:=
+LOCAL_SHARED_ANDROID_LIBRARIES:=
+LOCAL_SHARED_LIBRARIES:=
+# '',true
+LOCAL_SOURCE_FILES_ALL_GENERATED:=
+LOCAL_SRC_FILES:=
+LOCAL_SRC_FILES_EXCLUDE:=
+LOCAL_STATIC_ANDROID_LIBRARIES:=
+LOCAL_STATIC_JAVA_AAR_LIBRARIES:=
+LOCAL_STATIC_JAVA_LIBRARIES:=
+LOCAL_STATIC_LIBRARIES:=
+LOCAL_STRIP_MODULE:=
+LOCAL_SYSTEM_SHARED_LIBRARIES:=none
+LOCAL_TEST_DATA:=
+LOCAL_TEST_MODULE_TO_PROGUARD_WITH:=
+LOCAL_TIDY:=
+LOCAL_TIDY_CHECKS:=
+LOCAL_TIDY_FLAGS:=
+LOCAL_UNINSTALLABLE_MODULE:=
+LOCAL_UNSTRIPPED_PATH:=
+LOCAL_USE_AAPT2:=$(USE_AAPT2)
+LOCAL_USE_VNDK:=
+LOCAL_VENDOR_MODULE:=
+LOCAL_VTSC_FLAGS:=
+LOCAL_VTS_INCLUDES:=
+LOCAL_VTS_MODE:=
+LOCAL_WARNINGS_ENABLE:=
+LOCAL_WHOLE_STATIC_LIBRARIES:=
+LOCAL_YACCFLAGS:=
+OVERRIDE_BUILT_MODULE_PATH:=
 
 # arch specific variables
-LOCAL_SRC_FILES_$(TARGET_ARCH):=
-LOCAL_SRC_FILES_EXCLUDE_$(TARGET_ARCH):=
-LOCAL_CFLAGS_$(TARGET_ARCH):=
-LOCAL_CLANG_CFLAGS_$(TARGET_ARCH):=
-LOCAL_CPPFLAGS_$(TARGET_ARCH):=
-LOCAL_CLANG_CPPFLAGS_$(TARGET_ARCH):=
-LOCAL_C_INCLUDES_$(TARGET_ARCH):=
 LOCAL_ASFLAGS_$(TARGET_ARCH):=
+LOCAL_CFLAGS_$(TARGET_ARCH):=
+LOCAL_C_INCLUDES_$(TARGET_ARCH):=
 LOCAL_CLANG_ASFLAGS_$(TARGET_ARCH):=
-LOCAL_LDFLAGS_$(TARGET_ARCH):=
+LOCAL_CLANG_CFLAGS_$(TARGET_ARCH):=
+LOCAL_CLANG_CPPFLAGS_$(TARGET_ARCH):=
 LOCAL_CLANG_LDFLAGS_$(TARGET_ARCH):=
-LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):=
-LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):=
-LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_ARCH):=
-LOCAL_GENERATED_SOURCES_$(TARGET_ARCH):=
-LOCAL_REQUIRED_MODULES_$(TARGET_ARCH):=
 LOCAL_CLANG_$(TARGET_ARCH):=
-LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH):=
-LOCAL_STRIP_MODULE_$(TARGET_ARCH):=
+LOCAL_CPPFLAGS_$(TARGET_ARCH):=
+LOCAL_GENERATED_SOURCES_$(TARGET_ARCH):=
+LOCAL_HEADER_LIBRARIES_$(TARGET_ARCH):=
+LOCAL_LDFLAGS_$(TARGET_ARCH):=
 LOCAL_PACK_MODULE_RELOCATIONS_$(TARGET_ARCH):=
+LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH):=
+LOCAL_REQUIRED_MODULES_$(TARGET_ARCH):=
+LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):=
+LOCAL_SRC_FILES_EXCLUDE_$(TARGET_ARCH):=
+LOCAL_SRC_FILES_$(TARGET_ARCH):=
+LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):=
+LOCAL_STRIP_MODULE_$(TARGET_ARCH):=
+LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_ARCH):=
 ifdef TARGET_2ND_ARCH
-LOCAL_SRC_FILES_$(TARGET_2ND_ARCH):=
-LOCAL_SRC_FILES_EXCLUDE_$(TARGET_2ND_ARCH):=
-LOCAL_CFLAGS_$(TARGET_2ND_ARCH):=
-LOCAL_CLANG_CFLAGS_$(TARGET_2ND_ARCH):=
-LOCAL_CPPFLAGS_$(TARGET_2ND_ARCH):=
-LOCAL_CLANG_CPPFLAGS_$(TARGET_2ND_ARCH):=
-LOCAL_C_INCLUDES_$(TARGET_2ND_ARCH):=
 LOCAL_ASFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_CFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_C_INCLUDES_$(TARGET_2ND_ARCH):=
 LOCAL_CLANG_ASFLAGS_$(TARGET_2ND_ARCH):=
-LOCAL_LDFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_CLANG_CFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_CLANG_CPPFLAGS_$(TARGET_2ND_ARCH):=
 LOCAL_CLANG_LDFLAGS_$(TARGET_2ND_ARCH):=
-LOCAL_SHARED_LIBRARIES_$(TARGET_2ND_ARCH):=
-LOCAL_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
-LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
-LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH):=
-LOCAL_REQUIRED_MODULES_$(TARGET_2ND_ARCH):=
 LOCAL_CLANG_$(TARGET_2ND_ARCH):=
-LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH):=
-LOCAL_STRIP_MODULE_$(TARGET_2ND_ARCH):=
+LOCAL_CPPFLAGS_$(TARGET_2ND_ARCH):=
+LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH):=
+LOCAL_HEADER_LIBRARIES_$(TARGET_2ND_ARCH):=
+LOCAL_LDFLAGS_$(TARGET_2ND_ARCH):=
 LOCAL_PACK_MODULE_RELOCATIONS_$(TARGET_2ND_ARCH):=
+LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH):=
+LOCAL_REQUIRED_MODULES_$(TARGET_2ND_ARCH):=
+LOCAL_SHARED_LIBRARIES_$(TARGET_2ND_ARCH):=
+LOCAL_SRC_FILES_EXCLUDE_$(TARGET_2ND_ARCH):=
+LOCAL_SRC_FILES_$(TARGET_2ND_ARCH):=
+LOCAL_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
+LOCAL_STRIP_MODULE_$(TARGET_2ND_ARCH):=
+LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
 endif
-LOCAL_SRC_FILES_$(HOST_ARCH):=
-LOCAL_SRC_FILES_EXCLUDE_$(HOST_ARCH):=
-LOCAL_CFLAGS_$(HOST_ARCH):=
-LOCAL_CLANG_CFLAGS_$(HOST_ARCH):=
-LOCAL_CPPFLAGS_$(HOST_ARCH):=
-LOCAL_CLANG_CPPFLAGS_$(HOST_ARCH):=
-LOCAL_C_INCLUDES_$(HOST_ARCH):=
 LOCAL_ASFLAGS_$(HOST_ARCH):=
+LOCAL_CFLAGS_$(HOST_ARCH):=
+LOCAL_C_INCLUDES_$(HOST_ARCH):=
 LOCAL_CLANG_ASFLAGS_$(HOST_ARCH):=
-LOCAL_LDFLAGS_$(HOST_ARCH):=
+LOCAL_CLANG_CFLAGS_$(HOST_ARCH):=
+LOCAL_CLANG_CPPFLAGS_$(HOST_ARCH):=
+LOCAL_CLANG_$(HOST_ARCH):=
 LOCAL_CLANG_LDFLAGS_$(HOST_ARCH):=
+LOCAL_CPPFLAGS_$(HOST_ARCH):=
+LOCAL_GENERATED_SOURCES_$(HOST_ARCH):=
+LOCAL_HEADER_LIBRARIES_$(HOST_ARCH):=
+LOCAL_LDFLAGS_$(HOST_ARCH):=
+LOCAL_REQUIRED_MODULES_$(HOST_ARCH):=
 LOCAL_SHARED_LIBRARIES_$(HOST_ARCH):=
+LOCAL_SRC_FILES_EXCLUDE_$(HOST_ARCH):=
+LOCAL_SRC_FILES_$(HOST_ARCH):=
 LOCAL_STATIC_LIBRARIES_$(HOST_ARCH):=
 LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_ARCH):=
-LOCAL_GENERATED_SOURCES_$(HOST_ARCH):=
-LOCAL_REQUIRED_MODULES_$(HOST_ARCH):=
-LOCAL_CLANG_$(HOST_ARCH):=
 ifdef HOST_2ND_ARCH
-LOCAL_SRC_FILES_$(HOST_2ND_ARCH):=
-LOCAL_SRC_FILES_EXCLUDE_$(HOST_2ND_ARCH):=
-LOCAL_CFLAGS_$(HOST_2ND_ARCH):=
-LOCAL_CLANG_CFLAGS_$(HOST_2ND_ARCH):=
-LOCAL_CPPFLAGS_$(HOST_2ND_ARCH):=
-LOCAL_CLANG_CPPFLAGS_$(HOST_2ND_ARCH):=
-LOCAL_C_INCLUDES_$(HOST_2ND_ARCH):=
 LOCAL_ASFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_C_INCLUDES_$(HOST_2ND_ARCH):=
 LOCAL_CLANG_ASFLAGS_$(HOST_2ND_ARCH):=
-LOCAL_LDFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CLANG_CFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CLANG_CPPFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CLANG_$(HOST_2ND_ARCH):=
 LOCAL_CLANG_LDFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CPPFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_GENERATED_SOURCES_$(HOST_2ND_ARCH):=
+LOCAL_HEADER_LIBRARIES_$(HOST_2ND_ARCH):=
+LOCAL_LDFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_REQUIRED_MODULES_$(HOST_2ND_ARCH):=
 LOCAL_SHARED_LIBRARIES_$(HOST_2ND_ARCH):=
+LOCAL_SRC_FILES_EXCLUDE_$(HOST_2ND_ARCH):=
+LOCAL_SRC_FILES_$(HOST_2ND_ARCH):=
 LOCAL_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
 LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
-LOCAL_GENERATED_SOURCES_$(HOST_2ND_ARCH):=
-LOCAL_REQUIRED_MODULES_$(HOST_2ND_ARCH):=
-LOCAL_CLANG_$(HOST_2ND_ARCH):=
 endif
 
-LOCAL_SRC_FILES_$(HOST_OS):=
-LOCAL_STATIC_LIBRARIES_$(HOST_OS):=
-LOCAL_SHARED_LIBRARIES_$(HOST_OS):=
+LOCAL_ASFLAGS_$(HOST_OS):=
 LOCAL_CFLAGS_$(HOST_OS):=
+LOCAL_C_INCLUDES_$(HOST_OS):=
 LOCAL_CPPFLAGS_$(HOST_OS):=
+LOCAL_GENERATED_SOURCES_$(HOST_OS):=
+LOCAL_HEADER_LIBRARIES_$(HOST_OS):=
 LOCAL_LDFLAGS_$(HOST_OS):=
 LOCAL_LDLIBS_$(HOST_OS):=
-LOCAL_ASFLAGS_$(HOST_OS):=
-LOCAL_C_INCLUDES_$(HOST_OS):=
-LOCAL_GENERATED_SOURCES_$(HOST_OS):=
 LOCAL_REQUIRED_MODULES_$(HOST_OS):=
+LOCAL_SHARED_LIBRARIES_$(HOST_OS):=
+LOCAL_SRC_FILES_$(HOST_OS):=
+LOCAL_STATIC_LIBRARIES_$(HOST_OS):=
 
 ifdef HOST_CROSS_OS
-LOCAL_SRC_FILES_$(HOST_CROSS_OS):=
-LOCAL_STATIC_LIBRARIES_$(HOST_CROSS_OS):=
-LOCAL_SHARED_LIBRARIES_$(HOST_CROSS_OS):=
+LOCAL_ASFLAGS_$(HOST_CROSS_OS):=
 LOCAL_CFLAGS_$(HOST_CROSS_OS):=
+LOCAL_C_INCLUDES_$(HOST_CROSS_OS):=
 LOCAL_CPPFLAGS_$(HOST_CROSS_OS):=
+LOCAL_GENERATED_SOURCES_$(HOST_CROSS_OS):=
+LOCAL_HEADER_LIBRARIES_$(HOST_CROSS_OS):=
 LOCAL_LDFLAGS_$(HOST_CROSS_OS):=
 LOCAL_LDLIBS_$(HOST_CROSS_OS):=
-LOCAL_ASFLAGS_$(HOST_CROSS_OS):=
-LOCAL_C_INCLUDES_$(HOST_CROSS_OS):=
-LOCAL_GENERATED_SOURCES_$(HOST_CROSS_OS):=
 LOCAL_REQUIRED_MODULES_$(HOST_CROSS_OS):=
+LOCAL_SHARED_LIBRARIES_$(HOST_CROSS_OS):=
+LOCAL_SRC_FILES_$(HOST_CROSS_OS):=
+LOCAL_STATIC_LIBRARIES_$(HOST_CROSS_OS):=
 endif
 
 LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_ARCH):=
@@ -324,47 +366,59 @@
 endif
 endif
 
-LOCAL_SRC_FILES_32:=
-LOCAL_SRC_FILES_64:=
-LOCAL_SRC_FILES_EXCLUDE_32:=
-LOCAL_SRC_FILES_EXCLUDE_64:=
-LOCAL_SHARED_LIBRARIES_32:=
-LOCAL_SHARED_LIBRARIES_64:=
-LOCAL_STATIC_LIBRARIES_32:=
-LOCAL_STATIC_LIBRARIES_64:=
-LOCAL_WHOLE_STATIC_LIBRARIES_32:=
-LOCAL_WHOLE_STATIC_LIBRARIES_64:=
-LOCAL_GENERATED_SOURCES_32:=
-LOCAL_GENERATED_SOURCES_64:=
-LOCAL_CFLAGS_32:=
-LOCAL_CFLAGS_64:=
-LOCAL_CPPFLAGS_32:=
-LOCAL_CPPFLAGS_64:=
-LOCAL_LDFLAGS_32:=
-LOCAL_LDFLAGS_64:=
 LOCAL_ASFLAGS_32:=
 LOCAL_ASFLAGS_64:=
+LOCAL_CFLAGS_32:=
+LOCAL_CFLAGS_64:=
+LOCAL_C_INCLUDES_32:=
+LOCAL_C_INCLUDES_64:=
+LOCAL_CLANG_32:=
+LOCAL_CLANG_64:=
+LOCAL_CLANG_ASFLAGS_32:=
+LOCAL_CLANG_ASFLAGS_64:=
 LOCAL_CLANG_CFLAGS_32:=
 LOCAL_CLANG_CFLAGS_64:=
 LOCAL_CLANG_CPPFLAGS_32:=
 LOCAL_CLANG_CPPFLAGS_64:=
 LOCAL_CLANG_LDFLAGS_32:=
 LOCAL_CLANG_LDFLAGS_64:=
-LOCAL_CLANG_ASFLAGS_32:=
-LOCAL_CLANG_ASFLAGS_64:=
-LOCAL_C_INCLUDES_32:=
-LOCAL_C_INCLUDES_64:=
+LOCAL_CPPFLAGS_32:=
+LOCAL_CPPFLAGS_64:=
+LOCAL_GENERATED_SOURCES_32:=
+LOCAL_GENERATED_SOURCES_64:=
+LOCAL_HEADER_LIBRARIES_32:=
+LOCAL_HEADER_LIBRARIES_64:=
+LOCAL_INIT_RC_32:=
+LOCAL_INIT_RC_64:=
+LOCAL_LDFLAGS_32:=
+LOCAL_LDFLAGS_64:=
 LOCAL_MODULE_PATH_32:=
 LOCAL_MODULE_PATH_64:=
 LOCAL_MODULE_STEM_32:=
 LOCAL_MODULE_STEM_64:=
-LOCAL_CLANG_32:=
-LOCAL_CLANG_64:=
-LOCAL_INIT_RC_32:=
-LOCAL_INIT_RC_64:=
-LOCAL_JAVA_LANGUAGE_VERSION:=
-LOCAL_IS_RUNTIME_RESOURCE_OVERLAY:=
-LOCAL_RRO_THEME:=
+LOCAL_MODULE_SYMLINKS_32:=
+LOCAL_MODULE_SYMLINKS_64:=
+LOCAL_SHARED_LIBRARIES_32:=
+LOCAL_SHARED_LIBRARIES_64:=
+LOCAL_SRC_FILES_32:=
+LOCAL_SRC_FILES_64:=
+LOCAL_SRC_FILES_EXCLUDE_32:=
+LOCAL_SRC_FILES_EXCLUDE_64:=
+LOCAL_STATIC_LIBRARIES_32:=
+LOCAL_STATIC_LIBRARIES_64:=
+LOCAL_WHOLE_STATIC_LIBRARIES_32:=
+LOCAL_WHOLE_STATIC_LIBRARIES_64:=
+
+# Aux specific variables
+LOCAL_AUX_ARCH :=
+LOCAL_AUX_CPU :=
+LOCAL_AUX_OS :=
+LOCAL_AUX_OS_VARIANT :=
+LOCAL_AUX_SUBARCH :=
+LOCAL_AUX_TOOLCHAIN :=
+LOCAL_CUSTOM_BUILD_STEP_INPUT:=
+LOCAL_CUSTOM_BUILD_STEP_OUTPUT:=
+LOCAL_IS_AUX_MODULE :=
 
 # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
 # iterate over thousands of entries every time.
diff --git a/core/combo/HOST_CROSS_windows-x86.mk b/core/combo/HOST_CROSS_windows-x86.mk
index 6180a26..d924901 100644
--- a/core/combo/HOST_CROSS_windows-x86.mk
+++ b/core/combo/HOST_CROSS_windows-x86.mk
@@ -17,49 +17,7 @@
 # Settings to use MinGW as a cross-compiler under Linux
 # Included by combo/select.make
 
-$(combo_var_prefix)GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN
-$(combo_var_prefix)GLOBAL_CFLAGS += -Wno-unused-parameter
-$(combo_var_prefix)GLOBAL_CFLAGS += --sysroot prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32
-$(combo_var_prefix)GLOBAL_CFLAGS += -m32
-$(combo_var_prefix)GLOBAL_LDFLAGS += -m32
-TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32-
-$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include
-$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include
-$(combo_var_prefix)GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32
-
-# Workaround differences in inttypes.h between host and target.
-# See bug 12708004.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
-# Use C99-compliant printf functions (%zd).
-$(combo_var_prefix)GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
-# Admit to using >= Vista. Both are needed because of <_mingw.h>.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0600 -DWINVER=0x0600
-# Get 64-bit off_t and related functions.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64
-
-$(combo_var_prefix)CC := $(TOOLS_PREFIX)gcc
-$(combo_var_prefix)CXX := $(TOOLS_PREFIX)g++
-$(combo_var_prefix)AR := $(TOOLS_PREFIX)ar
-$(combo_var_prefix)NM := $(TOOLS_PREFIX)nm
-$(combo_var_prefix)OBJDUMP := $(TOOLS_PREFIX)objdump
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OBJDUMP) -x $(1) | grep "^Name" | cut -f3 -d" " > $(2)
 $(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)NM) -g -f p $(1) | cut -f1-2 -d" " >> $(2)
 endef
-
-$(combo_var_prefix)GLOBAL_LDFLAGS += \
-    --enable-stdcall-fixup
-
-ifneq ($(strip $(BUILD_HOST_static)),)
-# Statically-linked binaries are desirable for sandboxed environment
-$(combo_var_prefix)GLOBAL_LDFLAGS += -static
-endif # BUILD_HOST_static
-
-$(combo_var_prefix)SHLIB_SUFFIX := .dll
-$(combo_var_prefix)EXECUTABLE_SUFFIX := .exe
-
-$(combo_var_prefix)IS_64_BIT :=
-
-# The mingw gcc is 4.8, 4.9 is required for color diagnostics
-$(combo_var_prefix)UNKNOWN_CFLAGS := -fdiagnostics-color
diff --git a/core/combo/HOST_CROSS_windows-x86_64.mk b/core/combo/HOST_CROSS_windows-x86_64.mk
index e9b19cf..d924901 100644
--- a/core/combo/HOST_CROSS_windows-x86_64.mk
+++ b/core/combo/HOST_CROSS_windows-x86_64.mk
@@ -17,49 +17,7 @@
 # Settings to use MinGW as a cross-compiler under Linux
 # Included by combo/select.make
 
-$(combo_var_prefix)GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN
-$(combo_var_prefix)GLOBAL_CFLAGS += -Wno-unused-parameter
-$(combo_var_prefix)GLOBAL_CFLAGS += --sysroot prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32
-$(combo_var_prefix)GLOBAL_CFLAGS += -m64
-$(combo_var_prefix)GLOBAL_LDFLAGS += -m64
-TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32-
-$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include
-$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include
-$(combo_var_prefix)GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib64
-
-# Workaround differences in inttypes.h between host and target.
-# See bug 12708004.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
-# Use C99-compliant printf functions (%zd).
-$(combo_var_prefix)GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
-# Admit to using >= Vista. Both are needed because of <_mingw.h>.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0600 -DWINVER=0x0600
-# Get 64-bit off_t and related functions.
-$(combo_var_prefix)GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64
-
-$(combo_var_prefix)CC := $(TOOLS_PREFIX)gcc
-$(combo_var_prefix)CXX := $(TOOLS_PREFIX)g++
-$(combo_var_prefix)AR := $(TOOLS_PREFIX)ar
-$(combo_var_prefix)NM := $(TOOLS_PREFIX)nm
-$(combo_var_prefix)OBJDUMP := $(TOOLS_PREFIX)objdump
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OBJDUMP) -x $(1) | grep "^Name" | cut -f3 -d" " > $(2)
 $(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)NM) -g -f p $(1) | cut -f1-2 -d" " >> $(2)
 endef
-
-$(combo_var_prefix)GLOBAL_LDFLAGS += \
-    --enable-stdcall-fixup
-
-ifneq ($(strip $(BUILD_HOST_static)),)
-# Statically-linked binaries are desirable for sandboxed environment
-$(combo_var_prefix)GLOBAL_LDFLAGS += -static
-endif # BUILD_HOST_static
-
-$(combo_var_prefix)SHLIB_SUFFIX := .dll
-$(combo_var_prefix)EXECUTABLE_SUFFIX := .exe
-
-$(combo_var_prefix)IS_64_BIT := true
-
-# The mingw gcc is 4.8, 4.9 is required for color diagnostics
-$(combo_var_prefix)UNKNOWN_CFLAGS := -fdiagnostics-color
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index fc56e52..9a55cb5 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -17,45 +17,10 @@
 # Configuration for Darwin (Mac OS X) on x86.
 # Included by combo/select.mk
 
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32
-$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32
-
-ifneq ($(strip $(BUILD_HOST_static)),)
-# Statically-linked binaries are desirable for sandboxed environment
-$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static
-endif # BUILD_HOST_static
-
-# Workaround differences in inttypes.h between host and target.
-# See bug 12708004.
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
-
-include $(BUILD_COMBOS)/mac_version.mk
-
-$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1
-$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version)
-$(combo_2nd_arch_prefix)HOST_CC  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc
-$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-g++
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_macho,$(1),$(2))
 endef
 
-# gcc location for clang; to be updated when clang is updated
-# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
-$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)
-
-$(combo_2nd_arch_prefix)HOST_AR := $(AR)
-
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CPPFLAGS += -isystem $(mac_sdk_path)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
-$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
-
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
-$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
-
-$(combo_2nd_arch_prefix)HOST_SHLIB_SUFFIX := .dylib
-$(combo_2nd_arch_prefix)HOST_JNILIB_SUFFIX := .jnilib
-
 $(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs
 
 ############################################################
@@ -66,14 +31,13 @@
 define transform-host-o-to-shared-lib-inner
 $(hide) $(PRIVATE_CXX) \
         -dynamiclib -single_module -read_only_relocs suppress \
-        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
         $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
             $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
         ) \
         $(PRIVATE_ALL_OBJECTS) \
         $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-        $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-        $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+        $(PRIVATE_ALL_SHARED_LIBRARIES) \
+        $(PRIVATE_ALL_STATIC_LIBRARIES) \
         $(PRIVATE_LDLIBS) \
         -o $@ \
         -install_name @rpath/$(notdir $@) \
@@ -84,18 +48,17 @@
 
 define transform-host-o-to-executable-inner
 $(hide) $(PRIVATE_CXX) \
-        -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
-        -Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
+        $(foreach path,$(PRIVATE_RPATHS), \
+          -Wl,-rpath,@loader_path/$(path)) \
         -o $@ \
         -Wl,-headerpad_max_install_names \
-        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
         $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
            $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
         ) \
-        $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+        $(PRIVATE_ALL_SHARED_LIBRARIES) \
         $(PRIVATE_ALL_OBJECTS) \
-        $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-        $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+        $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
+        $(PRIVATE_ALL_STATIC_LIBRARIES) \
         $(PRIVATE_LDFLAGS) \
         $(PRIVATE_LDLIBS)
 endef
diff --git a/core/combo/HOST_darwin-x86_64.mk b/core/combo/HOST_darwin-x86_64.mk
index 251455f..6cca167 100644
--- a/core/combo/HOST_darwin-x86_64.mk
+++ b/core/combo/HOST_darwin-x86_64.mk
@@ -17,45 +17,10 @@
 # Configuration for Darwin (Mac OS X) on x86_64.
 # Included by combo/select.mk
 
-HOST_GLOBAL_CFLAGS += -m64
-HOST_GLOBAL_LDFLAGS += -m64
-
-ifneq ($(strip $(BUILD_HOST_static)),)
-# Statically-linked binaries are desirable for sandboxed environment
-HOST_GLOBAL_LDFLAGS += -static
-endif # BUILD_HOST_static
-
-# Workaround differences in inttypes.h between host and target.
-# See bug 12708004.
-HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
-
-include $(BUILD_COMBOS)/mac_version.mk
-
-HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1
-HOST_TOOLCHAIN_PREFIX := $(HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version)
-HOST_CC  := $(HOST_TOOLCHAIN_PREFIX)-gcc
-HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_macho,$(1),$(2))
 endef
 
-# gcc location for clang; to be updated when clang is updated
-# HOST_TOOLCHAIN_ROOT is a Darwin-specific define
-HOST_TOOLCHAIN_FOR_CLANG := $(HOST_TOOLCHAIN_ROOT)
-
-HOST_AR := $(AR)
-
-HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version)
-HOST_GLOBAL_CPPFLAGS += -isystem $(mac_sdk_path)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
-HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version)
-
-HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables
-HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error
-
-HOST_SHLIB_SUFFIX := .dylib
-HOST_JNILIB_SUFFIX := .jnilib
-
 HOST_GLOBAL_ARFLAGS := cqs
 
 # We Reuse the following functions with the same name from HOST_darwin-x86.mk:
diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk
index 169e2d2..4e83dc4 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -17,46 +17,10 @@
 # Configuration for builds hosted on linux-x86.
 # Included by combo/select.mk
 
-ifeq ($(strip $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)),)
-$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
-endif
-$(combo_2nd_arch_prefix)HOST_CC  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc
-$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)g++
-$(combo_2nd_arch_prefix)HOST_AR  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)ar
-$(combo_2nd_arch_prefix)HOST_READELF  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)readelf
-$(combo_2nd_arch_prefix)HOST_NM  := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-# gcc location for clang; to be updated when clang is updated
-$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
-
-# We expect SSE3 floating point math.
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -msse3 -mfpmath=sse -m32 -Wa,--noexecstack -march=prescott
-$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined-version
-
-ifneq ($(strip $(BUILD_HOST_static)),)
-# Statically-linked binaries are desirable for sandboxed environment
-$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static
-endif # BUILD_HOST_static
-
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC \
-  -no-canonical-prefixes \
-
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector
-
-# Workaround differences in inttypes.h between host and target.
-# See bug 12708004.
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
-
-# We build a 32-bit host art, and right now that also means building *all* host libraries
-# both 32- and 64-bit (whether art uses them or not --- 9d59f417767991246848c3e101cb27d2dfea5988).
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1
-
-$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
 ############################################################
 ## Macros after this line are shared by the 64-bit config.
 
diff --git a/core/combo/HOST_linux-x86_64.mk b/core/combo/HOST_linux-x86_64.mk
index 9766f2b..845733f 100644
--- a/core/combo/HOST_linux-x86_64.mk
+++ b/core/combo/HOST_linux-x86_64.mk
@@ -17,37 +17,6 @@
 # Configuration for builds hosted on linux-x86_64.
 # Included by combo/select.mk
 
-ifeq ($(strip $(HOST_TOOLCHAIN_PREFIX)),)
-HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
-endif
-HOST_CC  := $(HOST_TOOLCHAIN_PREFIX)gcc
-HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)g++
-HOST_AR  := $(HOST_TOOLCHAIN_PREFIX)ar
-HOST_READELF  := $(HOST_TOOLCHAIN_PREFIX)readelf
-HOST_NM  := $(HOST_TOOLCHAIN_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
-
-# gcc location for clang; to be updated when clang is updated
-HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8
-
-HOST_GLOBAL_CFLAGS += -m64 -Wa,--noexecstack
-HOST_GLOBAL_LDFLAGS += -m64 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined-version
-
-ifneq ($(strip $(BUILD_HOST_static)),)
-# Statically-linked binaries are desirable for sandboxed environment
-HOST_GLOBAL_LDFLAGS += -static
-endif # BUILD_HOST_static
-
-HOST_GLOBAL_CFLAGS += -fPIC \
-  -no-canonical-prefixes \
-
-HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector
-
-# Workaround differences in inttypes.h between host and target.
-# See bug 12708004.
-HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS
-
-HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 510aae5..2e179f6 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -33,15 +33,6 @@
 TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv5te
 endif
 
-# Decouple NDK library selection with platform compiler version
-$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9
-
-ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
-else
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
-endif
-
 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk
 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
 $(error Unknown ARM architecture version: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
@@ -50,146 +41,10 @@
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 include $(BUILD_SYSTEM)/combo/fdo.mk
 
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
-$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
-$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi-
-endif
-
-$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc
-$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++
-$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar
-$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy
-$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
-$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
-$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
-$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS :=    -O2 \
-                        -fomit-frame-pointer \
-                        -fstrict-aliasing    \
-                        -funswitch-loops
-
-# Modules can choose to compile some source as thumb.
-$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS :=  -mthumb \
-                        -Os \
-                        -fomit-frame-pointer \
-                        -fno-strict-aliasing
-
-# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk
-# or in your environment to force a full arm build, even for
-# files that are normally built as thumb; this can make
-# gdb debugging easier.  Don't forget to do a clean build.
-#
-# NOTE: if you try to build a -O0 build with thumb, several
-# of the libraries (libpv, libwebcore, libkjs) need to be built
-# with -mlong-calls.  When built at -O0, those libraries are
-# too big for a thumb "BL <label>" to go from one end to the other.
-ifeq ($(FORCE_ARM_DEBUGGING),true)
-  $(combo_2nd_arch_prefix)TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
-  $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
-endif
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
-			-msoft-float \
-			-ffunction-sections \
-			-fdata-sections \
-			-funwind-tables \
-			-fstack-protector-strong \
-			-Wa,--noexecstack \
-			-Werror=format-security \
-			-D_FORTIFY_SOURCE=2 \
-			-fno-short-enums \
-			-no-canonical-prefixes \
-			-fno-canonical-system-headers \
-			$(arch_variant_cflags) \
-
-# The "-Wunused-but-set-variable" option often breaks projects that enable
-# "-Wall -Werror" due to a commom idiom "ALOGV(mesg)" where ALOGV is turned
-# into no-op in some builds while mesg is defined earlier. So we explicitly
-# disable "-Wunused-but-set-variable" here.
-ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8 4.9, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \
-			-fno-strict-volatile-bitfields
-endif
-
-# This is to avoid the dreaded warning compiler message:
-#   note: the mangling of 'va_list' has changed in GCC 4.4
-#
-# The fact that the mangling changed does not affect the NDK ABI
-# very fortunately (since none of the exposed APIs used va_list
-# in their exported C++ functions). Also, GCC 4.5 has already
-# removed the warning from the compiler.
-#
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -Wno-psabi
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
-			-Wl,-z,noexecstack \
-			-Wl,-z,relro \
-			-Wl,-z,now \
-			-Wl,--build-id=md5 \
-			-Wl,--warn-shared-textrel \
-			-Wl,--fatal-warnings \
-			-Wl,--icf=safe \
-			-Wl,--hash-style=gnu \
-			-Wl,--no-undefined-version \
-			$(arch_variant_ldflags)
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
-
-# More flags/options can be added here
-$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
-			-DNDEBUG \
-			-g \
-			-Wstrict-aliasing=2 \
-			-fgcse-after-reload \
-			-frerun-cse-after-loop \
-			-frename-registers
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-
-
-## on some hosts, the target cross-compiler is not available so do not run this command
-ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
-# We compile with the global cflags to ensure that
-# any flags which affect libgcc are correctly taken
-# into account.
-$(combo_2nd_arch_prefix)TARGET_LIBGCC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
-        $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
-$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
-        $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
-$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
-        $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcov.a)
-endif
-
-KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_$(combo_2nd_arch_prefix)ARCH)
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
-	$(libc_root)/arch-arm/include \
-	$(libc_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/arm \
-
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-
 $(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
 
 $(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
index 6a1d861..a3f59a7 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -33,15 +33,6 @@
 TARGET_ARCH_VARIANT := armv8
 endif
 
-# Decouple NDK library selection with platform compiler version
-TARGET_NDK_GCC_VERSION := 4.9
-
-ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-TARGET_GCC_VERSION := 4.9
-else
-TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
-endif
-
 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
 $(error Unknown ARM architecture version: $(TARGET_ARCH_VARIANT))
@@ -50,119 +41,10 @@
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 include $(BUILD_SYSTEM)/combo/fdo.mk
 
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)
-TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/aarch64-linux-android-
-endif
-
-TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
-TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
-TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
-TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
-TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
-TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
-TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
-TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-TARGET_GLOBAL_CFLAGS += \
-    -fno-strict-aliasing \
-
-TARGET_GLOBAL_CFLAGS += \
-			-fstack-protector-strong \
-			-ffunction-sections \
-			-fdata-sections \
-			-funwind-tables \
-			-Wa,--noexecstack \
-			-Werror=format-security \
-			-D_FORTIFY_SOURCE=2 \
-			-fno-short-enums \
-			-no-canonical-prefixes \
-			-fno-canonical-system-headers \
-			$(arch_variant_cflags) \
-
-# Help catch common 32/64-bit errors.
-TARGET_GLOBAL_CFLAGS += \
-    -Werror=pointer-to-int-cast \
-    -Werror=int-to-pointer-cast \
-    -Werror=implicit-function-declaration \
-
-TARGET_GLOBAL_CFLAGS += -fno-strict-volatile-bitfields
-
-# This is to avoid the dreaded warning compiler message:
-#   note: the mangling of 'va_list' has changed in GCC 4.4
-#
-# The fact that the mangling changed does not affect the NDK ABI
-# very fortunately (since none of the exposed APIs used va_list
-# in their exported C++ functions). Also, GCC 4.5 has already
-# removed the warning from the compiler.
-#
-TARGET_GLOBAL_CFLAGS += -Wno-psabi
-
-TARGET_GLOBAL_LDFLAGS += \
-			-Wl,-z,noexecstack \
-			-Wl,-z,relro \
-			-Wl,-z,now \
-			-Wl,--build-id=md5 \
-			-Wl,--warn-shared-textrel \
-			-Wl,--fatal-warnings \
-			-Wl,-maarch64linux \
-			-Wl,--hash-style=gnu \
-			-Wl,--fix-cortex-a53-843419 \
-			-fuse-ld=gold \
-			-Wl,--icf=safe \
-			-Wl,--no-undefined-version \
-			$(arch_variant_ldflags)
-
-# Disable transitive dependency library symbol resolving.
-TARGET_GLOBAL_LDFLAGS += -Wl,--allow-shlib-undefined
-
-TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
-
-# More flags/options can be added here
-TARGET_RELEASE_CFLAGS := \
-			-DNDEBUG \
-			-O2 -g \
-			-Wstrict-aliasing=2 \
-			-fgcse-after-reload \
-			-frerun-cse-after-loop \
-			-frename-registers
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-
-TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
-	-print-libgcc-file-name)
-TARGET_LIBATOMIC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
-	-print-file-name=libatomic.a)
-TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
-	-print-file-name=libgcov.a)
-
-KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-TARGET_C_INCLUDES := \
-	$(libc_root)/arch-arm64/include \
-	$(libc_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/arm64 \
-
-TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-
-TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-
 TARGET_PACK_MODULE_RELOCATIONS := true
 
 TARGET_LINKER := /system/bin/linker64
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 186d88f..ba76969 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -33,15 +33,6 @@
 TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := mips32r2-fp
 endif
 
-# Decouple NDK library selection with platform compiler version
-$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9
-
-ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
-else
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
-endif
-
 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk
 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
 $(error Unknown MIPS architecture variant: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
@@ -50,121 +41,10 @@
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 include $(BUILD_SYSTEM)/combo/fdo.mk
 
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
-$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mips64el-linux-android-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
-$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/mips64el-linux-android-
-endif
-
-$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc
-$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++
-$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar
-$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy
-$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
-$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
-$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
-$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-TARGET_mips_CFLAGS :=	-O2 \
-			-fomit-frame-pointer \
-			-fno-strict-aliasing    \
-			-funswitch-loops
-
-# Set FORCE_MIPS_DEBUGGING to "true" in your buildspec.mk
-# or in your environment to gdb debugging easier.
-# Don't forget to do a clean build.
-ifeq ($(FORCE_MIPS_DEBUGGING),true)
-  TARGET_mips_CFLAGS += -fno-omit-frame-pointer
-endif
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
-			$(TARGET_mips_CFLAGS) \
-			-U__unix -U__unix__ -Umips \
-			-ffunction-sections \
-			-fdata-sections \
-			-funwind-tables \
-			-fstack-protector-strong \
-			-Wa,--noexecstack \
-			-Werror=format-security \
-			-D_FORTIFY_SOURCE=2 \
-			-no-canonical-prefixes \
-			-fno-canonical-system-headers \
-			$(arch_variant_cflags) \
-
-ifneq ($(ARCH_MIPS_PAGE_SHIFT),)
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DPAGE_SHIFT=$(ARCH_MIPS_PAGE_SHIFT)
-endif
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
-			-Wl,-z,noexecstack \
-			-Wl,-z,relro \
-			-Wl,-z,now \
-			-Wl,--build-id=md5 \
-			-Wl,--warn-shared-textrel \
-			-Wl,--fatal-warnings \
-			-Wl,--no-undefined-version \
-			$(arch_variant_ldflags)
-
-# Disable transitive dependency library symbol resolving.
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--allow-shlib-undefined
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
-
-# More flags/options can be added here
-$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
-			-DNDEBUG \
-			-g \
-			-Wstrict-aliasing=2 \
-			-fgcse-after-reload \
-			-frerun-cse-after-loop \
-			-frename-registers
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-
-
-## on some hosts, the target cross-compiler is not available so do not run this command
-ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
-# We compile with the global cflags to ensure that
-# any flags which affect libgcc are correctly taken
-# into account.
-$(combo_2nd_arch_prefix)TARGET_LIBGCC := \
-  $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a)
-$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \
-  $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
-LIBGCC_EH := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a)
-ifneq ($(LIBGCC_EH),libgcc_eh.a)
-  $(combo_2nd_arch_prefix)TARGET_LIBGCC += $(LIBGCC_EH)
-endif
-$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \
-        --print-file-name=libgcov.a)
-endif
-
-KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-mips # mips covers both mips and mips64.
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
-	$(libc_root)/arch-mips/include \
-	$(libc_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/mips \
-
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-
 $(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
 
 $(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
index 3e1f61a..b498d1f 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -33,15 +33,6 @@
 TARGET_ARCH_VARIANT := mips64r6
 endif
 
-# Decouple NDK library selection with platform compiler version
-TARGET_NDK_GCC_VERSION := 4.9
-
-ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-TARGET_GCC_VERSION := 4.9
-else
-TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
-endif
-
 TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
 ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
 $(error Unknown MIPS architecture variant: $(TARGET_ARCH_VARIANT))
@@ -50,130 +41,10 @@
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 include $(BUILD_SYSTEM)/combo/fdo.mk
 
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mips64el-linux-android-$(TARGET_GCC_VERSION)
-TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/mips64el-linux-android-
-endif
-
-TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
-TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
-TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
-TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
-TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
-TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
-TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
-TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-TARGET_mips_CFLAGS :=	-O2 \
-			-fomit-frame-pointer \
-			-fno-strict-aliasing    \
-			-funswitch-loops
-
-# Set FORCE_MIPS_DEBUGGING to "true" in your buildspec.mk
-# or in your environment to gdb debugging easier.
-# Don't forget to do a clean build.
-ifeq ($(FORCE_MIPS_DEBUGGING),true)
-  TARGET_mips_CFLAGS += -fno-omit-frame-pointer
-endif
-
-TARGET_GLOBAL_CFLAGS += \
-			$(TARGET_mips_CFLAGS) \
-			-U__unix -U__unix__ -Umips \
-			-ffunction-sections \
-			-fdata-sections \
-			-funwind-tables \
-			-fstack-protector-strong \
-			-Wa,--noexecstack \
-			-Werror=format-security \
-			-D_FORTIFY_SOURCE=2 \
-			-no-canonical-prefixes \
-			-fno-canonical-system-headers \
-			$(arch_variant_cflags) \
-
-# Help catch common 32/64-bit errors.
-TARGET_GLOBAL_CFLAGS += \
-    -Werror=pointer-to-int-cast \
-    -Werror=int-to-pointer-cast \
-    -Werror=implicit-function-declaration \
-
-ifneq ($(ARCH_MIPS_PAGE_SHIFT),)
-TARGET_GLOBAL_CFLAGS += -DPAGE_SHIFT=$(ARCH_MIPS_PAGE_SHIFT)
-endif
-
-TARGET_GLOBAL_LDFLAGS += \
-			-Wl,-z,noexecstack \
-			-Wl,-z,relro \
-			-Wl,-z,now \
-			-Wl,--build-id=md5 \
-			-Wl,--warn-shared-textrel \
-			-Wl,--fatal-warnings \
-			-Wl,--no-undefined-version \
-			$(arch_variant_ldflags)
-
-# Disable transitive dependency library symbol resolving.
-TARGET_GLOBAL_LDFLAGS += -Wl,--allow-shlib-undefined
-
-TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
-
-# More flags/options can be added here
-TARGET_RELEASE_CFLAGS := \
-			-DNDEBUG \
-			-g \
-			-Wstrict-aliasing=2 \
-			-fgcse-after-reload \
-			-frerun-cse-after-loop \
-			-frename-registers
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-
-
-## on some hosts, the target cross-compiler is not available so do not run this command
-ifneq ($(wildcard $(TARGET_CC)),)
-# We compile with the global cflags to ensure that
-# any flags which affect libgcc are correctly taken
-# into account.
-TARGET_LIBGCC := \
-  $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a)
-TARGET_LIBATOMIC := \
-  $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
-LIBGCC_EH := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a)
-ifneq ($(LIBGCC_EH),libgcc_eh.a)
-  TARGET_LIBGCC += $(LIBGCC_EH)
-endif
-TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
-        --print-file-name=libgcov.a)
-endif
-
-KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-mips
-# TODO: perhaps use $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH) instead of asm-mips ?
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-TARGET_C_INCLUDES := \
-	$(libc_root)/arch-mips64/include \
-	$(libc_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/mips \
-
-# TODO: perhaps use $(libm_root)/include/mips64 instead of mips ?
-
-TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-
-TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-
 TARGET_PACK_MODULE_RELOCATIONS := true
 
 TARGET_LINKER := /system/bin/linker64
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 558ec3b..2c4614b 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -22,15 +22,6 @@
 TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := x86
 endif
 
-# Decouple NDK library selection with platform compiler version
-$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9
-
-ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
-else
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
-endif
-
 # Include the arch-variant-specific configuration file.
 # Its role is to define various ARCH_X86_HAVE_XXX feature macros,
 # plus initial values for TARGET_GLOBAL_CFLAGS
@@ -43,108 +34,10 @@
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 include $(BUILD_SYSTEM)/combo/fdo.mk
 
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),)
-$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
-$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
-endif
-
-$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc
-$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++
-$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar
-$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy
-$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld
-$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf
-$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip
-$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
-$(combo_2nd_arch_prefix)TARGET_LIBGCC := \
-	$(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcc.a)
-$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \
-	$(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libatomic.a)
-$(combo_2nd_arch_prefix)TARGET_LIBGCOV := \
-	$(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcov.a)
-endif
-
-$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-
-KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
-			-O2 \
-			-Wa,--noexecstack \
-			-Werror=format-security \
-			-D_FORTIFY_SOURCE=2 \
-			-Wstrict-aliasing=2 \
-			-ffunction-sections \
-			-finline-functions \
-			-finline-limit=300 \
-			-fno-short-enums \
-			-fstrict-aliasing \
-			-funswitch-loops \
-			-funwind-tables \
-			-fstack-protector-strong \
-			-m32 \
-			-no-canonical-prefixes \
-			-fno-canonical-system-headers \
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
-
-ifeq ($(ARCH_X86_HAVE_SSSE3),true)   # yes, really SSSE3, not SSE3!
-    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
-endif
-ifeq ($(ARCH_X86_HAVE_SSE4),true)
-    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4
-endif
-ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
-    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.1
-endif
-ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
-    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.2
-endif
-ifeq ($(ARCH_X86_HAVE_AVX),true)
-    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mavx
-endif
-ifeq ($(ARCH_X86_HAVE_AES_NI),true)
-    $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -maes
-endif
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -m32
-
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
-$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--no-undefined-version
-
-$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
-	$(libc_root)/arch-x86/include \
-	$(libc_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/i387 \
-
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-
-$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-
 $(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
 
 $(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index 12166ec..d2172d6 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -22,15 +22,6 @@
 TARGET_ARCH_VARIANT := x86_64
 endif
 
-# Decouple NDK library selection with platform compiler version
-TARGET_NDK_GCC_VERSION := 4.9
-
-ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-TARGET_GCC_VERSION := 4.9
-else
-TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
-endif
-
 # Include the arch-variant-specific configuration file.
 # Its role is to define various ARCH_X86_HAVE_XXX feature macros,
 # plus initial values for TARGET_GLOBAL_CFLAGS
@@ -43,117 +34,10 @@
 include $(TARGET_ARCH_SPECIFIC_MAKEFILE)
 include $(BUILD_SYSTEM)/combo/fdo.mk
 
-# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else
-ifeq ($(strip $(TARGET_TOOLS_PREFIX)),)
-TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$(TARGET_GCC_VERSION)
-TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
-endif
-
-TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
-TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
-TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
-TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
-TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
-TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
-TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
-TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
-
 define $(combo_var_prefix)transform-shared-lib-to-toc
 $(call _gen_toc_command_for_elf,$(1),$(2))
 endef
 
-ifneq ($(wildcard $(TARGET_CC)),)
-TARGET_LIBGCC := \
-	$(shell $(TARGET_CC) -m64 -print-file-name=libgcc.a)
-TARGET_LIBATOMIC := \
-	$(shell $(TARGET_CC) -m64 -print-file-name=libatomic.a)
-TARGET_LIBGCOV := \
-	$(shell $(TARGET_CC) -m64 -print-file-name=libgcov.a)
-endif
-
-TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
-
-libc_root := bionic/libc
-libm_root := bionic/libm
-
-KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
-KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
-KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
-
-TARGET_GLOBAL_CFLAGS += \
-			-O2 \
-			-Wa,--noexecstack \
-			-Werror=format-security \
-			-D_FORTIFY_SOURCE=2 \
-			-Wstrict-aliasing=2 \
-			-ffunction-sections \
-			-finline-functions \
-			-finline-limit=300 \
-			-fno-short-enums \
-			-fstrict-aliasing \
-			-funswitch-loops \
-			-funwind-tables \
-			-fstack-protector-strong \
-			-m64 \
-			-no-canonical-prefixes \
-			-fno-canonical-system-headers
-
-# Help catch common 32/64-bit errors.
-TARGET_GLOBAL_CFLAGS += \
-    -Werror=pointer-to-int-cast \
-    -Werror=int-to-pointer-cast \
-    -Werror=implicit-function-declaration \
-
-TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
-
-ifeq ($(ARCH_X86_HAVE_SSSE3),true)   # yes, really SSSE3, not SSE3!
-    TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
-endif
-ifeq ($(ARCH_X86_HAVE_SSE4),true)
-    TARGET_GLOBAL_CFLAGS += -msse4
-endif
-ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
-    TARGET_GLOBAL_CFLAGS += -msse4.1
-endif
-ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
-    TARGET_GLOBAL_CFLAGS += -msse4.2
-endif
-ifeq ($(ARCH_X86_HAVE_POPCNT),true)
-    TARGET_GLOBAL_CFLAGS += -mpopcnt
-endif
-ifeq ($(ARCH_X86_HAVE_AVX),true)
-    TARGET_GLOBAL_CFLAGS += -mavx
-endif
-ifeq ($(ARCH_X86_HAVE_AES_NI),true)
-    TARGET_GLOBAL_CFLAGS += -maes
-endif
-
-TARGET_GLOBAL_LDFLAGS += -m64
-
-TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
-TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
-TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
-TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
-TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
-TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
-TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
-TARGET_GLOBAL_LDFLAGS += -Wl,--no-undefined-version
-
-TARGET_C_INCLUDES := \
-	$(libc_root)/arch-x86_64/include \
-	$(libc_root)/include \
-	$(KERNEL_HEADERS) \
-	$(libm_root)/include \
-	$(libm_root)/include/amd64 \
-
-TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
-TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
-TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
-
-TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
-TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
-
 TARGET_LINKER := /system/bin/linker64
 
 TARGET_GLOBAL_YASM_FLAGS := -f elf64 -m amd64
diff --git a/core/combo/arch/arm/armv5te.mk b/core/combo/arch/arm/armv5te.mk
index 88e57b7..bd75695 100644
--- a/core/combo/arch/arm/armv5te.mk
+++ b/core/combo/arch/arm/armv5te.mk
@@ -2,14 +2,3 @@
 # Generating binaries for the ARMv5TE architecture and higher
 #
 
-# Note: Hard coding the 'tune' value here is probably not ideal,
-# and a better solution should be found in the future.
-#
-arch_variant_cflags := \
-    -march=armv5te \
-    -mtune=xscale  \
-    -D__ARM_ARCH_5__ \
-    -D__ARM_ARCH_5T__ \
-    -D__ARM_ARCH_5E__ \
-    -D__ARM_ARCH_5TE__
-
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index 5d5b050..01d2235 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -5,50 +5,3 @@
 ARCH_ARM_HAVE_VFP               := true
 ARCH_ARM_HAVE_VFP_D32           := true
 ARCH_ARM_HAVE_NEON              := true
-
-local_arch_has_lpae := false
-
-ifneq (,$(filter cortex-a15 krait denver,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
-	# TODO: krait is not a cortex-a15, we set the variant to cortex-a15 so that
-	#       hardware divide operations are generated. This should be removed and a
-	#       krait CPU variant added to GCC. For clang we specify -mcpu for krait in
-	#       core/clang/arm.mk.
-	arch_variant_cflags := -mcpu=cortex-a15
-
-	local_arch_has_lpae := true
-	arch_variant_ldflags := \
-		-Wl,--no-fix-cortex-a8
-else
-ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a8)
-	arch_variant_cflags := -mcpu=cortex-a8
-	arch_variant_ldflags := \
-		-Wl,--fix-cortex-a8
-else
-ifneq (,$(filter cortex-a7 cortex-a53 cortex-a53.a57,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
-	arch_variant_cflags := -mcpu=cortex-a7
-
-	local_arch_has_lpae := true
-	arch_variant_ldflags := \
-		-Wl,--no-fix-cortex-a8
-else
-	arch_variant_cflags := -march=armv7-a
-	# Generic ARM might be a Cortex A8 -- better safe than sorry
-	arch_variant_ldflags := \
-		-Wl,--fix-cortex-a8
-endif
-endif
-endif
-
-ifeq (true,$(local_arch_has_lpae))
-	# Fake an ARM compiler flag as these processors support LPAE which GCC/clang
-	# don't advertise.
-	# TODO This is a hack and we need to add it for each processor that supports LPAE until some
-	# better solution comes around. See Bug 27340895
-	arch_variant_cflags += -D__ARM_FEATURE_LPAE=1
-endif
-
-local_arch_has_lpae :=
-
-arch_variant_cflags += \
-    -mfloat-abi=softfp \
-    -mfpu=neon
diff --git a/core/combo/arch/arm/armv7-a.mk b/core/combo/arch/arm/armv7-a.mk
index 4a51977..0c2f04d 100644
--- a/core/combo/arch/arm/armv7-a.mk
+++ b/core/combo/arch/arm/armv7-a.mk
@@ -3,14 +3,3 @@
 #
 ARCH_ARM_HAVE_ARMV7A            := true
 ARCH_ARM_HAVE_VFP               := true
-
-# Note: Hard coding the 'tune' value here is probably not ideal,
-# and a better solution should be found in the future.
-#
-arch_variant_cflags := \
-    -march=armv7-a \
-    -mfloat-abi=softfp \
-    -mfpu=vfpv3-d16
-
-arch_variant_ldflags := \
-	-Wl,--fix-cortex-a8
diff --git a/core/combo/arch/arm64/armv8-a.mk b/core/combo/arch/arm64/armv8-a.mk
index 5e27e5a..e69de29 100644
--- a/core/combo/arch/arm64/armv8-a.mk
+++ b/core/combo/arch/arm64/armv8-a.mk
@@ -1,5 +0,0 @@
-ifneq (,$(filter cortex-a53,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
-	arch_variant_cflags := -mcpu=cortex-a53
-else
-	arch_variant_cflags :=
-endif
diff --git a/core/combo/arch/mips/mips32-fp.mk b/core/combo/arch/mips/mips32-fp.mk
index 912ff63..4b09bc1 100644
--- a/core/combo/arch/mips/mips32-fp.mk
+++ b/core/combo/arch/mips/mips32-fp.mk
@@ -3,11 +3,3 @@
 
 ARCH_MIPS_HAS_FPU	:=true
 ARCH_HAVE_ALIGNED_DOUBLES :=true
-arch_variant_cflags := \
-    -mips32 \
-    -mfp32 \
-    -modd-spreg \
-    -mno-synci
-
-arch_variant_ldflags := \
-    -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2-fp-xburst.mk b/core/combo/arch/mips/mips32r2-fp-xburst.mk
index 09b3bc2..83fb12e 100644
--- a/core/combo/arch/mips/mips32r2-fp-xburst.mk
+++ b/core/combo/arch/mips/mips32r2-fp-xburst.mk
@@ -4,13 +4,3 @@
 
 ARCH_MIPS_HAS_FPU :=true
 ARCH_HAVE_ALIGNED_DOUBLES :=true
-arch_variant_cflags := \
-    -mips32r2 \
-    -mfp32 \
-    -modd-spreg \
-    -mno-fused-madd \
-    -Wa,-mmxu \
-    -mno-synci
-
-arch_variant_ldflags := \
-    -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2-fp.mk b/core/combo/arch/mips/mips32r2-fp.mk
index 9acb018..97c14c3 100644
--- a/core/combo/arch/mips/mips32r2-fp.mk
+++ b/core/combo/arch/mips/mips32r2-fp.mk
@@ -3,11 +3,3 @@
 
 ARCH_MIPS_HAS_FPU	:=true
 ARCH_HAVE_ALIGNED_DOUBLES :=true
-arch_variant_cflags := \
-    -mips32r2 \
-    -mfp32 \
-    -modd-spreg \
-    -msynci
-
-arch_variant_ldflags := \
-    -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2dsp-fp.mk b/core/combo/arch/mips/mips32r2dsp-fp.mk
index c4b49b6..522b6b9 100644
--- a/core/combo/arch/mips/mips32r2dsp-fp.mk
+++ b/core/combo/arch/mips/mips32r2dsp-fp.mk
@@ -5,12 +5,3 @@
 ARCH_MIPS_DSP_REV	:=1
 ARCH_MIPS_HAS_FPU       :=true
 ARCH_HAVE_ALIGNED_DOUBLES :=true
-arch_variant_cflags := \
-    -mips32r2 \
-    -mfp32 \
-    -modd-spreg \
-    -mdsp \
-    -msynci
-
-arch_variant_ldflags := \
-    -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2dspr2-fp.mk b/core/combo/arch/mips/mips32r2dspr2-fp.mk
index 8b05ffc..886d378 100644
--- a/core/combo/arch/mips/mips32r2dspr2-fp.mk
+++ b/core/combo/arch/mips/mips32r2dspr2-fp.mk
@@ -5,12 +5,3 @@
 ARCH_MIPS_DSP_REV	:=2
 ARCH_MIPS_HAS_FPU       :=true
 ARCH_HAVE_ALIGNED_DOUBLES :=true
-arch_variant_cflags := \
-    -mips32r2 \
-    -mfp32 \
-    -modd-spreg \
-    -mdspr2 \
-    -msynci
-
-arch_variant_ldflags := \
-    -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r6.mk b/core/combo/arch/mips/mips32r6.mk
index 315aa60..7bc6cac 100644
--- a/core/combo/arch/mips/mips32r6.mk
+++ b/core/combo/arch/mips/mips32r6.mk
@@ -2,11 +2,3 @@
 # Generating binaries for MIPS32R6/hard-float/little-endian
 
 ARCH_MIPS_REV6 := true
-arch_variant_cflags := \
-    -mips32r6 \
-    -mfp64 \
-    -mno-odd-spreg \
-    -msynci
-
-arch_variant_ldflags := \
-    -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips64/mips64r2.mk b/core/combo/arch/mips64/mips64r2.mk
index c5710d0..54aa387 100644
--- a/core/combo/arch/mips64/mips64r2.mk
+++ b/core/combo/arch/mips64/mips64r2.mk
@@ -4,7 +4,3 @@
 
 ARCH_MIPS_HAS_FPU	:=true
 ARCH_HAVE_ALIGNED_DOUBLES :=true
-arch_variant_cflags := \
-    -mips64r2 \
-    -msynci
-
diff --git a/core/combo/arch/mips64/mips64r6.mk b/core/combo/arch/mips64/mips64r6.mk
index 443de20..42d6c9e 100644
--- a/core/combo/arch/mips64/mips64r6.mk
+++ b/core/combo/arch/mips64/mips64r6.mk
@@ -1,7 +1,3 @@
 # Configuration for Android on mips64r6.
 
-ARCH_MIPS_REV6 := true
-arch_variant_cflags := \
-    -mips64r6 \
-    -msynci
-
+ARCH_MIPS64_REV6 := true
diff --git a/core/combo/arch/x86/atom.mk b/core/combo/arch/x86/atom.mk
index 3800350..d313a9a 100644
--- a/core/combo/arch/x86/atom.mk
+++ b/core/combo/arch/x86/atom.mk
@@ -7,9 +7,3 @@
 ARCH_X86_HAVE_SSSE3 := true
 ARCH_X86_HAVE_MOVBE := true
 ARCH_X86_HAVE_POPCNT := false   # popcnt is not supported by current Atom CPUs
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=atom \
-	-mfpmath=sse \
-
diff --git a/core/combo/arch/x86/haswell.mk b/core/combo/arch/x86/haswell.mk
index b3922c0..50c27b4 100644
--- a/core/combo/arch/x86/haswell.mk
+++ b/core/combo/arch/x86/haswell.mk
@@ -9,9 +9,3 @@
 ARCH_X86_HAVE_AVX    := true
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := true
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=core-avx2 \
-	-mfpmath=sse \
-
diff --git a/core/combo/arch/x86/ivybridge.mk b/core/combo/arch/x86/ivybridge.mk
index c9fc33b..44035d8 100644
--- a/core/combo/arch/x86/ivybridge.mk
+++ b/core/combo/arch/x86/ivybridge.mk
@@ -9,9 +9,3 @@
 ARCH_X86_HAVE_AVX    := true
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := false
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=core-avx-i \
-	-mfpmath=sse \
-
diff --git a/core/combo/arch/x86/sandybridge.mk b/core/combo/arch/x86/sandybridge.mk
index bca5953..a4c1bd9 100644
--- a/core/combo/arch/x86/sandybridge.mk
+++ b/core/combo/arch/x86/sandybridge.mk
@@ -5,13 +5,7 @@
 ARCH_X86_HAVE_SSE4   := true
 ARCH_X86_HAVE_SSE4_1 := true
 ARCH_X86_HAVE_SSE4_2 := true
-ARCH_X86_HAVE_AES_NI := true
-ARCH_X86_HAVE_AVX    := true
+ARCH_X86_HAVE_AES_NI := false
+ARCH_X86_HAVE_AVX    := false
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := false
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=corei7-avx \
-	-mfpmath=sse \
-
diff --git a/core/combo/arch/x86/silvermont.mk b/core/combo/arch/x86/silvermont.mk
index d064b1d..70b718c 100644
--- a/core/combo/arch/x86/silvermont.mk
+++ b/core/combo/arch/x86/silvermont.mk
@@ -11,9 +11,3 @@
 ARCH_X86_HAVE_AES_NI := true
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := true
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=slm \
-	-mfpmath=sse \
-
diff --git a/core/combo/arch/x86/x86.mk b/core/combo/arch/x86/x86.mk
index f070426..a55cc7a 100644
--- a/core/combo/arch/x86/x86.mk
+++ b/core/combo/arch/x86/x86.mk
@@ -11,9 +11,3 @@
 ARCH_X86_HAVE_SSSE3 := false
 ARCH_X86_HAVE_MOVBE := false
 ARCH_X86_HAVE_POPCNT := false
-
-
-# Some intrinsic functions used by libcxx only exist for prescott or newer CPUs.
-arch_variant_cflags := \
-    -march=prescott \
-
diff --git a/core/combo/arch/x86/x86_64.mk b/core/combo/arch/x86/x86_64.mk
new file mode 100644
index 0000000..fc2a087
--- /dev/null
+++ b/core/combo/arch/x86/x86_64.mk
@@ -0,0 +1,12 @@
+# This file is used as the second (32-bit) architecture when building a generic
+# x86_64 64-bit platform image. (full_x86_64-eng / sdk_x86_64-eng)
+#
+# The generic 'x86' variant cannot be used, since it resets some flags used
+# by the 'x86_64' variant.
+
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_MOVBE := false # Only supported on Atom.
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
diff --git a/core/combo/arch/x86_64/haswell.mk b/core/combo/arch/x86_64/haswell.mk
index 6067eee..f9c6ebd 100644
--- a/core/combo/arch/x86_64/haswell.mk
+++ b/core/combo/arch/x86_64/haswell.mk
@@ -9,7 +9,3 @@
 ARCH_X86_HAVE_AVX    := true
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := true
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=core-avx2
diff --git a/core/combo/arch/x86_64/ivybridge.mk b/core/combo/arch/x86_64/ivybridge.mk
index 90e23a9..69011d6 100644
--- a/core/combo/arch/x86_64/ivybridge.mk
+++ b/core/combo/arch/x86_64/ivybridge.mk
@@ -9,7 +9,3 @@
 ARCH_X86_HAVE_AVX    := true
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := false
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=core-avx-i
diff --git a/core/combo/arch/x86_64/sandybridge.mk b/core/combo/arch/x86_64/sandybridge.mk
index 865548c..2092d19 100644
--- a/core/combo/arch/x86_64/sandybridge.mk
+++ b/core/combo/arch/x86_64/sandybridge.mk
@@ -5,11 +5,7 @@
 ARCH_X86_HAVE_SSE4   := true
 ARCH_X86_HAVE_SSE4_1 := true
 ARCH_X86_HAVE_SSE4_2 := true
-ARCH_X86_HAVE_AES_NI := true
-ARCH_X86_HAVE_AVX    := true
+ARCH_X86_HAVE_AES_NI := false
+ARCH_X86_HAVE_AVX    := false
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := false
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=corei7-avx
diff --git a/core/combo/arch/x86_64/silvermont.mk b/core/combo/arch/x86_64/silvermont.mk
index 6c953a3..70b718c 100644
--- a/core/combo/arch/x86_64/silvermont.mk
+++ b/core/combo/arch/x86_64/silvermont.mk
@@ -11,7 +11,3 @@
 ARCH_X86_HAVE_AES_NI := true
 ARCH_X86_HAVE_POPCNT := true
 ARCH_X86_HAVE_MOVBE  := true
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-	-march=slm \
diff --git a/core/combo/arch/x86_64/x86_64.mk b/core/combo/arch/x86_64/x86_64.mk
index 08dd9cd..26a9d0f 100755
--- a/core/combo/arch/x86_64/x86_64.mk
+++ b/core/combo/arch/x86_64/x86_64.mk
@@ -11,8 +11,3 @@
 ARCH_X86_HAVE_SSE4 := true
 ARCH_X86_HAVE_SSE4_1 := true
 ARCH_X86_HAVE_SSE4_2 := true
-
-
-# CFLAGS for this arch
-arch_variant_cflags := \
-    -march=x86-64
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index 7f66ea8..d067ce7 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -31,7 +31,7 @@
 endif
 
 # Whatever compiler is on this system.
-COMMON_JAVAC := $(JAVACC) -J-Xmx1024M $(common_jdk_flags)
+COMMON_JAVAC := $(JAVACC) -J-Xmx2048M $(common_jdk_flags)
 
 # Eclipse.
 ifeq ($(CUSTOM_JAVA_COMPILER), eclipse)
diff --git a/core/combo/mac_version.mk b/core/combo/mac_version.mk
deleted file mode 100644
index 51394c6..0000000
--- a/core/combo/mac_version.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-# Detect Mac OS X and SDK versions.
-# Output variables:
-#   build_mac_version
-#   mac_sdk_version
-#   mac_sdk_root
-#   gcc_darwin_version
-
-ifndef build_mac_version
-
-build_mac_version := $(shell sw_vers -productVersion)
-
-mac_sdk_versions_supported :=  10.8 10.9 10.10 10.11
-ifneq ($(strip $(MAC_SDK_VERSION)),)
-mac_sdk_version := $(MAC_SDK_VERSION)
-ifeq ($(filter $(mac_sdk_version),$(mac_sdk_versions_supported)),)
-$(warning ****************************************************************)
-$(warning * MAC_SDK_VERSION $(MAC_SDK_VERSION) isn't one of the supported $(mac_sdk_versions_supported))
-$(warning ****************************************************************)
-$(error Stop.)
-endif
-else
-mac_sdk_versions_installed := $(shell xcodebuild -showsdks | grep macosx | sed -e "s/.*macosx//g")
-mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported)))
-ifeq ($(mac_sdk_version),)
-mac_sdk_version := $(firstword $(mac_sdk_versions_supported))
-$(warning none of the installed SDKs ($mac_sdk_versions_installed) match supported versions ($(mac_sdk_versions_supported)), trying $(mac_sdk_version))
-endif
-endif
-
-mac_sdk_path := $(shell xcode-select -print-path)
-# try /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk
-#  or /Volume/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk
-mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
-ifeq ($(wildcard $(mac_sdk_root)),)
-# try legacy /Developer/SDKs/MacOSX10.?.sdk
-$(warning no SDK $(mac_sdk_version) at $(mac_sdk_root), trying legacy dir)
-mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
-endif
-ifeq ($(wildcard $(mac_sdk_root)),)
-$(warning *****************************************************)
-$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
-$(warning *****************************************************)
-$(error Stop.)
-endif
-
-ifeq ($(mac_sdk_version),10.6)
-  gcc_darwin_version := 10
-else
-  gcc_darwin_version := 11
-endif
-
-endif  # ifndef build_mac_version
diff --git a/core/combo/select.mk b/core/combo/select.mk
index df12e7e..5e181b9 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -28,21 +28,8 @@
 
 # Set reasonable defaults for the various variables
 
-$(combo_var_prefix)CC := $(CC)
-$(combo_var_prefix)CXX := $(CXX)
-$(combo_var_prefix)AR := $(AR)
-$(combo_var_prefix)STRIP := $(STRIP)
-
-$(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
-$(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
-$(combo_var_prefix)GLOBAL_CPPFLAGS :=
-$(combo_var_prefix)GLOBAL_LDFLAGS :=
 $(combo_var_prefix)GLOBAL_ARFLAGS := crsPD
-$(combo_var_prefix)GLOBAL_LD_DIRS :=
 
-$(combo_var_prefix)EXECUTABLE_SUFFIX :=
-$(combo_var_prefix)SHLIB_SUFFIX := .so
-$(combo_var_prefix)JNILIB_SUFFIX := $($(combo_var_prefix)SHLIB_SUFFIX)
 $(combo_var_prefix)STATIC_LIB_SUFFIX := .a
 
 # Now include the combo for this specific target.
diff --git a/core/config.mk b/core/config.mk
index 2847d34..59c2a34 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -31,6 +31,37 @@
 backslash := \a
 backslash := $(patsubst %a,%,$(backslash))
 
+# this turns off the suffix rules built into make
+.SUFFIXES:
+
+# this turns off the RCS / SCCS implicit rules of GNU Make
+% : RCS/%,v
+% : RCS/%
+% : %,v
+% : s.%
+% : SCCS/s.%
+
+# If a rule fails, delete $@.
+.DELETE_ON_ERROR:
+
+# Check for broken versions of make.
+ifndef KATI
+ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
+$(warning ********************************************************************************)
+$(warning *  You are using version $(MAKE_VERSION) of make.)
+$(warning *  Android can only be built by versions 3.81 and higher.)
+$(warning *  see https://source.android.com/source/download.html)
+$(warning ********************************************************************************)
+$(error stopping)
+endif
+endif
+
+# Used to force goals to build.  Only use for conditionally defined goals.
+.PHONY: FORCE
+FORCE:
+
+ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
+
 # Tell python not to spam the source tree with .pyc files.  This
 # only has an effect on python 2.6 and above.
 export PYTHONDONTWRITEBYTECODE := 1
@@ -40,25 +71,6 @@
 $(error Please remove --color=always from your  $$GREP_OPTIONS)
 endif
 
-# Standard source directories.
-SRC_DOCS:= $(TOPDIR)docs
-# TODO: Enforce some kind of layering; only add include paths
-#       when a module links against a particular library.
-# TODO: See if we can remove most of these from the global list.
-SRC_HEADERS := \
-	$(TOPDIR)system/core/include \
-	$(TOPDIR)system/media/audio/include \
-	$(TOPDIR)hardware/libhardware/include \
-	$(TOPDIR)hardware/libhardware_legacy/include \
-	$(TOPDIR)hardware/ril/include \
-	$(TOPDIR)libnativehelper/include \
-	$(TOPDIR)frameworks/native/include \
-	$(TOPDIR)frameworks/native/opengl/include \
-	$(TOPDIR)frameworks/av/include \
-	$(TOPDIR)frameworks/base/include
-SRC_HOST_HEADERS:=$(TOPDIR)tools/include
-SRC_LIBRARIES:= $(TOPDIR)libs
-SRC_SERVERS:= $(TOPDIR)servers
 SRC_TARGET_DIR := $(TOPDIR)build/target
 SRC_API_DIR := $(TOPDIR)prebuilts/sdk/api
 SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api
@@ -67,6 +79,10 @@
 # Some specific paths to tools
 SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
 
+# Set up efficient math functions which are used in make.
+# Here since this file is included by envsetup as well as during build.
+include $(BUILD_SYSTEM)/math.mk
+
 # Various mappings to avoid hard-coding paths all over the place
 include $(BUILD_SYSTEM)/pathmap.mk
 
@@ -80,6 +96,9 @@
 BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
 BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
 BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
+BUILD_HEADER_LIBRARY:= $(BUILD_SYSTEM)/header_library.mk
+BUILD_AUX_STATIC_LIBRARY:= $(BUILD_SYSTEM)/aux_static_library.mk
+BUILD_AUX_EXECUTABLE:= $(BUILD_SYSTEM)/aux_executable.mk
 BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
 BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
 BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
@@ -166,7 +185,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:
@@ -198,8 +217,8 @@
 #     etc.
 #
 # NOTE: These directories MUST contain post-processed headers using the
-# bionic/libc/kernel/clean_header.py tool. Additionally, the original kernel
-# headers must also be checked in, but in a different subdirectory. By
+# bionic/libc/kernel/tools/clean_header.py tool. Additionally, the original
+# kernel headers must also be checked in, but in a different subdirectory. By
 # convention, the originals should be checked into original-kernel-headers
 # directory of the same parent dir. For example,
 #     device/samsung/tuna/kernel-headers            <----- post-processed
@@ -234,6 +253,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)
@@ -243,7 +265,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_
@@ -284,9 +306,14 @@
 include $(BUILD_SYSTEM)/combo/select.mk
 endif
 
+ifndef KATI
 include $(BUILD_SYSTEM)/ccache.mk
 include $(BUILD_SYSTEM)/goma.mk
 
+export CC_WRAPPER
+export CXX_WRAPPER
+endif
+
 ifdef TARGET_PREFER_32_BIT
 TARGET_PREFER_32_BIT_APPS := true
 TARGET_PREFER_32_BIT_EXECUTABLES := true
@@ -340,26 +367,35 @@
 TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
 TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
 
-# Compute TARGET_TOOLCHAIN_ROOT from TARGET_TOOLS_PREFIX
-# if only TARGET_TOOLS_PREFIX is passed to the make command.
-ifndef TARGET_TOOLCHAIN_ROOT
-TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLS_PREFIX)))
-TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLCHAIN_ROOT)))
-TARGET_TOOLCHAIN_ROOT := $(wildcard $(TARGET_TOOLCHAIN_ROOT))
+# GCC version selection
+TARGET_GCC_VERSION := 4.9
+ifdef TARGET_2ND_ARCH
+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
 
-# Disable WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK if tool can't be found
+# Unset WITH_TIDY_ONLY if global WITH_TIDY_ONLY is not true nor 1.
+ifeq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
+  WITH_TIDY_ONLY :=
+endif
+
+PATH_TO_CLANG_TIDY := \
+    $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin/clang-tidy
+ifeq ($(wildcard $(PATH_TO_CLANG_TIDY)),)
+  ifneq (,$(filter 1 true,$(WITH_TIDY)))
+    $(warning *** Disable WITH_TIDY because $(PATH_TO_CLANG_TIDY) does not exist)
+  endif
+  PATH_TO_CLANG_TIDY :=
+endif
+
+# 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)),)
@@ -369,14 +405,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
 
@@ -455,8 +483,9 @@
 #
 # Tools that are prebuilts for TARGET_BUILD_APPS
 #
+prebuilt_sdk_tools := prebuilts/sdk/tools
+prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
 
-ACP := $(HOST_OUT_EXECUTABLES)/acp
 AIDL := $(HOST_OUT_EXECUTABLES)/aidl
 AAPT := $(HOST_OUT_EXECUTABLES)/aapt
 AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
@@ -465,18 +494,32 @@
 SIGNAPK_JNI_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
 LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc
 BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat
+DEPMOD := $(HOST_OUT_EXECUTABLES)/depmod
 
 DX := $(HOST_OUT_EXECUTABLES)/dx
 MAINDEXCLASSES := $(HOST_OUT_EXECUTABLES)/mainDexClasses
 
+SOONG_ZIP := $(SOONG_HOST_OUT_EXECUTABLES)/soong_zip
+ZIP2ZIP := $(SOONG_HOST_OUT_EXECUTABLES)/zip2zip
+FILESLIST := $(SOONG_HOST_OUT_EXECUTABLES)/fileslist
+
+# 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
+MAKEPARALLEL := $(prebuilt_build_tools_bin)/makeparallel
+ZIPTIME := $(prebuilt_build_tools_bin)/ziptime
+
 USE_PREBUILT_SDK_TOOLS_IN_PLACE := true
 
 # Override the definitions above for unbundled and PDK builds
 ifneq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)))
-prebuilt_sdk_tools := prebuilts/sdk/tools
-prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
-
-ACP := $(prebuilt_sdk_tools_bin)/acp
 AIDL := $(prebuilt_sdk_tools_bin)/aidl
 AAPT := $(prebuilt_sdk_tools_bin)/aapt
 AAPT2 := $(prebuilt_sdk_tools_bin)/aapt2
@@ -494,6 +537,8 @@
 BCC_COMPAT := $(prebuilt_sdk_tools_bin)/bcc_compat
 endif # TARGET_BUILD_PDK
 endif # TARGET_BUILD_APPS || TARGET_BUILD_PDK
+prebuilt_sdk_tools :=
+prebuilt_sdk_tools_bin :=
 
 
 # ---------------------------------------------------------------
@@ -508,11 +553,11 @@
 BISON_PKGDATADIR := $(PWD)/external/bison/data
 BISON := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/bison/bison
 YACC := $(BISON) -d
+BISON_DATA := $(wildcard external/bison/data/* external/bison/data/*/*)
 
 YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
 
 DOXYGEN:= doxygen
-AIDL_CPP := $(HOST_OUT_EXECUTABLES)/aidl-cpp$(HOST_EXECUTABLE_SUFFIX)
 ifeq ($(HOST_OS),linux)
 BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms
 else
@@ -520,8 +565,11 @@
 BREAKPAD_GENERATE_SYMBOLS := false
 endif
 PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
+NANOPB_SRCS := external/nanopb-c/generator/protoc-gen-nanopb \
+    $(wildcard external/nanopb-c/generator/*.py \
+               external/nanopb-c/generator/google/*.py \
+               external/nanopb-c/generator/proto/*.py)
 VTSC := $(HOST_OUT_EXECUTABLES)/vtsc$(HOST_EXECUTABLE_SUFFIX)
-DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator
 MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
 MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
 ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
@@ -529,11 +577,28 @@
 else
 MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
 endif
+ifeq (,$(strip $(BOARD_CUSTOM_BPTTOOL)))
+BPTTOOL := $(HOST_OUT_EXECUTABLES)/bpttool$(HOST_EXECUTABLE_SUFFIX)
+else
+BPTTOOL := $(BOARD_CUSTOM_BPTTOOL)
+endif
+ifeq (,$(strip $(BOARD_CUSTOM_AVBTOOL)))
+AVBTOOL := $(HOST_OUT_EXECUTABLES)/avbtool$(HOST_EXECUTABLE_SUFFIX)
+else
+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)
+ifeq ($(TARGET_USES_MKE2FS),true)
+MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/mke2fs$(HOST_EXECUTABLE_SUFFIX)
+MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs.sh
+MKE2FS_CONF := system/extras/ext4_utils/mke2fs.conf
+else
 MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
-BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX)
 MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
+MKE2FS_CONF :=
+endif
+BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX)
 MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX)
 MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
 MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX)
@@ -543,9 +608,11 @@
 E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
 MKTARBALL := build/tools/mktarball.sh
 TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
-E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
 JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
+DESUGAR := $(HOST_OUT_JAVA_LIBRARIES)/desugar.jar
 DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
+FAT16COPY := build/tools/fat16copy.py
+CHECK_LINK_TYPE := build/tools/check_link_type.py
 
 ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
 DEFAULT_JACK_ENABLED:=full
@@ -553,16 +620,17 @@
 DEFAULT_JACK_ENABLED:=
 endif
 ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
+JACK_DEFAULT_ARGS :=
 DEFAULT_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
 else
-DEFAULT_JACK_EXTRA_ARGS := @$(BUILD_SYSTEM)/jack-default.args
+JACK_DEFAULT_ARGS := $(BUILD_SYSTEM)/jack-default.args
+DEFAULT_JACK_EXTRA_ARGS := @$(JACK_DEFAULT_ARGS)
 endif
-# Turn off jack warnings by default.
-DEFAULT_JACK_EXTRA_ARGS += --verbose error
 
 PROGUARD := external/proguard/bin/proguard.sh
 JAVATAGS := build/tools/java-event-log-tags.py
-RMTYPEDEFS := $(HOST_OUT_EXECUTABLES)/rmtypedefs
+MERGETAGS := build/tools/merge-event-log-tags.py
+BUILD_IMAGE_SRCS := $(wildcard build/tools/releasetools/*.py)
 APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
 VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
 BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
@@ -571,14 +639,8 @@
 VBOOT_SIGNER := prebuilts/misc/scripts/vboot_signer/vboot_signer.sh
 FEC := $(HOST_OUT_EXECUTABLES)/fec
 
-ifndef TARGET_BUILD_APPS
-ZIPTIME := $(HOST_OUT_EXECUTABLES)/ziptime$(HOST_EXECUTABLE_SUFFIX)
-endif
-
-# ijar converts a .jar file to a smaller .jar file which only has its
-# interfaces.
-IJAR := $(HOST_OUT_EXECUTABLES)/ijar$(BUILD_EXECUTABLE_SUFFIX)
 DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump2$(BUILD_EXECUTABLE_SUFFIX)
+PROFMAN := $(HOST_OUT_EXECUTABLES)/profman
 
 # relocation packer
 RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
@@ -621,6 +683,16 @@
 APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
 APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
 
+# Boolean variable determining if Treble is fully enabled
+PRODUCT_FULL_TREBLE := false
+ifneq ($(PRODUCT_FULL_TREBLE_OVERRIDE),)
+  PRODUCT_FULL_TREBLE := $(PRODUCT_FULL_TREBLE_OVERRIDE)
+else ifeq ($(PRODUCT_SHIPPING_API_LEVEL),)
+  #$(warning no product shipping level defined)
+else ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),26),)
+  PRODUCT_FULL_TREBLE := true
+endif
+
 # The default key if not set as LOCAL_CERTIFICATE
 ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
   DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
@@ -628,162 +700,36 @@
   DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
 endif
 
+FRAMEWORK_MANIFEST_FILE := system/libhidl/manifest.xml
+FRAMEWORK_COMPATIBILITY_MATRIX_FILE := hardware/interfaces/compatibility_matrix.xml
+
 # ###############################################################
 # Set up final options.
 # ###############################################################
 
-ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
-$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
-$(info *** Device configurations are no longer allowed to change the global flags.)
-$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
-$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
-$(error bailing...)
-endif
-
-# These can be changed to modify both host and device modules.
-COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
-COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
-
-# Force gcc to always output color diagnostics.  Ninja will strip the ANSI
-# color codes if it is not running in a terminal.
-ifdef BUILDING_WITH_NINJA
-COMMON_GLOBAL_CFLAGS += -fdiagnostics-color
-endif
-
-COMMON_GLOBAL_CPPFLAGS:= -Wsign-promo
-COMMON_RELEASE_CPPFLAGS:=
-
-GLOBAL_CFLAGS_NO_OVERRIDE := \
-    -Werror=int-to-pointer-cast \
-    -Werror=pointer-to-int-cast \
-
-GLOBAL_CLANG_CFLAGS_NO_OVERRIDE := \
-    -Werror=address-of-temporary \
-    -Werror=null-dereference \
-    -Werror=return-type \
-
-GLOBAL_CPPFLAGS_NO_OVERRIDE :=
-
-# list of flags to turn specific warnings in to errors
-TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time
-
 # We run gcc/clang with PWD=/proc/self/cwd to remove the $TOP
 # from the debug output. That way two builds in two different
 # directories will create the same output.
 # /proc doesn't exist on Darwin.
 ifeq ($(HOST_OS),linux)
 RELATIVE_PWD := PWD=/proc/self/cwd
-# Remove this useless prefix from the debug output.
-COMMON_GLOBAL_CFLAGS += -fdebug-prefix-map=/proc/self/cwd=
 else
 RELATIVE_PWD :=
 endif
 
-# Allow the C/C++ macros __DATE__ and __TIME__ to be set to the
-# build date and time, so that a build may be repeated.
-# Write the date and time to a file so that the command line
-# doesn't change every time, which would cause ninja to rebuild
-# the files.
-$(shell mkdir -p $(OUT_DIR) && \
-    $(DATE) "+%b %_d %Y" > $(OUT_DIR)/build_c_date.txt && \
-    $(DATE) +%T > $(OUT_DIR)/build_c_time.txt)
-BUILD_DATETIME_C_DATE := $$(cat $(OUT_DIR)/build_c_date.txt)
-BUILD_DATETIME_C_TIME := $$(cat $(OUT_DIR)/build_c_time.txt)
-ifeq ($(OVERRIDE_C_DATE_TIME),true)
-COMMON_GLOBAL_CFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
-endif
-
-HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
-HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
-
-HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
-HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
-
-TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
-TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
-
-TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
-TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
-
-HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
-TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
-
-HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
-TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) \
+TARGET_PROJECT_INCLUDES :=
+TARGET_PROJECT_SYSTEM_INCLUDES := \
 		$(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) \
 		$(TARGET_PRODUCT_KERNEL_HEADERS)
 
-# Many host compilers don't support these flags, so we have to make
-# sure to only specify them for the target compilers checked in to
-# the source tree.
-TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
-
-HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
-HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
-
-TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
-TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
-
 ifdef TARGET_2ND_ARCH
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS += -L$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS)
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS)
-endif
-
-ifdef HOST_2ND_ARCH
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS += -L$($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_PROJECT_INCLUDES := $(HOST_PROJECT_INCLUDES)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS)
-$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS)
-endif
-
-ifdef HOST_CROSS_OS
-HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $(HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
-HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
-HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
-HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
-HOST_CROSS_GLOBAL_LD_DIRS += -L$(HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
-HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_CROSS_OUT_HEADERS)
-HOST_CROSS_GLOBAL_CFLAGS += $(HOST_CROSS_RELEASE_CFLAGS)
-HOST_CROSS_GLOBAL_CPPFLAGS += $(HOST_CROSS_RELEASE_CPPFLAGS)
-
-ifdef HOST_CROSS_2ND_ARCH
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_LD_DIRS += -L$($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_HEADERS)
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS)
-$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS)
-endif
-endif
-
-ifdef BRILLO
-# Add a C define that identifies Brillo targets. __BRILLO__ should only be used
-# to differentiate between Brillo and non-Brillo-but-Android environments. Use
-# __ANDROID__ instead to test if something is being built in an Android-derived
-# environment (including Brillo) as opposed to an entirely different
-# environment (e.g. Chrome OS).
-TARGET_GLOBAL_CFLAGS += -D__BRILLO__
-ifdef TARGET_2ND_ARCH
-$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += -D__BRILLO__
-endif
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_SYSTEM_INCLUDES := $(TARGET_PROJECT_SYSTEM_INCLUDES)
 endif
 
 # allow overriding default Java libraries on a per-target basis
 ifeq ($(TARGET_DEFAULT_JAVA_LIBRARIES),)
-  TARGET_DEFAULT_JAVA_LIBRARIES := core-oj core-libart core-junit ext framework okhttp
+  TARGET_DEFAULT_JAVA_LIBRARIES := core-oj core-libart ext framework okhttp
 endif
 
 # Flags for DEX2OAT
@@ -798,8 +744,11 @@
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
 endif
 
-# define clang/llvm tools and global flags
-include $(BUILD_SYSTEM)/clang/config.mk
+# These will come from Soong, drop the environment versions
+unexport CLANG
+unexport CLANG_CXX
+unexport CCC_CC
+unexport CCC_CXX
 
 # ###############################################################
 # Collect a list of the SDK versions that we could compile against
@@ -843,8 +792,10 @@
 INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
 INTERNAL_PLATFORM_SYSTEM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-api.txt
 INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-removed.txt
+INTERNAL_PLATFORM_SYSTEM_EXACT_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-exact.txt
 INTERNAL_PLATFORM_TEST_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-api.txt
 INTERNAL_PLATFORM_TEST_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-removed.txt
+INTERNAL_PLATFORM_TEST_EXACT_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-exact.txt
 
 # This is the standard way to name a directory containing prebuilt target
 # objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
@@ -868,4 +819,70 @@
 RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
 RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
 
+ifeq ($(JAVA_NOT_REQUIRED),true)
+# Remove java and tools from our path so that we make sure nobody uses them.
+unexport ANDROID_JAVA_HOME
+unexport JAVA_HOME
+export ANDROID_BUILD_PATHS:=$(abspath $(BUILD_SYSTEM)/no_java_path):$(ANDROID_BUILD_PATHS)
+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/% \
+    hardware/interfaces/% \
+
+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
+
+# These goals don't need to collect and include Android.mks/CleanSpec.mks
+# in the source tree.
+dont_bother_goals := clean clobber dataclean installclean \
+    help out \
+    snod systemimage-nodeps \
+    stnod systemtarball-nodeps \
+    userdataimage-nodeps userdatatarball-nodeps \
+    cacheimage-nodeps \
+    bptimage-nodeps \
+    vnod vendorimage-nodeps \
+    systemotherimage-nodeps \
+    ramdisk-nodeps \
+    bootimage-nodeps \
+    recoveryimage-nodeps \
+    vbmetaimage-nodeps \
+    product-graph dump-products
+
+ifndef KATI
+include $(BUILD_SYSTEM)/ninja_config.mk
+include $(BUILD_SYSTEM)/soong_config.mk
+endif
+
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index dbcf276..729ef48 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -3,6 +3,7 @@
 ##############################################
 
 my_sanitize := $(strip $(LOCAL_SANITIZE))
+my_sanitize_diag := $(strip $(LOCAL_SANITIZE_DIAG))
 
 # SANITIZE_HOST is only in effect if the module is already using clang (host
 # modules that haven't set `LOCAL_CLANG := false` and device modules that
@@ -19,9 +20,8 @@
   endif
 endif
 
-# The sanitizer specified by the environment wins over the module.
 ifneq ($(my_global_sanitize),)
-  my_sanitize := $(my_global_sanitize)
+  my_sanitize := $(my_global_sanitize) $(my_sanitize)
 endif
 
 # The sanitizer specified in the product configuration wins over the previous.
@@ -32,10 +32,12 @@
   endif
 endif
 
-# Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden).
-SANITIZE_ARCH ?= 32 64
-ifeq ($(filter $(SANITIZE_ARCH),$(my_32_64_bit_suffix)),)
-  my_sanitize :=
+ifndef LOCAL_IS_HOST_MODULE
+  # Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden)
+  SANITIZE_TARGET_ARCH ?= $(TARGET_ARCH) $(TARGET_2ND_ARCH)
+  ifeq ($(filter $(SANITIZE_TARGET_ARCH),$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
+    my_sanitize :=
+  endif
 endif
 
 # Add a filter point based on module owner (to lighten the burden). The format is a space- or
@@ -52,6 +54,7 @@
 # Don't apply sanitizers to NDK code.
 ifdef LOCAL_SDK_VERSION
   my_sanitize :=
+  my_global_sanitize :=
 endif
 
 # Never always wins.
@@ -59,6 +62,29 @@
   my_sanitize :=
 endif
 
+# If CFI is disabled globally, remove it from my_sanitize.
+ifeq ($(strip $(ENABLE_CFI)),)
+  my_sanitize := $(filter-out cfi,$(my_sanitize))
+  my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
+endif
+
+# Disable CFI for arm32 (b/35157333).
+ifneq ($(filter arm,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
+  my_sanitize := $(filter-out cfi,$(my_sanitize))
+  my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
+endif
+
+# CFI needs gold linker, and mips toolchain does not have one.
+ifneq ($(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
+  my_sanitize := $(filter-out cfi,$(my_sanitize))
+  my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
+endif
+
+my_nosanitize = $(strip $(LOCAL_NOSANITIZE))
+ifneq ($(my_nosanitize),)
+  my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize))
+endif
+
 # TSAN is not supported on 32-bit architectures. For non-multilib cases, make
 # its use an error. For multilib cases, don't use it for the 32-bit case.
 ifneq ($(filter thread,$(my_sanitize)),)
@@ -71,21 +97,23 @@
   endif
 endif
 
+ifneq ($(filter safe-stack,$(my_sanitize)),)
+  ifeq ($(my_32_64_bit_suffix),32)
+    my_sanitize := $(filter-out safe-stack,$(my_sanitize))
+  endif
+endif
+
 # Undefined symbols can occur if a non-sanitized library links
 # sanitized static libraries. That's OK, because the executable
 # always depends on the ASan runtime library, which defines these
 # symbols.
-ifneq ($(strip $(SANITIZE_TARGET)),)
+ifneq ($(filter address thread,$(strip $(SANITIZE_TARGET))),)
   ifndef LOCAL_IS_HOST_MODULE
     ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
       ifeq ($(my_sanitize),)
         my_allow_undefined_symbols := true
       endif
     endif
-    # Workaround for a bug in AddressSanitizer that breaks stack unwinding.
-    # https://code.google.com/p/address-sanitizer/issues/detail?id=387
-    # Revert when external/compiler-rt is updated past r236014.
-    LOCAL_PACK_MODULE_RELOCATIONS := false
   endif
 endif
 
@@ -117,18 +145,32 @@
     my_ldflags += -fsanitize=$(fsanitize_arg)
     my_ldlibs += -lrt -ldl
   else
-    ifeq ($(filter address,$(my_sanitize)),)
-      my_cflags += -fsanitize-trap=all
-      my_cflags += -ftrap-function=abort
+    my_cflags += -fsanitize-trap=all
+    my_cflags += -ftrap-function=abort
+    ifneq ($(filter address thread,$(my_sanitize)),)
+      my_cflags += -fno-sanitize-trap=address,thread
+      my_shared_libraries += libdl
     endif
-    my_shared_libraries += libdl
   endif
 endif
 
-ifneq ($(filter address,$(my_sanitize)),)
-  # Frame pointer based unwinder in ASan requires ARM frame setup.
-  LOCAL_ARM_MODE := arm
-  my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
+ifneq ($(filter cfi,$(my_sanitize)),)
+  # __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp).
+  # LLVM is not set up to do this on a function basis, so force Thumb on the
+  # entire module.
+  LOCAL_ARM_MODE := thumb
+  my_cflags += $(CFI_EXTRA_CFLAGS)
+  my_ldflags += $(CFI_EXTRA_LDFLAGS)
+  my_arflags += --plugin $(LLVM_PREBUILTS_PATH)/../lib64/LLVMgold.so
+  # Workaround for b/33678192. CFI jumptables need Thumb2 codegen.  Revert when
+  # Clang is updated past r290384.
+  ifneq ($(filter arm,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
+    my_ldflags += -march=armv7-a
+  endif
+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)
   ifdef LOCAL_IS_HOST_MODULE
     # -nodefaultlibs (provided with libc++) prevents the driver from linking
@@ -136,16 +178,38 @@
     my_ldlibs += -lm -lpthread
     my_ldflags += -Wl,--no-as-needed
   else
-    my_cflags += -mllvm -asan-globals=0
+    # Add asan libraries unless LOCAL_MODULE is the asan library.
     # ASan runtime library must be the first in the link order.
-    my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
-                           $(my_shared_libraries) \
-                           $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
-    my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+    ifeq (,$(filter $(LOCAL_MODULE),$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY)))
+      my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
+                             $(my_shared_libraries)
+    endif
+    ifeq (,$(filter $(LOCAL_MODULE),$(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)))
+      my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+    endif
 
-    my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
-    # Make sure linker_asan get installed.
-    $(LOCAL_INSTALLED_MODULE) : | $(PRODUCT_OUT)$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
+    # Do not add unnecessary dependency in shared libraries.
+    ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+      my_ldflags += -Wl,--as-needed
+    endif
+
+    ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+      ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+        my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
+        # Make sure linker_asan get installed.
+        $(LOCAL_INSTALLED_MODULE) : | $(PRODUCT_OUT)$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
+      endif
+    endif
+  endif
+endif
+
+# If local module needs ASAN, add compiler flags.
+ifneq ($(filter address,$(my_sanitize)),)
+  # Frame pointer based unwinder in ASan requires ARM frame setup.
+  LOCAL_ARM_MODE := arm
+  my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
+  ifndef LOCAL_IS_HOST_MODULE
+    my_cflags += -mllvm -asan-globals=0
   endif
 endif
 
@@ -159,3 +223,13 @@
   recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
   my_cflags += -fsanitize-recover=$(recover_arg)
 endif
+
+ifneq ($(my_sanitize_diag),)
+  notrap_arg := $(subst $(space),$(comma),$(my_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/configure_local_jack.mk b/core/configure_local_jack.mk
index 2270c88..f8049a3 100644
--- a/core/configure_local_jack.mk
+++ b/core/configure_local_jack.mk
@@ -18,18 +18,23 @@
 LOCAL_JACK_ENABLED := $(ANDROID_FORCE_JACK_ENABLED)
 endif
 
+ifneq ($(ANDROID_COMPILE_WITH_JACK),true)
+LOCAL_JACK_ENABLED :=
+endif
+
 LOCAL_JACK_ENABLED := $(strip $(LOCAL_JACK_ENABLED))
 LOCAL_MODULE := $(strip $(LOCAL_MODULE))
 
-ifneq ($(LOCAL_JACK_ENABLED),full)
-ifneq ($(LOCAL_JACK_ENABLED),incremental)
+valid_jack_enabled_values := full incremental javac_frontend disabled
+
 ifdef LOCAL_JACK_ENABLED
-ifneq ($(LOCAL_JACK_ENABLED),disabled)
-$(error $(LOCAL_PATH): invalid LOCAL_JACK_ENABLED "$(LOCAL_JACK_ENABLED)" for $(LOCAL_MODULE))
-endif
-endif
-LOCAL_JACK_ENABLED :=
-endif
+  ifneq ($(LOCAL_JACK_ENABLED),$(filter $(firstword $(LOCAL_JACK_ENABLED)),$(valid_jack_enabled_values)))
+    $(error $(LOCAL_PATH): invalid LOCAL_JACK_ENABLED "$(LOCAL_JACK_ENABLED)" for $(LOCAL_MODULE))
+  endif
+
+  ifeq ($(LOCAL_JACK_ENABLED),disabled)
+    LOCAL_JACK_ENABLED :=
+  endif
 endif
 
 ifdef $(LOCAL_MODULE).JACK_VERSION
diff --git a/core/copy_headers.mk b/core/copy_headers.mk
index 7d5a5d9..c26d51d 100644
--- a/core/copy_headers.mk
+++ b/core/copy_headers.mk
@@ -1,10 +1,30 @@
+ifneq (,$(strip $(LOCAL_COPY_HEADERS)))
 ###########################################################
 ## Copy headers to the install tree
 ###########################################################
+$(call record-module-type,COPY_HEADERS)
 ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
-  my_prefix := HOST_
-else
-  my_prefix := TARGET_
+  $(shell echo $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_COPY_HEADERS may not be used with host modules >&2)
+  $(error done)
+endif
+
+# Modules linking against the SDK do not have the include path to use
+# COPY_HEADERS, so prevent them from exporting any either.
+ifdef LOCAL_SDK_VERSION
+$(shell echo $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Modules using LOCAL_SDK_VERSION may not use LOCAL_COPY_HEADERS >&2)
+$(error done)
+endif
+
+include $(BUILD_SYSTEM)/local_vndk.mk
+
+# If we're using the VNDK, only vendor modules using the VNDK may use
+# LOCAL_COPY_HEADERS. Platform libraries will not have the include path
+# present.
+ifdef BOARD_VNDK_VERSION
+ifndef LOCAL_USE_VNDK
+$(shell echo $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Only vendor modules using LOCAL_USE_VNDK may use LOCAL_COPY_HEADERS >&2)
+$(error done)
+endif
 endif
 
 # Create a rule to copy each header, and make the
@@ -16,8 +36,8 @@
   $(eval _chFrom := $(LOCAL_PATH)/$(header)) \
   $(eval _chTo := \
       $(if $(LOCAL_COPY_HEADERS_TO),\
-        $($(my_prefix)OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
-        $($(my_prefix)OUT_HEADERS)/$(notdir $(header)))) \
+        $(TARGET_OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
+        $(TARGET_OUT_HEADERS)/$(notdir $(header)))) \
   $(eval ALL_COPIED_HEADERS.$(_chTo).MAKEFILE += $(LOCAL_MODULE_MAKEFILE)) \
   $(eval ALL_COPIED_HEADERS.$(_chTo).SRC += $(_chFrom)) \
   $(if $(filter $(_chTo),$(ALL_COPIED_HEADERS)),, \
@@ -25,3 +45,5 @@
  )
 _chFrom :=
 _chTo :=
+
+endif # LOCAL_COPY_HEADERS
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index 37be1f7..fd9c442 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -70,6 +70,7 @@
     endif
 endif
 
+my_cxx_ldlibs :=
 ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
     my_cflags += -D_USING_LIBCXX
 
@@ -89,7 +90,7 @@
         my_cppflags += -nostdinc++
         my_ldflags += -nodefaultlibs
         my_ldlibs += -lpthread -lm
-        my_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
+        my_cxx_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
     else
         ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
             my_static_libraries += libunwind_llvm
@@ -105,18 +106,16 @@
 else ifeq ($(my_cxx_stl),ndk)
     # Using an NDK STL. Handled in binary.mk.
 else ifeq ($(my_cxx_stl),libstdc++)
-    # Using bionic's basic libstdc++. Not actually an STL. Only around until the
-    # tree is in good enough shape to not need it.
     ifndef LOCAL_IS_HOST_MODULE
-        my_c_includes += bionic/libstdc++/include
-        my_system_shared_libraries += libstdc++
+        $(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported for device modules)
+    else ifneq ($($(my_prefix)OS),windows)
+        $(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported on $($(my_prefix)OS))
     endif
-    # Host builds will use GNU libstdc++.
 else ifeq ($(my_cxx_stl),none)
     ifdef LOCAL_IS_HOST_MODULE
         my_cppflags += -nostdinc++
         my_ldflags += -nodefaultlibs
-        my_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
+        my_cxx_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
     endif
 else
     $(error $(LOCAL_PATH): $(LOCAL_MODULE): $(my_cxx_stl) is not a supported STL.)
diff --git a/core/definitions.mk b/core/definitions.mk
index 84ea801..cf877f5 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -55,10 +55,6 @@
 # its sub-variables.)
 ALL_MODULE_NAME_TAGS:=
 
-# Full paths to all prebuilt files that will be copied
-# (used to make the dependency on acp)
-ALL_PREBUILT:=
-
 # Full path to all files that are made by some tool
 ALL_GENERATED_SOURCES:=
 
@@ -96,9 +92,13 @@
 
 # Display names for various build targets
 TARGET_DISPLAY := target
+AUX_DISPLAY := aux
 HOST_DISPLAY := host
 HOST_CROSS_DISPLAY := host cross
 
+# All installed initrc files
+ALL_INIT_RC_INSTALLED_PAIRS :=
+
 ###########################################################
 ## Debugging; prints a variable list to stdout
 ###########################################################
@@ -123,6 +123,15 @@
 $(filter true, $(1))
 endef
 
+###########################################################
+## Rule for touching GCNO files.
+###########################################################
+define gcno-touch-rule
+$(2): $(1)
+	touch -c $$@
+endef
+
+###########################################################
 
 ###########################################################
 ## Retrieve the directory of the current makefile
@@ -133,7 +142,6 @@
 define my-dir
 $(strip \
   $(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \
-  $(eval LOCAL_MODULE_MAKEFILE_DEP := $(if $(BUILDING_WITH_NINJA),,$$(LOCAL_MODULE_MAKEFILE))) \
   $(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \
     $(error my-dir must be called before including any other makefile.) \
    , \
@@ -142,28 +150,13 @@
  )
 endef
 
-###########################################################
-## Remove any makefiles that are being handled by soong
-###########################################################
-ifeq ($(USE_SOONG),true)
-define filter-soong-makefiles
-$(foreach mk,$(1),\
-  $(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(mk))),\
-    $(info skipping $(mk) ...),\
-    $(mk)))
-endef
-else
-define filter-soong-makefiles
-$(1)
-endef
-endif
 
 ###########################################################
 ## Retrieve a list of all makefiles immediately below some directory
 ###########################################################
 
 define all-makefiles-under
-$(sort $(call filter-soong-makefiles,$(wildcard $(1)/*/Android.mk)))
+$(wildcard $(1)/*/Android.mk)
 endef
 
 ###########################################################
@@ -174,9 +167,8 @@
 # $(1): directory to search under
 # Ignores $(1)/Android.mk
 define first-makefiles-under
-$(call filter-soong-makefiles,\
-  $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
-        --mindepth=2 $(1) Android.mk))
+$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
+        --mindepth=2 $(addprefix --dir=,$(1)) Android.mk)
 endef
 
 ###########################################################
@@ -196,8 +188,7 @@
 
 # $(1): List of directories to look for under this directory
 define all-named-subdir-makefiles
-$(sort $(call filter-soong-makefiles,\
-  $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))))
+$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
 endef
 
 ###########################################################
@@ -425,8 +416,8 @@
 
 define find-subdir-assets
 $(sort $(if $(1),$(patsubst ./%,%, \
-	$(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \
-	$(warning Empty argument supplied to find-subdir-assets) \
+	$(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f ; fi)), \
+	$(warning Empty argument supplied to find-subdir-assets in $(LOCAL_PATH)) \
 ))
 endef
 
@@ -478,6 +469,20 @@
 endef
 
 ###########################################################
+## Find test data in a form required by LOCAL_TEST_DATA
+## $(1): the base dir, relative to the root of the source tree.
+## $(3): the file name pattern to be passed to find as "-name"
+## $(2): a list of subdirs of the base dir
+###########################################################
+
+define find-test-data-in-subdirs
+$(foreach f,$(sort $(patsubst ./%,%, \
+  $(shell cd $(1) ; \
+          find -L $(3) -type f -and -name $(2) -and -not -name ".*") \
+)),$(1):$(f))
+endef
+
+###########################################################
 ## Function we can evaluate to introduce a dynamic dependency
 ###########################################################
 
@@ -493,6 +498,28 @@
 $(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
 endef
 
+define def-host-aux-target
+$(eval _idf_val_:=$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST,$(if $(strip $(LOCAL_IS_AUX_MODULE)),AUX,))) \
+$(_idf_val_)
+endef
+
+###########################################################
+## Returns correct _idfPrefix from the list:
+##   { HOST, HOST_CROSS, AUX, TARGET }
+###########################################################
+# the following rules checked in order:
+# ($1 is in {AUX, HOST_CROSS} => $1;
+# ($1 is empty) => TARGET;
+# ($2 is not empty) => HOST_CROSS;
+# => HOST;
+define find-idf-prefix
+$(strip \
+    $(eval _idf_pfx_:=$(strip $(filter AUX HOST_CROSS,$(1)))) \
+    $(eval _idf_pfx_:=$(if $(strip $(1)),$(if $(_idf_pfx_),$(_idf_pfx_),$(if $(strip $(2)),HOST_CROSS,HOST)),TARGET)) \
+    $(_idf_pfx_)
+)
+endef
+
 ###########################################################
 ## The intermediates directory.  Where object files go for
 ## a given target.  We could technically get away without
@@ -503,7 +530,7 @@
 
 # $(1): target class, like "APPS"
 # $(2): target name, like "NotePad"
-# $(3): if non-empty, this is a HOST target.
+# $(3): { HOST, HOST_CROSS, AUX, <empty (TARGET)>, <other non-empty (HOST)> }
 # $(4): if non-empty, force the intermediates to be COMMON
 # $(5): if non-empty, force the intermediates to be for the 2nd arch
 # $(6): if non-empty, force the intermediates to be for the host cross os
@@ -515,7 +542,7 @@
     $(eval _idfName := $(strip $(2))) \
     $(if $(_idfName),, \
         $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
-    $(eval _idfPrefix := $(if $(strip $(3)),$(if $(strip $(6)),HOST_CROSS,HOST),TARGET)) \
+    $(eval _idfPrefix := $(call find-idf-prefix,$(3),$(6))) \
     $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
     $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
         $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
@@ -540,7 +567,7 @@
         $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \
     $(if $(strip $(LOCAL_MODULE)),, \
         $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \
-    $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1),$(2),$(3)) \
+    $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(call def-host-aux-target),$(1),$(2),$(3)) \
 )
 endef
 
@@ -555,7 +582,7 @@
 
 # $(1): target class, like "APPS"
 # $(2): target name, like "NotePad"
-# $(3): if non-empty, this is a HOST target.
+# $(3): { HOST, HOST_CROSS, AUX, <empty (TARGET)>, <other non-empty (HOST)> }
 # $(4): if non-empty, force the generated sources to be COMMON
 define generated-sources-dir-for
 $(strip \
@@ -565,7 +592,7 @@
     $(eval _idfName := $(strip $(2))) \
     $(if $(_idfName),, \
         $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
-    $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \
+    $(eval _idfPrefix := $(call find-idf-prefix,$(3),)) \
     $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
         $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \
       , \
@@ -585,30 +612,11 @@
         $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
     $(if $(strip $(LOCAL_MODULE)),, \
         $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
-    $(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \
+    $(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(call def-host-aux-target),$(1)) \
 )
 endef
 
 ###########################################################
-## Convert "path/to/libXXX.so" to "-lXXX".
-## Any "path/to/libXXX.a" elements pass through unchanged.
-###########################################################
-
-define normalize-libraries
-$(foreach so,$(filter %.so,$(1)),-l$(patsubst lib%.so,%,$(notdir $(so))))\
-$(filter-out %.so,$(1))
-endef
-
-# TODO: change users to call the common version.
-define normalize-host-libraries
-$(call normalize-libraries,$(1))
-endef
-
-define normalize-target-libraries
-$(call normalize-libraries,$(1))
-endef
-
-###########################################################
 ## Convert a list of short module names (e.g., "framework", "Browser")
 ## into the list of files that are built for those modules.
 ## NOTE: this won't return reliable results until after all
@@ -673,7 +681,7 @@
 # $(1): library name
 # $(2): Non-empty if IS_HOST_MODULE
 define _java-lib-full-classes.jar
-$(call _java-lib-dir,$(1),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX)
+$(call _java-lib-dir,$(1),$(2))/classes.jar
 endef
 
 # Get the jar files (you can pass to "javac -classpath") of static or shared
@@ -696,14 +704,6 @@
 $(call java-lib-files,$(1),$(2))
 endef
 
-# Get the jar files (you can pass to "javac -classpath") of host dalvik Java libraries.
-# You can also use them as dependency files.
-# A host dalvik Java library is different from a host Java library in that
-# the java lib file is classes.jar, not javalib.jar.
-# $(1): library name list
-define host-dex-java-lib-files
-$(foreach lib,$(1),$(call _java-lib-dir,$(lib),true)/classes.jar)
-endef
 
 ###########################################################
 ## Convert "core ext framework" to "out/.../classes.jack ..."
@@ -723,21 +723,6 @@
 $(foreach lib,$(1),$(call _jack-lib-full-classes,$(lib),$(2)))
 endef
 
-# $(1): library name list
-# $(2): Non-empty if IS_HOST_MODULE
-define jack-lib-deps
-$(call jack-lib-files,$(1),$(2))
-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.
@@ -761,6 +746,13 @@
 endef
 
 ###########################################################
+## Convert "a b c" into "a,b,c"
+###########################################################
+define normalize-comma-list
+$(subst $(space),$(comma),$(strip $(1)))
+endef
+
+###########################################################
 ## Read the word out of a colon-separated list of words.
 ## This has the same behavior as the built-in function
 ## $(word n,str).
@@ -850,6 +842,39 @@
 
 
 ###########################################################
+## Color-coded warnings and errors
+## Use echo-(warning|error) in a build rule
+## Use pretty-(warning|error) instead of $(warning)/$(error)
+###########################################################
+ESC_BOLD := \e[1m
+ESC_WARNING := \e[35m
+ESC_ERROR := \e[31m
+ESC_RESET := \e[0m
+
+# $(1): path (and optionally line) information
+# $(2): message to print
+define echo-warning
+echo -e "$(ESC_BOLD)$(1): $(ESC_WARNING)warning:$(ESC_RESET)$(ESC_BOLD)" $(2) "$(ESC_RESET)" >&2
+endef
+
+# $(1): path (and optionally line) information
+# $(2): message to print
+define echo-error
+echo -e "$(ESC_BOLD)$(1): $(ESC_ERROR)error:$(ESC_RESET)$(ESC_BOLD)" $(2) "$(ESC_RESET)" >&2
+endef
+
+# $(1): message to print
+define pretty-warning
+$(shell $(call echo-warning,$(LOCAL_MODULE_MAKEFILE),$(LOCAL_MODULE): $(1)))
+endef
+
+# $(1): message to print
+define pretty-error
+$(shell $(call echo-error,$(LOCAL_MODULE_MAKEFILE),$(LOCAL_MODULE): $(1)))
+$(error done)
+endef
+
+###########################################################
 ## Package filtering
 ###########################################################
 
@@ -898,39 +923,17 @@
 endif
 
 ###########################################################
-## Commands for munging the dependency files the compiler generates
-###########################################################
-# $(1): the input .d file
-# $(2): the output .P file
-define transform-d-to-p-args
-$(hide) cp $(1) $(2); \
-	sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-		-e '/^$$/ d' -e 's/$$/ :/' < $(1) >> $(2); \
-	rm -f $(1)
-endef
-
-define transform-d-to-p
-$(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P))
-endef
-
-###########################################################
 ## Commands for including the dependency files the compiler generates
 ###########################################################
 # $(1): the .P file
 # $(2): the main build target
-ifeq ($(BUILDING_WITH_NINJA),true)
 define include-depfile
 $(eval $(2) : .KATI_DEPFILE := $1)
 endef
-else
-define include-depfile
-$(eval -include $1)
-endef
-endif
 
 # $(1): object files
 define include-depfiles-for-objs
-$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.P), $(obj)))
+$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.d), $(obj)))
 endef
 
 ###########################################################
@@ -1029,7 +1032,6 @@
   $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
   $(PRIVATE_RS_SOURCE_FILES)
 $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),[email protected])
-$(call transform-d-to-p-args,[email protected],[email protected])
 $(hide) mkdir -p $(dir $@)
 $(hide) touch $@
 endef
@@ -1066,7 +1068,6 @@
   $(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
   $(PRIVATE_RS_SOURCE_FILES)
 $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),[email protected])
-$(call transform-d-to-p-args,[email protected],[email protected])
 $(hide) mkdir -p $(dir $@)
 $(hide) touch $@
 endef
@@ -1087,10 +1088,23 @@
 @mkdir -p $(dir $@)
 @mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
 @echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
-$(hide) $(AIDL_CPP) -d$(basename $@).aidl.P $(PRIVATE_AIDL_FLAGS) \
+$(hide) $(AIDL_CPP) -d$(basename $@).aidl.d -ninja $(PRIVATE_AIDL_FLAGS) \
     $< $(PRIVATE_HEADER_OUTPUT_DIR) $@
 endef
 
+## Given a .aidl file path, generate the rule to compile it a .java file
+# $(1): a .aidl source file
+# $(2): a directory to place the generated .java files in
+# $(3): name of a variable to add the path to the generated source file to
+#
+# You must call this with $(eval).
+define define-aidl-java-rule
+define-aidl-java-rule-src := $(patsubst %.aidl,%.java,$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
+$$(define-aidl-java-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL)
+	$$(transform-aidl-to-java)
+$(3) += $$(define-aidl-java-rule-src)
+endef
+
 ## Given a .aidl file path generate the rule to compile it a .cpp file.
 # $(1): a .aidl source file
 # $(2): a directory to place the generated .cpp files in
@@ -1136,13 +1150,14 @@
 define transform-logtags-to-java
 @mkdir -p $(dir $@)
 @echo "logtags: $@ <= $<"
-$(hide) $(JAVATAGS) -o $@ $^
+$(hide) $(JAVATAGS) -o $@ $< $(PRIVATE_MERGED_TAG)
 endef
 
 
 ###########################################################
 ## Commands for running protoc to compile .proto into .java
 ###########################################################
+# PATH contains HOST_OUT_EXECUTABLES to allow protoc-gen-* plugins
 
 define transform-proto-to-java
 @mkdir -p $(dir $@)
@@ -1150,6 +1165,7 @@
 @rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
 @mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
 $(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \
+        PATH=$$PATH:$(HOST_OUT_EXECUTABLES) \
         $(PROTOC) \
         $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
         $(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \
@@ -1162,10 +1178,14 @@
 ######################################################################
 ## Commands for running protoc to compile .proto into .pb.cc (or.pb.c) and .pb.h
 ######################################################################
+# PATH contains HOST_OUT_EXECUTABLES to allow protoc-gen-* plugins
+
 define transform-proto-to-cc
 @echo "Protoc: $@ <= $<"
 @mkdir -p $(dir $@)
-$(hide) $(PROTOC) \
+$(hide) \
+	PATH=$$PATH:$(HOST_OUT_EXECUTABLES) \
+	$(PROTOC) \
 	$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
 	$(PRIVATE_PROTOC_FLAGS) \
 	$<
@@ -1174,47 +1194,27 @@
   $(hide) mv $(basename $@).cc $@)
 endef
 
-
-######################################################################
-## Commands for generating DBus adaptors from .dbus-xml files.
-######################################################################
-define generate-dbus-adaptors
-@echo "Generating DBus adaptors for $(PRIVATE_MODULE)"
-@mkdir -p $(dir $@)
-$(hide) $(DBUS_GENERATOR) \
-	--service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
-	--adaptor=$@ \
-	$<
+###########################################################
+## Helper to set include paths form transform-*-to-o
+###########################################################
+define c-includes
+$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+$$(cat $(PRIVATE_IMPORT_INCLUDES))\
+$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),,\
+    $(addprefix -I ,\
+        $(filter-out $(PRIVATE_C_INCLUDES), \
+            $(PRIVATE_GLOBAL_C_INCLUDES))) \
+    $(addprefix -isystem ,\
+        $(filter-out $(PRIVATE_C_INCLUDES), \
+            $(PRIVATE_GLOBAL_C_SYSTEM_INCLUDES))))
 endef
 
-######################################################################
-## Commands for generating DBus proxies from .dbus-xml files.
-######################################################################
-define generate-dbus-proxies
-@echo "Generating DBus proxies for $(PRIVATE_MODULE)"
-@mkdir -p $(dir $@)
-$(hide) $(DBUS_GENERATOR) \
-	--service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
-	--proxy=$@ \
-	$(filter %.dbus-xml,$^)
-endef
-
-
 ###########################################################
 ## Commands for running gcc to compile a C++ file
 ###########################################################
 
-define transform-cpp-to-o
-@echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
-@mkdir -p $(dir $@)
-$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
-	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
-	$(addprefix -isystem ,\
-	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-	        $(filter-out $(PRIVATE_C_INCLUDES), \
-	            $(PRIVATE_TARGET_PROJECT_INCLUDES) \
-	            $(PRIVATE_TARGET_C_INCLUDES)))) \
+define transform-cpp-to-o-compiler-args
+	$(c-includes) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
@@ -1226,59 +1226,86 @@
 	$(PRIVATE_CPPFLAGS) \
 	$(PRIVATE_DEBUG_CFLAGS) \
 	$(PRIVATE_CFLAGS_NO_OVERRIDE) \
-	$(PRIVATE_CPPFLAGS_NO_OVERRIDE) \
-	-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
-$(transform-d-to-p)
+	$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
 endef
 
+define clang-tidy-cpp
+$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
+  -checks=$(PRIVATE_TIDY_CHECKS) \
+  $< -- $(transform-cpp-to-o-compiler-args)
+endef
+
+ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
+define transform-cpp-to-o
+$(if $(PRIVATE_TIDY_CHECKS),
+  @echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C++: $<"
+  $(clang-tidy-cpp))
+endef
+else
+define transform-cpp-to-o
+@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-cpp))
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
+  $(transform-cpp-to-o-compiler-args) \
+  -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+endef
+endif
+
 
 ###########################################################
 ## Commands for running gcc to compile a C file
 ###########################################################
 
 # $(1): extra flags
-define transform-c-or-s-to-o-no-deps
-@mkdir -p $(dir $@)
-$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
-	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
-	$(addprefix -isystem ,\
-	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-	        $(filter-out $(PRIVATE_C_INCLUDES), \
-	            $(PRIVATE_TARGET_PROJECT_INCLUDES) \
-	            $(PRIVATE_TARGET_C_INCLUDES)))) \
+define transform-c-or-s-to-o-compiler-args
+	$(c-includes) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
 	    $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
 	    $(PRIVATE_ARM_CFLAGS) \
 	 ) \
-	 $(1) \
-	-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+	 $(1)
 endef
 
-define transform-c-to-o-no-deps
-@echo "target $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<"
-$(call transform-c-or-s-to-o-no-deps, \
-    $(PRIVATE_CFLAGS) \
-    $(PRIVATE_CONLYFLAGS) \
-    $(PRIVATE_DEBUG_CFLAGS) \
-    $(PRIVATE_CFLAGS_NO_OVERRIDE))
+define transform-c-to-o-compiler-args
+$(call transform-c-or-s-to-o-compiler-args, \
+  $(PRIVATE_CFLAGS) \
+  $(PRIVATE_CONLYFLAGS) \
+  $(PRIVATE_DEBUG_CFLAGS) \
+  $(PRIVATE_CFLAGS_NO_OVERRIDE))
 endef
 
-define transform-s-to-o-no-deps
-@echo "target asm: $(PRIVATE_MODULE) <= $<"
-$(call transform-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS))
+define clang-tidy-c
+$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
+  -checks=$(PRIVATE_TIDY_CHECKS) \
+  $< -- $(transform-c-to-o-compiler-args)
 endef
 
+ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
 define transform-c-to-o
-$(transform-c-to-o-no-deps)
-$(transform-d-to-p)
+$(if $(PRIVATE_TIDY_CHECKS),
+  @echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C: $<"
+  $(clang-tidy-c))
 endef
+else
+define transform-c-to-o
+@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-c))
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
+  $(transform-c-to-o-compiler-args) \
+  -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+endef
+endif
 
 define transform-s-to-o
-$(transform-s-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(RELATIVE_PWD) $(PRIVATE_CC) \
+  $(call transform-c-or-s-to-o-compiler-args, $(PRIVATE_ASFLAGS)) \
+  -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
 endef
 
 # YASM compilation
@@ -1297,31 +1324,17 @@
 ## will error at build time.
 ###########################################################
 
-define transform-m-to-o-no-deps
-@echo "target ObjC: $(PRIVATE_MODULE) <= $<"
-$(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
-endef
-
 define transform-m-to-o
-$(transform-m-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
+$(call transform-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
 endef
 
 ###########################################################
 ## Commands for running gcc to compile a host C++ file
 ###########################################################
 
-define transform-host-cpp-to-o
-@echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<"
-@mkdir -p $(dir $@)
-$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
-	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
-	$(addprefix -isystem ,\
-	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-	        $(filter-out $(PRIVATE_C_INCLUDES), \
-	            $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \
-	            $(PRIVATE_HOST_C_INCLUDES)))) \
+define transform-host-cpp-to-o-compiler-args
+	$(c-includes) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_HOST_GLOBAL_CFLAGS) \
@@ -1331,69 +1344,96 @@
 	$(PRIVATE_CPPFLAGS) \
 	$(PRIVATE_DEBUG_CFLAGS) \
 	$(PRIVATE_CFLAGS_NO_OVERRIDE) \
-	$(PRIVATE_CPPFLAGS_NO_OVERRIDE) \
-	-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
-$(transform-d-to-p)
+	$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
 endef
 
+define clang-tidy-host-cpp
+$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
+  -checks=$(PRIVATE_TIDY_CHECKS) \
+  $< -- $(transform-host-cpp-to-o-compiler-args)
+endef
+
+ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
+define transform-host-cpp-to-o
+$(if $(PRIVATE_TIDY_CHECKS),
+  @echo "tidy $($(PRIVATE_PREFIX)DISPLAY) C++: $<"
+  $(clang-tidy-host-cpp))
+endef
+else
+define transform-host-cpp-to-o
+@echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-host-cpp))
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
+  $(transform-host-cpp-to-o-compiler-args) \
+  -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+endef
+endif
+
 
 ###########################################################
 ## Commands for running gcc to compile a host C file
 ###########################################################
 
-# $(1): extra flags
-define transform-host-c-or-s-to-o-no-deps
-@mkdir -p $(dir $@)
-$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
-	$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-	$(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
-	$(addprefix -isystem ,\
-	    $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
-	        $(filter-out $(PRIVATE_C_INCLUDES), \
-	            $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \
-	            $(PRIVATE_HOST_C_INCLUDES)))) \
+define transform-host-c-or-s-to-o-common-args
+	$(c-includes) \
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_HOST_GLOBAL_CFLAGS) \
 	    $(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \
-	 ) \
-	$(1) \
-	$(PRIVATE_CFLAGS_NO_OVERRIDE) \
-	-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+	 )
 endef
 
-define transform-host-c-to-o-no-deps
-@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<"
-$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) $(PRIVATE_DEBUG_CFLAGS))
+# $(1): extra flags
+define transform-host-c-or-s-to-o
+@mkdir -p $(dir $@)
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
+  $(transform-host-c-or-s-to-o-common-args) \
+  $(1) \
+  -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
 endef
 
-define transform-host-s-to-o-no-deps
-@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
-$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS))
+define transform-host-c-to-o-compiler-args
+  $(transform-host-c-or-s-to-o-common-args) \
+  $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) \
+  $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE)
 endef
 
+define clang-tidy-host-c
+$(hide) $(PATH_TO_CLANG_TIDY) $(PRIVATE_TIDY_FLAGS) \
+  -checks=$(PRIVATE_TIDY_CHECKS) \
+  $< -- $(transform-host-c-to-o-compiler-args)
+endef
+
+ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
 define transform-host-c-to-o
-$(transform-host-c-to-o-no-deps)
-$(transform-d-to-p)
+$(if $(PRIVATE_TIDY_CHECKS),
+  @echo "tidy $($(PRIVATE_PREFIX)DISPLAY) C: $<"
+  $(clang-tidy-host-c))
 endef
+else
+define transform-host-c-to-o
+@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(if $(PRIVATE_TIDY_CHECKS), $(clang-tidy-host-c))
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
+  $(transform-host-c-to-o-compiler-args) \
+  -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+endef
+endif
 
 define transform-host-s-to-o
-$(transform-host-s-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o, $(PRIVATE_ASFLAGS))
 endef
 
 ###########################################################
 ## Commands for running gcc to compile a host Objective-C file
 ###########################################################
 
-define transform-host-m-to-o-no-deps
-@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
-$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
-endef
-
 define transform-host-m-to-o
-$(transform-host-m-to-o-no-deps)
-$(transform-d-to-p)
+@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE))
 endef
 
 ###########################################################
@@ -1458,7 +1498,7 @@
 define compile-dotdot-s-file-no-deps
 o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
 $$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
-	$$(transform-$$(PRIVATE_HOST)s-to-o-no-deps)
+	$$(transform-$$(PRIVATE_HOST)s-to-o)
 $(3) += $$(o)
 endef
 
@@ -1487,6 +1527,7 @@
 endef
 
 # $(1): the full path of the source static library.
+# $(2): the full path of the destination static library.
 define _extract-and-include-single-target-whole-static-lib
 $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
     rm -rf $$ldir; \
@@ -1508,32 +1549,119 @@
         filelist="$$filelist $$ldir/$$ext$$f"; \
     done ; \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
-        $(PRIVATE_ARFLAGS) $@ $$filelist
+        $(2) $$filelist
 
 endef
 
 # $(1): the full path of the source static library.
+# $(2): the full path of the destination static library.
 define extract-and-include-whole-static-libs-first
 $(if $(strip $(1)),
-$(hide) cp $(1) $@)
+$(hide) cp $(1) $(2))
 endef
 
+# $(1): the full path of the destination static library.
 define extract-and-include-target-whole-static-libs
-$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
 $(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
-    $(call _extract-and-include-single-target-whole-static-lib, $(lib)))
+    $(call _extract-and-include-single-target-whole-static-lib, $(lib), $(1)))
 endef
 
 # Explicitly delete the archive first so that ar doesn't
 # try to add to an existing archive.
 define transform-o-to-static-lib
-@echo "target StaticLib: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
-@rm -f $@
-$(extract-and-include-target-whole-static-libs)
+@rm -f $@ [email protected]
+$(call extract-and-include-target-whole-static-libs,[email protected])
 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
-    $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
+    $(PRIVATE_ARFLAGS) \
+    [email protected],$(PRIVATE_ALL_OBJECTS))
+$(hide) mv -f [email protected] $@
+endef
+
+# $(1): the full path of the source static library.
+# $(2): the full path of the destination static library.
+define _extract-and-include-single-aux-whole-static-lib
+$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
+    rm -rf $$ldir; \
+    mkdir -p $$ldir; \
+    cp $(1) $$ldir; \
+    lib_to_include=$$ldir/$(notdir $(1)); \
+    filelist=; \
+    subdir=0; \
+    for f in `$(PRIVATE_AR) t $(1)`; do \
+        if [ -e $$ldir/$$f ]; then \
+            mkdir $$ldir/$$subdir; \
+            ext=$$subdir/; \
+            subdir=$$((subdir+1)); \
+            $(PRIVATE_AR) m $$lib_to_include $$f; \
+        else \
+            ext=; \
+        fi; \
+        $(PRIVATE_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
+        filelist="$$filelist $$ldir/$$ext$$f"; \
+    done ; \
+    $(PRIVATE_AR) $(AUX_GLOBAL_ARFLAGS) $(2) $$filelist
+
+endef
+
+define extract-and-include-aux-whole-static-libs
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
+    $(call _extract-and-include-single-aux-whole-static-lib, $(lib), $(1)))
+endef
+
+# Explicitly delete the archive first so that ar doesn't
+# try to add to an existing archive.
+define transform-o-to-aux-static-lib
+@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+@rm -f $@ [email protected]
+$(call extract-and-include-aux-whole-static-libs,[email protected])
+$(call split-long-arguments,$(PRIVATE_AR) \
+    $(AUX_GLOBAL_ARFLAGS) [email protected],$(PRIVATE_ALL_OBJECTS))
+$(hide) mv -f [email protected] $@
+endef
+
+define transform-o-to-aux-executable-inner
+$(hide) $(PRIVATE_CXX) -pie \
+	-Bdynamic \
+	-Wl,--gc-sections \
+	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
+	-Wl,--no-whole-archive \
+	$(PRIVATE_ALL_STATIC_LIBRARIES) \
+	$(PRIVATE_LDFLAGS) \
+	-o $@
+endef
+
+define transform-o-to-aux-executable
+@echo "$(AUX_DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-o-to-aux-executable-inner)
+endef
+
+define transform-o-to-aux-static-executable-inner
+$(hide) $(PRIVATE_CXX) \
+	-Bstatic \
+	-Wl,--gc-sections \
+	$(PRIVATE_ALL_OBJECTS) \
+	-Wl,--whole-archive \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
+	-Wl,--no-whole-archive \
+	$(PRIVATE_ALL_STATIC_LIBRARIES) \
+	$(PRIVATE_LDFLAGS) \
+	-Wl,-Map=$(@).map \
+	-o $@
+endef
+
+define transform-o-to-aux-static-executable
+@echo "$(AUX_DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-o-to-aux-static-executable-inner)
 endef
 
 ###########################################################
@@ -1541,6 +1669,7 @@
 ###########################################################
 
 # $(1): the full path of the source static library.
+# $(2): the full path of the destination static library.
 define _extract-and-include-single-host-whole-static-lib
 $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
     rm -rf $$ldir; \
@@ -1562,26 +1691,46 @@
         filelist="$$filelist $$ldir/$$ext$$f"; \
     done ; \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
-        $(PRIVATE_ARFLAGS) $@ $$filelist
+        $(2) $$filelist
 
 endef
 
 define extract-and-include-host-whole-static-libs
-$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
 $(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
-    $(call _extract-and-include-single-host-whole-static-lib, $(lib)))
+    $(call _extract-and-include-single-host-whole-static-lib, $(lib),$(1)))
 endef
 
+ifeq ($(HOST_OS),darwin)
+# On Darwin the host ar fails if there is nothing to add to .a at all.
+# We work around by adding a dummy.o and then deleting it.
+define create-dummy.o-if-no-objs
+$(if $(PRIVATE_ALL_OBJECTS),,$(hide) touch $(dir $(1))dummy.o)
+endef
+
+define get-dummy.o-if-no-objs
+$(if $(PRIVATE_ALL_OBJECTS),,$(dir $(1))dummy.o)
+endef
+
+define delete-dummy.o-if-no-objs
+$(if $(PRIVATE_ALL_OBJECTS),,$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) d $(1) $(dir $(1))dummy.o \
+  && rm -f $(dir $(1))dummy.o)
+endef
+endif  # HOST_OS is darwin
+
 # Explicitly delete the archive first so that ar doesn't
 # try to add to an existing archive.
 define transform-host-o-to-static-lib
 @echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
-@rm -f $@
-$(extract-and-include-host-whole-static-libs)
+@rm -f $@ [email protected]
+$(call extract-and-include-host-whole-static-libs,[email protected])
+$(call create-dummy.o-if-no-objs,[email protected])
 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \
-    $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
-    $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
+    $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) [email protected],\
+    $(PRIVATE_ALL_OBJECTS) $(call get-dummy.o-if-no-objs,[email protected]))
+$(call delete-dummy.o-if-no-objs,[email protected])
+$(hide) mv -f [email protected] $@
 endef
 
 
@@ -1598,21 +1747,20 @@
 	-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
 	-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
 	-shared -Wl,-soname,$(notdir $@) \
-	$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	   $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
 	) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
 	-Wl,--no-whole-archive \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_STATIC_LIBRARIES) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+	$(PRIVATE_ALL_SHARED_LIBRARIES) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)
 endef
@@ -1640,28 +1788,27 @@
 	-nostdlib -Wl,-soname,$(notdir $@) \
 	-Wl,--gc-sections \
 	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl$(comma)-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
 	-Wl,--no-whole-archive \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_STATIC_LIBRARIES) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
 	$(PRIVATE_TARGET_LIBATOMIC) \
 	$(PRIVATE_TARGET_LIBGCC) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
+	$(PRIVATE_ALL_SHARED_LIBRARIES) \
+	-o $@ \
 	$(PRIVATE_TARGET_CRTEND_SO_O) \
 	$(PRIVATE_LDLIBS)
 endef
 
 define transform-o-to-shared-lib
-@echo "target SharedLib: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
 $(transform-o-to-shared-lib-inner)
 endef
@@ -1676,14 +1823,34 @@
 endif
 
 define transform-to-stripped
-@echo "target Strip: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip: $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \
   $(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA))
 endef
 
+define transform-to-stripped-keep-mini-debug-info
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip (mini debug info): $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(hide) rm -f $@ [email protected] [email protected] [email protected]_symbols [email protected] [email protected]_debuginfo.xz
+if $(PRIVATE_STRIP) --strip-all -R .comment $< -o $@; then \
+  $(PRIVATE_OBJCOPY) --only-keep-debug $< [email protected] && \
+  $(PRIVATE_NM) -D $< --format=posix --defined-only | awk '{ print $$1 }' | sort >[email protected] && \
+  $(PRIVATE_NM) $< --format=posix --defined-only | awk '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort >[email protected] && \
+  comm -13 [email protected] [email protected] >[email protected]_symbols && \
+  $(PRIVATE_OBJCOPY) --rename-section .debug_frame=saved_debug_frame [email protected] [email protected]_debuginfo && \
+  $(PRIVATE_OBJCOPY) -S --remove-section .gdb_index --remove-section .comment [email protected]_symbols [email protected]_debuginfo && \
+  $(PRIVATE_OBJCOPY) --rename-section saved_debug_frame=.debug_frame [email protected]_debuginfo && \
+  rm -f [email protected]_debuginfo.xz && \
+  xz [email protected]_debuginfo && \
+  $(PRIVATE_OBJCOPY) --add-section [email protected]_debuginfo.xz $@; \
+else \
+  cp -f $< $@; \
+fi
+endef
+
 define transform-to-stripped-keep-symbols
-@echo "target Strip (keep symbols): $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Strip (keep symbols): $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_OBJCOPY) \
     `$(PRIVATE_READELF) -S $< | awk '/.debug_/ {print "-R " $$2}' | xargs` \
@@ -1695,7 +1862,7 @@
 ###########################################################
 
 define pack-elf-relocations
-@echo "target Pack Relocations: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Pack Relocations: $(PRIVATE_MODULE) ($@)"
 $(copy-file-to-target)
 $(hide) $(RELOCATION_PACKER) $@
 endef
@@ -1710,29 +1877,28 @@
 	-Wl,-dynamic-linker,$(PRIVATE_LINKER) \
 	-Wl,--gc-sections \
 	-Wl,-z,nocopyreloc \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
 	-Wl,--no-whole-archive \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_STATIC_LIBRARIES) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
 	$(PRIVATE_TARGET_LIBATOMIC) \
 	$(PRIVATE_TARGET_LIBGCC) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
+	$(PRIVATE_ALL_SHARED_LIBRARIES) \
+	-o $@ \
 	$(PRIVATE_TARGET_CRTEND_O) \
 	$(PRIVATE_LDLIBS)
 endef
 
 define transform-o-to-executable
-@echo "target Executable: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
 $(transform-o-to-executable-inner)
 endef
@@ -1754,28 +1920,27 @@
 	$(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
 	-Wl,--gc-sections \
 	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	$(PRIVATE_TARGET_CRTBEGIN_STATIC_O) \
 	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
 	$(PRIVATE_LDFLAGS) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
 	-Wl,--no-whole-archive \
-	$(call normalize-target-libraries,$(filter-out %libcompiler_rt.a,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))))) \
+	$(filter-out %libcompiler_rt.a,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)))) \
 	-Wl,--start-group \
-	$(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
-	$(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+	$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
 	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(call normalize-target-libraries,$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+	$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(PRIVATE_TARGET_LIBGCC) \
 	-Wl,--end-group \
 	$(PRIVATE_TARGET_CRTEND_O)
 endef
 
 define transform-o-to-static-executable
-@echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
 @mkdir -p $(dir $@)
 $(transform-o-to-static-executable-inner)
 endef
@@ -1799,18 +1964,17 @@
 $(hide) $(PRIVATE_CXX) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
 	-Wl,--no-whole-archive \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+	$(PRIVATE_ALL_STATIC_LIBRARIES) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
 	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
-	$(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+	$(PRIVATE_ALL_SHARED_LIBRARIES) \
 	-Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \
-	-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
-	-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
-	$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \
+	$(foreach path,$(PRIVATE_RPATHS), \
+	  -Wl,-rpath,\$$ORIGIN/$(path)) \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 		$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
 	) \
@@ -1935,11 +2099,13 @@
 define aapt2-link
 @mkdir -p $(dir $@)
 $(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
+$(call dump-words-to-file,$(PRIVATE_OVERLAY_FLAT),$(dir $@)aapt2-flat-overlay-list)
 $(hide) $(AAPT2) link -o $@ \
   $(PRIVATE_AAPT_FLAGS) \
   $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
   $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
   $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
+  $(addprefix -A ,$(PRIVATE_ASSET_DIR)) \
   $(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
   $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
   $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
@@ -1951,7 +2117,7 @@
   $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
   $(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \
   $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
-  $(addprefix -R , $(PRIVATE_OVERLAY_FLAT)) \
+  -R \@$(dir $@)aapt2-flat-overlay-list \
   \@$(dir $@)aapt2-flat-list
 endef
 
@@ -2041,6 +2207,10 @@
 $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
           find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \
 fi
+$(if $(PRIVATE_HAS_PROTO_SOURCES), \
+    $(hide) find $(PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list )
+$(if $(PRIVATE_HAS_RS_SOURCES), \
+    $(hide) find $(PRIVATE_RS_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list )
 $(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
     | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
 $(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
@@ -2071,7 +2241,6 @@
 $(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) rm -rf \
     $(foreach pkg, $(PRIVATE_JAR_EXCLUDE_PACKAGES), \
         $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))))
-$(if $(PRIVATE_RMTYPEDEFS), $(hide) $(RMTYPEDEFS) -v $(PRIVATE_CLASS_INTERMEDIATES_DIR))
 $(if $(PRIVATE_JAR_MANIFEST), \
     $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \
             $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf && \
@@ -2082,7 +2251,7 @@
 endef
 
 define transform-java-to-classes.jar
-@echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
 $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH))
 endef
 
@@ -2101,9 +2270,14 @@
 $(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
 $(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
 $(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
-$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
-          find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
-fi
+$(if $(PRIVATE_SOURCE_INTERMEDIATES_DIR), \
+    $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
+            find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
+    fi)
+$(if $(PRIVATE_HAS_PROTO_SOURCES), \
+    $(hide) find $(PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list )
+$(if $(PRIVATE_HAS_RS_SOURCES), \
+    $(hide) find $(PRIVATE_RS_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list )
 $(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
     | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
 $(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
@@ -2116,6 +2290,10 @@
     $(hide) $(call add-java-resources-to,[email protected])
     $(hide) unzip -qo [email protected] -d [email protected]
     $(hide) rm [email protected])
+$(if $(PRIVATE_JACK_IMPORT_JAR),
+    $(hide) mkdir -p [email protected]
+    $(hide) unzip -qo $(PRIVATE_JACK_IMPORT_JAR) -d [email protected]
+    $(hide) find [email protected] -iname "*.class" -delete)
 $(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
     export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \
 else \
@@ -2128,9 +2306,14 @@
         -D jack.dex.optimize="false") \
     $(if $(PRIVATE_RMTYPEDEFS), \
         -D jack.android.remove-typedef="true") \
+    $(if $(PRIVATE_JACK_IMPORT_JAR), \
+        --import $(PRIVATE_JACK_IMPORT_JAR) --import-resource [email protected]) \
     $(addprefix --classpath ,$(strip \
-        $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
+        $(call normalize-path-list,$(PRIVATE_JACK_SHARED_LIBRARIES)))) \
     $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
+    $(addprefix --pluginpath ,$(strip \
+         $(call normalize-path-list,$(PRIVATE_JACK_PLUGIN_PATH)))) \
+    $(if $(PRIVATE_JACK_PLUGIN),--plugin $(call normalize-comma-list,$(PRIVATE_JACK_PLUGIN))) \
     $(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource [email protected]) \
     -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
     -D jack.import.resource.policy=keep-first \
@@ -2167,6 +2350,10 @@
 $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
           find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> [email protected]; \
 fi
+$(if $(PRIVATE_HAS_PROTO_SOURCES), \
+    $(hide) find $(PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> [email protected] )
+$(if $(PRIVATE_HAS_RS_SOURCES), \
+    $(hide) find $(PRIVATE_RS_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> [email protected] )
 $(hide) tr ' ' '\n' < [email protected] \
     | sort -u > [email protected]
 $(hide) if [ -s [email protected] ] ; then \
@@ -2174,7 +2361,7 @@
 	    $(strip $(PRIVATE_JACK_FLAGS)) \
 	    $(strip $(PRIVATE_JACK_DEBUG_FLAGS)) \
 	    $(addprefix --classpath ,$(strip \
-	        $(call normalize-path-list,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES)) $(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
+	        $(call normalize-path-list,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES)) $(PRIVATE_JACK_SHARED_LIBRARIES)))) \
 	    -D jack.import.resource.policy=keep-first \
 	    -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
 	    -D jack.import.type.policy=keep-first \
@@ -2191,6 +2378,9 @@
 	$(hide) find [email protected] -iname "*.class" -delete
 	$(hide) $(call call-jack) \
 	    $(PRIVATE_JACK_FLAGS) \
+	    $(addprefix --pluginpath ,$(strip \
+                $(call normalize-path-list,$(PRIVATE_JACK_PLUGIN_PATH)))) \
+	    $(if $(PRIVATE_JACK_PLUGIN),--plugin $(call normalize-comma-list,$(PRIVATE_JACK_PLUGIN))) \
         -D jack.import.resource.policy=keep-first \
         -D jack.import.type.policy=keep-first \
         -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
@@ -2203,9 +2393,7 @@
 # Moves $1.tmp to $1 if necessary. This is designed to be used with
 # .KATI_RESTAT. For kati, this function doesn't update the timestamp
 # of $1 when $1.tmp is identical to $1 so that ninja won't rebuild
-# targets which depend on $1. For GNU make, this function simply
-# copies $1.tmp to $1.
-ifeq ($(BUILDING_WITH_NINJA),true)
+# targets which depend on $1.
 define commit-change-for-toc
 $(hide) if cmp -s $1.tmp $1 ; then \
  rm $1.tmp ; \
@@ -2213,12 +2401,6 @@
  mv $1.tmp $1 ; \
 fi
 endef
-else
-define commit-change-for-toc
-@# make doesn't support restat. We always update .toc files so the dependents will always be updated too.
-$(hide) mv $1.tmp $1
-endef
-endif
 
 ## Rule to create a table of contents from a .jar file.
 ## Must be called with $(eval).
@@ -2246,7 +2428,7 @@
 $1/classes.dex.toc: PRIVATE_INPUT_DEX_FILES := $1/classes*.dex
 $1/classes.dex.toc: $1/classes.dex $(DEXDUMP)
 	@echo Generating TOC: $$@
-	$(hide) $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > [email protected]
+	$(hide) ANDROID_LOG_TAGS="*:e" $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > [email protected]
 	$$(call commit-change-for-toc,$$@)
 endef
 
@@ -2282,6 +2464,10 @@
 $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
           find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
 fi
+$(if $(PRIVATE_HAS_PROTO_SOURCES), \
+    $(hide) find $(PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list )
+$(if $(PRIVATE_HAS_RS_SOURCES), \
+    $(hide) find $(PRIVATE_RS_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list )
 $(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
     | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
 $(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
@@ -2304,8 +2490,11 @@
     $(if $(NO_OPTIMIZE_DX), \
         -D jack.dex.optimize="false") \
     $(addprefix --classpath ,$(strip \
-        $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
+        $(call normalize-path-list,$(PRIVATE_JACK_SHARED_LIBRARIES)))) \
     $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
+    $(addprefix --pluginpath ,$(strip \
+        $(call normalize-path-list,$(PRIVATE_JACK_PLUGIN_PATH)))) \
+    $(if $(PRIVATE_JACK_PLUGIN),--plugin $(call normalize-comma-list,$(PRIVATE_JACK_PLUGIN))) \
     $(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource [email protected]) \
     -D jack.import.resource.policy=keep-first \
     -D jack.import.type.policy=keep-first \
@@ -2330,6 +2519,52 @@
     $(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER))
 endef
 
+define desugar-classpath
+$(filter-out -classpath -bootclasspath "",$(subst :,$(space),$(1)))
+endef
+
+# Takes an sdk version that might be PLATFORM_VERSION_CODENAME (for example P),
+# returns a number greater than the highest existing sdk version if it is, or
+# the input if it is not.
+define codename-or-sdk-to-sdk
+$(if $(filter $(1),$(PLATFORM_VERSION_CODENAME)),10000,$(1))
+endef
+
+define desugar-classes-jar
+@echo Desugar: $@
+@mkdir -p $(dir $@)
+$(hide) rm -f $@ [email protected]
+$(hide) java -jar $(DESUGAR) \
+    $(addprefix --bootclasspath_entry ,$(call desugar-bootclasspath,$(PRIVATE_BOOTCLASSPATH))) \
+    $(addprefix --classpath_entry ,$(PRIVATE_ALL_JAVA_LIBRARIES)) \
+    --min_sdk_version $(call codename-or-sdk-to-sdk,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+    --allow_empty_bootclasspath \
+    $(if $(filter --core-library,$(PRIVATE_DX_FLAGS)),--core_library) \
+    -i $< -o [email protected]
+    mv [email protected] $@
+endef
+
+
+#TODO: use a smaller -Xmx value for most libraries;
+#      only core.jar and framework.jar need a heap this big.
+define transform-classes.jar-to-dex
+@echo "target Dex: $(PRIVATE_MODULE)"
+@mkdir -p $(dir $@)
+$(hide) rm -f $(dir $@)classes*.dex
+$(hide) $(DX) \
+    -JXms16M -JXmx2048M \
+    --dex --output=$(dir $@) \
+    --min-sdk-version=$(call codename-or-sdk-to-sdk,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+    $(if $(NO_OPTIMIZE_DX), \
+        --no-optimize) \
+    $(if $(GENERATE_DEX_DEBUG), \
+	    --debug --verbose \
+	    --dump-to=$(@:.dex=.lst) \
+	    --dump-width=1000) \
+    $(PRIVATE_DX_FLAGS) \
+    $<
+endef
+
 # Create a mostly-empty .jar file that we'll add to later.
 # The MacOS jar tool doesn't like creating empty jar files,
 # so we need to give it something.
@@ -2448,21 +2683,6 @@
 fi
 endef
 
-# Returns the minSdkVersion of the specified APK as a decimal number. If the
-# version is a codename, returns the current platform SDK version (always a
-# decimal number) instead. If the APK does not specify a minSdkVersion, returns
-# 0 to match how the Android platform interprets this situation at runtime.
-#
-# This currently substitutes any version which contains characters other than
-# digits with the current platform's API Level number. This is because I
-# couldn't figure out an easy way to perform the substitution only for the
-# version codes listed in PLATFORM_VERSION_ALL_CODENAMES.
-define get-package-min-sdk-version-int
-$$(($(AAPT) dump badging $(1) 2>&1 | grep '^sdkVersion' || echo "sdkVersion:'0'") \
-    | cut -d"'" -f2 | \
-    sed -e s/^.*[^0-9].*$$/$(PLATFORM_SDK_VERSION)/)
-endef
-
 # Sign a package using the specified key/cert.
 #
 define sign-package
@@ -2473,7 +2693,6 @@
 define sign-package-arg
 $(hide) mv $(1) $(1).unsigned
 $(hide) java -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) -jar $(SIGNAPK_JAR) \
-    --min-sdk-version $(call get-package-min-sdk-version-int,[email protected]) \
     $(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \
     $(PRIVATE_ADDITIONAL_CERTIFICATES) $(1).unsigned $(1).signed
 $(hide) mv $(1).signed $(1)
@@ -2495,11 +2714,9 @@
 
 # Remove dynamic timestamps from packages
 #
-ifndef TARGET_BUILD_APPS
 define remove-timestamps-from-package
 $(hide) $(ZIPTIME) $@
 endef
-endif
 
 # Uncompress shared libraries embedded in an apk.
 #
@@ -2513,19 +2730,6 @@
   fi
 endef
 
-define install-dex-debug
-$(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \
-	    mkdir -p $(TOP)/dalvik/DEBUG-FILES; \
-	    $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.dex \
-		$(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).dex; \
-	fi
-$(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.lst" ]; then \
-	    mkdir -p $(TOP)/dalvik/DEBUG-FILES; \
-	    $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.lst \
-		$(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).lst; \
-	fi
-endef
-
 # TODO(joeo): If we can ever upgrade to post 3.81 make and get the
 # new prebuilt rules to work, we should change this to copy the
 # resources to the out directory and then copy the resources.
@@ -2554,7 +2758,7 @@
 # $(1): source file
 # $(2): destination file
 define copy-one-file
-$(2): $(1) | $(ACP)
+$(2): $(1)
 	@echo "Copy: $$@"
 	$$(copy-file-to-target)
 endef
@@ -2575,7 +2779,7 @@
 # $(1): source file
 # $(2): destination file, must end with .xml.
 define copy-xml-file-checked
-$(2): $(1) | $(ACP)
+$(2): $(1)
 	@echo "Copy xml: $$@"
 	$(hide) xmllint $$< >/dev/null  # Don't print the xml file to stdout.
 	$$(copy-file-to-target)
@@ -2590,31 +2794,30 @@
 # Copy a single file from one place to another,
 # preserving permissions and overwriting any existing
 # file.
-# We disable the "-t" option for acp cannot handle
-# high resolution timestamp correctly on file systems like ext4.
-# Therefore copy-file-to-target is the same as copy-file-to-new-target.
+# When we used acp, it could not handle high resolution timestamps
+# on file systems like ext4. Because of that, '-t' option was disabled
+# and copy-file-to-target was identical to copy-file-to-new-target.
+# Keep the behavior until we audit and ensure that switching this back
+# won't break anything.
 define copy-file-to-target
 @mkdir -p $(dir $@)
-$(hide) $(ACP) -fp $< $@
+$(hide) rm -f $@
+$(hide) cp $< $@
 endef
 
 # The same as copy-file-to-target, but use the local
 # cp command instead of acp.
 define copy-file-to-target-with-cp
 @mkdir -p $(dir $@)
-$(hide) cp -fp $< $@
-endef
-
-# The same as copy-file-to-target, but use the zipalign tool to do so.
-define copy-file-to-target-with-zipalign
-@mkdir -p $(dir $@)
-$(hide) $(ZIPALIGN) -f 4 $< $@
+$(hide) rm -f $@
+$(hide) cp -p $< $@
 endef
 
 # The same as copy-file-to-target, but strip out "# comment"-style
 # comments (for config files and such).
 define copy-file-to-target-strip-comments
 @mkdir -p $(dir $@)
+$(hide) rm -f $@
 $(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@
 endef
 
@@ -2622,31 +2825,27 @@
 # the old modification time.
 define copy-file-to-new-target
 @mkdir -p $(dir $@)
-$(hide) $(ACP) -fp $< $@
+$(hide) rm -f $@
+$(hide) cp $< $@
 endef
 
 # The same as copy-file-to-new-target, but use the local
 # cp command instead of acp.
 define copy-file-to-new-target-with-cp
 @mkdir -p $(dir $@)
-$(hide) cp -f $< $@
+$(hide) rm -f $@
+$(hide) cp $< $@
 endef
 
 # Copy a prebuilt file to a target location.
 define transform-prebuilt-to-target
-@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
 $(copy-file-to-target)
 endef
 
-# Copy a prebuilt file to a target location, using zipalign on it.
-define transform-prebuilt-to-target-with-zipalign
-@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)"
-$(copy-file-to-target-with-zipalign)
-endef
-
 # Copy a prebuilt file to a target location, stripping "# comment" comments.
 define transform-prebuilt-to-target-strip-comments
-@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Prebuilt: $(PRIVATE_MODULE) ($@)"
 $(copy-file-to-target-strip-comments)
 endef
 
@@ -2661,13 +2860,31 @@
   $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
 endef
 
+# Define a rule to create a symlink to a file.
+# $(1): full path to source
+# $(2): source (may be relative)
+# $(3): full path to destination
+define symlink-file
+$(eval $(_symlink-file))
+endef
+
+# Order-only dependency because make/ninja will follow the link when checking
+# the timestamp, so the file must exist
+define _symlink-file
+$(3): | $(1)
+	@echo "Symlink: $$@ -> $(2)"
+	@mkdir -p $(dir $$@)
+	@rm -rf $$@
+	$(hide) ln -sf $(2) $$@
+endef
 
 ###########################################################
 ## Commands to call Proguard
 ###########################################################
 define transform-jar-to-proguard
 @echo Proguard: $@
-$(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) \
+$(hide) $(PROGUARD) -injars '$<$(PRIVATE_PROGUARD_INJAR_FILTERS)' \
+    -outjars $@ $(PRIVATE_PROGUARD_FLAGS) \
     $(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR))
 endef
 
@@ -2676,7 +2893,7 @@
 ###########################################################
 
 define transform-generated-source
-@echo "target Generated: $(PRIVATE_MODULE) <= $<"
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Generated: $(PRIVATE_MODULE) <= $<"
 @mkdir -p $(dir $@)
 $(hide) $(PRIVATE_CUSTOM_TOOL)
 endef
@@ -2758,7 +2975,7 @@
 endef
 define add-radio-file-internal
 INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
-$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP)
+$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1)
 	$$(transform-prebuilt-to-target)
 endef
 
@@ -2773,7 +2990,7 @@
 define add-radio-file-checked-internal
 INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
 BOARD_INFO_CHECK += $(3):$(LOCAL_PATH)/$(1)
-$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP)
+$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1)
 	$$(transform-prebuilt-to-target)
 endef
 
@@ -2889,6 +3106,111 @@
   $(if $(filter $(TARGET_2ND_ARCH),$(1)),$(TARGET_2ND_ARCH),$(if $(1),none))))
 endef
 
+# ###############################################################
+# Set up statistics gathering
+# ###############################################################
+STATS.MODULE_TYPE := \
+  HOST_STATIC_LIBRARY \
+  HOST_SHARED_LIBRARY \
+  STATIC_LIBRARY \
+  SHARED_LIBRARY \
+  EXECUTABLE \
+  HOST_EXECUTABLE \
+  PACKAGE \
+  PHONY_PACKAGE \
+  HOST_PREBUILT \
+  PREBUILT \
+  MULTI_PREBUILT \
+  JAVA_LIBRARY \
+  STATIC_JAVA_LIBRARY \
+  HOST_JAVA_LIBRARY \
+  DROIDDOC \
+  COPY_HEADERS \
+  NATIVE_TEST \
+  NATIVE_BENCHMARK \
+  HOST_NATIVE_TEST \
+  FUZZ_TEST \
+  HOST_FUZZ_TEST \
+  STATIC_TEST_LIBRARY \
+  HOST_STATIC_TEST_LIBRARY \
+  NOTICE_FILE \
+  HOST_DALVIK_JAVA_LIBRARY \
+  HOST_DALVIK_STATIC_JAVA_LIBRARY \
+  base_rules \
+  HEADER_LIBRARY
+
+$(foreach $(s),$(STATS.MODULE_TYPE),$(eval STATS.MODULE_TYPE.$(s) :=))
+define record-module-type
+$(strip $(if $(LOCAL_RECORDED_MODULE_TYPE),,
+  $(if $(filter-out $(SOONG_ANDROID_MK),$(LOCAL_MODULE_MAKEFILE)),
+    $(if $(filter $(1),$(STATS.MODULE_TYPE)),
+      $(eval LOCAL_RECORDED_MODULE_TYPE := true)
+        $(eval STATS.MODULE_TYPE.$(1) += 1),
+      $(error Invalid module type: $(1))))))
+endef
+
+###########################################################
+# Link type checking
+###########################################################
+define check-link-type
+$(hide) mkdir -p $(dir $@) && rm -f $@
+$(hide) $(CHECK_LINK_TYPE) --makefile $(PRIVATE_MAKEFILE) --module $(PRIVATE_MODULE) \
+  --type "$(PRIVATE_LINK_TYPE)" $(addprefix --allowed ,$(PRIVATE_ALLOWED_TYPES)) \
+  $(addprefix --warn ,$(PRIVATE_WARN_TYPES)) $(PRIVATE_DEPS)
+$(hide) echo "$(PRIVATE_LINK_TYPE)" >$@
+endef
+
+define link-type-partitions
+ifndef LOCAL_IS_HOST_MODULE
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
+ifneq ($(filter $(TARGET_OUT_VENDOR)/%,$(my_module_path)),)
+$(1): PRIVATE_LINK_TYPE += partition:vendor
+$(1): PRIVATE_WARN_TYPES += partition:data
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
+else ifneq ($(filter $(TARGET_OUT_OEM)/%,$(my_module_path)),)
+$(1): PRIVATE_LINK_TYPE += partition:oem
+$(1): PRIVATE_WARN_TYPES += partition:data
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
+else ifneq ($(filter $(TARGET_OUT_ODM)/%,$(my_module_path)),)
+$(1): PRIVATE_LINK_TYPE += partition:odm
+$(1): PRIVATE_WARN_TYPES += partition:data
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm
+else ifneq ($(filter $(TARGET_OUT_DATA)/%,$(my_module_path)),)
+$(1): PRIVATE_LINK_TYPE += partition:data
+$(1): PRIVATE_ALLOWED_TYPES += partition:data partition:vendor partition:oem partition:odm
+else
+$(1): PRIVATE_WARN_TYPES += partition:vendor partition:oem partition:odm partition:data
+endif
+else # uninstallable module
+$(1): PRIVATE_ALLOWED_TYPES += partition:vendor partition:oem partition:odm partition:data
+endif
+endif
+endef
+
+###########################################################
+## Compatibility suite tools
+###########################################################
+
+# Return a list of output directories for a given suite and the current LOCAL_MODULE
+define compatibility_suite_dirs
+  $(strip \
+    $(COMPATIBILITY_TESTCASES_OUT_$(1)) \
+    $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE))
+endef
+
+# For each suite:
+# 1. Copy the files to the many suite output directories.
+# 2. Add all the files to each suite's dependent files list.
+# 3. Do the dependency addition to my_all_targets
+# Requires for each suite: my_compat_dist_$(suite) to be defined.
+define create-suite-dependencies
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_files_$(suite) := $(call copy-many-files, $(my_compat_dist_$(suite)))) \
+  $(eval COMPATIBILITY.$(suite).FILES := \
+    $(COMPATIBILITY.$(suite).FILES) $(my_compat_files_$(suite))) \
+  $(eval $(my_all_targets) : $(my_compat_files_$(suite))))
+endef
+
 ###########################################################
 ## Other includes
 ###########################################################
@@ -2932,3 +3254,40 @@
 #	  sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
 #	      -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
 #	  rm -f $*.d
+
+
+###########################################################
+# Append the information to generate a RRO package for the
+# source module.
+#
+#  $(1): Source module name.
+#  $(2): Whether $(3) is a manifest package name or not.
+#  $(3): Manifest package name if $(2) is true.
+#        Otherwise, android manifest file path of the
+#        source module.
+#  $(4): Whether LOCAL_EXPORT_PACKAGE_RESOURCES is set or
+#        not for the source module.
+#  $(5): Resource overlay list.
+###########################################################
+define append_enforce_rro_sources
+  $(eval ENFORCE_RRO_SOURCES += \
+      $(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||$(call normalize-path-list, $(strip $(5))))
+endef
+
+###########################################################
+# Generate all RRO packages for source modules stored in
+# ENFORCE_RRO_SOURCES
+###########################################################
+define generate_all_enforce_rro_packages
+$(foreach source,$(ENFORCE_RRO_SOURCES), \
+  $(eval _o := $(subst ||,$(space),$(source))) \
+  $(eval enforce_rro_source_module := $(word 1,$(_o))) \
+  $(eval enforce_rro_source_is_manifest_package_name := $(word 2,$(_o))) \
+  $(eval enforce_rro_source_manifest_package_info := $(word 3,$(_o))) \
+  $(eval enforce_rro_use_res_lib := $(word 4,$(_o))) \
+  $(eval enforce_rro_source_overlays := $(subst :, ,$(word 5,$(_o)))) \
+  $(eval enforce_rro_module := $(enforce_rro_source_module)__auto_generated_rro) \
+  $(eval include $(BUILD_SYSTEM)/generate_enforce_rro.mk) \
+  $(eval ALL_MODULES.$(enforce_rro_source_module).REQUIRED += $(enforce_rro_module)) \
+)
+endef
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 5df9dc3..0606c83 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -23,10 +23,12 @@
 # being used). To bundle everything one should set this to '%'
 SYSTEM_OTHER_ODEX_FILTER ?= app/% priv-app/%
 
+# Method returning whether the install path $(1) should be for system_other.
+install-on-system-other = $(filter-out $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(basename $(notdir $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(1)))))
+
 # The default values for pre-opting: always preopt PIC.
 # Conditional to building on linux, as dex2oat currently does not work on darwin.
 ifeq ($(HOST_OS),linux)
-  WITH_DEXPREOPT_PIC ?= true
   WITH_DEXPREOPT ?= true
 # For an eng build only pre-opt the boot image. This gives reasonable performance and still
 # allows a simple workflow: building in frameworks/base and syncing.
@@ -40,10 +42,6 @@
 endif
 
 GLOBAL_DEXPREOPT_FLAGS :=
-ifeq ($(WITH_DEXPREOPT_PIC),true)
-# Compile boot.oat as position-independent code if WITH_DEXPREOPT_PIC=true
-GLOBAL_DEXPREOPT_FLAGS += --compile-pic
-endif
 
 # $(1): the .jar or .apk to remove classes.dex
 define dexpreopt-remove-classes.dex
@@ -61,7 +59,7 @@
 _dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
 _dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
 
-$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP)
+$$(_dbj_jar_no_dex) : $$(_dbj_src_jar)
 	$$(call copy-file-to-target)
 ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
 	$$(call dexpreopt-remove-classes.dex,$$@)
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index acd4a02..9db5dbf 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
 
@@ -66,7 +61,7 @@
 # $(2): the full install path (including file name) of the corresponding .apk.
 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
 define get-odex-installed-file-path
-$(if $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(2)),
+$(if $(call install-on-system-other, $(2)),
   $(call get-odex-file-path,$(1),$(patsubst $(TARGET_OUT)/%,$(TARGET_OUT_SYSTEM_OTHER)/%,$(2))),
   $(call get-odex-file-path,$(1),$(2)))
 endef
@@ -90,17 +85,19 @@
 # is converted into to boot.art (to match the legacy assumption that boot.art
 # exists), and the rest are converted to boot-<name>.art.
 # In addition, each .art file has an associated .oat file.
-LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat)
-LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat
+LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat boot-$(jar).vdex)
+LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat boot.vdex
 
 my_2nd_arch_prefix :=
 include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
 
+ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
 ifdef TARGET_2ND_ARCH
 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
 include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
 my_2nd_arch_prefix :=
 endif
+endif
 
 
 ########################################################################
@@ -122,9 +119,13 @@
 	--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 \
+	--runtime-arg -Xnorelocate --compile-pic \
+	--no-generate-debug-info --generate-build-id \
 	--abort-on-hard-verifier-error \
+	--force-determinism \
 	--no-inline-from=core-oj.jar \
 	$(PRIVATE_DEX_PREOPT_FLAGS) \
+	$(PRIVATE_ART_FILE_PREOPT_FLAGS) \
+	$(PRIVATE_PROFILE_PREOPT_FLAGS) \
 	$(GLOBAL_DEXPREOPT_FLAGS)
 endef
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 1a0dc5b..860a66a 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,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) \
-		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+		--android-root=$(PRODUCT_OUT)/system \
+		--runtime-arg -Xnorelocate --compile-pic \
+		--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/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index b05d4da..b9c0fc6 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -42,15 +42,22 @@
 # if installing into system, and odex are being installed into system_other, don't strip
 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
 ifeq ($(LOCAL_DEX_PREOPT),true)
-ifneq ($(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(my_module_path)),)
+ifneq ($(call install-on-system-other, $(my_module_path)),)
 LOCAL_DEX_PREOPT := nostripping
 endif
 endif
 endif
 
 built_odex :=
+built_vdex :=
+built_art :=
 installed_odex :=
+installed_vdex :=
+installed_art :=
 built_installed_odex :=
+built_installed_vdex :=
+built_installed_art :=
+
 ifdef LOCAL_DEX_PREOPT
 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
 ifdef dexpreopt_boot_jar_module
@@ -76,10 +83,12 @@
 # #################################################
 # Odex for the 2nd arch
 ifdef TARGET_2ND_ARCH
+ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
 ifneq (first,$(my_module_multilib))
 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
 include $(BUILD_SYSTEM)/setup_one_odex.mk
 endif  # my_module_multilib is not first.
+endif  # TARGET_TRANSLATE_2ND_ARCH not true
 endif  # TARGET_2ND_ARCH
 # #################################################
 else  # must be APPS
@@ -97,9 +106,45 @@
 endif  # boot jar
 
 built_odex := $(strip $(built_odex))
+built_vdex := $(strip $(built_vdex))
+built_art := $(strip $(built_art))
 installed_odex := $(strip $(installed_odex))
+installed_vdex := $(strip $(installed_vdex))
+installed_art := $(strip $(installed_art))
 
 ifdef built_odex
+
+ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE
+ifeq (true,$(WITH_DEX_PREOPT_GENERATE_PROFILE))
+  LOCAL_DEX_PREOPT_GENERATE_PROFILE := true
+endif
+endif
+
+ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE))
+ifndef LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING
+$(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING))
+endif
+my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof
+my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(built_odex): $(my_built_profile)
+$(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
+$(my_built_profile): PRIVATE_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
+$(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
+$(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
+$(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
+$(my_built_profile): $(PROFMAN)
+$(my_built_profile): $(LOCAL_BUILT_MODULE)
+$(my_built_profile):
+	$(hide) mkdir -p $(dir $@)
+	ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
+		--create-profile-from=$(PRIVATE_SOURCE_CLASSES) \
+		--apk=$(PRIVATE_BUILT_MODULE) \
+		--dex-location=$(PRIVATE_DEX_LOCATION) \
+		--reference-profile-file=$@
+else
+$(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS :=
+endif
+
 ifndef LOCAL_DEX_PREOPT_FLAGS
 LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
 ifndef LOCAL_DEX_PREOPT_FLAGS
@@ -107,19 +152,36 @@
 endif
 endif
 
+ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS) $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(LOCAL_MODULE)))
+  # Jars of system server, apps loaded into system server, and apps the product wants to be
+  # compiled with the 'speed' compiler filter.
+  LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=speed
+else
+  # If no compiler filter is specified, default to 'quicken' to save on storage.
+  ifeq (,$(filter --compiler-filter=%, $(LOCAL_DEX_PREOPT_FLAGS)))
+    LOCAL_DEX_PREOPT_FLAGS += --compiler-filter=quicken
+  endif
+endif
+
 $(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
+$(built_vdex): $(built_odex)
+$(built_art): $(built_odex)
 endif
 
 # Add the installed_odex to the list of installed files for this module.
 ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
+ALL_MODULES.$(my_register_name).INSTALLED += $(installed_vdex)
+ALL_MODULES.$(my_register_name).INSTALLED += $(installed_art)
 ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_vdex)
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_art)
 
 # Record dex-preopt config.
 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
 DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
 DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
 DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
-DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE)
+DEXPREOPT.$(LOCAL_MODULE).VENDOR_MODULE := $(LOCAL_VENDOR_MODULE)
 DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
 DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
 DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
@@ -127,7 +189,7 @@
   $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
 
 
-# Make sure to install the .odex when you run "make <module_name>"
-$(my_register_name): $(installed_odex)
+# Make sure to install the .odex and .vdex when you run "make <module_name>"
+$(my_all_targets): $(installed_odex) $(installed_vdex) $(installed_art)
 
 endif # LOCAL_DEX_PREOPT
diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk
index 6bae25d..1b0be07 100644
--- a/core/dpi_specific_apk.mk
+++ b/core/dpi_specific_apk.mk
@@ -5,6 +5,7 @@
 dpi_apk_name := $(LOCAL_MODULE)_$(my_dpi)
 dpi_intermediate := $(call intermediates-dir-for,APPS,$(dpi_apk_name))
 built_dpi_apk := $(dpi_intermediate)/package.apk
+additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
 
 # Set up all the target-specific variables.
 $(built_dpi_apk): PRIVATE_MODULE := $(dpi_apk_name)
@@ -27,15 +28,15 @@
 $(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
 $(built_dpi_apk): PRIVATE_PRIVATE_KEY := $(private_key)
 $(built_dpi_apk): PRIVATE_CERTIFICATE := $(certificate)
-$(built_dpi_apk): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
-    $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
+$(built_dpi_apk): $(additional_certificates)
+$(built_dpi_apk): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
 
 $(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE :=
 ifneq ($(full_classes_jar),)
 $(built_dpi_apk): PRIVATE_DEX_FILE := $(built_dex)
 ifndef LOCAL_JACK_ENABLED
 # Use the jarjar processed arhive as the initial package file.
-$(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
 else
 $(built_dpi_apk): PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
 endif # LOCAL_JACK_ENABLED
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index f143579..2285b2c 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -14,6 +14,7 @@
 # limitations under the License.
 #
 
+$(call record-module-type,DROIDDOC)
 ##
 ##
 ## Common to both droiddoc and javadoc
@@ -165,7 +166,6 @@
         $(droiddoc) \
         $(html_dir_files) \
         $(full_java_lib_deps) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
         $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	@echo Docs droiddoc: $(PRIVATE_OUT_DIR)
 	$(hide) mkdir -p $(dir $@)
@@ -177,6 +177,7 @@
                 -encoding UTF-8 \
                 \@$(PRIVATE_SRC_LIST_FILE) \
                 -J-Xmx1600m \
+                -J-XX:-OmitStackTraceInFastThrow \
                 -XDignore.symbol.file \
                 $(PRIVATE_PROFILING_OPTIONS) \
                 -quiet \
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
index 1bd4777..acae48e 100644
--- a/core/dumpvar.mk
+++ b/core/dumpvar.mk
@@ -6,6 +6,7 @@
   TARGET_PRODUCT \
   TARGET_BUILD_VARIANT \
   TARGET_BUILD_TYPE \
+  TARGET_PLATFORM_VERSION \
   TARGET_BUILD_APPS \
   TARGET_ARCH \
   TARGET_ARCH_VARIANT \
@@ -22,7 +23,8 @@
   HOST_CROSS_2ND_ARCH \
   HOST_BUILD_TYPE \
   BUILD_ID \
-  OUT_DIR
+  OUT_DIR \
+  AUX_OS_VARIANT_LIST
 
 ifeq ($(TARGET_BUILD_PDK),true)
 print_build_config_vars += \
@@ -35,10 +37,15 @@
 # what to add to the path given the config we have chosen.
 ifeq ($(CALLED_FROM_SETUP),true)
 
-ifneq ($(filter /%,$(HOST_OUT_EXECUTABLES)),)
-ABP:=$(HOST_OUT_EXECUTABLES)
+ifneq ($(filter /%,$(SOONG_HOST_OUT_EXECUTABLES)),)
+ABP := $(SOONG_HOST_OUT_EXECUTABLES)
 else
-ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
+ABP := $(PWD)/$(SOONG_HOST_OUT_EXECUTABLES)
+endif
+ifneq ($(filter /%,$(HOST_OUT_EXECUTABLES)),)
+ABP := $(ABP):$(HOST_OUT_EXECUTABLES)
+else
+ABP := $(ABP):$(PWD)/$(HOST_OUT_EXECUTABLES)
 endif
 
 ANDROID_BUILD_PATHS := $(ABP)
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 91fd271..579338e 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -58,7 +58,7 @@
 # Do not pack relocations for executables. Because packing results in
 # non-zero p_vaddr which causes kernel to load executables to lower
 # address (starting at 0x8000) http://b/20665974
-ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
   my_pack_module_relocations := false
 endif
 
@@ -69,10 +69,10 @@
 
 ifeq (true,$(my_pack_module_relocations))
 # Pack relocations
-$(relocation_packer_output): $(relocation_packer_input) | $(ACP)
+$(relocation_packer_output): $(relocation_packer_input)
 	$(pack-elf-relocations)
 else
-$(relocation_packer_output): $(relocation_packer_input) | $(ACP)
+$(relocation_packer_output): $(relocation_packer_input)
 	@echo "target Unpacked: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target)
 endif
@@ -87,7 +87,7 @@
 endif
 symbolic_input := $(relocation_packer_output)
 symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
-$(symbolic_output) : $(symbolic_input) | $(ACP)
+$(symbolic_output) : $(symbolic_input)
 	@echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target)
 
@@ -116,11 +116,21 @@
   $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
   $(LOCAL_STRIP_MODULE))
 ifeq ($(my_strip_module),)
+  my_strip_module := mini-debug-info
+endif
+
+ifeq ($(my_strip_module),mini-debug-info)
+# Don't use mini-debug-info on mips (both 32-bit and 64-bit). objcopy checks that all
+# SH_MIPS_DWARF sections having name prefix .debug_ or .zdebug_, so there seems no easy
+# way using objcopy to remove all debug sections except .debug_frame on mips.
+ifneq ($(filter mips mips64,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
   my_strip_module := true
 endif
+endif
 
 $(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
 $(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
+$(strip_output): PRIVATE_NM := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NM)
 $(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
 ifeq ($(my_strip_module),no_debuglink)
 $(strip_output): PRIVATE_NO_DEBUGLINK := true
@@ -128,7 +138,11 @@
 $(strip_output): PRIVATE_NO_DEBUGLINK :=
 endif
 
-ifneq ($(filter true no_debuglink,$(my_strip_module)),)
+ifeq ($(my_strip_module),mini-debug-info)
+# Strip the binary, but keep debug frames and symbol table in a compressed .gnu_debugdata section.
+$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY) $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NM)
+	$(transform-to-stripped-keep-mini-debug-info)
+else ifneq ($(filter true no_debuglink,$(my_strip_module)),)
 # Strip the binary
 $(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
 	$(transform-to-stripped)
@@ -148,18 +162,9 @@
 else
 # Don't strip the binary, just copy it.  We can't skip this step
 # because a copy of the binary must appear at LOCAL_BUILT_MODULE.
-#
-# If the binary we're copying is acp or a prerequisite,
-# use cp(1) instead.
-ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
-$(strip_output): $(strip_input) | $(ACP)
-	@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target)
-else
 $(strip_output): $(strip_input)
 	@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target-with-cp)
-endif
+	$(copy-file-to-target)
 endif # my_strip_module
 
 $(cleantarget): PRIVATE_CLEAN_FILES += \
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 6cfb6a1..67ac751 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -11,16 +11,72 @@
 #         This can be useful if you set OUT_DIR to be a different directory
 #         than other outputs of your build system.
 
+# Returns all words in $1 up to and including $2
+define find_and_earlier
+  $(strip $(if $(1),
+    $(firstword $(1))
+    $(if $(filter $(firstword $(1)),$(2)),,
+      $(call find_and_earlier,$(wordlist 2,$(words $(1)),$(1)),$(2)))))
+endef
+
+#$(warning $(call find_and_earlier,A B C,A))
+#$(warning $(call find_and_earlier,A B C,B))
+#$(warning $(call find_and_earlier,A B C,C))
+#$(warning $(call find_and_earlier,A B C,D))
+
+define version-list
+$(1)PR1 $(1)PD1 $(1)PD2 $(1)PM1 $(1)PM2
+endef
+
+ALL_VERSIONS := O P Q R S T U V W X Y Z
+ALL_VERSIONS := $(foreach v,$(ALL_VERSIONS),$(call version-list,$(v)))
+
+# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is
+# not in [$1, $2]
+# $(1): min platform version
+# $(2): max platform version
+# $(3): default platform version
+define allowed-platform-versions
+$(strip \
+  $(if $(filter $(ALL_VERSIONS),$(1)),,
+    $(error Invalid MIN_PLATFORM_VERSION '$(1)'))
+  $(if $(filter $(ALL_VERSIONS),$(2)),,
+    $(error Invalid MAX_PLATFORM_VERSION '$(2)'))
+  $(if $(filter $(ALL_VERSIONS),$(3)),,
+    $(error Invalid DEFAULT_PLATFORM_VERSION '$(3)'))
+
+  $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2)))
+
+  $(if $(filter $(allowed_versions_),$(1)),,
+    $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)'))
+
+  $(eval allowed_versions_ := $(1) \
+    $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_)))
+
+  $(if $(filter $(allowed_versions_),$(3)),,
+    $(error DEFAULT_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)'))
+
+  $(allowed_versions_))
+endef
+
+#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1))
+#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1))
+
 # Set up version information.
 include $(BUILD_SYSTEM)/version_defaults.mk
 
+ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION))
+
+$(foreach v,$(ENABLED_VERSIONS), \
+  $(eval IS_AT_LEAST_$(v) := true))
+
 # ---------------------------------------------------------------
 # If you update the build system such that the environment setup
 # or buildspec.mk need to be updated, increment this number, and
 # people who haven't re-run those will have to do so before they
 # can build.  Make sure to also update the corresponding value in
 # buildspec.mk.default and envsetup.sh.
-CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
+CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 13
 
 # ---------------------------------------------------------------
 # The product defaults to generic on hardware
@@ -65,6 +121,7 @@
 HOST_CROSS_OS := windows
 HOST_CROSS_ARCH := x86
 HOST_CROSS_2ND_ARCH := x86_64
+2ND_HOST_CROSS_IS_64_BIT := true
 endif
 
 ifeq ($(HOST_OS),)
@@ -77,7 +134,7 @@
   HOST_2ND_ARCH := x86
   HOST_IS_64_BIT := true
 else
-ifneq (,$(findstring x86,$(UNAME)))
+ifneq (,$(findstring i686,$(UNAME))$(findstring x86,$(UNAME)))
 $(error Building on a 32-bit x86 host is not supported: $(UNAME)!)
 endif
 endif
@@ -111,6 +168,7 @@
 TARGET_COPY_OUT_SYSTEM := system
 TARGET_COPY_OUT_SYSTEM_OTHER := system_other
 TARGET_COPY_OUT_DATA := data
+TARGET_COPY_OUT_ASAN := $(TARGET_COPY_OUT_DATA)/asan
 TARGET_COPY_OUT_OEM := oem
 TARGET_COPY_OUT_ODM := odm
 TARGET_COPY_OUT_ROOT := root
@@ -187,7 +245,22 @@
 $(error TARGET_COPY_OUT_VENDOR must be set to 'vendor' to use a vendor image)
 endif
 ###########################################
+# Ensure that only TARGET_RECOVERY_UPDATER_LIBS *or* AB_OTA_UPDATER is set.
+TARGET_RECOVERY_UPDATER_LIBS ?=
+AB_OTA_UPDATER ?=
+.KATI_READONLY := TARGET_RECOVERY_UPDATER_LIBS AB_OTA_UPDATER
+ifeq ($(AB_OTA_UPDATER),true)
+  ifneq ($(strip $(TARGET_RECOVERY_UPDATER_LIBS)),)
+    $(error Do not use TARGET_RECOVERY_UPDATER_LIBS when using AB_OTA_UPDATER)
+  endif
+endif
 
+# Check BOARD_VNDK_VERSION
+ifdef BOARD_VNDK_VERSION
+  ifneq ($(BOARD_VNDK_VERSION),current)
+    $(error BOARD_VNDK_VERSION: Only "current" is implemented)
+  endif
+endif
 
 # ---------------------------------------------------------------
 # Set up configuration for target machine.
@@ -217,6 +290,8 @@
 endif
 endif
 
+SOONG_OUT_DIR := $(OUT_DIR)/soong
+
 DEBUG_OUT_DIR := $(OUT_DIR)/debug
 
 # Move the host or target under the debug/ directory
@@ -233,6 +308,7 @@
 HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
 HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
 HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
+SOONG_HOST_OUT := $(SOONG_OUT_DIR)/host/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
 # TODO: remove
 BUILD_OUT := $(HOST_OUT)
 
@@ -250,25 +326,32 @@
 OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
 
 BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin
+SOONG_HOST_OUT_EXECUTABLES := $(SOONG_HOST_OUT)/bin
 
 HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
 HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64
 HOST_OUT_RENDERSCRIPT_BITCODE := $(HOST_OUT_SHARED_LIBRARIES)
 HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework
 HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
+HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest64
+HOST_OUT_COVERAGE := $(HOST_OUT)/coverage
 
 HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT)/bin
 HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib
+HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest
+HOST_CROSS_OUT_COVERAGE := $(HOST_CROSS_OUT)/coverage
+HOST_OUT_TESTCASES := $(HOST_OUT)/testcases
 
 HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
-HOST_OUT_HEADERS := $(HOST_OUT_INTERMEDIATES)/include
 HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
 HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
 HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
 HOST_OUT_FAKE := $(HOST_OUT)/fake_packages
 
+# Nano environment config
+include $(BUILD_SYSTEM)/aux_config.mk
+
 HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj
-HOST_CROSS_OUT_HEADERS := $(HOST_CROSS_OUT_INTERMEDIATES)/include
 HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $(HOST_CROSS_OUT_INTERMEDIATES)/lib
 HOST_CROSS_OUT_NOTICE_FILES := $(HOST_CROSS_OUT_INTERMEDIATES)/NOTICE_FILES
 
@@ -285,14 +368,12 @@
 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib
 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_EXECUTABLES := $(HOST_OUT_EXECUTABLES)
 $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT_JAVA_LIBRARIES)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_TESTCASES := $(HOST_OUT_TESTCASES)
 
 # The default host library path.
 # It always points to the path where we build libraries in the default bitness.
-ifeq ($(HOST_PREFER_32_BIT),true)
-HOST_LIBRARY_PATH := $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)
-else
 HOST_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
-endif
 
 # Out for HOST_CROSS_2ND_ARCH
 HOST_CROSS_2ND_ARCH_VAR_PREFIX := 2ND_
@@ -301,6 +382,7 @@
 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES)/lib
 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib64
 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT_EXECUTABLES)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest64
 
 TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
 TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include
@@ -312,7 +394,7 @@
 
 TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
 ifneq ($(filter address,$(SANITIZE_TARGET)),)
-target_out_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
+target_out_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system
 else
 target_out_shared_libraries_base := $(TARGET_OUT)
 endif
@@ -335,19 +417,30 @@
 TARGET_OUT_ETC := $(TARGET_OUT)/etc
 TARGET_OUT_NOTICE_FILES := $(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
 TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
+TARGET_OUT_TESTCASES := $(PRODUCT_OUT)/testcases
 
 TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_OTHER)
 
 # Out for TARGET_2ND_ARCH
 TARGET_2ND_ARCH_VAR_PREFIX := $(HOST_2ND_ARCH_VAR_PREFIX)
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+# With this you can reference the arm binary translation library with libfoo_arm in PRODUCT_PACKAGES.
+TARGET_2ND_ARCH_MODULE_SUFFIX := _$(TARGET_2ND_ARCH)
+else
 TARGET_2ND_ARCH_MODULE_SUFFIX := $(HOST_2ND_ARCH_MODULE_SUFFIX)
+endif
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)/lib
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib/$(TARGET_2ND_ARCH)
+else
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
+endif
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS := $(TARGET_OUT_APPS)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT_APPS_PRIVILEGED)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_TESTCASES := $(TARGET_OUT_TESTCASES)
 
 TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
 TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
@@ -369,14 +462,19 @@
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest/$(TARGET_2ND_ARCH)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest/$(TARGET_2ND_ARCH)
+else
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
+endif
 
 TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
 
 TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
 ifneq ($(filter address,$(SANITIZE_TARGET)),)
-target_out_vendor_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)/vendor
+target_out_vendor_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/vendor
 else
 target_out_vendor_shared_libraries_base := $(TARGET_OUT_VENDOR)
 endif
@@ -388,13 +486,21 @@
 else
 TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
 endif
+TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
 TARGET_OUT_VENDOR_JAVA_LIBRARIES := $(TARGET_OUT_VENDOR)/framework
 TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR)/app
+TARGET_OUT_VENDOR_APPS_PRIVILEGED := $(TARGET_OUT_VENDOR)/priv-app
 TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
 
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR_EXECUTABLES)
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib/$(TARGET_2ND_ARCH)
+else
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
+endif
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES)
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR_APPS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS_PRIVILEGED := $(TARGET_OUT_VENDOR_APPS_PRIVILEGED)
 
 TARGET_OUT_OEM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_OEM)
 TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM)/bin
@@ -409,7 +515,11 @@
 TARGET_OUT_OEM_ETC := $(TARGET_OUT_OEM)/etc
 
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM_EXECUTABLES)
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib/$(TARGET_2ND_ARCH)
+else
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
+endif
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM_APPS)
 
 TARGET_OUT_ODM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ODM)
@@ -423,7 +533,11 @@
 TARGET_OUT_ODM_ETC := $(TARGET_OUT_ODM)/etc
 
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM_EXECUTABLES)
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib/$(TARGET_2ND_ARCH)
+else
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib
+endif
 $(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS := $(TARGET_OUT_ODM_APPS)
 
 TARGET_OUT_BREAKPAD := $(PRODUCT_OUT)/breakpad
@@ -435,6 +549,7 @@
 TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
 TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
 TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
+TARGET_OUT_COVERAGE := $(PRODUCT_OUT)/coverage
 
 TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
 TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
@@ -455,16 +570,22 @@
 TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
 
 COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
-PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE
+PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE NATIVE_TESTS HEADER_LIBRARIES
 
 ifeq (,$(strip $(DIST_DIR)))
   DIST_DIR := $(OUT_DIR)/dist
 endif
 
-ifeq ($(PRINT_BUILD_CONFIG),)
-PRINT_BUILD_CONFIG := true
+ifndef KATI
+PRINT_BUILD_CONFIG ?= true
 endif
 
 ifeq ($(USE_CLANG_PLATFORM_BUILD),)
 USE_CLANG_PLATFORM_BUILD := true
 endif
+
+ifneq ($(USE_CLANG_PLATFORM_BUILD),true)
+ifneq ($(USE_CLANG_PLATFORM_BUILD),false)
+$(error USE_CLANG_PLATFORM_BUILD must be true or false)
+endif
+endif
diff --git a/core/executable.mk b/core/executable.mk
index e22ea0e..f1b2462 100644
--- a/core/executable.mk
+++ b/core/executable.mk
@@ -16,17 +16,29 @@
 endif
 
 ifneq (true,$(my_skip_this_target))
+$(call record-module-type,EXECUTABLE)
+
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+# If a native test explicity specifies to build only for the translation arch,
+# we'll still need LOCAL_MULTILIB=both and let module_arch_supported.mk choose
+# to build only for TARGET_2ND_ARCH.
+ifneq (1,$(words $(LOCAL_MODULE_TARGET_ARCH)))
+LOCAL_MULTILIB := first
+endif
+endif
 
 my_prefix := TARGET_
 include $(BUILD_SYSTEM)/multilib.mk
 
 ifeq ($(my_module_multilib),both)
+ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
 ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),)
 $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
 endif
 ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),)
 $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
 endif
+endif
 else #!LOCAL_MULTILIB == both
 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
 endif
diff --git a/core/executable_internal.mk b/core/executable_internal.mk
index febea98..3509bd2 100644
--- a/core/executable_internal.mk
+++ b/core/executable_internal.mk
@@ -34,36 +34,30 @@
 endif
 
 # Define PRIVATE_ variables from global vars
-my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS)
 ifeq ($(LOCAL_NO_LIBGCC),true)
 my_target_libgcc :=
 else
-my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC)
+my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a
 endif
-my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC)
+my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
 ifeq ($(LOCAL_NO_CRT),true)
 my_target_crtbegin_dynamic_o :=
 my_target_crtbegin_static_o :=
 my_target_crtend_o :=
+else ifdef LOCAL_USE_VNDK
+my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.vendor.o
+my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.vendor.o
+my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.vendor.o
 else
-my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_DYNAMIC_O)
-my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_STATIC_O)
-my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_O)
+my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
 endif
-ifdef LOCAL_SDK_VERSION
-# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
-# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
-my_target_global_ld_dirs := \
-    $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
-    $(my_ndk_sysroot_lib)) \
-    $(my_target_global_ld_dirs)
-my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
+ifneq ($(LOCAL_SDK_VERSION),)
 my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o)
 my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o)
 my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o)
 endif
-$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
-$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
 $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
 $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
 $(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
@@ -73,11 +67,11 @@
 $(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
 
 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
-$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
+$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libgcc) $(my_target_libatomic)
 	$(transform-o-to-static-executable)
 	$(PRIVATE_POST_LINK_CMD)
 else
-$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
+$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libgcc) $(my_target_libatomic)
 	$(transform-o-to-executable)
 	$(PRIVATE_POST_LINK_CMD)
 endif
diff --git a/core/executable_prefer_symlink.mk b/core/executable_prefer_symlink.mk
index 931550f..9b9814e 100644
--- a/core/executable_prefer_symlink.mk
+++ b/core/executable_prefer_symlink.mk
@@ -10,43 +10,33 @@
 # et al. since those variables make no sense in that context.
 ifneq ($(LOCAL_IS_HOST_MODULE),true)
   my_symlink := $(addprefix $(TARGET_OUT)/bin/, $(LOCAL_MODULE))
+  my_src_binary_name :=
   ifeq ($(TARGET_IS_64_BIT),true)
     ifeq ($(TARGET_SUPPORTS_64_BIT_APPS)|$(TARGET_SUPPORTS_32_BIT_APPS),true|true)
       # We support both 32 and 64 bit apps, so we will have to
       # base our decision on whether the target prefers one or the
       # other.
       ifeq ($(TARGET_PREFER_32_BIT_APPS),true)
-        $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+        my_src_binary_name := $(LOCAL_MODULE_STEM_32)
       else
-        $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_64)
+        my_src_binary_name := $(LOCAL_MODULE_STEM_64)
       endif
     else ifeq ($(TARGET_SUPPORTS_64_BIT_APPS),true)
       # We support only 64 bit apps.
-      $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_64)
+      my_src_binary_name := $(LOCAL_MODULE_STEM_64)
     else
       # We support only 32 bit apps.
-      $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+      my_src_binary_name := $(LOCAL_MODULE_STEM_32)
     endif
   else
-    $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+    my_src_binary_name := $(LOCAL_MODULE_STEM_32)
   endif
 else
   my_symlink := $(addprefix $(HOST_OUT)/bin/, $(LOCAL_MODULE))
-  ifneq ($(HOST_PREFER_32_BIT),true)
-$(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_64)
-  else
-$(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
-  endif
+  my_src_binary_name := $(LOCAL_MODULE_STEM_64)
 endif
 
-# $(my_symlink) doesn't need to depend on $(PRIVATE_SRC_BINARY_NAME): we can generate symlink to nonexistent file.
-# If you add the dependency, make would compare the timestamp of a file against that of its symlink:
-# they are always equal, because make follows symlink.
-$(my_symlink): $(LOCAL_MODULE_MAKEFILE_DEP)
-	@echo "Symlink: $@ -> $(PRIVATE_SRC_BINARY_NAME)"
-	@mkdir -p $(dir $@)
-	@rm -rf $@
-	$(hide) ln -sf $(PRIVATE_SRC_BINARY_NAME) $@
+$(call symlink-file,$(my_module_path)/$(my_src_binary_name),$(my_src_binary_name),$(my_symlink))
 
 # We need this so that the installed files could be picked up based on the
 # local module name
diff --git a/core/fuzz_test.mk b/core/fuzz_test.mk
index fc582b3..f6d6e9a 100644
--- a/core/fuzz_test.mk
+++ b/core/fuzz_test.mk
@@ -2,6 +2,7 @@
 ## A thin wrapper around BUILD_EXECUTABLE
 ## Common flags for fuzz tests are added.
 ###########################################
+$(call record-module-type,FUZZ_TEST)
 
 ifdef LOCAL_SDK_VERSION
     $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.)
@@ -22,8 +23,8 @@
 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
 endif
 
-LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(LOCAL_MODULE)
 
 ifndef LOCAL_MULTILIB
 ifndef LOCAL_32_BIT_ONLY
diff --git a/core/generate_enforce_rro.mk b/core/generate_enforce_rro.mk
new file mode 100644
index 0000000..579089c
--- /dev/null
+++ b/core/generate_enforce_rro.mk
@@ -0,0 +1,30 @@
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := $(enforce_rro_module)
+
+intermediates := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),,COMMON)
+rro_android_manifest_file := $(intermediates)/AndroidManifest.xml
+
+ifeq (true,$(enforce_rro_source_is_manifest_package_name))
+$(rro_android_manifest_file): PRIVATE_PACKAGE_NAME := $(enforce_rro_source_manifest_package_info)
+$(rro_android_manifest_file): build/tools/generate-enforce-rro-android-manifest.py
+	$(hide) build/tools/generate-enforce-rro-android-manifest.py -u -p $(PRIVATE_PACKAGE_NAME) -o $@
+else
+$(rro_android_manifest_file): PRIVATE_SOURCE_MANIFEST_FILE := $(enforce_rro_source_manifest_package_info)
+$(rro_android_manifest_file): $(enforce_rro_source_manifest_package_info) build/tools/generate-enforce-rro-android-manifest.py
+	$(hide) build/tools/generate-enforce-rro-android-manifest.py -p $(PRIVATE_SOURCE_MANIFEST_FILE) -o $@
+endif
+
+LOCAL_PATH:= $(intermediates)
+
+ifeq ($(enforce_rro_use_res_lib),true)
+LOCAL_RES_LIBRARIES := $(enforce_rro_source_module)
+endif
+
+LOCAL_FULL_MANIFEST_FILE := $(rro_android_manifest_file)
+LOCAL_CERTIFICATE := platform
+
+LOCAL_AAPT_FLAGS += --auto-add-overlay
+LOCAL_RESOURCE_DIR := $(enforce_rro_source_overlays)
+
+include $(BUILD_RRO_PACKAGE)
diff --git a/core/goma.mk b/core/goma.mk
index 6535b3e..4e8318a 100644
--- a/core/goma.mk
+++ b/core/goma.mk
@@ -14,18 +14,11 @@
 # limitations under the License.
 #
 
+# Used by the compiler wrapper, but should only be set by gomacc
+unexport GOMACC_PATH
+
 # Notice: this works only with Google's Goma build infrastructure.
 ifneq ($(filter-out false,$(USE_GOMA)),)
-  # Check if USE_NINJA is not false because GNU make won't work well
-  # with goma. Note this file is evaluated twice, once by GNU make and
-  # once by kati with USE_NINJA=false. We do this check in the former
-  # pass.
-  ifndef KATI
-    ifeq ($(USE_NINJA),false)
-      $(error USE_GOMA=true is not compatible with USE_NINJA=false)
-    endif
-  endif
-
   # Goma requires a lot of processes and file descriptors.
   ifeq ($(shell echo $$(($$(ulimit -u) < 2500 || $$(ulimit -n) < 16000))),1)
     $(warning Max user processes and/or open files are insufficient)
@@ -56,11 +49,9 @@
   # gomacc can start goma client's daemon process automatically, but
   # it is safer and faster to start up it beforehand. We run this as a
   # background process so this won't slow down the build.
-  # We use "ensure_start" command when the compiler_proxy is already
-  # running and uses GOMA_HERMETIC=error flag. The compiler_proxy will
-  # restart otherwise.
-  # TODO(hamaji): Remove this condition after http://b/25676777 is fixed.
-  $(shell ( if ( curl http://localhost:$$($(GOMA_CC) port)/flagz | grep GOMA_HERMETIC=error ); then cmd=ensure_start; else cmd=restart; fi; GOMA_HERMETIC=error $(goma_ctl) $${cmd} ) &> /dev/null &)
+  ifndef NOSTART_GOMA
+    $(shell ( $(goma_ctl) ensure_start ) &> /dev/null &)
+  endif
 
   goma_ctl :=
   goma_dir :=
diff --git a/core/header_library.mk b/core/header_library.mk
new file mode 100644
index 0000000..5144679
--- /dev/null
+++ b/core/header_library.mk
@@ -0,0 +1,72 @@
+$(call record-module-type,HEADER_LIBRARY)
+ifdef LOCAL_IS_HOST_MODULE
+  my_prefix := HOST_
+  LOCAL_HOST_PREFIX :=
+else
+  my_prefix := TARGET_
+endif
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifndef my_module_multilib
+  # libraries default to building for both architecturess
+  my_module_multilib := both
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+  include $(BUILD_SYSTEM)/header_library_internal.mk
+endif
+
+ifdef $(my_prefix)2ND_ARCH
+  LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX)
+  include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+  ifeq ($(my_module_arch_supported),true)
+    # Build for 2ND_ARCH
+    OVERRIDE_BUILT_MODULE_PATH :=
+    LOCAL_BUILT_MODULE :=
+    LOCAL_INSTALLED_MODULE :=
+    LOCAL_INTERMEDIATE_TARGETS :=
+    include $(BUILD_SYSTEM)/header_library_internal.mk
+  endif
+  LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif # 2ND_ARCH
+
+ifdef LOCAL_IS_HOST_MODULE
+  ifdef HOST_CROSS_OS
+    my_prefix := HOST_CROSS_
+    LOCAL_HOST_PREFIX := $(my_prefix)
+
+    include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+    ifeq ($(my_module_arch_supported),true)
+      # Build for 2ND_ARCH
+      OVERRIDE_BUILT_MODULE_PATH :=
+      LOCAL_BUILT_MODULE :=
+      LOCAL_INSTALLED_MODULE :=
+      LOCAL_INTERMEDIATE_TARGETS :=
+      include $(BUILD_SYSTEM)/header_library_internal.mk
+    endif
+
+    ifdef HOST_CROSS_2ND_ARCH
+      LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
+      include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+      ifeq ($(my_module_arch_supported),true)
+        # Build for HOST_CROSS_2ND_ARCH
+        OVERRIDE_BUILT_MODULE_PATH :=
+        LOCAL_BUILT_MODULE :=
+        LOCAL_INSTALLED_MODULE :=
+        LOCAL_INTERMEDIATE_TARGETS :=
+        include $(BUILD_SYSTEM)/header_library_internal.mk
+      endif
+      LOCAL_2ND_ARCH_VAR_PREFIX :=
+    endif
+
+    LOCAL_HOST_PREFIX :=
+  endif
+endif
+
+my_module_arch_supported :=
diff --git a/core/header_library_internal.mk b/core/header_library_internal.mk
new file mode 100644
index 0000000..35ee1bc
--- /dev/null
+++ b/core/header_library_internal.mk
@@ -0,0 +1,21 @@
+###########################################################
+## Standard rules for building a header library.
+##
+## Additional inputs from base_rules.make:
+## None.
+###########################################################
+
+LOCAL_MODULE_CLASS := HEADER_LIBRARIES
+LOCAL_UNINSTALLABLE_MODULE := true
+ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
+$(error $(LOCAL_PATH): Cannot set module stem for a library)
+endif
+
+include $(BUILD_SYSTEM)/binary.mk
+
+ifneq ($(strip $(all_objects)),)
+$(call pretty-error,Header libraries may not have any sources)
+endif
+
+$(LOCAL_BUILT_MODULE):
+	$(hide) touch $@
diff --git a/core/help.mk b/core/help.mk
index 6e0b2c0..c034e79 100644
--- a/core/help.mk
+++ b/core/help.mk
@@ -22,6 +22,7 @@
 	@echo "droid                   Default target"
 	@echo "clean                   (aka clobber) equivalent to rm -rf out/"
 	@echo "snod                    Quickly rebuild the system image from built packages"
+	@echo "vnod                    Quickly rebuild the vendor image from built packages"
 	@echo "offline-sdk-docs        Generate the HTML for the developer SDK docs"
 	@echo "doc-comment-check-docs  Check HTML doc links & validity, without generating HTML"
 	@echo "libandroid_runtime      All the JNI framework stuff"
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
index 83047d4..34e88ce 100644
--- a/core/host_dalvik_java_library.mk
+++ b/core/host_dalvik_java_library.mk
@@ -13,6 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+$(call record-module-type,HOST_DALVIK_JAVA_LIBRARY)
 
 #
 # Rules for building a host dalvik java library. These libraries
@@ -23,15 +24,26 @@
 ifeq ($(HOST_OS),linux)
 USE_CORE_LIB_BOOTCLASSPATH := true
 
+#################################
+include $(BUILD_SYSTEM)/configure_local_jack.mk
+#################################
+
 #######################################
 include $(BUILD_SYSTEM)/host_java_library_common.mk
 #######################################
+ifdef LOCAL_JACK_ENABLED
+ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
+  # For static library, $(LOCAL_BUILT_MODULE) is $(full_classes_jack).
+  LOCAL_BUILT_MODULE_STEM := classes.jack
+endif
+endif
 
 ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
-  LOCAL_JAVA_LIBRARIES += core-oj-hostdex core-libart-hostdex
+  LOCAL_JAVA_LIBRARIES :=  core-oj-hostdex core-libart-hostdex $(LOCAL_JAVA_LIBRARIES)
 endif
 
 full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
+full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar
 full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
 full_classes_jar := $(intermediates.COMMON)/classes.jar
 full_classes_jack := $(intermediates.COMMON)/classes.jack
@@ -40,6 +52,7 @@
 
 LOCAL_INTERMEDIATE_TARGETS += \
     $(full_classes_compiled_jar) \
+    $(full_classes_desugar_jar) \
     $(full_classes_jarjar_jar) \
     $(full_classes_jack) \
     $(full_classes_jar) \
@@ -51,7 +64,11 @@
 ifdef LOCAL_JACK_ENABLED
 LOCAL_CHECKED_MODULE := $(jack_check_timestamp)
 else
+ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
 LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
+else
+LOCAL_CHECKED_MODULE := $(built_dex)
+endif
 endif
 endif
 
@@ -64,12 +81,10 @@
 
 include $(BUILD_SYSTEM)/java_common.mk
 
-# The layers file allows you to enforce a layering between java packages.
-# Run build/tools/java-layers.py for more details.
-layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
-
 $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
 
+ifndef LOCAL_JACK_ENABLED
+
 $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
@@ -81,27 +96,45 @@
         $(full_java_lib_deps) \
         $(jar_manifest_file) \
         $(proto_java_sources_file_stamp) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
         $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
 
+my_desugaring :=
+ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.8)
+my_desugaring := true
+$(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
+$(full_classes_desugar_jar): $(full_classes_compiled_jar) $(DESUGAR)
+	$(desugar-classes-jar)
+endif
+
+ifndef my_desugaring
+full_classes_desugar_jar := $(full_classes_compiled_jar)
+endif
+
 # Run jarjar if necessary, otherwise just copy the file.
 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+$(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
 	@echo JarJar: $@
 	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
 else
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
+full_classes_jarjar_jar := $(full_classes_desugar_jar)
 endif
 
-$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
+$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
 
-ifndef LOCAL_JACK_ENABLED
+ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
+# No dex; all we want are the .class files with resources.
+$(LOCAL_BUILT_MODULE) : $(java_resource_sources)
+$(LOCAL_BUILT_MODULE) : $(full_classes_jar)
+	@echo "host Static Jar: $(PRIVATE_MODULE) ($@)"
+	$(copy-file-to-target)
+
+else # !LOCAL_IS_STATIC_JAVA_LIBRARY
+$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
+$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
+$(built_dex): $(full_classes_jar) $(DX)
+	$(transform-classes.jar-to-dex)
 
 $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
 $(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
@@ -111,33 +144,43 @@
 	$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
 	$(add-dex-to-package)
 
+endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
+
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(PLATFORM_SDK_VERSION)
+endif
+
 else # LOCAL_JACK_ENABLED
 $(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
+  PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
 
 ifeq ($(LOCAL_JACK_ENABLED),incremental)
 $(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
+  PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
 else
 $(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_JACK_INCREMENTAL_DIR :=
+  PRIVATE_JACK_INCREMENTAL_DIR :=
 endif
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_MIN_SDK_VERSION := $(PLATFORM_JACK_MIN_SDK_VERSION)
 
 jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
-        $(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_MODULE_MAKEFILE_DEP) \
-        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK)
+        $(jar_manifest_file) $(proto_java_sources_file_stamp) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(NORMALIZE_PATH) $(JACK_DEFAULT_ARGS) $(JACK)
+
+ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
 $(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack)
-$(built_dex): $(jack_all_deps) | setup-jack-server
+$(built_dex): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
+$(built_dex): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
+$(built_dex): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
 	@echo Building with Jack: $@
 	$(jack-java-to-dex)
 
-$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
-	@echo Checking build with Jack: $@
-	$(jack-check-java)
-
 # $(full_classes_jack) is just by-product of $(built_dex).
 # The dummy command was added because, without it, make misses the fact the $(built_dex) also
 # change $(full_classes_jack).
@@ -151,6 +194,18 @@
 	$(add-dex-to-package)
 	$(add-carried-jack-resources)
 
+else  # LOCAL_IS_STATIC_JAVA_LIBRARY
+$(full_classes_jack): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
+$(full_classes_jack): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
+$(full_classes_jack): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
+	@echo Building with Jack: $@
+	$(java-to-jack)
+
+endif  # LOCAL_IS_STATIC_JAVA_LIBRARY
+
+$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
+	@echo Checking build with Jack: $@
+	$(jack-check-java)
 endif # LOCAL_JACK_ENABLED
 
 USE_CORE_LIB_BOOTCLASSPATH :=
diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk
index c296be3..78faf73 100644
--- a/core/host_dalvik_static_java_library.mk
+++ b/core/host_dalvik_static_java_library.mk
@@ -13,48 +13,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+$(call record-module-type,HOST_DALVIK_STATIC_JAVA_LIBRARY)
 
 #
 # Rules for building a host dalvik static java library.
 # These libraries will be compiled against libcore and not the host
 # JRE.
 #
-ifeq ($(HOST_OS),linux)
-
 LOCAL_UNINSTALLABLE_MODULE := true
 LOCAL_IS_STATIC_JAVA_LIBRARY := true
-USE_CORE_LIB_BOOTCLASSPATH := true
-LOCAL_JAVA_LIBRARIES += core-oj-hostdex core-libart-hostdex
 
-intermediates.COMMON := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),true,COMMON,)
-full_classes_jack := $(intermediates.COMMON)/classes.jack
-LOCAL_INTERMEDIATE_TARGETS += \
-    $(full_classes_jack)
+include $(BUILD_SYSTEM)/host_dalvik_java_library.mk
 
-include $(BUILD_SYSTEM)/host_java_library.mk
-# proguard is not supported
-# *.proto files are not supported
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_MIN_SDK_VERSION := $(PLATFORM_JACK_MIN_SDK_VERSION)
-
-$(full_classes_jack): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jack): \
-	PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
-ifeq ($(LOCAL_JACK_ENABLED),incremental)
-$(full_classes_jack): \
-	PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
-else
-$(full_classes_jack): \
-	PRIVATE_JACK_INCREMENTAL_DIR :=
-endif
-$(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_deps) \
-        $(jar_manifest_file) $(layers_file) $(LOCAL_MODULE_MAKEFILE_DEP) \
-        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
-        $(JACK) | setup-jack-server
-	@echo Building with Jack: $@
-	$(java-to-jack)
-
-USE_CORE_LIB_BOOTCLASSPATH :=
 LOCAL_IS_STATIC_JAVA_LIBRARY :=
-endif
diff --git a/core/host_executable.mk b/core/host_executable.mk
index 6f19bd1..1480c2c 100644
--- a/core/host_executable.mk
+++ b/core/host_executable.mk
@@ -1,3 +1,4 @@
+$(call record-module-type,HOST_EXECUTABLE)
 LOCAL_IS_HOST_MODULE := true
 my_prefix := HOST_
 LOCAL_HOST_PREFIX :=
@@ -5,26 +6,24 @@
 
 ifndef LOCAL_MODULE_HOST_ARCH
 ifndef my_module_multilib
-ifeq ($(HOST_PREFER_32_BIT),true)
-my_module_multilib := 32
-else
 # By default we only build host module for the first arch.
 my_module_multilib := first
 endif
 endif
-endif
 
 ifeq ($(LOCAL_NO_FPIE),)
 LOCAL_LDFLAGS += $(HOST_FPIE_FLAGS)
 endif
 
 ifeq ($(my_module_multilib),both)
+ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
 ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),)
 $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
 endif
 ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),)
 $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
 endif
+endif
 else #!LOCAL_MULTILIB == both
 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
 endif
diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk
index b682ffd..19200fd 100644
--- a/core/host_executable_internal.mk
+++ b/core/host_executable_internal.mk
@@ -29,6 +29,14 @@
 my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
 $(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
 
+my_libdir := $(notdir $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))
+ifeq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
+$(LOCAL_BUILT_MODULE): PRIVATE_RPATHS := ../../$(my_libdir)
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_RPATHS := ../$(my_libdir) $(my_libdir)
+endif
+my_libdir :=
+
 $(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
 	$(transform-host-o-to-executable)
 
diff --git a/core/host_fuzz_test.mk b/core/host_fuzz_test.mk
index cc7baad..1c9eed2 100644
--- a/core/host_fuzz_test.mk
+++ b/core/host_fuzz_test.mk
@@ -2,6 +2,7 @@
 ## A thin wrapper around BUILD_HOST_EXECUTABLE
 ## Common flags for host fuzz tests are added.
 ################################################
+$(call record-module-type,HOST_FUZZ_TEST)
 
 LOCAL_CFLAGS += -fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
 LOCAL_STATIC_LIBRARIES += libLLVMFuzzer
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 97079fd..f1da553 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -14,6 +14,8 @@
 # limitations under the License.
 #
 
+$(call record-module-type,HOST_JAVA_LIBRARY)
+
 #
 # Standard rules for building a host java library.
 #
@@ -35,6 +37,7 @@
 # emma is hardcoded to use the leaf name of its input for the output file --
 # only the output directory can be changed
 full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar))
+full_classes_jar := $(intermediates.COMMON)/classes.jar
 
 LOCAL_INTERMEDIATE_TARGETS += \
     $(full_classes_compiled_jar) \
@@ -55,6 +58,11 @@
 # Run build/tools/java-layers.py for more details.
 layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
 
+# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS
+ifeq ($(RUN_ERROR_PRONE),true)
+LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
+endif
+
 $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
@@ -66,10 +74,13 @@
         $(full_java_lib_deps) \
         $(jar_manifest_file) \
         $(proto_java_sources_file_stamp) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
+        $(NORMALIZE_PATH) \
         $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
 
+javac-check : $(full_classes_compiled_jar)
+javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
+
 # Run jarjar if necessary, otherwise just copy the file.
 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
@@ -77,9 +88,7 @@
 	@echo JarJar: $@
 	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
 else
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
+full_classes_jarjar_jar := $(full_classes_compiled_jar)
 endif
 
 ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
@@ -96,14 +105,9 @@
 # $(full_classes_emma_jar)
 $(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
 	$(transform-classes.jar-to-emma)
-
-$(built_javalib_jar) : $(full_classes_emma_jar)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
-
 else # LOCAL_EMMA_INSTRUMENT
-$(built_javalib_jar): $(full_classes_jarjar_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
+full_classes_emma_jar := $(full_classes_jarjar_jar)
 endif # LOCAL_EMMA_INSTRUMENT
 
+$(eval $(call copy-one-file,$(full_classes_emma_jar),$(LOCAL_BUILT_MODULE)))
+$(eval $(call copy-one-file,$(full_classes_emma_jar),$(full_classes_jar)))
diff --git a/core/host_java_library_common.mk b/core/host_java_library_common.mk
index 35a6e28..8df4b37 100644
--- a/core/host_java_library_common.mk
+++ b/core/host_java_library_common.mk
@@ -26,19 +26,6 @@
 intermediates := $(call local-intermediates-dir)
 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
 
-built_javalib_jar := $(intermediates)/javalib.jar
-
-#################################
-include $(BUILD_SYSTEM)/configure_local_jack.mk
-#################################
-
-ifdef LOCAL_JACK_ENABLED
-ifdef LOCAL_IS_STATIC_JAVA_LIBRARY
-LOCAL_BUILT_MODULE_STEM := classes.jack
-LOCAL_INTERMEDIATE_TARGETS += $(built_javalib_jar)
-endif
-endif
-
 # base_rules.mk looks at this
 all_res_assets :=
 
@@ -61,4 +48,3 @@
 
 LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
 LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
-
diff --git a/core/host_native_test.mk b/core/host_native_test.mk
index 7cba1ae..aa05bb3 100644
--- a/core/host_native_test.mk
+++ b/core/host_native_test.mk
@@ -2,25 +2,22 @@
 ## A thin wrapper around BUILD_HOST_EXECUTABLE
 ## Common flags for host native tests are added.
 ################################################
+$(call record-module-type,HOST_NATIVE_TEST)
+
+ifdef LOCAL_MODULE_CLASS
+ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
+$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must be NATIVE_TESTS with BUILD_HOST_NATIVE_TEST)
+endif
+endif
+
+LOCAL_MODULE_CLASS := NATIVE_TESTS
 
 include $(BUILD_SYSTEM)/host_test_internal.mk
 
-needs_symlink :=
 ifndef LOCAL_MULTILIB
-  ifndef LOCAL_32_BIT_ONLY
-    LOCAL_MULTILIB := both
-
-    ifeq (,$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64))
-      LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-      LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-      needs_symlink := true
-    endif
-  endif
+ifndef LOCAL_32_BIT_ONLY
+LOCAL_MULTILIB := both
+endif
 endif
 
 include $(BUILD_HOST_EXECUTABLE)
-
-ifdef needs_symlink
-include $(BUILD_SYSTEM)/executable_prefer_symlink.mk
-needs_symlink :=
-endif
diff --git a/core/host_prebuilt.mk b/core/host_prebuilt.mk
index 7baab69..79f3ffa 100644
--- a/core/host_prebuilt.mk
+++ b/core/host_prebuilt.mk
@@ -14,5 +14,6 @@
 # limitations under the License.
 #
 
+$(call record-module-type,HOST_PREBUILT)
 LOCAL_IS_HOST_MODULE := true
 include $(BUILD_MULTI_PREBUILT)
diff --git a/core/host_shared_library.mk b/core/host_shared_library.mk
index 2e0c9f1c..5da7913 100644
--- a/core/host_shared_library.mk
+++ b/core/host_shared_library.mk
@@ -1,3 +1,4 @@
+$(call record-module-type,HOST_SHARED_LIBRARY)
 LOCAL_IS_HOST_MODULE := true
 my_prefix := HOST_
 LOCAL_HOST_PREFIX :=
@@ -5,14 +6,10 @@
 
 ifndef LOCAL_MODULE_HOST_ARCH
 ifndef my_module_multilib
-ifeq ($(HOST_PREFER_32_BIT),true)
-my_module_multilib := 32
-else
 # libraries default to building for both architecturess
 my_module_multilib := both
 endif
 endif
-endif
 
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 include $(BUILD_SYSTEM)/module_arch_supported.mk
diff --git a/core/host_shared_library_internal.mk b/core/host_shared_library_internal.mk
index 272e76f..bfbde21 100644
--- a/core/host_shared_library_internal.mk
+++ b/core/host_shared_library_internal.mk
@@ -44,7 +44,6 @@
 $(LOCAL_BUILT_MODULE): \
         $(all_objects) \
         $(all_libraries) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
         $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-o-to-shared-lib)
 
diff --git a/core/host_shared_test_lib.mk b/core/host_shared_test_lib.mk
index 1eb9b26..ed7e23a 100644
--- a/core/host_shared_test_lib.mk
+++ b/core/host_shared_test_lib.mk
@@ -1,8 +1 @@
-##################################################
-## A thin wrapper around BUILD_HOST_SHARED_LIBRARY
-## Common flags for host native tests are added.
-##################################################
-
-include $(BUILD_SYSTEM)/host_test_internal.mk
-
-include $(BUILD_HOST_SHARED_LIBRARY)
+$(error BUILD_HOST_SHARED_TEST_LIBRARY is obsolete)
diff --git a/core/host_static_library.mk b/core/host_static_library.mk
index 068c702..aa0421e 100644
--- a/core/host_static_library.mk
+++ b/core/host_static_library.mk
@@ -1,3 +1,4 @@
+$(call record-module-type,HOST_STATIC_LIBRARY)
 LOCAL_IS_HOST_MODULE := true
 my_prefix := HOST_
 LOCAL_HOST_PREFIX :=
@@ -5,14 +6,10 @@
 
 ifndef LOCAL_MODULE_HOST_ARCH
 ifndef my_module_multilib
-ifeq ($(HOST_PREFER_32_BIT),true)
-my_module_multilib := 32
-else
 # libraries default to building for both architecturess
 my_module_multilib := both
 endif
 endif
-endif
 
 LOCAL_2ND_ARCH_VAR_PREFIX :=
 include $(BUILD_SYSTEM)/module_arch_supported.mk
diff --git a/core/host_static_test_lib.mk b/core/host_static_test_lib.mk
index 5423dc6..a24cd62 100644
--- a/core/host_static_test_lib.mk
+++ b/core/host_static_test_lib.mk
@@ -2,6 +2,7 @@
 ## A thin wrapper around BUILD_HOST_STATIC_LIBRARY
 ## Common flags for host native tests are added.
 ##################################################
+$(call record-module-type,HOST_STATIC_TEST_LIBRARY)
 
 include $(BUILD_SYSTEM)/host_test_internal.mk
 
diff --git a/core/host_test_internal.mk b/core/host_test_internal.mk
index 7f6aff0..ffb22c7 100644
--- a/core/host_test_internal.mk
+++ b/core/host_test_internal.mk
@@ -2,13 +2,30 @@
 ## Shared definitions for all host test compilations.
 #####################################################
 
-LOCAL_CFLAGS_windows += -DGTEST_OS_WINDOWS
-LOCAL_CFLAGS_linux += -DGTEST_OS_LINUX
-LOCAL_LDLIBS_linux += -lpthread
-LOCAL_CFLAGS_darwin += -DGTEST_OS_LINUX
-LOCAL_LDLIBS_darwin += -lpthread
+ifeq ($(LOCAL_GTEST),true)
+  LOCAL_CFLAGS_windows += -DGTEST_OS_WINDOWS
+  LOCAL_CFLAGS_linux += -DGTEST_OS_LINUX
+  LOCAL_LDLIBS_linux += -lpthread
+  LOCAL_CFLAGS_darwin += -DGTEST_OS_MAC
+  LOCAL_LDLIBS_darwin += -lpthread
 
-LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g
-LOCAL_C_INCLUDES +=  external/gtest/include
+  LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g
 
-LOCAL_STATIC_LIBRARIES += libgtest_main_host libgtest_host
+  LOCAL_STATIC_LIBRARIES += libgtest_main_host libgtest_host
+endif
+
+ifdef LOCAL_MODULE_PATH
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE))
+endif
+
+ifdef LOCAL_MODULE_PATH_32
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE))
+endif
+
+ifdef LOCAL_MODULE_PATH_64
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
+endif
+
+ifndef LOCAL_MODULE_RELATIVE_PATH
+LOCAL_MODULE_RELATIVE_PATH := $(LOCAL_MODULE)
+endif
diff --git a/core/install_jni_libs.mk b/core/install_jni_libs.mk
index 625a8a2..6b550c1 100644
--- a/core/install_jni_libs.mk
+++ b/core/install_jni_libs.mk
@@ -18,9 +18,19 @@
 ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),)
 my_embed_jni := true
 endif
-ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),)
-# If this app isn't to be installed to system partitions.
-my_embed_jni := true
+ifeq ($(PRODUCT_FULL_TREBLE),true)
+  ifeq ($(filter $(TARGET_OUT)/%, $(my_module_path)),)
+    # If this app isn't to be installed to the system partition, and the device
+    # is fully treble-ized then jni libs are embedded, Otherwise, access to the
+    # directory where the lib is installed to (usually /vendor/lib) needs to be
+    # allowed for system processes, which is a Treble violation.
+    my_embed_jni := true
+  endif
+else
+  ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),)
+    # If this app isn't to be installed to system, vendor, or oem partitions.
+    my_embed_jni := true
+  endif
 endif
 
 jni_shared_libraries :=
diff --git a/core/install_jni_libs_internal.mk b/core/install_jni_libs_internal.mk
index 27b9697..c5804a4 100644
--- a/core/install_jni_libs_internal.mk
+++ b/core/install_jni_libs_internal.mk
@@ -32,10 +32,10 @@
 endif
 ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT))
 my_jni_shared_libraries += \
-    $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_$(my_2nd_arch_prefix)CPU_ABI)/libstlport_shared.so
+    $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources/cxx-stl/stlport/libs/$(TARGET_$(my_2nd_arch_prefix)CPU_ABI)/libstlport_shared.so
 else ifeq (c++_shared,$(LOCAL_NDK_STL_VARIANT))
 my_jni_shared_libraries += \
-    $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/llvm-libc++/libs/$(TARGET_$(my_2nd_arch_prefix)CPU_ABI)/libc++_shared.so
+    $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources/cxx-stl/llvm-libc++/libs/$(TARGET_$(my_2nd_arch_prefix)CPU_ABI)/libc++_shared.so
 endif
 
 # Set the abi directory used by the local JNI shared libraries.
@@ -59,6 +59,8 @@
 $(LOCAL_INSTALLED_MODULE) : $(addprefix $(my_shared_library_path)/, $(my_jni_filenames))
 
 # Create symlink in the app specific lib path
+# Skip creating this symlink when running the second part of a target sanitization build.
+ifndef SANITIZE_TARGET
 ifdef LOCAL_POST_INSTALL_CMD
 # Add a shell command separator
 LOCAL_POST_INSTALL_CMD += ;
@@ -70,6 +72,11 @@
   mkdir -p $(my_app_lib_path) \
   $(foreach lib, $(my_jni_filenames), ;ln -sf $(my_symlink_target_dir)/$(lib) $(my_app_lib_path)/$(lib))
 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
+else
+ifdef LOCAL_POST_INSTALL_CMD
+$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
+endif
+endif
 
 # Clear jni_shared_libraries to not embed it into the apk.
 my_jni_shared_libraries :=
@@ -98,3 +105,33 @@
 endif  # my_embed_jni
 endif  # inner my_prebuilt_jni_libs
 endif  # outer my_prebuilt_jni_libs
+
+# Verify that all included libraries are built against the NDK
+ifneq ($(strip $(LOCAL_JNI_SHARED_LIBRARIES)),)
+my_link_type := $(call intermediates-dir-for,APPS,$(LOCAL_MODULE))/$(my_2nd_arch_prefix)jni_link_type
+all_link_types: $(my_link_type)
+my_link_type_deps := $(strip \
+  $(foreach l,$(LOCAL_JNI_SHARED_LIBRARIES),\
+    $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),,,$(my_2nd_arch_prefix))/link_type))
+ifneq ($(LOCAL_SDK_VERSION),)
+$(my_link_type): PRIVATE_LINK_TYPE := app:sdk
+$(my_link_type): PRIVATE_WARN_TYPES := native:platform
+$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk
+else
+$(my_link_type): PRIVATE_LINK_TYPE := app:platform
+$(my_link_type): PRIVATE_WARN_TYPES :=
+$(my_link_type): PRIVATE_ALLOWED_TYPES := native:ndk native:platform
+endif
+$(eval $(call link-type-partitions,$(my_link_type)))
+$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
+$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
+$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
+	@echo Check JNI module types: $@
+	$(check-link-type)
+
+$(LOCAL_BUILT_MODULE): | $(my_link_type)
+
+my_link_type :=
+my_link_type_deps :=
+endif
diff --git a/core/jack-default.args b/core/jack-default.args
index 8d70a82..0232301 100644
--- a/core/jack-default.args
+++ b/core/jack-default.args
@@ -2,4 +2,6 @@
 -D sched.runner.thread.kind=fixed
 -D sched.runner.thread.fixed.count=4
 --sanity-checks off
--D jack.reporter.level.file=error=--,warning=-
\ No newline at end of file
+-D jack.reporter.level.file=error=--,warning=-
+--verbose error
+-D jack.jayce.cache=false
diff --git a/core/java.mk b/core/java.mk
index 2602daf..b31e316 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -67,7 +67,11 @@
   ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
     LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano
   else
-    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite
+    ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream)
+      # No library for stream protobufs
+    else
+      LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite
+    endif
   endif
 endif
 endif
@@ -109,20 +113,15 @@
 LOCAL_PROGUARD_ENABLED :=
 endif
 
-ifdef LOCAL_PROGUARD_ENABLED
-proguard_jar_leaf := proguard.classes.jar
-else
-proguard_jar_leaf := noproguard.classes.jar
-endif
-
 full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_jar_leaf)
+full_classes_desugar_jar := $(intermediates.COMMON)/classes-desugar.jar
 jarjar_leaf := classes-jarjar.jar
 full_classes_jarjar_jar := $(intermediates.COMMON)/$(jarjar_leaf)
 emma_intermediates_dir := $(intermediates.COMMON)/emma_out
 # emma is hardcoded to use the leaf name of its input for the output file --
 # only the output directory can be changed
 full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf)
-full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf)
+full_classes_proguard_jar := $(intermediates.COMMON)/classes-proguard.jar
 built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)/classes.dex
 full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
 
@@ -142,6 +141,7 @@
 
 LOCAL_INTERMEDIATE_TARGETS += \
     $(full_classes_compiled_jar) \
+    $(full_classes_desugar_jar) \
     $(full_classes_jarjar_jar) \
     $(full_classes_emma_jar) \
     $(full_classes_jar) \
@@ -169,7 +169,7 @@
 ifneq ($(renderscript_sources),)
 renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
 RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp
-renderscript_intermediate.COMMON := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript
+renderscript_intermediate.COMMON := $(intermediates.COMMON)/renderscript
 
 # Defaulting to an empty string uses the latest available platform SDK.
 renderscript_target_api :=
@@ -213,7 +213,7 @@
 else
 LOCAL_RENDERSCRIPT_INCLUDES := \
     $(TOPDIR)external/clang/lib/Headers \
-    $(TOPDIR)frameworks/rs/scriptc \
+    $(TOPDIR)frameworks/rs/script_api/include \
     $(LOCAL_RENDERSCRIPT_INCLUDES)
 endif
 
@@ -306,10 +306,9 @@
 ## AIDL: Compile .aidl files to .java
 ###########################################################
 aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
+aidl_java_sources :=
 
 ifneq ($(strip $(aidl_sources)),)
-aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
-aidl_sources := $(addprefix $(LOCAL_PATH)/, $(aidl_sources))
 
 aidl_preprocess_import :=
 ifdef LOCAL_SDK_VERSION
@@ -323,20 +322,17 @@
 # build against the platform.
 LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
 endif # LOCAL_SDK_VERSION
-$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
 
-$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \
-        $(LOCAL_PATH)/%.aidl \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
-        $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-        $(AIDL) \
-        $(aidl_preprocess_import)
-	$(transform-aidl-to-java)
+$(foreach s,$(aidl_sources),\
+    $(eval $(call define-aidl-java-rule,$(s),$(intermediates.COMMON),aidl_java_sources)))
 $(foreach java,$(aidl_java_sources), \
     $(call include-depfile,$(java:%.java=%.P),$(java)))
 
-else
-aidl_java_sources :=
+$(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import)
+
+$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
+$(aidl_java_sources): PRIVATE_MODULE := $(LOCAL_MODULE)
+
 endif
 
 ##########################################
@@ -348,7 +344,11 @@
 ifndef LOCAL_CHECKED_MODULE
 ifdef full_classes_jar
 ifdef LOCAL_JACK_ENABLED
+ifeq ($(LOCAL_JACK_ENABLED),javac_frontend)
+LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
+else
 LOCAL_CHECKED_MODULE := $(jack_check_timestamp)
+endif
 else
 LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
 endif
@@ -367,7 +367,8 @@
 logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
 logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources))
 
-$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
+$(logtags_java_sources): PRIVATE_MERGED_TAG := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
+$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt $(JAVATAGS) build/tools/event_log_tags.py
 	$(transform-logtags-to-java)
 
 else
@@ -381,6 +382,9 @@
 
 include $(BUILD_SYSTEM)/java_common.mk
 
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES := $(if $(renderscript_sources),true)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RS_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/renderscript
+
 #######################################
 # defines built_odex along with rule to install odex
 include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
@@ -405,15 +409,7 @@
 # Droiddoc isn't currently able to generate stubs for modules, so we're just
 # allowing it to use the classes.jar as the "stubs" that would be use to link
 # against, for the cases where someone needs the jar to link against.
-# - Use the classes.jar instead of the handful of other intermediates that
-#   we have, because it's the most processed, but still hasn't had dex run on
-#   it, so it's closest to what's on the device.
-# - This extra copy, with the dependency on LOCAL_BUILT_MODULE allows the
-#   PRIVATE_ vars to be preserved.
-$(full_classes_stubs_jar): PRIVATE_SOURCE_FILE := $(full_classes_jar)
-$(full_classes_stubs_jar) : $(full_classes_jar) | $(ACP)
-	@echo Copying $(PRIVATE_SOURCE_FILE)
-	$(hide) $(ACP) -fp $(PRIVATE_SOURCE_FILE) $@
+$(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar)))
 ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
 
 # The layers file allows you to enforce a layering between java packages.
@@ -422,14 +418,16 @@
 $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
 $(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE)
 
-ifdef LOCAL_RMTYPEDEFS
-$(full_classes_compiled_jar): | $(RMTYPEDEFS)
-endif
-
 # Compile the java files to a .jar file.
 # This intentionally depends on java_sources, not all_java_sources.
 # Deps for generated source files must be handled separately,
 # via deps on the target that generates the sources.
+
+# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS
+ifeq ($(RUN_ERROR_PRONE),true)
+LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
+endif
+
 $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
@@ -443,24 +441,37 @@
         $(layers_file) \
         $(RenderScript_file_stamp) \
         $(proto_java_sources_file_stamp) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
+        $(NORMALIZE_PATH) \
         $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-java-to-classes.jar)
 
-# Run jarjar if necessary, otherwise just copy the file.
+javac-check : $(full_classes_compiled_jar)
+javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
+
+my_desugaring :=
+ifndef LOCAL_JACK_ENABLED
+ifndef LOCAL_IS_STATIC_JAVA_LIBRARY
+my_desugaring := true
+$(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
+$(full_classes_desugar_jar): $(full_classes_compiled_jar) $(DESUGAR)
+	$(desugar-classes-jar)
+endif
+endif
+
+ifndef my_desugaring
+full_classes_desugar_jar := $(full_classes_compiled_jar)
+endif
+
+# Run jarjar if necessary
 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+$(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
 	@echo JarJar: $@
 	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
 else
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
+full_classes_jarjar_jar := $(full_classes_desugar_jar)
 endif
 
-full_classes_jar_source := $(full_classes_jarjar_jar)
-ifndef LOCAL_JACK_ENABLED
 ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
 $(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.emma.ignore
 $(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
@@ -477,18 +488,18 @@
 # $(full_classes_emma_jar)
 $(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(EMMA_JAR)
 	$(transform-classes.jar-to-emma)
-full_classes_jar_source := $(full_classes_emma_jar)
+
+else
+full_classes_emma_jar := $(full_classes_jarjar_jar)
 endif
-endif
+
+# TODO: this should depend on full_classes_emma_jar once coverage works again
+full_classes_pre_proguard_jar := $(full_classes_jarjar_jar)
 
 # Keep a copy of the jar just before proguard processing.
-$(full_classes_jar): $(full_classes_jar_source) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
+$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(intermediates.COMMON)/classes-pre-proguard.jar))
 
-$(call define-jar-to-toc-rule, $(full_classes_jar))
-
-# Run proguard if necessary, otherwise just copy the file.
+# Run proguard if necessary
 ifdef LOCAL_PROGUARD_ENABLED
 ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
     $(warning while processing: $(LOCAL_MODULE))
@@ -518,29 +529,37 @@
 endif
 
 # jack already has the libraries in its classpath and doesn't support jars
-legacy_proguard_flags := $(addprefix -libraryjars ,$(my_support_library_sdk_raise) $(full_shared_java_libs))
+legacy_proguard_flags := $(addprefix -libraryjars ,$(my_support_library_sdk_raise) \
+  $(filter-out $(my_support_library_sdk_raise),$(full_shared_java_libs)))
 
 legacy_proguard_flags += -printmapping $(proguard_dictionary)
 jack_proguard_flags := -printmapping $(jack_dictionary)
 
 common_proguard_flags := -forceprocessing
 
+common_proguard_flag_files :=
 ifeq ($(filter nosystem,$(LOCAL_PROGUARD_ENABLED)),)
-common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.flags
+common_proguard_flag_files += $(BUILD_SYSTEM)/proguard.flags
 ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
 ifdef LOCAL_JACK_ENABLED
-common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
+common_proguard_flag_files += $(BUILD_SYSTEM)/proguard.jacoco.flags
 else
 common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.emma.flags
 endif # LOCAL_JACK_ENABLED
 endif
 # If this is a test package, add proguard keep flags for tests.
 ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
-common_proguard_flags += -include $(BUILD_SYSTEM)/proguard_tests.flags
+common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_tests.flags
 ifeq ($(filter shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
 common_proguard_flags += -dontshrink # don't shrink tests by default
 endif # shrinktests
 endif # test package
+ifneq ($(common_proguard_flag_files),)
+common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files))
+# This is included from $(BUILD_SYSTEM)/proguard.flags
+common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_basic_keeps.flags
+endif
+
 ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
 # By default no obfuscation
 common_proguard_flags += -dontobfuscate
@@ -590,22 +609,38 @@
 else
 extra_input_jar :=
 endif
+
+# If not using jack and building against the current SDK version then filter
+# out junit and android.test classes from the application that are to be
+# removed from the Android API as part of b/30188076 but which are still
+# present in the Android API. This is to allow changes to be made to the
+# build to statically include those classes into the application without
+# simultaneously removing those classes from the API.
+proguard_injar_filters :=
+ifndef LOCAL_JACK_ENABLED
+ifdef LOCAL_SDK_VERSION
+ifeq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+proguard_injar_filters := (!junit/framework/**,!junit/runner/**,!android/test/**)
+endif
+endif
+endif
+
+$(full_classes_proguard_jar): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters)
 $(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
 $(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
-$(full_classes_proguard_jar) : $(full_classes_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(proguard_flag_files) | $(ACP) $(PROGUARD)
+$(full_classes_proguard_jar) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) | $(PROGUARD)
 	$(call transform-jar-to-proguard)
 
 else  # LOCAL_PROGUARD_ENABLED not defined
-$(full_classes_proguard_jar) : $(full_classes_jar)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
-
+full_classes_proguard_jar := $(full_classes_pre_proguard_jar)
 endif # LOCAL_PROGUARD_ENABLED defined
 
+$(eval $(call copy-one-file,$(full_classes_proguard_jar),$(full_classes_jar)))
+
+$(call define-jar-to-toc-rule, $(full_classes_jar))
+
+ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
 ifndef LOCAL_JACK_ENABLED
-# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
-# will work even when intermediates != intermediates.COMMON.
-$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
 $(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
 # If you instrument class files that have local variable debug information in
 # them emma does not correctly maintain the local variable table.
@@ -616,22 +651,25 @@
 ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
 $(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals
 endif
+$(built_dex_intermediate): $(full_classes_jar) $(DX)
+	$(transform-classes.jar-to-dex)
 endif # LOCAL_JACK_ENABLED is disabled
 
-$(built_dex): $(built_dex_intermediate) | $(ACP)
+$(built_dex): $(built_dex_intermediate)
 	@echo Copying: $@
 	$(hide) mkdir -p $(dir $@)
 	$(hide) rm -f $(dir $@)/classes*.dex
-	$(hide) $(ACP) -fp $(dir $<)/classes*.dex $(dir $@)
-ifneq ($(GENERATE_DEX_DEBUG),)
-	$(install-dex-debug)
-endif
+	$(hide) cp -fp $(dir $<)/classes*.dex $(dir $@)
+
+java-dex: $(built_dex)
+
+endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
 
 findbugs_xml := $(intermediates.COMMON)/findbugs.xml
 $(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
     $(call normalize-path-list,$(filter %.jar,$(full_java_libs)))))
 $(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS)
-$(findbugs_xml) : $(full_classes_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS))
+$(findbugs_xml) : $(full_classes_pre_proguard_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS))
 	@echo Findbugs: $@
 	$(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \
 		$(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \
@@ -653,6 +691,14 @@
 
 endif  # full_classes_jar is defined
 
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(PLATFORM_SDK_VERSION)
+endif
+
 ifdef LOCAL_JACK_ENABLED
 $(LOCAL_INTERMEDIATE_TARGETS): \
 	PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
@@ -694,16 +740,19 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
 
 jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
-        $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) $(proguard_flag_files) \
+        $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) \
+        $(common_proguard_flag_files) $(proguard_flag_files) \
         $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) $(JACK)
+        $(NORMALIZE_PATH) $(JACK_DEFAULT_ARGS) $(JACK)
 
 $(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
 	@echo Checking build with Jack: $@
 	$(jack-check-java)
 
 ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
-$(full_classes_jack): $(jack_all_deps) | setup-jack-server
+$(full_classes_jack): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
+$(full_classes_jack): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
+$(full_classes_jack): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
 	@echo Building with Jack: $@
 	$(java-to-jack)
 
@@ -716,6 +765,8 @@
 $(built_dex_intermediate): PRIVATE_CLASSES_JACK := $(full_classes_jack)
 
 ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
+LOCAL_JACK_PLUGIN_PATH += $(HOST_OUT_JAVA_LIBRARIES)/jack-coverage-plugin.jar
+LOCAL_JACK_PLUGIN += com.android.jack.coverage.CodeCoverage
 $(built_dex_intermediate): PRIVATE_JACK_COVERAGE_OPTIONS := \
     -D jack.coverage=true \
     -D jack.coverage.metadata.file=$(intermediates.COMMON)/coverage.em \
@@ -726,7 +777,29 @@
 $(built_dex_intermediate): PRIVATE_JACK_COVERAGE_OPTIONS :=
 endif
 
-$(built_dex_intermediate): $(jack_all_deps) | setup-jack-server
+# Compiling with javac to jar, then converting jar to dex with jack
+ifeq ($(LOCAL_JACK_ENABLED),javac_frontend)
+
+# PRIVATE_EXTRA_JAR_ARGS and source files were already handled during javac
+$(built_dex_intermediate): PRIVATE_EXTRA_JAR_ARGS :=
+$(built_dex_intermediate): PRIVATE_JAVA_SOURCES :=
+$(built_dex_intermediate): PRIVATE_SOURCE_INTERMEDIATES_DIR :=
+$(built_dex_intermediate): PRIVATE_HAS_PROTO_SOURCES :=
+$(built_dex_intermediate): PRIVATE_HAS_RS_SOURCES :=
+
+# Incremental compilation is not supported when mixing javac and jack
+$(built_dex_intermediate): PRIVATE_JACK_INCREMENTAL_DIR :=
+
+# Pass output of javac to jack
+$(built_dex_intermediate): PRIVATE_JACK_IMPORT_JAR := $(full_classes_compiled_jar)
+$(built_dex_intermediate): $(full_classes_compiled_jar)
+else # LOCAL_JACK_ENABLED != javac_frontend
+$(built_dex_intermediate): PRIVATE_JACK_IMPORT_JAR :=
+endif # LOCAL_JACK_ENABLED != javac_frontend
+
+$(built_dex_intermediate): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
+$(built_dex_intermediate): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
+$(built_dex_intermediate): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
 	@echo Building with Jack: $@
 	$(jack-java-to-dex)
 
@@ -740,9 +813,11 @@
 
 endif #LOCAL_IS_STATIC_JAVA_LIBRARY
 
+$(noshrob_classes_jack): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
+$(noshrob_classes_jack): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
 $(noshrob_classes_jack): PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-noshrob-rsc
 $(noshrob_classes_jack): PRIVATE_JACK_PROGUARD_FLAGS :=
-$(noshrob_classes_jack): $(jack_all_deps) | setup-jack-server
+$(noshrob_classes_jack): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
 	@echo Building with Jack: $@
 	$(java-to-jack)
 endif  # full_classes_jar is defined
diff --git a/core/java_common.mk b/core/java_common.mk
index 9b7d10f..03856ac 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -19,7 +19,12 @@
   ifneq (,$(filter $(LOCAL_SDK_VERSION), $(private_sdk_versions_without_any_java_18_support)))
     LOCAL_JAVA_LANGUAGE_VERSION := 1.7
   else
-    LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+    # This retains 1.7 for ART build bots only. http://b/27583810
+    ifeq (,$(LEGACY_USE_JAVA7))
+      LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+    else
+      LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+    endif
   endif
 endif
 LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION)
@@ -34,9 +39,7 @@
 ifneq ($(proto_sources),)
 proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
 
-# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
-# automatically found by the java compiling function transform-java-to-classes.jar.
-proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
+proto_java_intemediate_dir := $(intermediates.COMMON)/proto
 proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
 proto_java_sources_dir := $(proto_java_intemediate_dir)/src
 
@@ -49,7 +52,12 @@
   ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
   else
+    ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javastream_out
+$(proto_java_sources_file_stamp): $(HOST_OUT_EXECUTABLES)/protoc-gen-javastream
+    else
 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
+    endif
   endif
 endif
 $(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
@@ -128,6 +136,15 @@
   extra_jar_args :=
 endif # java_resource_file_groups
 
+#####################################
+## Warn if there is unrecognized file in LOCAL_SRC_FILES.
+my_unknown_src_files := $(filter-out \
+  %.java %.aidl %.proto %.logtags %.fs %.rs, \
+  $(LOCAL_SRC_FILES) $(LOCAL_INTERMEDIATE_SOURCES) $(LOCAL_GENERATED_SOURCES))
+ifneq ($(my_unknown_src_files),)
+$(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unknown_src_files))
+endif
+
 ######################################
 ## PRIVATE java vars
 # LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
@@ -139,7 +156,7 @@
 full_static_java_libs := \
     $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
       $(call intermediates-dir-for, \
-        JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
+        JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jar)
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
 
@@ -148,6 +165,9 @@
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_PROTO_SOURCES := $(if $(proto_sources),true)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/proto
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES :=
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
@@ -201,11 +221,11 @@
 ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
 my_bootclasspath := ""
 else
-my_bootclasspath := $(call normalize-path-list,$(call host-dex-java-lib-files,core-oj-hostdex core-libart-hostdex))
+my_bootclasspath := $(call normalize-path-list,$(call java-lib-files,core-oj-hostdex core-libart-hostdex,true))
 endif
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_bootclasspath)
 
-full_shared_java_libs := $(call host-dex-java-lib-files,$(LOCAL_JAVA_LIBRARIES))
+full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
 full_java_lib_deps := $(full_shared_java_libs)
 else # !USE_CORE_LIB_BOOTCLASSPATH
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
@@ -227,7 +247,7 @@
   link_apk_libraries := \
       $(foreach lib,$(apk_libraries), \
         $(call intermediates-dir-for, \
-              APPS,$(lib),,COMMON)/classes.jar)
+              APPS,$(lib),,COMMON)/classes-pre-proguard.jar)
 
   # link against the jar with full original names (before proguard processing).
   full_shared_java_libs += $(link_apk_libraries)
@@ -248,7 +268,7 @@
   link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
       APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
   # link against the jar with full original names (before proguard processing).
-  link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
+  link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes-pre-proguard.jar
   full_java_libs += $(link_instr_classes_jar)
   full_java_lib_deps += $(link_instr_classes_jar)
 endif  # LOCAL_INSTRUMENTATION_FOR
@@ -317,54 +337,16 @@
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JACK_LIBRARIES := $(full_static_jack_libs)
 
-ifndef LOCAL_IS_HOST_MODULE
-ifeq ($(LOCAL_SDK_VERSION),)
-ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
-my_bootclasspath :=
-else
-my_bootclasspath := $(call jack-lib-files,core-oj core-libart)
-endif
-else  # LOCAL_SDK_VERSION
-ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
-# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
-my_bootclasspath := $(call jack-lib-files,android_stubs_current)
-else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
-my_bootclasspath := $(call jack-lib-files,android_system_stubs_current)
-else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
-my_bootclasspath := $(call jack-lib-files,android_test_stubs_current)
-else
-my_bootclasspath :=$(call jack-lib-files,sdk_v$(LOCAL_SDK_VERSION))
-endif # current, system_current, or test_current
-endif # LOCAL_SDK_VERSION
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(my_bootclasspath)
-
 full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
-full_jack_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+full_jack_deps := $(full_shared_jack_libs)
+
+ifndef LOCAL_IS_HOST_MODULE
 # Turn off .toc optimization for apps build as we cannot build dexdump.
 ifeq (,$(TARGET_BUILD_APPS))
 full_jack_deps := $(patsubst %.jack, %.dex.toc, $(full_jack_deps))
 endif
-
-else # LOCAL_IS_HOST_MODULE
-
-ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
-ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
-my_bootclasspath :=
-else
-my_bootclasspath := $(call jack-lib-files,core-oj-hostdex core-libart-hostdex,$(LOCAL_IS_HOST_MODULE))
-endif
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(my_bootclasspath)
-# Compiling against the final jack library. If we want to add support for obfuscated library
-# we'll need to change that to compile against the not obfuscated jack library.
-full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
-full_jack_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
-else
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES :=
-full_shared_jack_libs := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
-full_jack_deps := $(full_shared_jack_libs)
-endif # USE_CORE_LIB_BOOTCLASSPATH
 endif # !LOCAL_IS_HOST_MODULE
-full_jack_libs := $(full_shared_jack_libs) $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
+full_shared_jack_libs += $(LOCAL_JACK_CLASSPATH)
 full_jack_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
 
 ifndef LOCAL_IS_HOST_MODULE
@@ -378,7 +360,6 @@
 
   # link against the jar with full original names (before proguard processing).
   full_shared_jack_libs += $(link_apk_jack_libraries)
-  full_jack_libs += $(link_apk_jack_libraries)
   full_jack_deps += $(link_apk_jack_libraries)
 endif
 
@@ -388,14 +369,52 @@
 ifdef LOCAL_INSTRUMENTATION_FOR
    # link against the jar with full original names (before proguard processing).
    link_instr_classes_jack := $(link_instr_intermediates_dir.COMMON)/classes.noshrob.jack
-   full_jack_libs += $(link_instr_classes_jack)
+   full_shared_jack_libs += $(link_instr_classes_jack)
    full_jack_deps += $(link_instr_classes_jack)
 endif  # LOCAL_INSTRUMENTATION_FOR
 endif  # !LOCAL_IS_HOST_MODULE
 
 # Propagate local configuration options to this target.
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JACK_LIBRARIES:= $(full_jack_libs)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_SHARED_LIBRARIES:= $(full_shared_jack_libs)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
 
 endif  # need_compile_java
 endif # LOCAL_JACK_ENABLED
+
+
+###########################################################
+# Verify that all libraries are safe to use
+###########################################################
+ifndef LOCAL_IS_HOST_MODULE
+my_link_type := $(intermediates.COMMON)/link_type
+all_link_types: $(my_link_type)
+my_link_type_deps := $(strip \
+  $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES),\
+    $(call intermediates-dir-for, \
+      JAVA_LIBRARIES,$(lib),,COMMON)/link_type) \
+  $(foreach lib,$(apk_libraries), \
+    $(call intermediates-dir-for, \
+      APPS,$(lib),,COMMON)/link_type))
+ifeq ($(LOCAL_SDK_VERSION),system_current)
+$(my_link_type): PRIVATE_LINK_TYPE := java:system
+$(my_link_type): PRIVATE_WARN_TYPES := java:platform
+$(my_link_type): PRIVATE_ALLOWED_TYPES := java:sdk java:system
+else ifneq ($(LOCAL_SDK_VERSION),)
+$(my_link_type): PRIVATE_LINK_TYPE := java:sdk
+$(my_link_type): PRIVATE_WARN_TYPES := java:system java:platform
+$(my_link_type): PRIVATE_ALLOWED_TYPES := java:sdk
+else
+$(my_link_type): PRIVATE_LINK_TYPE := java:platform
+$(my_link_type): PRIVATE_WARN_TYPES :=
+$(my_link_type): PRIVATE_ALLOWED_TYPES := java:sdk java:system java:platform
+endif
+$(eval $(call link-type-partitions,$(my_link_type)))
+$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
+$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(my_link_type): PRIVATE_MAKEFILE := $(LOCAL_MODULE_MAKEFILE)
+$(my_link_type): $(my_link_type_deps) $(CHECK_LINK_TYPE)
+	@echo Check Java library module types: $@
+	$(check-link-type)
+
+$(LOCAL_BUILT_MODULE): $(my_link_type)
+endif  # !LOCAL_IS_HOST_MODULE
diff --git a/core/java_library.mk b/core/java_library.mk
index 81a4a6a..9db587d 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -2,6 +2,7 @@
 ## Standard rules for building a java library.
 ##
 ###########################################################
+$(call record-module-type,JAVA_LIBRARY)
 
 ifdef LOCAL_IS_HOST_MODULE
 $(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY)
@@ -34,9 +35,14 @@
 endif
 endif
 
+# For non-static java libraries, other modules should depend on
+# out/target/common/obj/JAVA_LIBRARIES/.../javalib.jar (for jack)
+# or out/target/common/obj/JAVA_LIBRARIES/.../classes.jar (for javac).
+# For static java libraries, other modules should depend on
+# out/target/common/obj/JAVA_LIBRARIES/.../classes.jar
+# There are some dependencies outside the build system that assume static
+# java libraries produce javalib.jar, so we will copy classes.jar there too.
 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
-
-# This file will be the one that other modules should depend on.
 common_javalib.jar := $(intermediates.COMMON)/javalib.jar
 LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
 
@@ -64,27 +70,20 @@
 #################################
 
 ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
-# No dex; all we want are the .class files with resources.
-$(common_javalib.jar) : $(java_resource_sources)
-ifdef LOCAL_PROGUARD_ENABLED
-$(common_javalib.jar) : $(full_classes_proguard_jar)
-else
-$(common_javalib.jar) : $(full_classes_jar)
-endif
-	@echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target)
+# There are some dependencies outside the build system that assume classes.jar
+# is available as javalib.jar so copy it there too.
+$(eval $(call copy-one-file,$(full_classes_jar),$(common_javalib.jar)))
 
 ifdef LOCAL_JACK_ENABLED
-$(LOCAL_BUILT_MODULE) : $(full_classes_jack)
+$(eval $(call copy-one-file,$(full_classes_jack),$(LOCAL_BUILT_MODULE)))
 else
-$(LOCAL_BUILT_MODULE) : $(common_javalib.jar)
+$(eval $(call copy-one-file,$(full_classes_jar),$(LOCAL_BUILT_MODULE)))
 endif
-	$(copy-file-to-target)
 
 else # !LOCAL_IS_STATIC_JAVA_LIBRARY
 
 $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
-$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
 $(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
 $(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME)
 	@echo "target Jar: $(PRIVATE_MODULE) ($@)"
@@ -103,8 +102,7 @@
 ifneq ($(dexpreopt_boot_jar_module),) # boot jar
 # boot jar's rules are defined in dex_preopt.mk
 dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
-$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP)
-	$(call copy-file-to-target)
+$(eval $(call copy-one-file,$(dexpreopted_boot_jar),$(LOCAL_BUILT_MODULE)))
 
 # For libart boot jars, we don't have .odex files.
 else # ! boot jar
@@ -114,8 +112,7 @@
 	@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
 	$(call dexpreopt-one-file,$<,$@)
 
-$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
-	$(call copy-file-to-target)
+$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
@@ -123,8 +120,7 @@
 endif # ! boot jar
 
 else # LOCAL_DEX_PREOPT
-$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
-	$(call copy-file-to-target)
+$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
 
 endif # LOCAL_DEX_PREOPT
 endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
deleted file mode 100644
index f4633d0..0000000
--- a/core/legacy_prebuilts.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-
-# This is the list of modules grandfathered to use ALL_PREBUILT
-
-# DO NOT ADD ANY NEW MODULE TO THIS FILE
-#
-# ALL_PREBUILT modules are hard to control and audit and we don't want
-# to add any new such module in the system
-
-GRANDFATHERED_ALL_PREBUILT := \
-	bmgr \
-	ime \
-	input \
-	monkey \
-	pm \
-	RFFspeed_501.bmd \
-	RFFstd_501.bmd \
-	svc
diff --git a/core/local_vndk.mk b/core/local_vndk.mk
new file mode 100644
index 0000000..5ac5f26
--- /dev/null
+++ b/core/local_vndk.mk
@@ -0,0 +1,40 @@
+
+#Set LOCAL_USE_VNDK for modules going into vendor partition, except for host modules
+#If LOCAL_SDK_VERSION is set, thats a more restrictive set, so they dont need LOCAL_USE_VNDK
+ifndef LOCAL_IS_HOST_MODULE
+ifndef LOCAL_SDK_VERSION
+  ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_OEM_MODULE)))
+    LOCAL_USE_VNDK:=true
+  else
+    ifneq (,$(filter $(TARGET_OUT_VENDOR)%,$(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)))
+      LOCAL_USE_VNDK:=true
+    endif
+  endif
+endif
+endif
+
+# Verify LOCAL_USE_VNDK usage, and set LOCAL_SDK_VERSION if necessary
+
+ifdef LOCAL_IS_HOST_MODULE
+  ifdef LOCAL_USE_VNDK
+    $(shell echo $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Do not use LOCAL_USE_VNDK with host modules >&2)
+    $(error done)
+  endif
+endif
+ifdef LOCAL_USE_VNDK
+  ifneq ($(LOCAL_USE_VNDK),true)
+    $(shell echo '$(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_USE_VNDK must be "true" or empty, not "$(LOCAL_USE_VNDK)"' >&2)
+    $(error done)
+  endif
+
+  ifdef LOCAL_SDK_VERSION
+    $(shell echo $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): LOCAL_USE_VNDK must not be used with LOCAL_SDK_VERSION >&2)
+    $(error done)
+  endif
+
+  # If we're not using the VNDK, drop all restrictions
+  ifndef BOARD_VNDK_VERSION
+    LOCAL_USE_VNDK:=
+  endif
+endif
+
diff --git a/core/main.mk b/core/main.mk
index 5a054a0..f51070b 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -9,44 +9,23 @@
 SHELL := /bin/bash
 endif
 
-# this turns off the suffix rules built into make
-.SUFFIXES:
+ifndef KATI
 
-# this turns off the RCS / SCCS implicit rules of GNU Make
-% : RCS/%,v
-% : RCS/%
-% : %,v
-% : s.%
-% : SCCS/s.%
-
-# If a rule fails, delete $@.
-.DELETE_ON_ERROR:
-
-# Figure out where we are.
-#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-#TOP := $(patsubst %/,%,$(TOP))
-
-# TOPDIR is the normal variable you should use, because
-# if we are executing relative to the current directory
-# it can be "", whereas TOP must be "." which causes
-# pattern matching problems when make strips off the
-# trailing "./" from paths in various places.
-#ifeq ($(TOP),.)
-#TOPDIR :=
-#else
-#TOPDIR := $(TOP)/
-#endif
-
-# Check for broken versions of make.
-ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
-$(warning ********************************************************************************)
-$(warning *  You are using version $(MAKE_VERSION) of make.)
-$(warning *  Android can only be built by versions 3.81 and higher.)
-$(warning *  see https://source.android.com/source/download.html)
-$(warning ********************************************************************************)
-$(error stopping)
+host_prebuilts := linux-x86
+ifeq ($(shell uname),Darwin)
+host_prebuilts := darwin-x86
 endif
 
+.PHONY: run_soong_ui
+run_soong_ui:
+	+@prebuilts/build-tools/$(host_prebuilts)/bin/makeparallel --ninja build/soong/soong_ui.bash --make-mode $(MAKECMDGOALS)
+
+.PHONY: $(MAKECMDGOALS)
+$(sort $(MAKECMDGOALS)) : run_soong_ui
+	@#empty
+
+else # KATI
+
 # Absolute path of the present working direcotry.
 # This overrides the shell variable $PWD, which does not necessarily points to
 # the top of the source tree, for example when "make -C" is used in m/mm/mmm.
@@ -57,9 +36,6 @@
 
 BUILD_SYSTEM := $(TOPDIR)build/core
 
-# Ensure JAVA_NOT_REQUIRED is not set externally.
-JAVA_NOT_REQUIRED := false
-
 # This is the default target.  It must be the first declared target.
 .PHONY: droid
 DEFAULT_GOAL := droid
@@ -68,54 +44,17 @@
 .PHONY: droid_targets
 droid_targets:
 
-# Used to force goals to build.  Only use for conditionally defined goals.
-.PHONY: FORCE
-FORCE:
-
-# These goals don't need to collect and include Android.mks/CleanSpec.mks
-# in the source tree.
-dont_bother_goals := clean clobber dataclean installclean \
-    help out \
-    snod systemimage-nodeps \
-    stnod systemtarball-nodeps \
-    userdataimage-nodeps userdatatarball-nodeps \
-    cacheimage-nodeps \
-    vendorimage-nodeps \
-    systemotherimage-nodeps \
-    ramdisk-nodeps \
-    bootimage-nodeps \
-    recoveryimage-nodeps \
-    product-graph dump-products
+# Set up various standard variables based on configuration
+# and host information.
+include $(BUILD_SYSTEM)/config.mk
 
 ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
 dont_bother := true
 endif
 
-ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
+include $(SOONG_MAKEVARS_MK)
 
-# Targets that provide quick help on the build system.
-include $(BUILD_SYSTEM)/help.mk
-
-# Set up various standard variables based on configuration
-# and host information.
-include $(BUILD_SYSTEM)/config.mk
-
-relaunch_with_ninja :=
-ifneq ($(USE_NINJA),false)
-ifndef BUILDING_WITH_NINJA
-relaunch_with_ninja := true
-endif
-endif
-
-ifeq ($(relaunch_with_ninja),true)
-# Mark this is a ninja build.
-$(shell mkdir -p $(OUT_DIR) && touch $(OUT_DIR)/ninja_build)
-include build/core/ninja.mk
-else # !relaunch_with_ninja
-ifndef BUILDING_WITH_NINJA
-# Remove ninja build mark if it exists.
-$(shell rm -f $(OUT_DIR)/ninja_build)
-endif
+include $(BUILD_SYSTEM)/clang/config.mk
 
 # Write the build number to a file so it can be read back in
 # without changing the command line every time.  Avoids rebuilds
@@ -135,8 +74,10 @@
 -include cts/build/config.mk
 # VTS-specific config.
 -include test/vts/tools/vts-tradefed/build/config.mk
-# STS-specific config.
--include test/sts/tools/sts-tradefed/build/config.mk
+# device-tests-specific-config.
+-include tools/tradefederation/build/suites/device-tests/config.mk
+# general-tests-specific-config.
+-include tools/tradefederation/build/suites/general-tests/config.mk
 
 # This allows us to force a clean build - included after the config.mk
 # environment setup is done, but before we generate any dependencies.  This
@@ -148,8 +89,9 @@
 -include vendor/google/build/config.mk
 
 VERSION_CHECK_SEQUENCE_NUMBER := 6
+JAVA_NOT_REQUIRED_CHECKED :=
 -include $(OUT_DIR)/versions_checked.mk
-ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
+ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER)$(JAVA_NOT_REQUIRED),$(VERSIONS_CHECKED)$(JAVA_NOT_REQUIRED_CHECKED))
 
 $(info Checking build tools versions...)
 
@@ -180,7 +122,7 @@
 $(error Directory names containing spaces not supported)
 endif
 
-ifeq ($(JAVA_NOT_REQUIRED), false)
+ifneq ($(JAVA_NOT_REQUIRED),true)
 java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1)
 javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
 
@@ -282,6 +224,8 @@
         > $(OUT_DIR)/versions_checked.mk)
 $(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
         >> $(OUT_DIR)/versions_checked.mk)
+$(shell echo 'JAVA_NOT_REQUIRED_CHECKED := $(JAVA_NOT_REQUIRED)' \
+        >> $(OUT_DIR)/versions_checked.mk)
 endif
 
 # These are the modifier targets that don't do anything themselves, but
@@ -294,6 +238,37 @@
 EMMA_INSTRUMENT := true
 endif
 
+#
+# -----------------------------------------------------------------
+# Validate ADDITIONAL_DEFAULT_PROPERTIES.
+ifneq ($(ADDITIONAL_DEFAULT_PROPERTIES),)
+$(error ADDITIONAL_DEFAULT_PROPERTIES must not be set before here: $(ADDITIONAL_DEFAULT_PROPERTIES))
+endif
+
+#
+# -----------------------------------------------------------------
+# Validate ADDITIONAL_BUILD_PROPERTIES.
+ifneq ($(ADDITIONAL_BUILD_PROPERTIES),)
+$(error ADDITIONAL_BUILD_PROPERTIES must not be set before here: $(ADDITIONAL_BUILD_PROPERTIES))
+endif
+
+#
+# -----------------------------------------------------------------
+# Add the product-defined properties to the build properties.
+ifdef PRODUCT_SHIPPING_API_LEVEL
+ADDITIONAL_BUILD_PROPERTIES += \
+  ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
+endif
+
+ifneq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
+  ADDITIONAL_BUILD_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
+else
+  ifndef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+    ADDITIONAL_BUILD_PROPERTIES += $(PRODUCT_PROPERTY_OVERRIDES)
+  endif
+endif
+
+
 # Bring in standard build system definitions.
 include $(BUILD_SYSTEM)/definitions.mk
 
@@ -358,6 +333,8 @@
   ADDITIONAL_BUILD_PROPERTIES += ro.bionic.ld.warning=1
 endif
 
+ADDITIONAL_BUILD_PROPERTIES += ro.treble.enabled=${PRODUCT_FULL_TREBLE}
+
 # -----------------------------------------------------------------
 ###
 ### In this section we set up the things that are different
@@ -459,6 +436,9 @@
 $(error The 'sdk' target may not be specified with any other targets)
 endif
 
+# AUX dependencies are already added by now; remove triggers from the MAKECMDGOALS
+MAKECMDGOALS := $(strip $(filter-out AUX-%,$(MAKECMDGOALS)))
+
 # TODO: this should be eng I think.  Since the sdk is built from the eng
 # variant.
 tags_to_install := debug eng
@@ -504,21 +484,25 @@
 #
 # Typical build; include any Android.mk files we can find.
 #
-subdirs := $(TOP)
 
 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)
+# Before we go and include all of the module makefiles, mark the PRODUCT_*
+# and ADDITIONAL*PROPERTIES values readonly so that they won't be modified.
+$(call readonly-product-vars)
+ADDITIONAL_DEFAULT_PROPERTIES := $(strip $(ADDITIONAL_DEFAULT_PROPERTIES))
+.KATI_READONLY := ADDITIONAL_DEFAULT_PROPERTIES
+ADDITIONAL_BUILD_PROPERTIES := $(strip $(ADDITIONAL_BUILD_PROPERTIES))
+.KATI_READONLY := ADDITIONAL_BUILD_PROPERTIES
+
+ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
+ENFORCE_RRO_SOURCES :=
 endif
 
 ifneq ($(ONE_SHOT_MAKEFILE),)
 # We've probably been invoked by the "mm" shell function
 # with a subdirectory's makefile.
-include $(ONE_SHOT_MAKEFILE)
+include $(SOONG_ANDROID_MK) $(wildcard $(ONE_SHOT_MAKEFILE))
 # Change CUSTOM_MODULES to include only modules that were
 # defined by this makefile; this will install all of those
 # modules as a side-effect.  Do this after including ONE_SHOT_MAKEFILE
@@ -532,11 +516,28 @@
 NOTICE-TARGET-%: ;
 
 # A helper goal printing out install paths
-.PHONY: GET-INSTALL-PATH
-GET-INSTALL-PATH:
-	@echo "Install paths for modules in $(ONE_SHOT_MAKEFILE):"
-	@$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \
-		echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))
+define register_module_install_path
+.PHONY: GET-MODULE-INSTALL-PATH-$(1)
+GET-MODULE-INSTALL-PATH-$(1):
+	echo 'INSTALL-PATH: $(1) $(ALL_MODULES.$(1).INSTALLED)'
+endef
+
+SORTED_ALL_MODULES := $(sort $(ALL_MODULES))
+UNIQUE_ALL_MODULES :=
+$(foreach m,$(SORTED_ALL_MODULES),\
+    $(if $(call streq,$(m),$(lastword $(UNIQUE_ALL_MODULES))),,\
+        $(eval UNIQUE_ALL_MODULES += $(m))))
+SORTED_ALL_MODULES :=
+
+$(foreach mod,$(UNIQUE_ALL_MODULES),$(if $(ALL_MODULES.$(mod).INSTALLED),\
+    $(eval $(call register_module_install_path,$(mod)))\
+    $(foreach path,$(ALL_MODULES.$(mod).PATH),\
+        $(eval my_path_prefix := GET-INSTALL-PATH-IN)\
+        $(foreach component,$(subst /,$(space),$(path)),\
+            $(eval my_path_prefix := $$(my_path_prefix)-$$(component))\
+            $(eval .PHONY: $$(my_path_prefix))\
+            $(eval $$(my_path_prefix): GET-MODULE-INSTALL-PATH-$(mod))))))
+UNIQUE_ALL_MODULES :=
 
 else # ONE_SHOT_MAKEFILE
 
@@ -545,16 +546,11 @@
 # Include all of the makefiles in the system
 #
 
-# Can't use first-makefiles-under here because
-# --mindepth=2 makes the prunes not work.
-subdir_makefiles := \
-	$(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) $(subdirs) Android.mk)
+subdir_makefiles := $(SOONG_ANDROID_MK) $(call first-makefiles-under,$(TOP))
+subdir_makefiles_total := $(words $(subdir_makefiles))
+.KATI_READONLY := subdir_makefiles_total
 
-ifeq ($(USE_SOONG),true)
-subdir_makefiles := $(SOONG_ANDROID_MK) $(call filter-soong-makefiles,$(subdir_makefiles))
-endif
-
-$(foreach mk, $(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
+$(foreach mk,$(subdir_makefiles),$(info [$(call inc_and_print,subdir_makefiles_inc)/$(subdir_makefiles_total)] including $(mk) ...)$(eval include $(mk)))
 
 ifdef PDK_FUSION_PLATFORM_ZIP
 # Bring in the PDK platform.zip modules.
@@ -565,33 +561,17 @@
 
 endif # ONE_SHOT_MAKEFILE
 
-# 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
-
-include $(BUILD_SYSTEM)/legacy_prebuilts.mk
-ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
-  $(warning *** Some files have been added to ALL_PREBUILT.)
-  $(warning *)
-  $(warning * ALL_PREBUILT is a deprecated mechanism that)
-  $(warning * should not be used for new files.)
-  $(warning * As an alternative, use PRODUCT_COPY_FILES in)
-  $(warning * the appropriate product definition.)
-  $(warning * build/target/product/core.mk is the product)
-  $(warning * definition used in all products.)
-  $(warning *)
-  $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
-  $(warning *)
-  $(error ALL_PREBUILT contains unexpected files)
-endif
-
 # -------------------------------------------------------------------
 # All module makefiles have been included at this point.
 # -------------------------------------------------------------------
 
+# -------------------------------------------------------------------
+# Enforce to generate all RRO packages for modules having resource
+# overlays.
+# -------------------------------------------------------------------
+ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
+$(call generate_all_enforce_rro_packages)
+endif
 
 # -------------------------------------------------------------------
 # Fix up CUSTOM_MODULES to refer to installed files rather than
@@ -615,19 +595,33 @@
 #
 # Resolve the required module name to 32-bit or 64-bit variant.
 # Get a list of corresponding 32-bit module names, if one exists.
+ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
 define get-32-bit-modules
-$(strip $(foreach m,$(1),\
+$(sort $(foreach m,$(1),\
   $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),\
-    $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX))))
+    $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX))\
+  $(if $(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),\
+    $(m)$(HOST_2ND_ARCH_MODULE_SUFFIX))\
+    ))
 endef
 # Get a list of corresponding 32-bit module names, if one exists;
 # otherwise return the original module name
 define get-32-bit-modules-if-we-can
-$(strip $(foreach m,$(1),\
-  $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),\
-    $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX),
-    $(m))))
+$(sort $(foreach m,$(1),\
+  $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS)$(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),\
+    $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX)) \
+    $(if $(ALL_MODULES.$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX).CLASS),$(m)$(HOST_2ND_ARCH_MODULE_SUFFIX)),\
+  $(m))))
 endef
+else  # TARGET_TRANSLATE_2ND_ARCH
+# For binary translation config, by default only install the first arch.
+define get-32-bit-modules
+endef
+
+define get-32-bit-modules-if-we-can
+$(strip $(1))
+endef
+endif  # TARGET_TRANSLATE_2ND_ARCH
 
 # If a module is for a cross host os, the required modules must be for
 # that OS too.
@@ -642,7 +636,7 @@
       $(eval r := $(addprefix host_cross_,$(r))))\
     $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),\
       $(eval r_r := $(call get-32-bit-modules-if-we-can,$(r))),\
-      $(if $(filter EXECUTABLES SHARED_LIBRARIES,$(ALL_MODULES.$(m).CLASS)),\
+      $(if $(filter EXECUTABLES SHARED_LIBRARIES NATIVE_TESTS,$(ALL_MODULES.$(m).CLASS)),\
         $(eval r_r := $(r)),\
         $(eval r_r := $(r) $(call get-32-bit-modules,$(r)))\
        )\
@@ -656,16 +650,24 @@
 $(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), \
     $(eval r := $(call module-installed-files,$(r))) \
     $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
-    $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
-    $(eval hc_m := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
+    $(eval h_m := $(filter $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
+    $(eval hc_m := $(filter $(HOST_CROSS_OUT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
     $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
-    $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \
-    $(eval hc_r := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(r))) \
+    $(eval h_r := $(filter $(HOST_OUT)/%, $(r))) \
+    $(eval hc_r := $(filter $(HOST_CROSS_OUT)/%, $(r))) \
     $(eval t_m := $(filter-out $(t_r), $(t_m))) \
     $(eval h_m := $(filter-out $(h_r), $(h_m))) \
     $(eval hc_m := $(filter-out $(hc_r), $(hc_m))) \
@@ -693,11 +695,14 @@
   $(eval p := $(subst :,$(space),$(m)))\
   $(eval mod := $(firstword $(p)))\
   $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\
+  $(eval root := $(1)OUT$(if $(call streq,$(1),TARGET_),_ROOT))\
   $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\
   $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
-  $(eval r := $(filter $($(1)OUT)/%,$(call module-installed-files,\
+  $(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
 
@@ -804,7 +809,7 @@
 ifdef overridden_packages
 #  old_modules_to_install := $(modules_to_install)
   modules_to_install := \
-      $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk %/$(p).odex), \
+      $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk %/$(p).odex %/$(p).vdex), \
           $(modules_to_install))
 endif
 #$(error filtered out
@@ -878,9 +883,6 @@
 # This is used to to get the ordering right, you can also use these,
 # but they're considered undocumented, so don't complain if their
 # behavior changes.
-.PHONY: prebuilt
-prebuilt: $(ALL_PREBUILT)
-
 # An internal target that depends on all copied headers
 # (see copy_headers.make).  Other targets that need the
 # headers to be copied first can depend on this target.
@@ -891,17 +893,14 @@
 
 # All the droid stuff, in directories
 .PHONY: files
-files: prebuilt \
-        $(modules_to_install) \
-        $(INSTALLED_ANDROID_INFO_TXT_TARGET)
+files: $(modules_to_install) \
+       $(INSTALLED_ANDROID_INFO_TXT_TARGET)
 
 # -------------------------------------------------------------------
 
 .PHONY: checkbuild
 checkbuild: $(modules_to_check) droid_targets
-ifeq ($(USE_SOONG),true)
-checkbuild: checkbuild-soong
-endif
+
 ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT))
 droid: checkbuild
 endif
@@ -928,6 +927,9 @@
 .PHONY: cacheimage
 cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
 
+.PHONY: bptimage
+bptimage: $(INSTALLED_BPTIMAGE_TARGET)
+
 .PHONY: vendorimage
 vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
 
@@ -937,20 +939,11 @@
 .PHONY: bootimage
 bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
 
-# phony target that include any targets in $(ALL_MODULES)
-.PHONY: all_modules
-ifndef BUILD_MODULES_IN_PATHS
-all_modules: $(ALL_MODULES)
-else
-# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree
-build_modules_in_paths := $(patsubst ./%,%,$(BUILD_MODULES_IN_PATHS))
-module_path_patterns := $(foreach p, $(build_modules_in_paths),\
-    $(if $(filter %/,$(p)),$(p)%,$(p)/%))
-my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
-    $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m))))
-all_modules: $(my_all_modules)
-endif
+.PHONY: vbmetaimage
+vbmetaimage: $(INSTALLED_VBMETAIMAGE_TARGET)
 
+.PHONY: auxiliary
+auxiliary: $(INSTALLED_AUX_TARGETS)
 
 # Build files and then package it into the rom formats
 .PHONY: droidcore
@@ -958,8 +951,10 @@
 	systemimage \
 	$(INSTALLED_BOOTIMAGE_TARGET) \
 	$(INSTALLED_RECOVERYIMAGE_TARGET) \
+	$(INSTALLED_VBMETAIMAGE_TARGET) \
 	$(INSTALLED_USERDATAIMAGE_TARGET) \
 	$(INSTALLED_CACHEIMAGE_TARGET) \
+	$(INSTALLED_BPTIMAGE_TARGET) \
 	$(INSTALLED_VENDORIMAGE_TARGET) \
 	$(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
 	$(INSTALLED_FILES_FILE) \
@@ -1003,15 +998,18 @@
   $(SYMBOLS_ZIP) : $(apps_only_installed_files)
   $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP))
 
+  $(COVERAGE_ZIP) : $(apps_only_installed_files)
+  $(call dist-for-goals,apps_only, $(COVERAGE_ZIP))
+
 .PHONY: apps_only
 apps_only: $(unbundled_build_modules)
 
 droid_targets: apps_only
 
 # Combine the NOTICE files for a apps_only build
-$(eval $(call combine-notice-files, \
+$(eval $(call combine-notice-files, html, \
     $(target_notice_file_txt), \
-    $(target_notice_file_html), \
+    $(target_notice_file_html_or_xml), \
     "Notices for files for apps:", \
     $(TARGET_OUT_NOTICE_FILES), \
     $(apps_only_installed_files)))
@@ -1023,6 +1021,7 @@
     $(INTERNAL_OTA_PACKAGE_TARGET) \
     $(BUILT_OTATOOLS_PACKAGE) \
     $(SYMBOLS_ZIP) \
+    $(COVERAGE_ZIP) \
     $(INSTALLED_FILES_FILE) \
     $(INSTALLED_FILES_FILE_VENDOR) \
     $(INSTALLED_FILES_FILE_SYSTEMOTHER) \
@@ -1066,13 +1065,14 @@
 $(call dist-for-goals,sdk win_sdk, \
     $(ALL_SDK_TARGETS) \
     $(SYMBOLS_ZIP) \
+    $(COVERAGE_ZIP) \
     $(INSTALLED_BUILD_PROP_TARGET) \
 )
 
 # umbrella targets to assit engineers in verifying builds
 .PHONY: java native target host java-host java-target native-host native-target \
         java-host-tests java-target-tests native-host-tests native-target-tests \
-        java-tests native-tests host-tests target-tests tests
+        java-tests native-tests host-tests target-tests tests java-dex
 # some synonyms
 .PHONY: host-java target-java host-native target-native \
         target-java-tests target-native-tests
@@ -1084,14 +1084,8 @@
 target-native-tests : native-target-tests
 tests : host-tests target-tests
 
-# To catch more build breakage, check build tests modules in eng and userdebug builds.
-ifneq ($(ANDROID_NO_TEST_CHECK),true)
-ifneq ($(TARGET_BUILD_PDK),true)
-ifneq ($(filter eng userdebug,$(TARGET_BUILD_VARIANT)),)
-droidcore : target-tests host-tests
-endif
-endif
-endif
+# Phony target to run all java compilations that use javac instead of jack.
+.PHONY: javac-check
 
 ifneq (,$(filter samplecode, $(MAKECMDGOALS)))
 .PHONY: samplecode
@@ -1102,7 +1096,7 @@
 $(foreach module,$(sample_MODULES),$(eval $(call \
         copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
 sample_ADDITIONAL_INSTALLED := \
-        $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
+        $(filter-out $(modules_to_install) $(modules_to_check),$(sample_MODULES))
 samplecode: $(sample_APKS_COLLECTION)
 	@echo "Collect sample code apks: $^"
 	# remove apks that are not intended to be installed.
@@ -1136,4 +1130,15 @@
 .PHONY: nothing
 nothing:
 	@echo Successfully read the makefiles.
-endif # !relaunch_with_ninja
+
+.PHONY: tidy_only
+tidy_only:
+	@echo Successfully make tidy_only.
+
+ndk: $(SOONG_OUT_DIR)/ndk.timestamp
+.PHONY: ndk
+
+.PHONY: all_link_types
+all_link_types:
+
+endif # KATI
diff --git a/core/math.mk b/core/math.mk
new file mode 100644
index 0000000..047d046
--- /dev/null
+++ b/core/math.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2017 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.
+#
+
+###########################################################
+# 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))
+
+define math_gt_or_eq
+$(if $(filter $(1),$(call math_max,$(1),$(2))),true)
+endef
+
+#$(warning $(call math_gt_or_eq, 2, 1))
+#$(warning $(call math_gt_or_eq, 1, 1))
+#$(warning $(if $(call math_gt_or_eq, 1, 2),false,true))
+
+# $1 is the variable name to increment
+define inc_and_print
+$(strip $(eval $(1) := $($(1)) .)$(words $($(1))))
+endef
diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk
index ed2fed6..77c57ab 100644
--- a/core/multi_prebuilt.mk
+++ b/core/multi_prebuilt.mk
@@ -14,6 +14,7 @@
 # limitations under the License.
 #
 
+$(call record-module-type,MULTI_PREBUILT)
 ifneq ($(LOCAL_MODULE)$(LOCAL_MODULE_CLASS),)
 $(error $(LOCAL_PATH): LOCAL_MODULE or LOCAL_MODULE_CLASS not needed by \
   BUILD_MULTI_PREBUILT, use BUILD_PREBUILT instead!)
diff --git a/core/native_benchmark.mk b/core/native_benchmark.mk
index ac37701..e73bcad 100644
--- a/core/native_benchmark.mk
+++ b/core/native_benchmark.mk
@@ -2,6 +2,7 @@
 ## A thin wrapper around BUILD_EXECUTABLE
 ## Common flags for native benchmarks are added.
 ###########################################
+$(call record-module-type,NATIVE_BENCHMARK)
 
 LOCAL_STATIC_LIBRARIES += libgoogle-benchmark
 
diff --git a/core/native_test.mk b/core/native_test.mk
index 93b7e1a..8b49fbd 100644
--- a/core/native_test.mk
+++ b/core/native_test.mk
@@ -2,6 +2,15 @@
 ## A thin wrapper around BUILD_EXECUTABLE
 ## Common flags for native tests are added.
 ###########################################
+$(call record-module-type,NATIVE_TEST)
+
+ifdef LOCAL_MODULE_CLASS
+ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
+$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must be NATIVE_TESTS with BUILD_HOST_NATIVE_TEST)
+endif
+endif
+
+LOCAL_MODULE_CLASS := NATIVE_TESTS
 
 include $(BUILD_SYSTEM)/target_test_internal.mk
 
diff --git a/core/ninja.mk b/core/ninja.mk
deleted file mode 100644
index 9d0ff9a..0000000
--- a/core/ninja.mk
+++ /dev/null
@@ -1,192 +0,0 @@
-NINJA ?= prebuilts/ninja/$(HOST_PREBUILT_TAG)/ninja
-
-ifeq ($(USE_SOONG),true)
-USE_SOONG_FOR_KATI := true
-endif
-
-ifeq ($(USE_SOONG_FOR_KATI),true)
-include $(BUILD_SYSTEM)/soong.mk
-else
-KATI ?= $(HOST_OUT_EXECUTABLES)/ckati
-MAKEPARALLEL ?= $(HOST_OUT_EXECUTABLES)/makeparallel
-endif
-
-KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
-
-# Modifier goals we don't need to pass to Ninja.
-NINJA_EXCLUDE_GOALS := showcommands all dist
-.PHONY : $(NINJA_EXCLUDE_GOALS)
-
-# A list of goals which affect parsing of makefiles and we need to pass to Kati.
-PARSE_TIME_MAKE_GOALS := \
-	$(PARSE_TIME_MAKE_GOALS) \
-	$(dont_bother_goals) \
-	all \
-	APP-% \
-	DUMP_% \
-	ECLIPSE-% \
-	PRODUCT-% \
-	boottarball-nodeps \
-	btnod \
-	build-art% \
-	build_kernel-nodeps \
-	clean-oat% \
-	continuous_instrumentation_tests \
-	continuous_native_tests \
-	cts \
-	custom_images \
-	deps-license \
-	dicttool_aosp \
-	dist \
-	dump-products \
-	dumpvar-% \
-	eng \
-	fusion \
-	oem_image \
-	old-cts \
-	online-system-api-sdk-docs \
-	pdk \
-	platform \
-	platform-java \
-	product-graph \
-	samplecode \
-	sdk \
-	sdk_addon \
-	sdk_repo \
-	snod \
-	stnod \
-	systemimage-nodeps \
-	systemtarball-nodeps \
-	target-files-package \
-	test-art% \
-	user \
-	userdataimage \
-	userdebug \
-	valgrind-test-art% \
-	vts \
-	win_sdk \
-	winsdk-tools
-
--include vendor/google/build/ninja_config.mk
-
-# Any Android goals that need to be built.
-ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(KATI) $(MAKEPARALLEL),\
-    $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
-# Goals we need to pass to Ninja.
-NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
-# Goals we need to pass to Kati.
-KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS),  $(ANDROID_GOALS))
-
-define replace_space_and_slash
-$(subst /,_,$(subst $(space),_,$(sort $1)))
-endef
-
-KATI_NINJA_SUFFIX := -$(TARGET_PRODUCT)
-ifneq ($(KATI_GOALS),)
-KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(call replace_space_and_slash,$(KATI_GOALS))
-endif
-ifneq ($(ONE_SHOT_MAKEFILE),)
-KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmm-$(call replace_space_and_slash,$(ONE_SHOT_MAKEFILE))
-endif
-ifneq ($(BUILD_MODULES_IN_PATHS),)
-KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmma-$(call replace_space_and_slash,$(BUILD_MODULES_IN_PATHS))
-endif
-
-my_checksum_suffix :=
-my_ninja_suffix_too_long := $(filter 1, $(shell v='$(KATI_NINJA_SUFFIX)' && echo $$(($${$(pound)v} > 64))))
-ifneq ($(my_ninja_suffix_too_long),)
-# Replace the suffix with a checksum if it gets too long.
-my_checksum_suffix := $(KATI_NINJA_SUFFIX)
-KATI_NINJA_SUFFIX := -$(word 1, $(shell echo $(my_checksum_suffix) | $(MD5SUM)))
-endif
-
-KATI_BUILD_NINJA := $(OUT_DIR)/build$(KATI_NINJA_SUFFIX).ninja
-KATI_ENV_SH := $(OUT_DIR)/env$(KATI_NINJA_SUFFIX).sh
-
-# Write out a file mapping checksum to the real suffix.
-ifneq ($(my_checksum_suffix),)
-my_ninja_suffix_file := $(basename $(KATI_BUILD_NINJA)).suf
-$(shell mkdir -p $(dir $(my_ninja_suffix_file)) && \
-    echo $(my_checksum_suffix) > $(my_ninja_suffix_file))
-endif
-
-ifeq (,$(NINJA_STATUS))
-NINJA_STATUS := [%p %s/%t]$(space)
-endif
-
-ifneq (,$(filter showcommands,$(ORIGINAL_MAKECMDGOALS)))
-NINJA_ARGS += "-v"
-endif
-
-ifdef USE_GOMA
-KATI_MAKEPARALLEL := $(MAKEPARALLEL)
-# Ninja runs remote jobs (i.e., commands which contain gomacc) with
-# this parallelism. Note the parallelism of all other jobs is still
-# limited by the -j flag passed to GNU make.
-NINJA_REMOTE_NUM_JOBS ?= 500
-NINJA_ARGS += -j$(NINJA_REMOTE_NUM_JOBS)
-else
-NINJA_MAKEPARALLEL := $(MAKEPARALLEL) --ninja
-endif
-
-ifeq ($(USE_SOONG),true)
-COMBINED_BUILD_NINJA := $(OUT_DIR)/combined$(KATI_NINJA_SUFFIX).ninja
-
-$(COMBINED_BUILD_NINJA): $(KATI_BUILD_NINJA) $(SOONG_ANDROID_MK)
-	$(hide) echo "builddir = $(OUT_DIR)" > $(COMBINED_BUILD_NINJA)
-	$(hide) echo "subninja $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
-	$(hide) echo "subninja $(KATI_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
-else
-COMBINED_BUILD_NINJA := $(KATI_BUILD_NINJA)
-endif
-
-$(sort $(DEFAULT_GOAL) $(ANDROID_GOALS)) : ninja_wrapper
-	@#empty
-
-.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)
-
-# Dummy Android.mk and CleanSpec.mk files so that kati won't recurse into the
-# out directory
-DUMMY_OUT_MKS := $(OUT_DIR)/Android.mk $(OUT_DIR)/CleanSpec.mk
-$(DUMMY_OUT_MKS):
-	@mkdir -p $(dir $@)
-	$(hide) echo '# This file prevents findleaves.py from traversing this directory further' >$@
-
-KATI_FIND_EMULATOR := --use_find_emulator
-ifeq ($(KATI_EMULATE_FIND),false)
-  KATI_FIND_EMULATOR :=
-endif
-$(KATI_BUILD_NINJA): $(KATI) $(MAKEPARALLEL) $(DUMMY_OUT_MKS) $(SOONG_ANDROID_MK) FORCE
-	@echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
-	+$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --no_ignore_dirty=$(SOONG_ANDROID_MK) --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo $(KATI_FIND_EMULATOR) -f build/core/main.mk $(KATI_GOALS) --gen_all_targets BUILDING_WITH_NINJA=true SOONG_ANDROID_MK=$(SOONG_ANDROID_MK)
-
-ifneq ($(USE_SOONG_FOR_KATI),true)
-KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
-KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
-# Build static ckati. Unfortunately Mac OS X doesn't officially support static exectuables.
-ifeq ($(BUILD_OS),linux)
-# We need everything in libpthread.a otherwise C++11's threading library will be disabled.
-KATI_LD += -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl
-endif
-
-KATI_INTERMEDIATES_PATH := $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/ckati_intermediates
-KATI_BIN_PATH := $(HOST_OUT_EXECUTABLES)
-include build/kati/Makefile.ckati
-
-MAKEPARALLEL_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
-MAKEPARALLEL_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
-# Build static makeparallel. Unfortunately Mac OS X doesn't officially support static exectuables.
-ifeq ($(BUILD_OS),linux)
-MAKEPARALLEL_LD += -static
-endif
-
-MAKEPARALLEL_INTERMEDIATES_PATH := $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/makeparallel_intermediates
-MAKEPARALLEL_BIN_PATH := $(HOST_OUT_EXECUTABLES)
-include build/tools/makeparallel/Makefile
-endif
-
-.PHONY: FORCE
-FORCE:
diff --git a/core/ninja_config.mk b/core/ninja_config.mk
new file mode 100644
index 0000000..f456b8b
--- /dev/null
+++ b/core/ninja_config.mk
@@ -0,0 +1,71 @@
+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
+
+KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
+
+# Modifier goals we don't need to pass to Ninja.
+NINJA_EXCLUDE_GOALS := showcommands all dist
+.PHONY : $(NINJA_EXCLUDE_GOALS)
+
+# A list of goals which affect parsing of makefiles and we need to pass to Kati.
+PARSE_TIME_MAKE_GOALS := \
+	$(PARSE_TIME_MAKE_GOALS) \
+	$(dont_bother_goals) \
+	all \
+	APP-% \
+	DUMP_% \
+	ECLIPSE-% \
+	PRODUCT-% \
+	AUX-% \
+	boottarball-nodeps \
+	brillo_tests \
+	btnod \
+	build-art% \
+	build_kernel-nodeps \
+	clean-oat% \
+	continuous_instrumentation_tests \
+	continuous_native_tests \
+	cts \
+	custom_images \
+	deps-license \
+	dicttool_aosp \
+	dist \
+	dump-products \
+	eng \
+	fusion \
+	oem_image \
+	online-system-api-sdk-docs \
+	pdk \
+	platform \
+	platform-java \
+	product-graph \
+	samplecode \
+	sdk \
+	sdk_addon \
+	sdk_repo \
+	snod \
+	stnod \
+	systemimage-nodeps \
+	systemtarball-nodeps \
+	target-files-package \
+	test-art% \
+	user \
+	userdataimage \
+	userdebug \
+	valgrind-test-art% \
+	vts \
+	win_sdk \
+	winsdk-tools
+
+include $(wildcard vendor/*/build/ninja_config.mk)
+
+# Any Android goals that need to be built.
+ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(CKATI) $(MAKEPARALLEL),\
+    $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
+# Goals we need to pass to Ninja.
+NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
+# Goals we need to pass to Kati.
+KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS),  $(ANDROID_GOALS))
diff --git a/core/no_java_path/jar b/core/no_java_path/jar
new file mode 120000
index 0000000..8586397
--- /dev/null
+++ b/core/no_java_path/jar
@@ -0,0 +1 @@
+java
\ No newline at end of file
diff --git a/core/no_java_path/jarsigner b/core/no_java_path/jarsigner
new file mode 120000
index 0000000..8586397
--- /dev/null
+++ b/core/no_java_path/jarsigner
@@ -0,0 +1 @@
+java
\ No newline at end of file
diff --git a/core/no_java_path/java b/core/no_java_path/java
new file mode 100755
index 0000000..f3422f3
--- /dev/null
+++ b/core/no_java_path/java
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo "Error: JAVA_NOT_REQUIRED=true, $(basename $0) is unavailable." 1>&2
+exit 1
diff --git a/core/no_java_path/javac b/core/no_java_path/javac
new file mode 120000
index 0000000..8586397
--- /dev/null
+++ b/core/no_java_path/javac
@@ -0,0 +1 @@
+java
\ No newline at end of file
diff --git a/core/no_java_path/keytool b/core/no_java_path/keytool
new file mode 120000
index 0000000..8586397
--- /dev/null
+++ b/core/no_java_path/keytool
@@ -0,0 +1 @@
+java
\ No newline at end of file
diff --git a/core/notice_files.mk b/core/notice_files.mk
index e7f8974..f850fff 100644
--- a/core/notice_files.mk
+++ b/core/notice_files.mk
@@ -1,6 +1,7 @@
 ###########################################################
 ## Track NOTICE files
 ###########################################################
+$(call record-module-type,NOTICE_FILE)
 
 ifneq ($(LOCAL_NOTICE_FILE),)
 notice_file:=$(strip $(LOCAL_NOTICE_FILE))
@@ -13,6 +14,14 @@
   notice_file :=
 endif
 
+# Soong generates stub libraries that don't need NOTICE files
+ifdef LOCAL_NO_NOTICE_FILE
+  ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+    $(call pretty-error,LOCAL_NO_NOTICE_FILE should not be used by Android.mk files)
+  endif
+  notice_file :=
+endif
+
 ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES)
 # If this is a NOTICE-only module, we don't include base_rule.mk,
 # so my_prefix is not set at this point.
@@ -32,15 +41,15 @@
 # compliance.
 # Includes the leading slash
 ifdef LOCAL_INSTALLED_MODULE
-  module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+  module_installed_filename := $(patsubst $(PRODUCT_OUT)/%,%,$(LOCAL_INSTALLED_MODULE))
 else
   # This module isn't installable
-  ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
+  ifneq ($(filter STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
     # Stick the static libraries with the dynamic libraries.
     # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
     # device-obj or host-obj.
     module_installed_filename := \
-        $(patsubst $(PRODUCT_OUT)%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
+        $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
   else
     ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
       # Stick the static java libraries with the regular java libraries.
@@ -52,7 +61,7 @@
         module_leaf := $(LOCAL_MODULE).jar
       endif
       module_installed_filename := \
-          $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
+          $(patsubst $(PRODUCT_OUT)/%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
     else
       $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
     endif # JAVA_LIBRARIES
@@ -60,8 +69,8 @@
 endif
 
 # In case it's actually a host file
-module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
-module_installed_filename := $(patsubst $(HOST_CROSS_OUT)%,%,$(module_installed_filename))
+module_installed_filename := $(patsubst $(HOST_OUT)/%,%,$(module_installed_filename))
+module_installed_filename := $(patsubst $(HOST_CROSS_OUT)/%,%,$(module_installed_filename))
 
 installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
 
diff --git a/core/package.mk b/core/package.mk
index 78b65db..4fe058d 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -2,6 +2,12 @@
 # TARGET_ARCH and TARGET_2ND_ARCH.
 # To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32".
 
+$(call record-module-type,PACKAGE)
+
+ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+LOCAL_MULTILIB := first
+endif
+
 my_prefix := TARGET_
 include $(BUILD_SYSTEM)/multilib.mk
 
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 551f18e..242203b 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -75,10 +75,6 @@
 LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
 endif
 
-ifdef LOCAL_PACKAGE_SPLITS
-LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
-endif
-
 need_compile_asset :=
 ifeq (,$(LOCAL_ASSET_DIR))
 LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
@@ -100,7 +96,34 @@
     $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
       $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
 
+enforce_rro_enabled :=
+ifneq ($(PRODUCT_ENFORCE_RRO_TARGETS),)
+  ifneq ($(package_resource_overlays),)
+    ifeq ($(PRODUCT_ENFORCE_RRO_TARGETS),*)
+      enforce_rro_enabled := true
+    else ifneq (,$(filter $(LOCAL_PACKAGE_NAME), $(PRODUCT_ENFORCE_RRO_TARGETS)))
+      enforce_rro_enabled := true
+    endif
+  endif
+
+  ifdef enforce_rro_enabled
+    ifeq (,$(LOCAL_MODULE_PATH))
+      ifeq (true,$(LOCAL_PROPRIETARY_MODULE))
+        enforce_rro_enabled :=
+      else ifeq (true,$(LOCAL_OEM_MODULE))
+        enforce_rro_enabled :=
+      else ifeq (true,$(LOCAL_ODM_MODULE))
+        enforce_rro_enabled :=
+      endif
+    else ifeq ($(filter $(TARGET_OUT)/%,$(LOCAL_MODULE_PATH)),)
+      enforce_rro_enabled :=
+    endif
+  endif
+endif
+
+ifndef enforce_rro_enabled
 LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
+endif
 
 all_assets := $(strip \
     $(foreach dir, $(LOCAL_ASSET_DIR), \
@@ -140,9 +163,9 @@
     $(addprefix $(d)/, \
         $(call find-subdir-assets,$(d)))))
 
-my_res_resources := $(strip \
+my_res_resources := $(if $(my_res_dir),$(strip \
     $(addprefix $(my_res_dir)/, \
-        $(call find-subdir-assets,$(my_res_dir))))
+        $(call find-subdir-assets,$(my_res_dir)))))
 
 all_resources := $(strip $(my_res_resources) $(my_overlay_resources))
 
@@ -163,6 +186,10 @@
        ) \
      ))
 
+ifdef LOCAL_PACKAGE_SPLITS
+LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
+endif
+
 endif  # LOCAL_USE_AAPT2
 
 ifneq ($(all_resources),)
@@ -171,7 +198,6 @@
 
 all_res_assets := $(strip $(all_assets) $(all_resources))
 
-
 # If no assets or resources were found, clear the directory variables so
 # we don't try to build them.
 ifneq (true,$(need_compile_asset))
@@ -251,25 +277,26 @@
 LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
 LOCAL_JACK_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
 endif # Contains java code
-else
+else  # ! LOCAL_JACK_ENABLED
 LOCAL_STATIC_JAVA_LIBRARIES += emma
-endif # LOCAL_JACK_ENABLED
-else
+endif # ! LOCAL_JACK_ENABLED
+else  # ! TARGET_BUILD_APPS
+ifdef LOCAL_JACK_ENABLED
 # If build against the SDK in full build, core.jar is not used
 # so coverage classes are not present.
-ifdef LOCAL_JACK_ENABLED
 # Jack needs jacoco on the classpath but we do not want it to be in
 # the final apk. While it is a static library, we add it to the
 # LOCAL_JAVA_LIBRARIES which are only present on the classpath.
 # Note: we have nothing to do for proguard since jacoco will be
 # on the classpath only, thus not modified during the compilation.
 LOCAL_JAVA_LIBRARIES += jacocoagent
-else
-# We have to use prebuilt emma.jar to make Proguard happy;
+else  # ! LOCAL_JACK_ENABLED
+# If build against the SDK in full build, core.jar is not used,
+# we have to use prebiult emma.jar to make Proguard happy;
 # Otherwise emma classes are included in core.jar.
 LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR)
-endif # LOCAL_JACK_ENABLED
-endif # full build
+endif # ! LOCAL_JACK_ENABLED
+endif # ! TARGET_BUILD_APPS
 endif # LOCAL_SDK_VERSION
 endif # EMMA_INSTRUMENT_STATIC
 endif # LOCAL_EMMA_INSTRUMENT
@@ -307,13 +334,6 @@
 
 $(LOCAL_INTERMEDIATE_TARGETS): \
     PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
-ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
-$(LOCAL_INTERMEDIATE_TARGETS): \
-    PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
-else
-$(LOCAL_INTERMEDIATE_TARGETS): \
-    PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
-endif
 
 ifeq ($(LOCAL_DATA_BINDING),true)
 data_binding_stamp := $(data_binding_intermediates)/data-binding.stamp
@@ -344,10 +364,41 @@
 endif  # LOCAL_DATA_BINDING
 
 ifeq ($(need_compile_res),true)
+
+###############################
+## APK splits
+built_apk_splits :=
+installed_apk_splits :=
+my_apk_split_configs :=
+
+ifdef LOCAL_PACKAGE_SPLITS
+my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS)
+my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs))
+built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk)
+installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
+endif
+
 ifdef LOCAL_USE_AAPT2
 my_compiled_res_base_dir := $(intermediates)/flat-res
+renderscript_target_api :=
+ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
+renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
+else
+ifneq (,$(LOCAL_SDK_VERSION))
+# Set target-api for LOCAL_SDK_VERSIONs other than current.
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+renderscript_target_api := $(LOCAL_SDK_VERSION)
+endif
+endif  # LOCAL_SDK_VERSION is set
+endif  # LOCAL_RENDERSCRIPT_TARGET_API is set
+ifneq (,$(renderscript_target_api))
+ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true)
 my_generated_res_dirs := $(rs_generated_res_dir)
 my_generated_res_dirs_deps := $(RenderScript_file_stamp)
+endif  # renderscript_target_api < 21
+endif  # renderscript_target_api is set
+my_asset_dirs := $(LOCAL_ASSET_DIR)
+my_full_asset_paths := $(all_assets)
 # Add AAPT2 link specific flags.
 $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --no-static-lib-packages
 include $(BUILD_SYSTEM)/aapt2.mk
@@ -463,7 +514,7 @@
 ifneq ($(full_classes_jar),)
 $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
 # Use the jarjar processed arhive as the initial package file.
-$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
 $(LOCAL_BUILT_MODULE): $(built_dex)
 else
 $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
@@ -494,6 +545,7 @@
 endif
 private_key := $(LOCAL_CERTIFICATE).pk8
 certificate := $(LOCAL_CERTIFICATE).x509.pem
+additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
 
 $(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR)
 $(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
@@ -502,8 +554,8 @@
 PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
 PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
 
-$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
-    $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
+$(LOCAL_BUILT_MODULE): $(additional_certificates)
+$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
 
 # Define the rule to build the actual package.
 # PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>.
@@ -535,15 +587,8 @@
 endif
 	@echo "target Package: $(PRIVATE_MODULE) ($@)"
 ifdef LOCAL_USE_AAPT2
-ifdef LOCAL_JACK_ENABLED
 	$(call copy-file-to-new-target)
-else
-	@# TODO: implement merge-two-packages.
-	$(if $(PRIVATE_SOURCE_ARCHIVE),\
-	  $(call merge-two-packages,$(PRIVATE_RES_PACKAGE) $(PRIVATE_SOURCE_ARCHIVE),$@),
-	  $(call copy-file-to-new-target))
-endif
-else  # LOCAL_USE_AAPT2
+else  # ! LOCAL_USE_AAPT2
 ifdef LOCAL_JACK_ENABLED
 	$(create-empty-package)
 else
@@ -602,12 +647,6 @@
 ###############################
 ## APK splits
 ifdef LOCAL_PACKAGE_SPLITS
-# LOCAL_PACKAGE_SPLITS is a list of resource labels.
-# aapt will convert comma inside resource lable to underscore in the file names.
-my_split_suffixes := $(subst $(comma),_,$(LOCAL_PACKAGE_SPLITS))
-built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk)
-installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
-
 # The splits should have been built in the same command building the base apk.
 # This rule just runs signing.
 # Note that we explicily check the existence of the split apk and remove the
@@ -623,7 +662,7 @@
 	$(sign-package)
 
 # Rules to install the splits
-$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP)
+$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk
 	@echo "Install: $@"
 	$(copy-file-to-new-target)
 
@@ -633,27 +672,23 @@
   $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
 
 # Make sure to install the splits when you run "make <module_name>".
-$(my_register_name): $(installed_apk_splits)
+$(my_all_targets): $(installed_apk_splits)
 
 ifdef LOCAL_COMPATIBILITY_SUITE
-cts_testcase_file := $(foreach s,$(my_split_suffixes),$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE)_$(s).apk)
-$(cts_testcase_file) : $(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP)
-	$(copy-file-to-new-target)
 
-COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES := \
-  $(COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES) \
-  $(cts_testcase_file)
+$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+  $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
+    $(foreach s,$(my_split_suffixes),\
+      $(built_module_path)/package_$(s).apk:$(dir)/$(LOCAL_MODULE)_$(s).apk))))
 
-$(my_register_name) : $(cts_testcase_file)
+$(call create-suite-dependencies)
+
 endif # LOCAL_COMPATIBILITY_SUITE
 endif # LOCAL_PACKAGE_SPLITS
 
 # Save information about this package
 PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
 PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
-ifdef package_resource_overlays
-PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays)
-endif
 
 PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
 
@@ -661,3 +696,27 @@
 
 # Reset internal variables.
 all_res_assets :=
+
+ifdef enforce_rro_enabled
+  ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
+    enforce_rro_use_res_lib := true
+  else
+    enforce_rro_use_res_lib := false
+  endif
+
+  ifdef LOCAL_MANIFEST_PACKAGE_NAME
+    enforce_rro_is_manifest_package_name := true
+    enforce_rro_manifest_package_info := $(LOCAL_MANIFEST_PACKAGE_NAME)
+  else
+    enforce_rro_is_manifest_package_name := false
+    enforce_rro_manifest_package_info := $(full_android_manifest)
+  endif
+
+$(call append_enforce_rro_sources, \
+    $(my_register_name), \
+    $(enforce_rro_is_manifest_package_name), \
+    $(enforce_rro_manifest_package_info), \
+    $(enforce_rro_use_res_lib), \
+    $(package_resource_overlays) \
+    )
+endif  # enforce_rro_enabled
diff --git a/core/pathmap.mk b/core/pathmap.mk
index effc878..7ca9588 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -49,8 +49,7 @@
     audio-route:system/media/audio_route/include \
     wilhelm:frameworks/wilhelm/include \
     wilhelm-ut:frameworks/wilhelm/src/ut \
-    mediandk:frameworks/av/media/ndk/ \
-    speex:external/speex/include
+    mediandk:frameworks/av/media/ndk/
 
 #
 # Returns the path to the requested module's include directory,
@@ -100,78 +99,3 @@
 #
 FRAMEWORKS_BASE_JAVA_SRC_DIRS := \
 	$(addprefix frameworks/base/,$(FRAMEWORKS_BASE_SUBDIRS))
-
-#
-# A list of all source roots under frameworks/support.
-#
-FRAMEWORKS_SUPPORT_SUBDIRS := \
-        annotations \
-        compat \
-        media-compat \
-        fragment \
-        core-ui \
-        core-utils \
-        v7/gridlayout \
-        v7/cardview \
-        v7/mediarouter \
-        v7/palette \
-        v8/renderscript \
-        v13 \
-        v17/leanback \
-        design \
-        percent \
-        recommendation \
-        transition \
-        v7/preference \
-        v14/preference \
-        v17/preference-leanback \
-        documents-archive \
-        customtabs
-
-#
-# A list of all source roots under frameworks/multidex.
-#
-FRAMEWORKS_MULTIDEX_SUBDIRS := \
-        multidex/library/src \
-        multidex/instrumentation/src
-
-#
-# A version of FRAMEWORKS_SUPPORT_SUBDIRS that is expanded to full paths from
-# the root of the tree.
-#
-FRAMEWORKS_SUPPORT_JAVA_SRC_DIRS := \
-	$(addprefix frameworks/support/,$(FRAMEWORKS_SUPPORT_SUBDIRS)) \
-	$(addprefix frameworks/,$(FRAMEWORKS_MULTIDEX_SUBDIRS)) \
-        frameworks/support/graphics/drawable/animated \
-        frameworks/support/graphics/drawable/static \
-	frameworks/support/v7/appcompat/src \
-	frameworks/support/v7/recyclerview/src
-
-#
-# A list of support library modules.
-#
-FRAMEWORKS_SUPPORT_JAVA_LIBRARIES := \
-    $(foreach dir,$(FRAMEWORKS_SUPPORT_SUBDIRS),android-support-$(subst /,-,$(dir))) \
-    android-support-v4 \
-    android-support-vectordrawable \
-    android-support-animatedvectordrawable \
-    android-support-v7-appcompat \
-    android-support-v7-recyclerview \
-    android-support-multidex \
-    android-support-multidex-instrumentation
-
-#
-# A list of all documented source roots under frameworks/data-binding.
-#
-FRAMEWORKS_DATA_BINDING_SUBDIRS := \
-        baseLibrary/src/main \
-        extensions/library/src/main \
-        extensions/library/src/doc
-
-#
-# A version of FRAMEWORKS_DATA_BINDING_SUBDIRS that is expanded to full paths from
-# the root of the tree.
-#
-FRAMEWORKS_DATA_BINDING_JAVA_SRC_DIRS := \
-	$(addprefix frameworks/data-binding/,$(FRAMEWORKS_DATA_BINDING_SUBDIRS))
-
diff --git a/core/pdk_config.mk b/core/pdk_config.mk
index c0aaacd..8c986d6 100644
--- a/core/pdk_config.mk
+++ b/core/pdk_config.mk
@@ -17,7 +17,7 @@
   target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates \
   target/common/obj/JAVA_LIBRARIES/core-oj_intermediates \
   target/common/obj/JAVA_LIBRARIES/core-libart_intermediates \
-  target/common/obj/JAVA_LIBRARIES/core-junit_intermediates \
+  target/common/obj/JAVA_LIBRARIES/legacy-test_intermediates \
   target/common/obj/JAVA_LIBRARIES/ext_intermediates \
   target/common/obj/JAVA_LIBRARIES/framework_intermediates \
   target/common/obj/JAVA_LIBRARIES/ims-common_intermediates \
diff --git a/core/pdk_fusion_modules.mk b/core/pdk_fusion_modules.mk
index 49b30dc..0c03f37 100644
--- a/core/pdk_fusion_modules.mk
+++ b/core/pdk_fusion_modules.mk
@@ -23,7 +23,7 @@
 LOCAL_BUILT_MODULE_STEM:=$(7)
 LOCAL_MODULE_SUFFIX:=$(suffix $(7))
 LOCAL_PRIVILEGED_MODULE:=$(8)
-LOCAL_PROPRIETARY_MODULE:=$(9)
+LOCAL_VENDOR_MODULE:=$(9)
 LOCAL_MODULE_TARGET_ARCH:=$(10)
 LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=$(11)
 LOCAL_CERTIFICATE:=PRESIGNED
@@ -72,7 +72,7 @@
     $(PDK.DEXPREOPT.$(a).DEX_PREOPT_FLAGS),\
     package.apk,\
     $(PDK.DEXPREOPT.$(a).PRIVILEGED_MODULE),\
-    $(PDK.DEXPREOPT.$(a).PROPRIETARY_MODULE),\
+    $(PDK.DEXPREOPT.$(a).VENDOR_MODULE),\
     $(PDK.DEXPREOPT.$(a).TARGET_ARCH),\
     $(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(a).STRIPPED_SRC),\
     )))
diff --git a/core/phony_package.mk b/core/phony_package.mk
index 866b13c..578d629 100644
--- a/core/phony_package.mk
+++ b/core/phony_package.mk
@@ -1,3 +1,4 @@
+$(call record-module-type,PHONY_PACKAGE)
 ifneq ($(strip $(LOCAL_SRC_FILES)),)
 $(error LOCAL_SRC_FILES are not allowed for phony packages)
 endif
@@ -7,7 +8,7 @@
 
 include $(BUILD_SYSTEM)/base_rules.mk
 
-$(LOCAL_BUILT_MODULE): $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(hide) echo "Fake: $@"
 	$(hide) mkdir -p $(dir $@)
 	$(hide) touch $@
diff --git a/core/post_clean.mk b/core/post_clean.mk
deleted file mode 100644
index f08abff..0000000
--- a/core/post_clean.mk
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright (C) 2012 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.
-
-# Clean steps that need global knowledge of individual modules.
-# This file must be included after all Android.mks have been loaded.
-
-#######################################################
-# Checks the current build configurations against the previous build,
-# clean artifacts in TARGET_COMMON_OUT_ROOT if necessary.
-# If a package's resource overlay has been changed, its R class needs to be
-# regenerated.
-previous_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt
-current_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_overlays.txt
-current_all_packages_config := $(dir $(current_package_overlay_config))current_packages.txt
-
-$(shell rm -rf $(current_package_overlay_config) \
-    && mkdir -p $(dir $(current_package_overlay_config)) \
-    && touch $(current_package_overlay_config))
-$(shell echo '$(PACKAGES)' > $(current_all_packages_config))
-$(foreach p, $(PACKAGES), $(if $(PACKAGES.$(p).RESOURCE_OVERLAYS), \
-  $(shell echo '$(p)' '$(PACKAGES.$(p).RESOURCE_OVERLAYS)' >> $(current_package_overlay_config))))
-
-ifneq (,$(wildcard $(previous_package_overlay_config)))
-packages_overlay_changed := $(shell build/tools/diff_package_overlays.py \
-    $(current_all_packages_config) $(current_package_overlay_config) \
-    $(previous_package_overlay_config))
-ifneq (,$(packages_overlay_changed))
-overlay_cleanup_cmd := $(strip rm -rf $(foreach p, $(packages_overlay_changed),\
-    $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/$(p)_intermediates))
-$(info *** Overlay change detected, clean shared intermediate files...)
-$(info *** $(overlay_cleanup_cmd))
-$(shell $(overlay_cleanup_cmd))
-overlay_cleanup_cmd :=
-endif
-packages_overlay_changed :=
-endif
-
-# Now current becomes previous.
-$(shell mv -f $(current_package_overlay_config) $(previous_package_overlay_config))
-
-previous_package_overlay_config :=
-current_package_overlay_config :=
-current_all_packages_config :=
-
-#######################################################
-# Check if we need to delete obsolete generated java files.
-# When an aidl/proto/etc file gets deleted (or renamed), the generated java file is obsolete.
-previous_gen_java_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_gen_java_config.mk
-current_gen_java_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/current_gen_java_config.mk
-
-$(shell rm -rf $(current_gen_java_config) \
-  && mkdir -p $(dir $(current_gen_java_config))\
-  && touch $(current_gen_java_config))
--include $(previous_gen_java_config)
-
-intermediates_to_clean :=
-modules_with_gen_java_files :=
-$(foreach p, $(ALL_MODULES), \
-  $(eval gs := $(strip $(ALL_MODULES.$(p).AIDL_FILES)\
-                       $(ALL_MODULES.$(p).PROTO_FILES)\
-                       $(ALL_MODULES.$(p).RS_FILES)))\
-  $(if $(gs),\
-    $(eval modules_with_gen_java_files += $(p))\
-    $(shell echo 'GEN_SRC_FILES.$(p) := $(gs)' >> $(current_gen_java_config)))\
-  $(if $(filter-out $(gs),$(GEN_SRC_FILES.$(p))),\
-    $(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR))))
-intermediates_to_clean := $(strip $(intermediates_to_clean))
-ifdef intermediates_to_clean
-$(info *** Obsolete generated java files detected, clean intermediate files...)
-$(info *** rm -rf $(intermediates_to_clean))
-$(shell rm -rf $(intermediates_to_clean))
-intermediates_to_clean :=
-endif
-
-# For modules not loaded by the current build (e.g. you are running mm/mmm),
-# we copy the info from the previous bulid.
-$(foreach p, $(filter-out $(ALL_MODULES),$(MODULES_WITH_GEN_JAVA_FILES)),\
-  $(shell echo 'GEN_SRC_FILES.$(p) := $(GEN_SRC_FILES.$(p))' >> $(current_gen_java_config)))
-MODULES_WITH_GEN_JAVA_FILES := $(sort $(MODULES_WITH_GEN_JAVA_FILES) $(modules_with_gen_java_files))
-$(shell echo 'MODULES_WITH_GEN_JAVA_FILES := $(MODULES_WITH_GEN_JAVA_FILES)' >> $(current_gen_java_config))
-
-# Now current becomes previous.
-$(shell cmp $(current_gen_java_config) $(previous_gen_java_config) > /dev/null 2>&1 || mv -f $(current_gen_java_config) $(previous_gen_java_config))
-
-MODULES_WITH_GEN_JAVA_FILES :=
-modules_with_gen_java_files :=
-previous_gen_java_config :=
-current_gen_java_config :=
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index 428922b..839e14f 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -5,12 +5,20 @@
 ## None.
 ##
 ###########################################################
+$(call record-module-type,PREBUILT)
 
 ifdef LOCAL_IS_HOST_MODULE
   my_prefix := HOST_
   LOCAL_HOST_PREFIX :=
 else
   my_prefix := TARGET_
+
+  ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
+    # Only support prebuilt shared and static libraries for translated arch
+    ifeq ($(filter SHARED_LIBRARIES STATIC_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
+      LOCAL_MULTILIB := first
+    endif
+  endif
 endif
 
 include $(BUILD_SYSTEM)/multilib.mk
@@ -52,7 +60,7 @@
 
 ifdef LOCAL_IS_HOST_MODULE
 ifdef HOST_CROSS_OS
-ifneq (,$(filter EXECUTABLES STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)))
+ifneq (,$(filter EXECUTABLES STATIC_LIBRARIES SHARED_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)))
 my_prefix := HOST_CROSS_
 LOCAL_HOST_PREFIX := $(my_prefix)
 include $(BUILD_SYSTEM)/module_arch_supported.mk
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index b6727fa..8a5470e 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -16,9 +16,6 @@
 $(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
 endif
 
-# Not much sense to check build prebuilts
-LOCAL_DONT_CHECK_MODULE := true
-
 my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
 
 ifdef LOCAL_PREBUILT_MODULE_FILE
@@ -38,6 +35,8 @@
   endif
 endif
 
+LOCAL_CHECKED_MODULE := $(my_prebuilt_src_file)
+
 my_strip_module := $(firstword \
   $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
   $(LOCAL_STRIP_MODULE))
@@ -46,9 +45,18 @@
   $(LOCAL_PACK_MODULE_RELOCATIONS))
 
 ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
-  # Put the built targets of all shared libraries in a common directory
-  # to simplify the link line.
-  OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
+  # LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES indicates that this prebuilt should be
+  # installed to the common directory of libraries. This is needed for the NDK
+  # shared libraries built by soong, as we build many different versions of each
+  # library (one for each API level). Since they all have the same basename,
+  # they'd clobber each other (as well as any platform libraries by the same
+  # name).
+  ifneq ($(LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES),false)
+    # Put the built targets of all shared libraries in a common directory
+    # to simplify the link line.
+    OVERRIDE_BUILT_MODULE_PATH :=  \
+        $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
+  endif
   ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
     # Strip but not try to add debuglink
     my_strip_module := no_debuglink
@@ -70,6 +78,16 @@
   prebuilt_module_is_a_library :=
 endif
 
+ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+  ifeq ($(prebuilt_module_is_a_library),true)
+    SOONG_ALREADY_CONV := $(SOONG_ALREADY_CONV) $(LOCAL_MODULE)
+  endif
+
+  ifdef LOCAL_USE_VNDK
+    SPLIT_VENDOR.$(LOCAL_MODULE_CLASS).$(patsubst %.vendor,%,$(LOCAL_MODULE)) := 1
+  endif
+endif
+
 # Don't install static libraries by default.
 ifndef LOCAL_UNINSTALLABLE_MODULE
 ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
@@ -90,11 +108,11 @@
 endif
 endif
 
-ifneq ($(filter true no_debuglink,$(my_strip_module) $(my_pack_module_relocations)),)
+ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module) $(my_pack_module_relocations)),)
   ifdef LOCAL_IS_HOST_MODULE
     $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH))
   endif
-  ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
+  ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
     $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
   endif
   ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
@@ -112,19 +130,39 @@
 
 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) : $(LOCAL_MODULE_MAKEFILE_DEP)
+export_cflags := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d))
+# Soong exports cflags instead of include dirs, so that -isystem can be included.
+ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+export_cflags += $(LOCAL_EXPORT_CFLAGS)
+else ifdef LOCAL_EXPORT_CFLAGS
+$(call pretty-error,LOCAL_EXPORT_CFLAGS can only be used by Soong, use LOCAL_EXPORT_C_INCLUDE_DIRS instead)
+endif
+$(export_includes): PRIVATE_EXPORT_CFLAGS := $(export_cflags)
+$(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS)
 	@echo Export includes file: $< -- $@
 	$(hide) mkdir -p $(dir $@) && rm -f $@
-ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
-	$(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
-	        echo "-I $$d" >> $@; \
-	        done
+ifdef export_cflags
+	$(hide) echo "$(PRIVATE_EXPORT_CFLAGS)" >$@
 else
 	$(hide) touch $@
 endif
+export_cflags :=
 
-$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
+my_link_type := $(intermediates)/link_type
+ifdef LOCAL_SDK_VERSION
+$(my_link_type): PRIVATE_LINK_TYPE := native:ndk
+else ifdef LOCAL_USE_VNDK
+$(my_link_type): PRIVATE_LINK_TYPE := native:vendor
+else
+$(my_link_type): PRIVATE_LINK_TYPE := native:platform
+endif
+$(eval $(call link-type-partitions,$(my_link_type)))
+$(my_link_type):
+	@echo Check module type: $@
+	$(hide) mkdir -p $(dir $@) && rm -f $@
+	$(hide) echo "$(PRIVATE_LINK_TYPE)" >$@
+
+$(LOCAL_BUILT_MODULE) : | $(export_includes) $(my_link_type)
 endif  # prebuilt_module_is_a_library
 
 # The real dependency will be added after all Android.mks are loaded and the install paths
@@ -134,6 +172,14 @@
 my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
 # Extra shared libraries introduced by LOCAL_CXX_STL.
 include $(BUILD_SYSTEM)/cxx_stl_setup.mk
+ifdef LOCAL_USE_VNDK
+  ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
+    my_shared_libraries := $(addsuffix .vendor,$(my_shared_libraries))
+  else
+    my_shared_libraries := $(foreach l,$(my_shared_libraries),\
+      $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
+  endif
+endif
 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
   $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
 
@@ -151,6 +197,34 @@
 # "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
 endif  # my_strip_module not true
 
+ifeq ($(NATIVE_COVERAGE),true)
+ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE)))
+  $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir))
+  ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true)
+    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
+    my_coverage_path := $(my_coverage_path)/$(basename $(my_installed_module_stem)).gcnodir
+    $(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
+    $(LOCAL_BUILT_MODULE): $(my_coverage_path)
+  endif
+else
+# Coverage information is needed when static lib is a dependency of another
+# coverage-enabled module.
+ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS))
+GCNO_ARCHIVE := $(LOCAL_MODULE).gcnodir
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS :=
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES :=
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix)
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
+$(intermediates)/$(GCNO_ARCHIVE) :
+	$(transform-o-to-static-lib)
+endif
+endif
+endif
+
 ifeq ($(LOCAL_MODULE_CLASS),APPS)
 PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
 
@@ -200,6 +274,7 @@
   LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
   PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
 
+  $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
   $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
   $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
 endif
@@ -226,6 +301,7 @@
   PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
   PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
 
+  $(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
   $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
   $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
 endif
@@ -243,7 +319,7 @@
 #######################################
 ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
 # There is a replacement for the prebuilt .apk we can install without any processing.
-$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED) | $(ACP)
+$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED)
 	$(transform-prebuilt-to-target)
 
 else  # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
@@ -261,7 +337,7 @@
 endif
 $(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
 
-$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) $(AAPT)
+$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(SIGNAPK_JAR)
 	$(transform-prebuilt-to-target)
 	$(uncompress-shared-libs)
 ifdef LOCAL_DEX_PREOPT
@@ -305,14 +381,15 @@
 endif
 my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
 
+$(built_apk_splits) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
 $(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
 $(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
-$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP) $(AAPT)
+$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk
 	$(copy-file-to-new-target)
 	$(sign-package)
 
 # Rules to install the split apks.
-$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP)
+$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk
 	@echo "Install: $@"
 	$(copy-file-to-new-target)
 
@@ -322,12 +399,11 @@
   $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
 
 # Make sure to install the splits when you run "make <module_name>".
-$(my_register_name): $(installed_apk_splits)
+$(my_all_targets): $(installed_apk_splits)
 
 endif # LOCAL_PACKAGE_SPLITS
 
-else # LOCAL_MODULE_CLASS != APPS
-ifeq ($(prebuilt_module_is_dex_javalib),true)
+else ifeq ($(prebuilt_module_is_dex_javalib),true)  # ! LOCAL_MODULE_CLASS != APPS
 # This is a target shared library, i.e. a jar with classes.dex.
 #######################################
 # defines built_odex along with rule to install odex
@@ -337,7 +413,7 @@
 ifneq ($(dexpreopt_boot_jar_module),) # boot jar
 # boot jar's rules are defined in dex_preopt.mk
 dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
-$(built_module) : $(dexpreopted_boot_jar) | $(ACP)
+$(built_module) : $(dexpreopted_boot_jar)
 	$(call copy-file-to-target)
 
 # For libart boot jars, we don't have .odex files.
@@ -348,53 +424,71 @@
 	@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
 	$(call dexpreopt-one-file,$<,$@)
 
-$(built_module) : $(my_prebuilt_src_file) | $(ACP)
+$(built_module) : $(my_prebuilt_src_file)
 	$(call copy-file-to-target)
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
 endif # boot jar
 else # ! LOCAL_DEX_PREOPT
-$(built_module) : $(my_prebuilt_src_file) | $(ACP)
+$(built_module) : $(my_prebuilt_src_file)
 	$(call copy-file-to-target)
 endif # LOCAL_DEX_PREOPT
 
 else  # ! prebuilt_module_is_dex_javalib
+$(built_module) : $(my_prebuilt_src_file)
 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
-$(built_module) : $(my_prebuilt_src_file)
 	$(transform-prebuilt-to-target-strip-comments)
-ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
-	$(hide) chmod +x $@
-endif
-else ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
-$(built_module) : $(my_prebuilt_src_file) | $(ACP)
-	$(transform-prebuilt-to-target)
-ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
-	$(hide) chmod +x $@
-endif
 else
-$(built_module) : $(my_prebuilt_src_file)
-	$(copy-file-to-target-with-cp)
-ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
-	$(hide) chmod +x $@
+	$(transform-prebuilt-to-target)
 endif
+ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
+	$(hide) chmod +x $@
 endif
 endif # ! prebuilt_module_is_dex_javalib
-endif # LOCAL_MODULE_CLASS != APPS
 
 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
 my_src_jar := $(my_prebuilt_src_file)
-ifeq ($(LOCAL_IS_HOST_MODULE),)
+
+ifdef LOCAL_IS_HOST_MODULE
+# for host java libraries deps should be in the common dir, so we make a copy in
+# the common dir.
+common_classes_jar := $(intermediates.COMMON)/classes.jar
+
+$(common_classes_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(common_classes_jar): PRIVATE_PREFIX := $(my_prefix)
+
+$(common_classes_jar) : $(my_src_jar)
+	$(transform-prebuilt-to-target)
+
+else # !LOCAL_IS_HOST_MODULE
 # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
 # while the deps should be in the common dir, so we make a copy in the common dir.
 common_classes_jar := $(intermediates.COMMON)/classes.jar
+common_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
 common_javalib_jar := $(intermediates.COMMON)/javalib.jar
 
-$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_PREFIX := $(my_prefix)
+
+my_link_type := $(intermediates.COMMON)/link_type
+ifeq ($(LOCAL_SDK_VERSION),system_current)
+$(my_link_type): PRIVATE_LINK_TYPE := java:system
+else ifneq ($(LOCAL_SDK_VERSION),)
+$(my_link_type): PRIVATE_LINK_TYPE := java:sdk
+else
+$(my_link_type): PRIVATE_LINK_TYPE := java:platform
+endif
+$(eval $(call link-type-partitions,$(my_link_type)))
+$(my_link_type):
+	@echo Check module type: $@
+	$(hide) mkdir -p $(dir $@) && rm -f $@
+	$(hide) echo "$(PRIVATE_LINK_TYPE)" >$@
+$(LOCAL_BUILT_MODULE): $(my_link_type)
 
 ifeq ($(prebuilt_module_is_dex_javalib),true)
 # For prebuilt shared Java library we don't have classes.jar.
-$(common_javalib_jar) : $(my_src_jar) | $(ACP)
+$(common_javalib_jar) : $(my_src_jar)
 	$(transform-prebuilt-to-target)
 
 else  # ! prebuilt_module_is_dex_javalib
@@ -412,10 +506,13 @@
 
 endif
 
-$(common_classes_jar) : $(my_src_jar) | $(ACP)
+$(common_classes_jar) : $(my_src_jar)
 	$(transform-prebuilt-to-target)
 
-$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
+$(common_classes_pre_proguard_jar) : $(my_src_jar)
+	$(transform-prebuilt-to-target)
+
+$(common_javalib_jar) : $(common_classes_jar)
 	$(transform-prebuilt-to-target)
 
 $(call define-jar-to-toc-rule, $(common_classes_jar))
@@ -457,25 +554,26 @@
 endif # LOCAL_IS_HOST_MODULE is not set
 
 ifneq ($(prebuilt_module_is_dex_javalib),true)
-ifneq ($(LOCAL_JILL_FLAGS),)
-$(error LOCAL_JILL_FLAGS is not supported any more, please use jack options in LOCAL_JACK_FLAGS instead)
-endif
 
+ifdef LOCAL_JACK_ENABLED
 # We may be building classes.jack from a host jar for host dalvik Java library.
 $(intermediates.COMMON)/classes.jack : PRIVATE_JACK_FLAGS:=$(LOCAL_JACK_FLAGS)
-$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := 1
-$(intermediates.COMMON)/classes.jack : $(my_src_jar) $(LOCAL_MODULE_MAKEFILE_DEP) \
-        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK) | setup-jack-server
+$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := $(if $(strip $(LOCAL_MIN_SDK_VERSION)),$(LOCAL_MIN_SDK_VERSION),1)
+$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
+$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
+$(intermediates.COMMON)/classes.jack : $(LOCAL_JACK_PLUGIN_PATH) $(my_src_jar) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK_DEFAULT_ARGS) $(JACK) \
+        | setup-jack-server
 	$(transform-jar-to-jack)
 
 # Update timestamps of .toc files for prebuilts so dependents will be
 # always rebuilt.
 $(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack
 	touch $@
-
+endif # LOCAL_JACK_ENABLED
 endif # ! prebuilt_module_is_dex_javalib
 endif # JAVA_LIBRARIES
 
-$(built_module) : $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
 
 my_prebuilt_src_file :=
diff --git a/core/product.mk b/core/product.mk
index c69e963..34cd21c 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -94,6 +94,7 @@
     PRODUCT_EXTRA_RECOVERY_KEYS \
     PRODUCT_PACKAGE_OVERLAYS \
     DEVICE_PACKAGE_OVERLAYS \
+    PRODUCT_ENFORCE_RRO_TARGETS \
     PRODUCT_SDK_ATREE_FILES \
     PRODUCT_SDK_ADDON_NAME \
     PRODUCT_SDK_ADDON_COPY_FILES \
@@ -111,7 +112,9 @@
     PRODUCT_SUPPORTS_VERITY_FEC \
     PRODUCT_OEM_PROPERTIES \
     PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
+    PRODUCT_SYSTEM_SERVER_APPS \
     PRODUCT_SYSTEM_SERVER_JARS \
+    PRODUCT_DEXPREOPT_SPEED_APPS \
     PRODUCT_VBOOT_SIGNING_KEY \
     PRODUCT_VBOOT_SIGNING_SUBKEY \
     PRODUCT_VERITY_SIGNING_KEY \
@@ -124,6 +127,11 @@
     PRODUCT_SYSTEM_BASE_FS_PATH \
     PRODUCT_VENDOR_BASE_FS_PATH \
     PRODUCT_SHIPPING_API_LEVEL \
+    VENDOR_PRODUCT_RESTRICT_VENDOR_FILES \
+    VENDOR_EXCEPTION_MODULES \
+    VENDOR_EXCEPTION_PATHS \
+    PRODUCT_ART_USE_READ_BARRIER \
+    PRODUCT_IOT \
     PRODUCT_SYSTEM_HEADROOM \
 
 
@@ -286,41 +294,19 @@
 _product_stash_var_list += \
 	DEFAULT_SYSTEM_DEV_CERTIFICATE \
 	WITH_DEXPREOPT \
-	WITH_DEXPREOPT_BOOT_IMG_ONLY
-
-_product_stash_var_list += \
-	GLOBAL_CFLAGS_NO_OVERRIDE \
-	GLOBAL_CPPFLAGS_NO_OVERRIDE \
-	GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \
+	WITH_DEXPREOPT_BOOT_IMG_ONLY \
+	WITH_DEXPREOPT_APP_IMAGE
 
 #
-# 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 4117332..32a3809 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_word1))\
         $(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 :=
@@ -264,6 +268,8 @@
 # A list of module names of BOOTCLASSPATH (jar files)
 PRODUCT_BOOT_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BOOT_JARS))
 PRODUCT_SYSTEM_SERVER_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_SERVER_JARS))
+PRODUCT_SYSTEM_SERVER_APPS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_SERVER_APPS))
+PRODUCT_DEXPREOPT_SPEED_APPS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEXPREOPT_SPEED_APPS))
 
 # Find the device that this product maps to.
 TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)
@@ -319,9 +325,6 @@
   PRODUCT_MANUFACTURER := unknown
 endif
 
-# Add reserved headroom to a system image.
-PRODUCT_SYSTEM_HEADROOM := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM))
-
 ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CHARACTERISTICS),)
   TARGET_AAPT_CHARACTERISTICS := default
 else
@@ -353,18 +356,16 @@
 # whitespace characters on either side of the '='.
 PRODUCT_PROPERTY_OVERRIDES := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
+.KATI_READONLY := PRODUCT_PROPERTY_OVERRIDES
 
 PRODUCT_SHIPPING_API_LEVEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SHIPPING_API_LEVEL))
-ifdef PRODUCT_SHIPPING_API_LEVEL
-ADDITIONAL_BUILD_PROPERTIES += \
-    ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
-endif
 
 # A list of property assignments, like "key = value", with zero or more
 # whitespace characters on either side of the '='.
 # used for adding properties to default.prop
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+.KATI_READONLY := PRODUCT_DEFAULT_PROPERTY_OVERRIDES
 
 # Should we use the default resources or add any product specific overlays
 PRODUCT_PACKAGE_OVERLAYS := \
@@ -376,11 +377,6 @@
 PRODUCT_VENDOR_KERNEL_HEADERS := \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_KERNEL_HEADERS)
 
-# Add the product-defined properties to the build properties.
-ADDITIONAL_BUILD_PROPERTIES := \
-    $(ADDITIONAL_BUILD_PROPERTIES) \
-    $(PRODUCT_PROPERTY_OVERRIDES)
-
 # The OTA key(s) specified by the product config, if any.  The names
 # of these keys are stored in the target-files zip so that post-build
 # signing tools can substitute them for the test key embedded by
@@ -422,3 +418,19 @@
     $(eval cf := $(subst $(_PSMC_SP_PLACE_HOLDER),$(space),$(cf)))\
     $(eval SANITIZER.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))
 _psmc_modules :=
+
+# Make this art variable visible to soong_config.mk.
+PRODUCT_ART_USE_READ_BARRIER := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ART_USE_READ_BARRIER))
+
+# Whether the product is an Android Things variant.
+PRODUCT_IOT := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_IOT))
+
+# Package list to apply enforcing RRO.
+PRODUCT_ENFORCE_RRO_TARGETS := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ENFORCE_RRO_TARGETS))
+
+# Add reserved headroom to a system image.
+PRODUCT_SYSTEM_HEADROOM := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM))
diff --git a/core/setup_one_odex.mk b/core/setup_one_odex.mk
index 36b6817..f0ffe81 100644
--- a/core/setup_one_odex.mk
+++ b/core/setup_one_odex.mk
@@ -34,8 +34,35 @@
 
 my_installed_odex := $(call get-odex-installed-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
 
+my_built_vdex := $(patsubst %.odex,%.vdex,$(my_built_odex))
+my_installed_vdex := $(patsubst %.odex,%.vdex,$(my_installed_odex))
+my_installed_art := $(patsubst %.odex,%.art,$(my_installed_odex))
+
+ifndef LOCAL_DEX_PREOPT_APP_IMAGE
+# Local override not defined, use the global one.
+ifeq (true,$(WITH_DEX_PREOPT_APP_IMAGE))
+  LOCAL_DEX_PREOPT_APP_IMAGE := true
+endif
+endif
+
+ifeq (true,$(LOCAL_DEX_PREOPT_APP_IMAGE))
+my_built_art := $(patsubst %.odex,%.art,$(my_built_odex))
+$(my_built_odex): PRIVATE_ART_FILE_PREOPT_FLAGS := --app-image-file=$(my_built_art) \
+    --image-format=lz4
+$(eval $(call copy-one-file,$(my_built_art),$(my_installed_art)))
+built_art += $(my_built_art)
+installed_art += $(my_installed_art)
+built_installed_art += $(my_built_art):$(my_installed_art)
+endif
+
 $(eval $(call copy-one-file,$(my_built_odex),$(my_installed_odex)))
+$(eval $(call copy-one-file,$(my_built_vdex),$(my_installed_vdex)))
 
 built_odex += $(my_built_odex)
+built_vdex += $(my_built_vdex)
+
 installed_odex += $(my_installed_odex)
+installed_vdex += $(my_installed_vdex)
+
 built_installed_odex += $(my_built_odex):$(my_installed_odex)
+built_installed_vdex += $(my_built_vdex):$(my_installed_vdex)
diff --git a/core/shared_library.mk b/core/shared_library.mk
index 2f48341..a15b1a6 100644
--- a/core/shared_library.mk
+++ b/core/shared_library.mk
@@ -1,3 +1,4 @@
+$(call record-module-type,SHARED_LIBRARY)
 my_prefix := TARGET_
 include $(BUILD_SYSTEM)/multilib.mk
 
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
index b9a5e3e..687536b 100644
--- a/core/shared_library_internal.mk
+++ b/core/shared_library_internal.mk
@@ -39,33 +39,26 @@
 include $(BUILD_SYSTEM)/dynamic_binary.mk
 
 # Define PRIVATE_ variables from global vars
-my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS)
 ifeq ($(LOCAL_NO_LIBGCC),true)
 my_target_libgcc :=
 else
-my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC)
+my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a
 endif
-my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC)
+my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a
 ifeq ($(LOCAL_NO_CRT),true)
 my_target_crtbegin_so_o :=
 my_target_crtend_so_o :=
+else ifdef LOCAL_USE_VNDK
+my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.vendor.o
+my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.vendor.o
 else
-my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_SO_O)
-my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_SO_O)
+my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
 endif
-ifdef LOCAL_SDK_VERSION
-# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
-# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
-my_target_global_ld_dirs := \
-    $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
-    $(my_ndk_sysroot_lib)) \
-    $(my_target_global_ld_dirs)
-my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
+ifneq ($(LOCAL_SDK_VERSION),)
 my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o)
 my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o)
 endif
-$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
-$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
 $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
 $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
 $(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
@@ -76,8 +69,44 @@
         $(all_libraries) \
         $(my_target_crtbegin_so_o) \
         $(my_target_crtend_so_o) \
-        $(LOCAL_MODULE_MAKEFILE_DEP) \
+        $(my_target_libgcc) \
+        $(my_target_libatomic) \
         $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-o-to-shared-lib)
 
+ifeq ($(my_native_coverage),true)
+gcno_suffix := .gcnodir
+
+built_whole_gcno_libraries := \
+    $(foreach lib,$(my_whole_static_libraries), \
+      $(call intermediates-dir-for, \
+        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
+        $(my_host_cross))/$(lib)$(gcno_suffix))
+
+built_static_gcno_libraries := \
+    $(foreach lib,$(my_static_libraries), \
+      $(call intermediates-dir-for, \
+        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
+        $(my_host_cross))/$(lib)$(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) : PRIVATE_INTERMEDIATES_DIR := $(intermediates)
+$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries)
+	$(transform-o-to-static-lib)
+
+$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
+	$(copy-file-to-target)
+
+$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
+endif
+
 endif  # skip_build_from_source
diff --git a/core/shared_test_lib.mk b/core/shared_test_lib.mk
index fbfdc9c..1ea9fe7 100644
--- a/core/shared_test_lib.mk
+++ b/core/shared_test_lib.mk
@@ -1,8 +1 @@
-#############################################
-## A thin wrapper around BUILD_SHARED_LIBRARY
-## Common flags for native tests are added.
-#############################################
-
-include $(BUILD_SYSTEM)/target_test_internal.mk
-
-include $(BUILD_SHARED_LIBRARY)
+$(error BUILD_SHARED_TEST_LIBRARY is obsolete)
diff --git a/core/soong.mk b/core/soong.mk
deleted file mode 100644
index 2463953..0000000
--- a/core/soong.mk
+++ /dev/null
@@ -1,80 +0,0 @@
-SOONG_OUT_DIR := $(OUT_DIR)/soong
-SOONG_HOST_EXECUTABLES := $(SOONG_OUT_DIR)/host/$(HOST_PREBUILT_TAG)/bin
-KATI := $(SOONG_HOST_EXECUTABLES)/ckati
-MAKEPARALLEL := $(SOONG_HOST_EXECUTABLES)/makeparallel
-
-SOONG := $(SOONG_OUT_DIR)/soong
-SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
-SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
-SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android.mk
-SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
-SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
-
-# We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from
-# SOONG_OUT_DIR to TOP changes
-SOONG_NEEDS_REBOOTSTRAP :=
-ifneq ($(wildcard $(SOONG_BOOTSTRAP)),)
-  ifneq ($(SOONG_OUT_DIR),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$BUILDDIR)))
-    SOONG_NEEDS_REBOOTSTRAP := FORCE
-    $(warning soong_out_dir changed)
-  endif
-  ifneq ($(strip $(shell build/soong/reverse_path.py $(SOONG_OUT_DIR))),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$SRCDIR_FROM_BUILDDIR)))
-    SOONG_NEEDS_REBOOTSTRAP := FORCE
-    $(warning reverse path changed)
-  endif
-endif
-
-# Bootstrap soong.
-$(SOONG_BOOTSTRAP): bootstrap.bash $(SOONG_NEEDS_REBOOTSTRAP)
-	$(hide) mkdir -p $(dir $@)
-	$(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash
-
-# Create soong.variables with copies of makefile settings.  Runs every build,
-# but only updates soong.variables if it changes
-SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$
-$(SOONG_VARIABLES): FORCE
-	$(hide) mkdir -p $(dir $@)
-	$(hide) (\
-	echo '{'; \
-	echo '    "Device_uses_jemalloc": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
-	echo '    "Device_uses_dlmalloc": $(if $(filter true,$(MALLOC_SVELTE)),true,false),'; \
-	echo '    "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \
-	echo '    "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \
-	echo '    "Brillo": $(if $(BRILLO),true,false),'; \
-	echo ''; \
-	echo '    "DeviceName": "$(TARGET_DEVICE)",'; \
-	echo '    "DeviceArch": "$(TARGET_ARCH)",'; \
-	echo '    "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
-	echo '    "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \
-	echo '    "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \
-	echo '    "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \
-	echo ''; \
-	echo '    "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \
-	echo '    "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \
-	echo '    "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
-	echo '    "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \
-	echo ''; \
-	echo '    "HostArch": "$(HOST_ARCH)",'; \
-	echo '    "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \
-	echo ''; \
-	echo '    "CrossHost": "$(HOST_CROSS_OS)",'; \
-	echo '    "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
-	echo '    "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)"'; \
-	echo '}') > $(SOONG_VARIABLES_TMP); \
-	if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
-	  mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
-	else \
-	  rm $(SOONG_VARIABLES_TMP); \
-	fi
-
-# Tell soong that it is embedded in make
-$(SOONG_IN_MAKE):
-	$(hide) mkdir -p $(dir $@)
-	$(hide) touch $@
-
-# Build an Android.mk listing all soong outputs as prebuilts
-$(SOONG_ANDROID_MK): $(SOONG_BOOTSTRAP) $(SOONG_VARIABLES) $(SOONG_IN_MAKE) FORCE
-	$(hide) $(SOONG) $(KATI) $(MAKEPARALLEL) $(NINJA_ARGS)
-
-$(KATI): $(SOONG_ANDROID_MK)
-$(MAKEPARALLEL): $(SOONG_ANDROID_MK)
diff --git a/core/soong_config.mk b/core/soong_config.mk
new file mode 100644
index 0000000..a075c96
--- /dev/null
+++ b/core/soong_config.mk
@@ -0,0 +1,80 @@
+SOONG := $(SOONG_OUT_DIR)/soong
+SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
+SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
+SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
+SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
+SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
+SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
+
+BINDER32BIT :=
+ifneq ($(TARGET_USES_64_BIT_BINDER),true)
+ifneq ($(TARGET_IS_64_BIT),true)
+BINDER32BIT := true
+endif
+endif
+
+# Create soong.variables with copies of makefile settings.  Runs every build,
+# but only updates soong.variables if it changes
+SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$
+$(SOONG_VARIABLES): FORCE
+	$(hide) mkdir -p $(dir $@)
+	$(hide) (\
+	echo '{'; \
+	echo '    "Make_suffix": "-$(TARGET_PRODUCT)",'; \
+	echo ''; \
+	echo '    "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \
+	echo '    "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \
+	echo '    "Brillo": $(if $(BRILLO),true,false),'; \
+	echo '    "Malloc_not_svelte": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
+	echo '    "Allow_missing_dependencies": $(if $(TARGET_BUILD_APPS)$(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),true,false),'; \
+	echo '    "SanitizeHost": [$(if $(SANITIZE_HOST),"$(subst $(space),"$(comma)",$(SANITIZE_HOST))")],'; \
+	echo '    "SanitizeDevice": [$(if $(SANITIZE_TARGET),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET))")],'; \
+	echo '    "SanitizeDeviceArch": [$(if $(SANITIZE_TARGET_ARCH),"$(subst $(space),"$(comma)",$(SANITIZE_TARGET_ARCH))")],'; \
+	echo '    "HostStaticBinaries": $(if $(strip $(BUILD_HOST_static)),true,false),'; \
+	echo '    "Binder32bit": $(if $(BINDER32BIT),true,false),'; \
+	echo '    "DevicePrefer32BitExecutables": $(if $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)),true,false),'; \
+	echo '    "UseGoma": $(if $(filter-out false,$(USE_GOMA)),true,false),'; \
+	echo '    "Debuggable": $(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),true,false),'; \
+	echo '    "Eng": $(if $(filter eng,$(TARGET_BUILD_VARIANT)),true,false),'; \
+	echo '    "VendorPath": "$(TARGET_COPY_OUT_VENDOR)",'; \
+	echo ''; \
+	echo '    "ClangTidy": $(if $(filter 1 true,$(WITH_TIDY)),true,false),'; \
+	echo '    "TidyChecks": "$(WITH_TIDY_CHECKS)",'; \
+	echo ''; \
+	echo '    "NativeCoverage": $(if $(filter true,$(NATIVE_COVERAGE)),true,false),'; \
+	echo '    "CoveragePaths": [$(if $(COVERAGE_PATHS),"$(subst $(space),"$(comma)",$(subst $(comma),$(space),$(COVERAGE_PATHS)))")],'; \
+	echo '    "CoverageExcludePaths": [$(if $(COVERAGE_EXCLUDE_PATHS),"$(subst $(space),"$(comma)",$(subst $(comma),$(space),$(COVERAGE_EXCLUDE_PATHS)))")],'; \
+	echo ''; \
+	echo '    "DeviceName": "$(TARGET_DEVICE)",'; \
+	echo '    "DeviceArch": "$(TARGET_ARCH)",'; \
+	echo '    "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
+	echo '    "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \
+	echo '    "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \
+	echo '    "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \
+	echo '    "DeviceVndkVersion": "$(BOARD_VNDK_VERSION)",'; \
+	echo ''; \
+	echo '    "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \
+	echo '    "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \
+	echo '    "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
+	echo '    "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \
+	echo ''; \
+	echo '    "HostArch": "$(HOST_ARCH)",'; \
+	echo '    "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \
+	echo ''; \
+	echo '    "CrossHost": "$(HOST_CROSS_OS)",'; \
+	echo '    "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
+	echo '    "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)",'; \
+	echo '    "Safestack": $(if $(filter true,$(USE_SAFESTACK)),true,false),'; \
+	echo '    "EnableCFI": $(if $(filter true,$(ENABLE_CFI)),true,false),'; \
+	echo '    "Treble": $(if $(filter true,$(PRODUCT_FULL_TREBLE)),true,false),'; \
+	echo '    "Override_rs_driver": "$(OVERRIDE_RS_DRIVER)",'; \
+	echo ''; \
+	echo '    "ArtUseReadBarrier": $(if $(filter false,$(PRODUCT_ART_USE_READ_BARRIER)),false,true),'; \
+	echo ''; \
+	echo '    "BtConfigIncludeDir": "$(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)"'; \
+	echo '}') > $(SOONG_VARIABLES_TMP); \
+	if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
+	  mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
+	else \
+	  rm $(SOONG_VARIABLES_TMP); \
+	fi
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index 1279878..69196f4 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -19,6 +19,7 @@
 # classpaths.  They can, however, be included wholesale in
 # other java modules.
 
+$(call record-module-type,STATIC_JAVA_LIBRARY)
 LOCAL_UNINSTALLABLE_MODULE := true
 LOCAL_IS_STATIC_JAVA_LIBRARY := true
 LOCAL_MODULE_CLASS := JAVA_LIBRARIES
@@ -68,7 +69,7 @@
 
 proguard_options_file :=
 
-ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
+ifneq ($(filter custom,$(LOCAL_PROGUARD_ENABLED)),custom)
   proguard_options_file := $(intermediates.COMMON)/proguard_options
 endif
 
@@ -140,12 +141,6 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
 
-ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
-else
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
-endif
-
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR :=
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME :=
@@ -154,8 +149,23 @@
 ifdef LOCAL_USE_AAPT2
 # One more level with name res so we can zip up the flat resources that can be linked by apps.
 my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res
+renderscript_target_api :=
+ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
+renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
+else
+ifneq (,$(LOCAL_SDK_VERSION))
+# Set target-api for LOCAL_SDK_VERSIONs other than current.
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+renderscript_target_api := $(LOCAL_SDK_VERSION)
+endif
+endif  # LOCAL_SDK_VERSION is set
+endif  # LOCAL_RENDERSCRIPT_TARGET_API is set
+ifneq (,$(renderscript_target_api))
+ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true)
 my_generated_res_dirs := $(rs_generated_res_dir)
 my_generated_res_dirs_deps := $(RenderScript_file_stamp)
+endif  # renderscript_target_api < 21
+endif  # renderscript_target_api is set
 include $(BUILD_SYSTEM)/aapt2.mk
 $(my_res_package) : $(framework_res_package_export_deps)
 else
@@ -173,14 +183,22 @@
 endif # LOCAL_JACK_ENABLED
 $(full_classes_compiled_jar): $(R_file_stamp)
 
+
+# if we have custom proguarding done use the proguarded classes jar instead of the normal classes jar
+ifeq ($(filter custom,$(LOCAL_PROGUARD_ENABLED)),custom)
+aar_classes_jar = $(full_classes_jar)
+else
+aar_classes_jar = $(full_classes_pre_proguard_jar)
+endif
+
 # Rule to build AAR, archive including classes.jar, resource, etc.
 built_aar := $(intermediates.COMMON)/javalib.aar
 $(built_aar): PRIVATE_MODULE := $(LOCAL_MODULE)
 $(built_aar): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
-$(built_aar): PRIVATE_CLASSES_JAR := $(full_classes_jar)
+$(built_aar): PRIVATE_CLASSES_JAR := $(aar_classes_jar)
 $(built_aar): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
 $(built_aar): PRIVATE_R_TXT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.txt
-$(built_aar) : $(full_classes_jar) $(full_android_manifest)
+$(built_aar) : $(aar_classes_jar) $(full_android_manifest)
 	@echo "target AAR:  $(PRIVATE_MODULE) ($@)"
 	$(hide) rm -rf $(dir $@)aar && mkdir -p $(dir $@)aar/res
 	$(hide) cp $(PRIVATE_ANDROID_MANIFEST) $(dir $@)aar/AndroidManifest.xml
@@ -196,5 +214,6 @@
 endif  # need_compile_res
 
 # Reset internal variables.
+aar_classes_jar :=
 all_res_assets :=
 LOCAL_IS_STATIC_JAVA_LIBRARY :=
diff --git a/core/static_library.mk b/core/static_library.mk
index a8ae399..25e5279 100644
--- a/core/static_library.mk
+++ b/core/static_library.mk
@@ -1,3 +1,4 @@
+$(call record-module-type,STATIC_LIBRARY)
 my_prefix := TARGET_
 include $(BUILD_SYSTEM)/multilib.mk
 
diff --git a/core/static_library_internal.mk b/core/static_library_internal.mk
index cabe823..6b4d22f 100644
--- a/core/static_library_internal.mk
+++ b/core/static_library_internal.mk
@@ -20,14 +20,26 @@
 
 include $(BUILD_SYSTEM)/binary.mk
 
-ifeq ($(LOCAL_RAW_STATIC_LIBRARY),true)
-LOCAL_RAW_STATIC_LIBRARY:=
-$(all_objects) : PRIVATE_TARGET_PROJECT_INCLUDES :=
-$(all_objects) : PRIVATE_TARGET_C_INCLUDES :=
-$(all_objects) : PRIVATE_TARGET_GLOBAL_CFLAGS :=
-$(all_objects) : PRIVATE_TARGET_GLOBAL_CPPFLAGS :=
-endif
-
 $(LOCAL_BUILT_MODULE) : $(built_whole_libraries)
 $(LOCAL_BUILT_MODULE) : $(all_objects)
 	$(transform-o-to-static-lib)
+
+ifeq ($(NATIVE_COVERAGE),true)
+gcno_suffix := .gcnodir
+
+built_whole_gcno_libraries := \
+    $(foreach lib,$(my_whole_static_libraries), \
+      $(call intermediates-dir-for, \
+        STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
+        $(my_host_cross))/$(lib)$(gcno_suffix))
+
+GCNO_ARCHIVE := $(LOCAL_MODULE)$(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))
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix)
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
+$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_INTERMEDIATES_DIR := $(intermediates)
+$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries)
+	$(transform-o-to-static-lib)
+endif
diff --git a/core/static_test_lib.mk b/core/static_test_lib.mk
index 9d0bcc8..a0e2970 100644
--- a/core/static_test_lib.mk
+++ b/core/static_test_lib.mk
@@ -2,6 +2,7 @@
 ## A thin wrapper around BUILD_STATIC_LIBRARY
 ## Common flags for native tests are added.
 #############################################
+$(call record-module-type,STATIC_TEST_LIBRARY)
 
 include $(BUILD_SYSTEM)/target_test_internal.mk
 
diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk
index 4715fe8..59a3a9e 100644
--- a/core/target_test_internal.mk
+++ b/core/target_test_internal.mk
@@ -2,14 +2,25 @@
 ## Shared definitions for all target test compilations.
 #######################################################
 
-LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING
+ifeq ($(LOCAL_GTEST),true)
+  LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING
 
-LOCAL_C_INCLUDES += external/gtest/include
-
-ifndef LOCAL_SDK_VERSION
-LOCAL_STATIC_LIBRARIES += libgtest_main libgtest
-else
-LOCAL_STATIC_LIBRARIES += libgtest_main_ndk libgtest_ndk
+  ifndef LOCAL_SDK_VERSION
+    LOCAL_STATIC_LIBRARIES += libgtest_main libgtest
+  else
+    ifneq (,$(filter c++_%,$(LOCAL_NDK_STL_VARIANT)))
+        my_ndk_gtest_suffix := _c++
+    else ifneq ($(filter stlport_,$(LOCAL_NDK_STL_VARIANT)),)
+        my_ndk_gtest_suffix := _stlport
+    else ifneq ($(filter gnustl_,$(LOCAL_NDK_STL_VARIANT)),)
+        my_ndk_gtest_suffix := _gnustl
+    else # system STL, use stlport
+        my_ndk_gtest_suffix := _stlport
+    endif
+    LOCAL_STATIC_LIBRARIES += \
+        libgtest_main_ndk$(my_ndk_gtest_suffix) \
+        libgtest_ndk$(my_ndk_gtest_suffix)
+  endif
 endif
 
 ifdef LOCAL_MODULE_PATH
@@ -24,5 +35,6 @@
 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
 endif
 
-LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+ifndef LOCAL_MODULE_RELATIVE_PATH
+LOCAL_MODULE_RELATIVE_PATH := $(LOCAL_MODULE)
+endif
diff --git a/core/tasks/check_boot_jars/package_whitelist.txt b/core/tasks/check_boot_jars/package_whitelist.txt
index 3cb6e28..1889117 100644
--- a/core/tasks/check_boot_jars/package_whitelist.txt
+++ b/core/tasks/check_boot_jars/package_whitelist.txt
@@ -8,6 +8,7 @@
 java\.io
 java\.lang
 java\.lang\.annotation
+java\.lang\.invoke
 java\.lang\.ref
 java\.lang\.reflect
 java\.math
@@ -28,6 +29,11 @@
 java\.sql
 java\.text
 java\.text\.spi
+java\.time
+java\.time\.chrono
+java\.time\.format
+java\.time\.temporal
+java\.time\.zone
 java\.util
 java\.util\.concurrent
 java\.util\.concurrent\.atomic
@@ -61,10 +67,13 @@
 javax\.xml\.transform\.stream
 javax\.xml\.validation
 javax\.xml\.xpath
+jdk\.net
 org\.w3c\.dom
 org\.w3c\.dom\.ls
 org\.w3c\.dom\.traversal
 # OpenJdk internal implementation.
+sun\.invoke\.util
+sun\.invoke\.empty
 sun\.misc
 sun\.util.*
 sun\.text.*
@@ -112,9 +121,11 @@
 
 
 ###################################################
-# core-junit.jar
+# legacy-test.jar
 junit\.extensions
 junit\.framework
+android\.test
+android\.test\.suitebuilder\.annotation
 
 
 ###################################################
diff --git a/core/tasks/device-tests.mk b/core/tasks/device-tests.mk
new file mode 100644
index 0000000..731937f
--- /dev/null
+++ b/core/tasks/device-tests.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2017 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 agrls eed 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.
+
+
+.PHONY: device-tests
+
+device-tests-zip := $(PRODUCT_OUT)/device-tests.zip
+$(device-tests-zip): $(COMPATIBILITY.device-tests.FILES) $(SOONG_ZIP)
+	echo $(COMPATIBILITY.device-tests.FILES) > [email protected]
+	sed -i -e 's/\s\+/\n/g' [email protected]
+	grep $(HOST_OUT_TESTCASES) [email protected] > [email protected] || true
+	grep $(TARGET_OUT_TESTCASES) [email protected] > [email protected] || true
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(HOST_OUT) -l [email protected] -C $(PRODUCT_OUT) -l [email protected]
+
+device-tests: $(device-tests-zip)
+$(call dist-for-goals, device-tests, $(device-tests-zip))
diff --git a/core/tasks/general-tests.mk b/core/tasks/general-tests.mk
new file mode 100644
index 0000000..e02faa7
--- /dev/null
+++ b/core/tasks/general-tests.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2017 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 agrls eed 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.
+
+.PHONY: general-tests
+
+general-tests-zip := $(PRODUCT_OUT)/general-tests.zip
+$(general-tests-zip): $(COMPATIBILITY.general-tests.FILES) $(SOONG_ZIP)
+	echo $(COMPATIBILITY.general-tests.FILES) > [email protected]
+	sed -i -e 's/\s\+/\n/g' [email protected]
+	grep $(HOST_OUT_TESTCASES) [email protected] > [email protected] || true
+	grep $(TARGET_OUT_TESTCASES) [email protected] > [email protected] || true
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(HOST_OUT) -l [email protected] -C $(PRODUCT_OUT) -l [email protected]
+
+general-tests: $(general-tests-zip)
+$(call dist-for-goals, general-tests, $(general-tests-zip))
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/core/tasks/sts.mk b/core/tasks/sts.mk
deleted file mode 100644
index b3c3baa..0000000
--- a/core/tasks/sts.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2016 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.
-
-test_suite_name := sts
-test_suite_tradefed := sts-tradefed
-test_suite_readme := test/sts/README.md
-
-include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk
-
-.PHONY: sts
-sts: $(compatibility_zip)
-$(call dist-for-goals, sts, $(compatibility_zip))
diff --git a/core/tasks/tools/build_custom_image.mk b/core/tasks/tools/build_custom_image.mk
index ec491fa..f0db476 100644
--- a/core/tasks/tools/build_custom_image.mk
+++ b/core/tasks/tools/build_custom_image.mk
@@ -90,6 +90,7 @@
 	$(hide) echo "mount_point=$(PRIVATE_MOUNT_POINT)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
 	$(hide) echo "fs_type=$(PRIVATE_FILE_SYSTEM_TYPE)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
 	$(hide) echo "partition_size=$(PRIVATE_PARTITION_SIZE)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
+	$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
 	$(if $(PRIVATE_SELINUX),$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt)
 	$(if $(PRIVATE_SUPPORT_VERITY),\
 	  $(hide) echo "verity=$(PRIVATE_SUPPORT_VERITY)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt;\
diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk
index d8f900e..20b8314 100644
--- a/core/tasks/tools/compatibility.mk
+++ b/core/tasks/tools/compatibility.mk
@@ -25,9 +25,14 @@
 out_dir := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name)
 test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES)
 test_tools := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar \
-  $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \
   $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util-tests.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/compatibility-common-util-tests.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/compatibility-tradefed-tests.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/host-libprotobuf-java-full.jar \
   $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed).jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed)-tests.jar \
   $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \
   $(test_suite_readme)
 
@@ -37,13 +42,14 @@
 $(compatibility_zip): PRIVATE_TOOLS := $(test_tools)
 $(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name)
 $(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config)
-$(compatibility_zip): $(test_artifacts) $(test_tools) $(test_suite_dynamic_config) | $(ADB) $(ACP)
+$(compatibility_zip): $(test_artifacts) $(test_tools) $(test_suite_dynamic_config) $(SOONG_ZIP) | $(ADB) $(ACP)
 # Make dir structure
 	$(hide) mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases
 # Copy tools
 	$(hide) $(ACP) -fp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools
 	$(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) $(ACP) -fp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic)
-	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
+	$(hide) find $(dir $@)/$(PRIVATE_NAME) | sort >[email protected]
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(dir $@) -l [email protected]
 
 # Reset all input variables
 test_suite_name :=
diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk
index 24a7608..4dde9fd 100644
--- a/core/tasks/tools/package-modules.mk
+++ b/core/tasks/tools/package-modules.mk
@@ -9,21 +9,32 @@
 #
 #
 
+my_makefile := $(lastword $(filter-out $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
 my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name))
 my_built_modules :=
 my_copy_pairs :=
 my_pickup_files :=
 
+# Iterate over the modules and include their direct dependencies stated in the
+# LOCAL_REQUIRED_MODULES.
+my_modules_and_deps := $(my_modules)
+$(foreach m,$(my_modules),\
+  $(eval _explicitly_required := \
+    $(strip $(ALL_MODULES.$(m).EXPLICITLY_REQUIRED)\
+    $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).EXPLICITLY_REQUIRED)))\
+  $(eval my_modules_and_deps += $(_explicitly_required))\
+)
+
 # Iterate over modules' built files and installed files;
 # Calculate the dest files in the output zip file.
 
-$(foreach m,$(my_modules),\
+$(foreach m,$(my_modules_and_deps),\
   $(eval _pickup_files := $(strip $(ALL_MODULES.$(m).PICKUP_FILES)\
     $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PICKUP_FILES)))\
   $(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\
     $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\
   $(if $(_pickup_files)$(_built_files),,\
-    $(warning Unknown installed file for module '$(m)'))\
+    $(shell $(call echo-warning,$(my_makefile),$(my_package_name): Unknown installed file for module '$(m)')))\
   $(eval my_pickup_files += $(_pickup_files))\
   $(foreach i, $(_built_files),\
     $(eval bui_ins := $(subst :,$(space),$(i)))\
@@ -37,26 +48,16 @@
       $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
   ))
 
-define copy-tests-in-batch
-$(hide) $(foreach p, $(1),\
-  $(eval pair := $(subst :,$(space),$(p)))\
-  mkdir -p $(dir $(word 2,$(pair)));\
-  cp -Rf $(word 1,$(pair)) $(word 2,$(pair));)
-endef
-
 my_package_zip := $(my_staging_dir)/$(my_package_name).zip
 $(my_package_zip): PRIVATE_COPY_PAIRS := $(my_copy_pairs)
 $(my_package_zip): PRIVATE_PICKUP_FILES := $(my_pickup_files)
 $(my_package_zip) : $(my_built_modules)
 	@echo "Package $@"
 	@rm -rf $(dir $@) && mkdir -p $(dir $@)
-	$(call copy-tests-in-batch,$(wordlist 1,200,$(PRIVATE_COPY_PAIRS)))
-	$(call copy-tests-in-batch,$(wordlist 201,400,$(PRIVATE_COPY_PAIRS)))
-	$(call copy-tests-in-batch,$(wordlist 401,600,$(PRIVATE_COPY_PAIRS)))
-	$(call copy-tests-in-batch,$(wordlist 601,800,$(PRIVATE_COPY_PAIRS)))
-	$(call copy-tests-in-batch,$(wordlist 801,1000,$(PRIVATE_COPY_PAIRS)))
-	$(call copy-tests-in-batch,$(wordlist 1001,1200,$(PRIVATE_COPY_PAIRS)))
-	$(call copy-tests-in-batch,$(wordlist 1201,9999,$(PRIVATE_COPY_PAIRS)))
+	$(foreach p, $(PRIVATE_COPY_PAIRS),\
+	  $(eval pair := $(subst :,$(space),$(p)))\
+	  mkdir -p $(dir $(word 2,$(pair))) && \
+	  cp -Rf $(word 1,$(pair)) $(word 2,$(pair)) && ) true
 	$(hide) $(foreach f, $(PRIVATE_PICKUP_FILES),\
-	  cp -RfL $(f) $(dir $@);)
+	  cp -RfL $(f) $(dir $@) && ) true
 	$(hide) cd $(dir $@) && zip -rqX $(notdir $@) *
diff --git a/core/tasks/vendor_module_check.mk b/core/tasks/vendor_module_check.mk
index e3761ae..ae967c6 100644
--- a/core/tasks/vendor_module_check.mk
+++ b/core/tasks/vendor_module_check.mk
@@ -47,19 +47,43 @@
         widevine
 
 
-ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))
+_restrictions := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))
 
-_vendor_check_modules := $(product_MODULES)
+ifneq (,$(_restrictions))
+ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_PRODUCT_RESTRICT_VENDOR_FILES))
+$(error Error: cannot set both PRODUCT_RESTRICT_VENDOR_FILES and VENDOR_PRODUCT_RESTRICT_VENDOR_FILES)
+endif
+_vendor_exception_path_prefix :=
+_vendor_exception_modules :=
+else
+_restrictions := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_PRODUCT_RESTRICT_VENDOR_FILES))
+_vendor_exception_path_prefix := $(patsubst %, vendor/%/%, $(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_EXCEPTION_PATHS))
+_vendor_exception_modules := $(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_EXCEPTION_MODULES)
+endif
+
+
+ifneq (,$(_restrictions))
+
+_vendor_check_modules := \
+$(foreach m, $(filter-out $(_vendor_exception_modules), $(product_MODULES)), \
+  $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\
+    $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
+      $(if $(filter-out $(_vendor_exception_path_prefix), $(ALL_MODULES.$(m).PATH)),\
+        $(m)))))
 
 _vendor_module_owner_info :=
 # Restrict owners
-ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
+ifneq (,$(filter true owner all, $(_restrictions)))
 
-ifneq (,$(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)))
-$(error Error: Product "$(TARGET_PRODUCT)" cannot have overlay in vendor tree: \
+_vendor_package_overlays := $(filter-out $(_vendor_exception_path_prefix),\
     $(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)))
+ifneq (,$(_vendor_package_overlays))
+$(error Error: Product "$(TARGET_PRODUCT)" cannot have overlay in vendor tree: $(_vendor_package_overlays))
 endif
-_vendor_check_copy_files := $(filter vendor/%, $(PRODUCT_COPY_FILES))
+_vendor_package_overlays :=
+
+_vendor_check_copy_files := $(filter-out $(_vendor_exception_path_prefix),\
+    $(filter vendor/%, $(PRODUCT_COPY_FILES)))
 ifneq (,$(_vendor_check_copy_files))
 $(foreach c, $(_vendor_check_copy_files), \
   $(if $(filter $(_vendor_owner_whitelist), $(call word-colon,3,$(c))),,\
@@ -69,28 +93,24 @@
 _vendor_check_copy_files :=
 
 $(foreach m, $(_vendor_check_modules), \
-  $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
-    $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\
-      $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
-        $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
-          "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\
-      $(if $(ALL_MODULES.$(m).INSTALLED),\
-        $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER))))))
+  $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
+    $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
+      "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\
+  $(if $(ALL_MODULES.$(m).INSTALLED),\
+    $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER))))
 
 endif
 
 
 # Restrict paths
-ifneq (,$(filter path all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
+ifneq (,$(filter path all, $(_restrictions)))
 
 $(foreach m, $(_vendor_check_modules), \
-  $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
-    $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\
-      $(if $(filter-out ,$(ALL_MODULES.$(m).INSTALLED)),\
-        $(if $(filter $(TARGET_OUT_VENDOR)/% $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED)),,\
-          $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \
-            in product "$(TARGET_PRODUCT)" being installed to \
-            $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree))))))
+  $(if $(filter-out ,$(ALL_MODULES.$(m).INSTALLED)),\
+    $(if $(filter $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_ODM)/% $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED)),,\
+      $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \
+        in product "$(TARGET_PRODUCT)" being installed to \
+        $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree or odm tree))))
 
 endif
 
@@ -113,4 +133,7 @@
 _vendor_module_owner_info_txt :=
 _vendor_module_owner_info :=
 _vendor_check_modules :=
+_vendor_exception_path_prefix :=
+_vendor_exception_modules :=
+_restrictions :=
 endif
diff --git a/core/tasks/vts.mk b/core/tasks/vts.mk
deleted file mode 100644
index 507f22e..0000000
--- a/core/tasks/vts.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (C) 2016 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.
-
-test_suite_name := vts
-test_suite_tradefed := vts-tradefed
-test_suite_readme := test/vts/README.md
-
-include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk
-
-.PHONY: vts
-vts: $(compatibility_zip)
-$(call dist-for-goals, vts, $(compatibility_zip))
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index ce01b75..420d8b1 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -34,28 +34,60 @@
 # if the file exists.
 #
 INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk)
-ifneq "" "$(INTERNAL_BUILD_ID_MAKEFILE)"
+ifdef INTERNAL_BUILD_ID_MAKEFILE
   include $(INTERNAL_BUILD_ID_MAKEFILE)
 endif
 
-ifeq "" "$(PLATFORM_VERSION)"
-  # This is the canonical definition of the platform version,
-  # which is the version that we reveal to the end user.
-  # Update this value when the platform version changes (rather
-  # than overriding it somewhere else).  Can be an arbitrary string.
+DEFAULT_PLATFORM_VERSION := OPR1
+MIN_PLATFORM_VERSION := OPR1
+MAX_PLATFORM_VERSION := OPR1
 
-  # When you add a new PLATFORM_VERSION which will result in a new
-  # PLATFORM_SDK_VERSION please ensure you add a corresponding isAtLeast*
-  # method in the following java file:
-  # frameworks/support/compat/gingerbread/android/support/v4/os/BuildCompat.java
+ALLOWED_VERSIONS := $(call allowed-platform-versions,\
+  $(MIN_PLATFORM_VERSION),\
+  $(MAX_PLATFORM_VERSION),\
+  $(DEFAULT_PLATFORM_VERSION))
 
-  # When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION
-  # please add that PLATFORM_VERSION to the following text file:
-  # cts/tests/tests/os/assets/platform_versions.txt
-  PLATFORM_VERSION := 7.1.2
+ifndef TARGET_PLATFORM_VERSION
+  TARGET_PLATFORM_VERSION := $(DEFAULT_PLATFORM_VERSION)
 endif
 
-ifeq "" "$(PLATFORM_SDK_VERSION)"
+ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION)))
+  $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of)
+  $(error $(ALLOWED_VERSIONS))
+endif
+
+# Default versions for each TARGET_PLATFORM_VERSION
+# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional
+# on this
+
+# This is the canonical definition of the platform version,
+# which is the version that we reveal to the end user.
+# Update this value when the platform version changes (rather
+# than overriding it somewhere else).  Can be an arbitrary string.
+
+# When you add a new PLATFORM_VERSION which will result in a new
+# PLATFORM_SDK_VERSION please ensure you add a corresponding isAtLeast*
+# method in the following java file:
+# frameworks/support/compat/gingerbread/android/support/v4/os/BuildCompat.java
+
+# When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION
+# please add that PLATFORM_VERSION to the following text file:
+# cts/tests/tests/os/assets/platform_versions.txt
+PLATFORM_VERSION.OPR1 := 8.0.0
+
+# This is the current development code-name, if the build is not a final
+# release build.  If this is a final release build, it is simply "REL".
+PLATFORM_VERSION_CODENAME.OPR1 := REL
+
+ifndef PLATFORM_VERSION
+  PLATFORM_VERSION := $(PLATFORM_VERSION.$(TARGET_PLATFORM_VERSION))
+  ifndef PLATFORM_VERSION
+    # PLATFORM_VERSION falls back to TARGET_PLATFORM_VERSION
+    PLATFORM_VERSION := $(TARGET_PLATFORM_VERSION)
+  endif
+endif
+
+ifndef PLATFORM_SDK_VERSION
   # This is the canonical definition of the SDK version, which defines
   # the set of APIs and functionality available in the platform.  It
   # is a single integer that increases monotonically as updates to
@@ -72,22 +104,24 @@
   # When you increment the PLATFORM_SDK_VERSION please ensure you also
   # clear out the following text file of all older PLATFORM_VERSION's:
   # cts/tests/tests/os/assets/platform_versions.txt
-  PLATFORM_SDK_VERSION := 25
+  PLATFORM_SDK_VERSION := 26
 endif
 
-ifeq "" "$(PLATFORM_JACK_MIN_SDK_VERSION)"
+ifndef PLATFORM_JACK_MIN_SDK_VERSION
   # This is definition of the min SDK version given to Jack for the current
   # platform. For released version it should be the same as
   # PLATFORM_SDK_VERSION. During development, this number may be incremented
-  # before PLATFORM_SDK_VERSION if the plateform starts to add new java
+  # before PLATFORM_SDK_VERSION if the platform starts to add new java
   # language supports.
-  PLATFORM_JACK_MIN_SDK_VERSION := 25
+  PLATFORM_JACK_MIN_SDK_VERSION := o-b1
 endif
 
-ifeq "" "$(PLATFORM_VERSION_CODENAME)"
-  # This is the current development code-name, if the build is not a final
-  # release build.  If this is a final release build, it is simply "REL".
-  PLATFORM_VERSION_CODENAME := REL
+ifndef PLATFORM_VERSION_CODENAME
+  PLATFORM_VERSION_CODENAME := $(PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION))
+  ifndef PLATFORM_VERSION_CODENAME
+    # PLATFORM_VERSION_CODENAME falls back to TARGET_PLATFORM_VERSION
+    PLATFORM_VERSION_CODENAME := $(TARGET_PLATFORM_VERSION)
+  endif
 
   # This is all of the development codenames that are active.  Should be either
   # the same as PLATFORM_VERSION_CODENAME or a comma-separated list of additional
@@ -95,10 +129,10 @@
   PLATFORM_VERSION_ALL_CODENAMES := $(PLATFORM_VERSION_CODENAME)
 endif
 
-ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
+ifeq (REL,$(PLATFORM_VERSION_CODENAME))
   PLATFORM_PREVIEW_SDK_VERSION := 0
 else
-  ifeq "" "$(PLATFORM_PREVIEW_SDK_VERSION)"
+  ifndef PLATFORM_PREVIEW_SDK_VERSION
     # This is the definition of a preview SDK version over and above the current
     # platform SDK version. Unlike the platform SDK version, a higher value
     # for preview SDK version does NOT mean that all prior preview APIs are
@@ -112,29 +146,29 @@
   endif
 endif
 
-ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
+ifndef DEFAULT_APP_TARGET_SDK
   # This is the default minSdkVersion and targetSdkVersion to use for
   # all .apks created by the build system.  It can be overridden by explicitly
   # setting these in the .apk's AndroidManifest.xml.  It is either the code
   # name of the development build or, if this is a release build, the official
   # SDK version of this release.
-  ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
+  ifeq (REL,$(PLATFORM_VERSION_CODENAME))
     DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION)
   else
     DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)
   endif
 endif
 
-ifeq "" "$(PLATFORM_SECURITY_PATCH)"
+ifndef PLATFORM_SECURITY_PATCH
     #  Used to indicate the security patch that has been applied to the device.
     #  It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin.
     #  It must be of the form "YYYY-MM-DD" on production devices.
     #  It must match one of the Android Security Patch Level strings of the Public Security Bulletins.
     #  If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
-    PLATFORM_SECURITY_PATCH := 2017-11-01
+      PLATFORM_SECURITY_PATCH := 2017-12-01
 endif
 
-ifeq "" "$(PLATFORM_BASE_OS)"
+ifndef PLATFORM_BASE_OS
   # Used to indicate the base os applied to the device.
   # Can be an arbitrary string, but must be a single word.
   #
@@ -142,7 +176,7 @@
   PLATFORM_BASE_OS :=
 endif
 
-ifeq "" "$(BUILD_ID)"
+ifndef BUILD_ID
   # Used to signify special builds.  E.g., branches and/or releases,
   # like "M5-RC7".  Can be an arbitrary string, but must be a single
   # word and a valid file name.
@@ -151,7 +185,7 @@
   BUILD_ID := UNKNOWN
 endif
 
-ifeq "" "$(BUILD_DATETIME)"
+ifndef BUILD_DATETIME
   # Used to reproduce builds by setting the same time. Must be the number
   # of seconds since the Epoch.
   BUILD_DATETIME := $(shell date +%s)
@@ -163,7 +197,7 @@
 DATE := date -d @$(BUILD_DATETIME)
 endif
 
-ifeq "" "$(BUILD_NUMBER)"
+ifndef BUILD_NUMBER
   # BUILD_NUMBER should be set to the source control value that
   # represents the current state of the source code.  E.g., a
   # perforce changelist number or a git hash.  Can be an arbitrary string
diff --git a/envsetup.sh b/envsetup.sh
index 35df2d5..ec6c960 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -28,9 +28,9 @@
 
 Look at the source to view more functions. The complete list is:
 EOF
-    T=$(gettop)
-    local A
-    A=""
+    local T=$(gettop)
+    local A=""
+    local i
     for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
       A="$A $i"
     done
@@ -40,7 +40,7 @@
 # Get all the build variables needed by this script in a single call to the build system.
 function build_build_var_cache()
 {
-    T=$(gettop)
+    local T=$(gettop)
     # Grep out the variable names from the script.
     cached_vars=`cat $T/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
     cached_abs_vars=`cat $T/build/envsetup.sh | tr '()' '  ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
@@ -74,6 +74,7 @@
 function destroy_build_var_cache()
 {
     unset BUILD_VAR_CACHE_READY
+    local v
     for v in $cached_vars; do
       unset var_cache_$v
     done
@@ -89,11 +90,11 @@
 {
     if [ "$BUILD_VAR_CACHE_READY" = "true" ]
     then
-        eval echo \"\${abs_var_cache_$1}\"
+        eval "echo \"\${abs_var_cache_$1}\""
     return
     fi
 
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
@@ -107,11 +108,11 @@
 {
     if [ "$BUILD_VAR_CACHE_READY" = "true" ]
     then
-        eval echo \"\${var_cache_$1}\"
+        eval "echo \"\${var_cache_$1}\""
     return
     fi
 
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
@@ -123,7 +124,7 @@
 # check to see if the supplied product is one we can build
 function check_product()
 {
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
@@ -141,6 +142,7 @@
 # check to see if the supplied variant is valid
 function check_variant()
 {
+    local v
     for v in ${VARIANT_CHOICES[@]}
     do
         if [ "$v" = "$1" ]
@@ -153,7 +155,7 @@
 
 function setpaths()
 {
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP."
         return
@@ -184,18 +186,19 @@
     fi
 
     # and in with the new
-    prebuiltdir=$(getprebuilt)
-    gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
+    local prebuiltdir=$(getprebuilt)
+    local gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
 
     # defined in core/config.mk
-    targetgccversion=$(get_build_var TARGET_GCC_VERSION)
-    targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)
+    local targetgccversion=$(get_build_var TARGET_GCC_VERSION)
+    local targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)
     export TARGET_GCC_VERSION=$targetgccversion
 
     # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
     export ANDROID_TOOLCHAIN=
     export ANDROID_TOOLCHAIN_2ND_ARCH=
     local ARCH=$(get_build_var TARGET_ARCH)
+    local toolchaindir toolchaindir2=
     case $ARCH in
         x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
             ;;
@@ -217,7 +220,7 @@
         export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
     fi
 
-    if [ -d "$gccprebuiltdir/$toolchaindir2" ]; then
+    if [ "$toolchaindir2" -a -d "$gccprebuiltdir/$toolchaindir2" ]; then
         export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2
     fi
 
@@ -260,6 +263,12 @@
     unset ANDROID_HOST_OUT
     export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
 
+    unset ANDROID_HOST_OUT_TESTCASES
+    export ANDROID_HOST_OUT_TESTCASES=$(get_abs_build_var HOST_OUT_TESTCASES)
+
+    unset ANDROID_TARGET_OUT_TESTCASES
+    export ANDROID_TARGET_OUT_TESTCASES=$(get_abs_build_var TARGET_OUT_TESTCASES)
+
     # needed for building linux on MacOS
     # TODO: fix the path
     #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
@@ -267,7 +276,7 @@
 
 function printconfig()
 {
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
@@ -290,7 +299,7 @@
 
 function set_sequence_number()
 {
-    export BUILD_ENV_SEQUENCE_NUMBER=10
+    export BUILD_ENV_SEQUENCE_NUMBER=13
 }
 
 function settitle()
@@ -329,6 +338,8 @@
             . $f
         done
     fi
+
+    complete -C "bit --tab" bit
 }
 
 function choosetype()
@@ -393,6 +404,7 @@
 #
 function chooseproduct()
 {
+    local default_value
     if [ "x$TARGET_PRODUCT" != x ] ; then
         default_value=$TARGET_PRODUCT
     else
@@ -563,50 +575,42 @@
         then
             selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
         fi
-    elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
-    then
+    else
         selection=$answer
     fi
 
-    if [ -z "$selection" ]
-    then
-        echo
-        echo "Invalid lunch combo: $answer"
-        return 1
-    fi
-
     export TARGET_BUILD_APPS=
 
-    local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
-    check_variant $variant
-    if [ $? -ne 0 ]
-    then
-        echo
-        echo "** Invalid variant: '$variant'"
-        echo "** Must be one of ${VARIANT_CHOICES[@]}"
-        variant=
+    local product variant_and_version variant version
+
+    product=${selection%%-*} # Trim everything after first dash
+    variant_and_version=${selection#*-} # Trim everything up to first dash
+    if [ "$variant_and_version" != "$selection" ]; then
+        variant=${variant_and_version%%-*}
+        if [ "$variant" != "$variant_and_version" ]; then
+            version=${variant_and_version#*-}
+        fi
     fi
 
-    local product=$(echo -n $selection | sed -e "s/-.*$//")
-    TARGET_PRODUCT=$product \
-    TARGET_BUILD_VARIANT=$variant \
-    build_build_var_cache
-    if [ $? -ne 0 ]
+    if [ -z "$product" ]
     then
         echo
-        echo "** Don't have a product spec for: '$product'"
-        echo "** Do you have the right repo manifest?"
-        product=
-    fi
-
-    if [ -z "$product" -o -z "$variant" ]
-    then
-        echo
+        echo "Invalid lunch combo: $selection"
         return 1
     fi
 
-    export TARGET_PRODUCT=$product
-    export TARGET_BUILD_VARIANT=$variant
+    TARGET_PRODUCT=$product \
+    TARGET_BUILD_VARIANT=$variant \
+    TARGET_PLATFORM_VERSION=$version \
+    build_build_var_cache
+    if [ $? -ne 0 ]
+    then
+        return 1
+    fi
+
+    export TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT)
+    export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT)
+    export TARGET_PLATFORM_VERSION=$(get_build_var TARGET_PLATFORM_VERSION)
     export TARGET_BUILD_TYPE=release
 
     echo
@@ -696,7 +700,7 @@
             PWD= /bin/pwd
         else
             local HERE=$PWD
-            T=
+            local T=
             while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
                 \cd ..
                 T=`PWD= /bin/pwd -P`
@@ -715,11 +719,18 @@
     local T="$1"
     test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
     if [ -n "$WITH_STATIC_ANALYZER" ]; then
+        # Use scan-build to collect all static analyzer reports into directory
+        # /tmp/scan-build-yyyy-mm-dd-hhmmss-*
+        # The clang compiler passed by --use-analyzer here is not important.
+        # build/core/binary.mk will set CLANG_CXX and CLANG before calling
+        # c++-analyzer and ccc-analyzer.
+        local CLANG_VERSION=$(get_build_var LLVM_PREBUILTS_VERSION)
+        local BUILD_OS=$(get_build_var BUILD_OS)
+        local CLANG_DIR="$T/prebuilts/clang/host/${BUILD_OS}-x86/${CLANG_VERSION}"
         echo "\
-$T/prebuilts/misc/linux-x86/analyzer/tools/scan-build/scan-build \
---use-analyzer $T/prebuilts/misc/linux-x86/analyzer/bin/analyzer \
---status-bugs \
---top=$T"
+${CLANG_DIR}/tools/scan-build/bin/scan-build \
+--use-analyzer ${CLANG_DIR}/bin/clang \
+--status-bugs"
     fi
 }
 
@@ -737,12 +748,12 @@
 
 function findmakefile()
 {
-    TOPFILE=build/core/envsetup.mk
+    local TOPFILE=build/core/envsetup.mk
     local HERE=$PWD
-    T=
+    local T=
     while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
         T=`PWD= /bin/pwd`
-        if [ -f "$T/Android.mk" ]; then
+        if [ -f "$T/Android.mk" -o -f "$T/Android.bp" ]; then
             echo $T/Android.mk
             \cd $HERE
             return
@@ -775,6 +786,7 @@
             echo "Couldn't locate a makefile from the current directory."
             return 1
         else
+            local ARG
             for ARG in $@; do
                 case $ARG in
                   GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;;
@@ -782,11 +794,17 @@
             done
             if [ -n "$GET_INSTALL_PATH" ]; then
               MODULES=
-              ARGS=GET-INSTALL-PATH
+              ARGS=GET-INSTALL-PATH-IN-$(dirname ${M})
+              ARGS=${ARGS//\//-}
             else
-              MODULES=all_modules
+              MODULES=MODULES-IN-$(dirname ${M})
+              # Convert "/" to "-".
+              MODULES=${MODULES//\//-}
               ARGS=$@
             fi
+            if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then
+              MODULES=tidy_only
+            fi
             ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS
         fi
     fi
@@ -799,28 +817,38 @@
     if [ "$T" ]; then
         local MAKEFILE=
         local MODULES=
+        local MODULES_IN_PATHS=
         local ARGS=
         local DIR TO_CHOP
+        local DIR_MODULES
         local GET_INSTALL_PATH=
+        local GET_INSTALL_PATHS=
         local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
         local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
         for DIR in $DIRS ; do
-            MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
-            if [ "$MODULES" = "" ]; then
-                MODULES=all_modules
-            fi
+            DIR_MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
             DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
-            if [ -f $DIR/Android.mk ]; then
+            # Remove the leading ./ and trailing / if any exists.
+            DIR=${DIR#./}
+            DIR=${DIR%/}
+            if [ -f $DIR/Android.mk -o -f $DIR/Android.bp ]; then
                 local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
                 local TO_CHOP=`expr $TO_CHOP + 1`
                 local START=`PWD= /bin/pwd`
-                local MFILE=`echo $START | cut -c${TO_CHOP}-`
-                if [ "$MFILE" = "" ] ; then
-                    MFILE=$DIR/Android.mk
+                local MDIR=`echo $START | cut -c${TO_CHOP}-`
+                if [ "$MDIR" = "" ] ; then
+                    MDIR=$DIR
                 else
-                    MFILE=$MFILE/$DIR/Android.mk
+                    MDIR=$MDIR/$DIR
                 fi
-                MAKEFILE="$MAKEFILE $MFILE"
+                MDIR=${MDIR%/.}
+                if [ "$DIR_MODULES" = "" ]; then
+                    MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$MDIR"
+                    GET_INSTALL_PATHS="$GET_INSTALL_PATHS GET-INSTALL-PATH-IN-$MDIR"
+                else
+                    MODULES="$MODULES $DIR_MODULES"
+                fi
+                MAKEFILE="$MAKEFILE $MDIR/Android.mk"
             else
                 case $DIR in
                   showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
@@ -835,10 +863,17 @@
             fi
         done
         if [ -n "$GET_INSTALL_PATH" ]; then
-          ARGS=$GET_INSTALL_PATH
+          ARGS=${GET_INSTALL_PATHS//\//-}
           MODULES=
+          MODULES_IN_PATHS=
         fi
-        ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
+        if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then
+          MODULES=tidy_only
+          MODULES_IN_PATHS=
+        fi
+        # Convert "/" to "-".
+        MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
+        ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $MODULES_IN_PATHS $ARGS
     else
         echo "Couldn't locate the top of the tree.  Try setting TOP."
         return 1
@@ -856,8 +891,10 @@
       echo "Couldn't locate the top of the tree.  Try setting TOP."
       return 1
     fi
-    local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
-    local MODULES_IN_PATHS=MODULES-IN-$MY_PWD
+    local M=$(findmakefile)
+    # Remove the path to top as the makefilepath needs to be relative
+    local M=`echo $M|sed 's:'$T'/::'`
+    local MODULES_IN_PATHS=MODULES-IN-$(dirname ${M})
     # Convert "/" to "-".
     MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
     $DRV make -C $T -f build/core/main.mk $@ $MODULES_IN_PATHS
@@ -907,9 +944,13 @@
 
 function croot()
 {
-    T=$(gettop)
+    local T=$(gettop)
     if [ "$T" ]; then
-        \cd $(gettop)
+        if [ "$1" ]; then
+            \cd $(gettop)/$1
+        else
+            \cd $(gettop)
+        fi
     else
         echo "Couldn't locate the top of the tree.  Try setting TOP."
     fi
@@ -917,9 +958,9 @@
 
 function cproj()
 {
-    TOPFILE=build/core/envsetup.mk
+    local TOPFILE=build/core/envsetup.mk
     local HERE=$PWD
-    T=
+    local T=
     while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
         T=$PWD
         if [ -f "$T/Android.mk" ]; then
@@ -1022,7 +1063,7 @@
         return;
     fi;
     echo "Setting core limit for $PID to infinite...";
-    adb shell prlimit $PID 4 -1 -1
+    adb shell /system/bin/ulimit -p $PID -c unlimited
 }
 
 # core - send SIGV and pull the core for process
@@ -1106,8 +1147,7 @@
             adb shell cat $TMP
         else
             # Dump stacks of native process
-            local USE64BIT="$(is64bit $PID)"
-            adb shell debuggerd$USE64BIT -b $PID
+            adb shell debuggerd -b $PID
         fi
     fi
 }
@@ -1171,6 +1211,7 @@
 
 function resgrep()
 {
+    local dir
     for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do
         find $dir -type f -name '*\.xml' -exec grep --color -n "$@" {} +
     done
@@ -1198,7 +1239,7 @@
     Darwin)
         function mgrep()
         {
-            find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' \
+            find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk|.*\.bp)' \
                 -exec grep --color -n "$@" {} +
         }
 
@@ -1212,7 +1253,7 @@
     *)
         function mgrep()
         {
-            find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f \
+            find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk|.*\.bp)' -type f \
                 -exec grep --color -n "$@" {} +
         }
 
@@ -1232,7 +1273,7 @@
 
 function tracedmdump()
 {
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP."
         return
@@ -1409,7 +1450,7 @@
         echo "Couldn't locate output files.  Try running 'lunch' first." >&2
         return
     fi
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
@@ -1426,7 +1467,7 @@
 # simple shortcut to the runtest command
 function runtest()
 {
-    T=$(gettop)
+    local T=$(gettop)
     if [ ! "$T" ]; then
         echo "Couldn't locate the top of the tree.  Try setting TOP." >&2
         return
@@ -1439,7 +1480,8 @@
         echo "Usage: godir <regex>"
         return
     fi
-    T=$(gettop)
+    local T=$(gettop)
+    local FILELIST
     if [ ! "$OUT_DIR" = "" ]; then
         mkdir -p $OUT_DIR
         FILELIST=$OUT_DIR/filelist
diff --git a/libs/host/Android.mk b/libs/host/Android.mk
deleted file mode 100644
index bc25e4b..0000000
--- a/libs/host/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
-    CopyFile.c
-
-LOCAL_CFLAGS := -Werror -Wall
-
-LOCAL_MODULE:= libhost
-LOCAL_MODULE_HOST_OS := darwin linux windows
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
-LOCAL_CXX_STL := none
-
-# acp uses libhost, so we can't use
-# acp to install libhost.
-LOCAL_ACP_UNAVAILABLE:= true
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-# Include toolchain prebuilt modules if they exist.
--include $(TARGET_TOOLCHAIN_ROOT)/toolchain.mk
diff --git a/target/board/Android.mk b/target/board/Android.mk
index f8ecc4e..4c804e0 100644
--- a/target/board/Android.mk
+++ b/target/board/Android.mk
@@ -2,6 +2,8 @@
 # Set up product-global definitions and include product-specific rules.
 #
 
+LOCAL_PATH := $(call my-dir)
+
 -include $(TARGET_DEVICE_DIR)/AndroidBoard.mk
 
 # Generate a file that contains various information about the
@@ -25,3 +27,92 @@
 else
 	$(hide) echo "board=$(TARGET_BOOTLOADER_BOARD_NAME)" > $@
 endif
+
+# Copy compatibility metadata to the device.
+
+# Device Manifest
+ifdef DEVICE_MANIFEST_FILE
+include $(CLEAR_VARS)
+LOCAL_MODULE        := manifest.xml
+LOCAL_MODULE_CLASS  := ETC
+LOCAL_MODULE_PATH   := $(TARGET_OUT_VENDOR)
+
+GEN := $(local-generated-sources-dir)/manifest.xml
+$(GEN): $(DEVICE_MANIFEST_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
+	BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@
+
+LOCAL_PREBUILT_MODULE_FILE := $(GEN)
+include $(BUILD_PREBUILT)
+BUILT_VENDOR_MANIFEST := $(LOCAL_BUILT_MODULE)
+endif
+
+# Device Compatibility Matrix
+ifdef DEVICE_MATRIX_FILE
+include $(CLEAR_VARS)
+LOCAL_MODULE        := compatibility_matrix.xml
+LOCAL_MODULE_CLASS  := ETC
+LOCAL_MODULE_PATH   := $(TARGET_OUT_VENDOR)
+
+GEN := $(local-generated-sources-dir)/compatibility_matrix.xml
+$(GEN): $(DEVICE_MATRIX_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
+	# TODO(b/37342627): put BOARD_VNDK_VERSION & BOARD_VNDK_LIBRARIES into device matrix.
+	$(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@
+
+LOCAL_PREBUILT_MODULE_FILE := $(GEN)
+include $(BUILD_PREBUILT)
+BUILT_VENDOR_MATRIX := $(LOCAL_BUILT_MODULE)
+endif
+
+# Framework Manifest
+include $(CLEAR_VARS)
+LOCAL_MODULE        := system_manifest.xml
+LOCAL_MODULE_STEM   := manifest.xml
+LOCAL_MODULE_CLASS  := ETC
+LOCAL_MODULE_PATH   := $(TARGET_OUT)
+
+GEN := $(local-generated-sources-dir)/manifest.xml
+
+$(GEN): PRIVATE_FLAGS :=
+
+# TODO(b/37954458), (b/37321309) remove check of PRODUCT_FULL_TREBLE after
+# putting device compatibility matrices for non-treble devices.
+ifeq ($(PRODUCT_FULL_TREBLE),true)
+ifdef BUILT_VENDOR_MATRIX
+$(GEN): $(BUILT_VENDOR_MATRIX)
+$(GEN): PRIVATE_FLAGS := -c "$(BUILT_VENDOR_MATRIX)"
+endif
+endif
+
+$(GEN): $(FRAMEWORK_MANIFEST_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
+	BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@ $(PRIVATE_FLAGS)
+
+LOCAL_PREBUILT_MODULE_FILE := $(GEN)
+include $(BUILD_PREBUILT)
+BUILT_SYSTEM_MANIFEST := $(LOCAL_BUILT_MODULE)
+
+# Framework Compatibility Matrix
+include $(CLEAR_VARS)
+LOCAL_MODULE        := system_compatibility_matrix.xml
+LOCAL_MODULE_STEM   := compatibility_matrix.xml
+LOCAL_MODULE_CLASS  := ETC
+LOCAL_MODULE_PATH   := $(TARGET_OUT)
+
+GEN := $(local-generated-sources-dir)/compatibility_matrix.xml
+
+$(GEN): PRIVATE_FLAGS :=
+
+# TODO(b/37954458), (b/37321309) remove check of PRODUCT_FULL_TREBLE after
+# putting complete HAL manifests on non-treble devices.
+ifeq ($(PRODUCT_FULL_TREBLE),true)
+ifdef BUILT_VENDOR_MANIFEST
+$(GEN): $(BUILT_VENDOR_MANIFEST)
+$(GEN): PRIVATE_FLAGS := -c "$(BUILT_VENDOR_MANIFEST)"
+endif
+endif
+
+$(GEN): $(FRAMEWORK_COMPATIBILITY_MATRIX_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
+	# TODO(b/37405869) (b/37715375) inject avb versions as well for devices that have avb enabled.
+	POLICYVERS=$(POLICYVERS) BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@ $(PRIVATE_FLAGS)
+LOCAL_PREBUILT_MODULE_FILE := $(GEN)
+include $(BUILD_PREBUILT)
+BUILT_SYSTEM_COMPATIBILITY_MATRIX := $(LOCAL_BUILT_MODULE)
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 02c1c88..9cbe215 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -23,7 +23,6 @@
 TARGET_CPU_VARIANT := generic
 TARGET_CPU_ABI := armeabi-v7a
 TARGET_CPU_ABI2 := armeabi
-
 HAVE_HTC_AUDIO_DRIVER := true
 BOARD_USES_GENERIC_AUDIO := true
 
@@ -35,9 +34,12 @@
 ifeq ($(HOST_OS),linux)
   ifeq ($(WITH_DEXPREOPT),)
     WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_BOOT_IMG_ONLY := false
   endif
 endif
 
+TARGET_USES_HWC2 := true
+
 # Build OpenGLES emulation guest and host libraries
 BUILD_EMULATOR_OPENGL := true
 
@@ -46,7 +48,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192  # 1.75 GB
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648  # 2 GB
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
@@ -55,7 +57,3 @@
 
 BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
 
-ifeq ($(TARGET_PRODUCT),sdk)
-  # include an expanded selection of fonts for the SDK.
-  EXTENDED_FONT_FOOTPRINT := true
-endif
diff --git a/target/board/generic/sepolicy/file.te b/target/board/generic/sepolicy/file.te
index 6fad80a..9227f80 100644
--- a/target/board/generic/sepolicy/file.te
+++ b/target/board/generic/sepolicy/file.te
@@ -1 +1,2 @@
 type qemud_socket, file_type;
+type sysfs_writable, fs_type, sysfs_type, mlstrustedobject;
diff --git a/target/board/generic/sepolicy/file_contexts b/target/board/generic/sepolicy/file_contexts
index e9502d9..d1a1e8c 100644
--- a/target/board/generic/sepolicy/file_contexts
+++ b/target/board/generic/sepolicy/file_contexts
@@ -17,4 +17,6 @@
 /system/bin/qemud            u:object_r:qemud_exec:s0
 /sys/qemu_trace(/.*)?        u:object_r:sysfs_writable:s0
 /system/etc/init.goldfish.sh u:object_r:goldfish_setup_exec:s0
+/system/vendor/bin/init.ranchu-core.sh u:object_r:goldfish_setup_exec:s0
+/system/vendor/bin/init.ranchu-net.sh u:object_r:goldfish_setup_exec:s0
 /system/bin/qemu-props       u:object_r:qemu_props_exec:s0
diff --git a/target/board/generic/sepolicy/goldfish_setup.te b/target/board/generic/sepolicy/goldfish_setup.te
index b8f121c..78d20fc 100644
--- a/target/board/generic/sepolicy/goldfish_setup.te
+++ b/target/board/generic/sepolicy/goldfish_setup.te
@@ -1,5 +1,5 @@
 # goldfish-setup service: runs init.goldfish.sh script
-type goldfish_setup, domain, domain_deprecated;
+type goldfish_setup, domain;
 type goldfish_setup_exec, exec_type, file_type;
 
 init_daemon_domain(goldfish_setup)
@@ -12,7 +12,9 @@
 allow goldfish_setup toolbox_exec:file rx_file_perms;
 allow goldfish_setup self:capability { net_admin net_raw };
 allow goldfish_setup self:udp_socket create_socket_perms;
+allowxperm goldfish_setup self:udp_socket ioctl priv_sock_ioctls;
 
+wakelock_use(goldfish_setup)
 net_domain(goldfish_setup)
 
 # Set net.eth0.dns*, debug.sf.nobootanimation
diff --git a/target/board/generic/sepolicy/hal_gnss_default.te b/target/board/generic/sepolicy/hal_gnss_default.te
new file mode 100644
index 0000000..0dd3d03
--- /dev/null
+++ b/target/board/generic/sepolicy/hal_gnss_default.te
@@ -0,0 +1,3 @@
+#============= hal_gnss_default ==============
+allow hal_gnss_default vndbinder_device:chr_file { ioctl open read write };
+
diff --git a/target/board/generic/sepolicy/hal_graphics_composer_default.te b/target/board/generic/sepolicy/hal_graphics_composer_default.te
new file mode 100644
index 0000000..034bdef
--- /dev/null
+++ b/target/board/generic/sepolicy/hal_graphics_composer_default.te
@@ -0,0 +1,3 @@
+#============= hal_graphics_composer_default ==============
+allow hal_graphics_composer_default vndbinder_device:chr_file { ioctl open read write };
+
diff --git a/target/board/generic/sepolicy/logd.te b/target/board/generic/sepolicy/logd.te
deleted file mode 100644
index b3e60d7..0000000
--- a/target/board/generic/sepolicy/logd.te
+++ /dev/null
@@ -1,11 +0,0 @@
-# goldfish logcat service:  runs logcat -Q in logd domain
-
-# See global logd.te, these only set for eng & userdebug, allow for all builds
-
-domain_auto_trans(init, logcat_exec, logd)
-
-# Read from logd.
-read_logd(logd)
-
-# Write to /dev/ttyS2 and /dev/ttyGF2.
-allow logd serial_device:chr_file { write open };
diff --git a/target/board/generic/sepolicy/logpersist.te b/target/board/generic/sepolicy/logpersist.te
new file mode 100644
index 0000000..3fc0250
--- /dev/null
+++ b/target/board/generic/sepolicy/logpersist.te
@@ -0,0 +1,13 @@
+# goldfish logcat service:  runs logcat -Q in logpersist domain
+
+# See global logcat.te/logpersist.te, only set for eng & userdebug,
+# allow for all builds in a non-conflicting manner.
+
+domain_auto_trans(init, logcat_exec, logpersist)
+
+# Read from logd.
+unix_socket_connect(logpersist, logdr, logd)
+
+# Write to /dev/ttyS2 and /dev/ttyGF2.
+allow logpersist serial_device:chr_file { write open };
+get_prop(logpersist, qemu_cmdline)
diff --git a/target/board/generic/sepolicy/property.te b/target/board/generic/sepolicy/property.te
index 22d580a..a486702 100644
--- a/target/board/generic/sepolicy/property.te
+++ b/target/board/generic/sepolicy/property.te
@@ -1,3 +1,4 @@
 type qemu_prop, property_type;
+type qemu_cmdline, property_type;
 type radio_noril_prop, property_type;
 type opengles_prop, property_type;
diff --git a/target/board/generic/sepolicy/property_contexts b/target/board/generic/sepolicy/property_contexts
index 142b062..c66a85f 100644
--- a/target/board/generic/sepolicy/property_contexts
+++ b/target/board/generic/sepolicy/property_contexts
@@ -1,4 +1,5 @@
 qemu.                   u:object_r:qemu_prop:s0
+qemu.cmdline            u:object_r:qemu_cmdline:s0
 ro.emu.                 u:object_r:qemu_prop:s0
 ro.emulator.            u:object_r:qemu_prop:s0
 ro.radio.noril          u:object_r:radio_noril_prop:s0
diff --git a/target/board/generic/sepolicy/qemu_props.te b/target/board/generic/sepolicy/qemu_props.te
index 6768ce7..d5571fd 100644
--- a/target/board/generic/sepolicy/qemu_props.te
+++ b/target/board/generic/sepolicy/qemu_props.te
@@ -1,5 +1,5 @@
 # qemu-props service:  Sets system properties on boot.
-type qemu_props, domain, domain_deprecated;
+type qemu_props, domain;
 type qemu_props_exec, exec_type, file_type;
 
 init_daemon_domain(qemu_props)
@@ -9,3 +9,4 @@
 set_prop(qemu_props, dalvik_prop)
 set_prop(qemu_props, config_prop)
 set_prop(qemu_props, opengles_prop)
+set_prop(qemu_props, qemu_cmdline)
diff --git a/target/board/generic/sepolicy/qemud.te b/target/board/generic/sepolicy/qemud.te
index 797cf5c..eee21c4 100644
--- a/target/board/generic/sepolicy/qemud.te
+++ b/target/board/generic/sepolicy/qemud.te
@@ -1,5 +1,5 @@
 # qemu support daemon
-type qemud, domain, domain_deprecated;
+type qemud, domain;
 type qemud_exec, exec_type, file_type;
 
 init_daemon_domain(qemud)
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index 02d0a6f..a1c7b75 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -65,9 +65,12 @@
 ifeq ($(HOST_OS),linux)
   ifeq ($(WITH_DEXPREOPT),)
     WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_BOOT_IMG_ONLY := false
   endif
 endif
 
+TARGET_USES_HWC2 := true
+
 # Build OpenGLES emulation host and guest libraries
 BUILD_EMULATOR_OPENGL := true
 
@@ -76,7 +79,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192  # 1.75 GB
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2684354560  # 2.5 GB
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
diff --git a/target/board/generic_arm64/system.prop b/target/board/generic_arm64/system.prop
index aee6b13..24578a9 100644
--- a/target/board/generic_arm64/system.prop
+++ b/target/board/generic_arm64/system.prop
@@ -2,5 +2,5 @@
 # system.prop for generic arm64 sdk
 #
 
-rild.libpath=/system/lib/libreference-ril.so
+rild.libpath=/system/lib64/libreference-ril.so
 rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_arm64_a/BoardConfig.mk b/target/board/generic_arm64_a/BoardConfig.mk
new file mode 100644
index 0000000..fbac417
--- /dev/null
+++ b/target/board/generic_arm64_a/BoardConfig.mk
@@ -0,0 +1,71 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# Common boardconfig settings for generic AOSP products targetting mobile
+# (phone/table) devices.
+
+# Bootloader is not part of generic AOSP image
+TARGET_NO_BOOTLOADER := true
+
+# Kernel is also not part of generic AOSP image
+TARGET_NO_KERNEL := true
+
+# system.img is always ext4 with sparse option
+TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
+TARGET_USES_MKE2FS := true
+
+# Enable dex pre-opt to speed up initial boot
+ifeq ($(HOST_OS),linux)
+  ifeq ($(WITH_DEXPREOPT),)
+    WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_PIC := true
+    ifneq ($(TARGET_BUILD_VARIANT),user)
+      # Retain classes.dex in APK's for non-user builds
+      DEX_PREOPT_DEFAULT := nostripping
+    endif
+  endif
+endif
+
+# Generic AOSP image always requires separate vendor.img
+BOARD_USES_VENDORIMAGE := true
+TARGET_COPY_OUT_VENDOR := vendor
+
+# Generic AOSP image does NOT support HWC1
+TARGET_USES_HWC2 := true
+
+TARGET_ARCH := arm64
+TARGET_ARCH_VARIANT := armv8-a
+TARGET_CPU_ABI := arm64-v8a
+TARGET_CPU_ABI2 :=
+TARGET_CPU_VARIANT := generic
+
+TARGET_2ND_ARCH := arm
+TARGET_2ND_ARCH_VARIANT := armv7-a-neon
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+TARGET_2ND_CPU_VARIANT := generic
+
+TARGET_USES_64_BIT_BINDER := true
+
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736	# 1.5 GB
+
+# TODO(b/35790399): remove when b/35790399 is fixed.
+BOARD_NAND_SPARE_SIZE := 0
+BOARD_FLASH_BLOCK_SIZE := 512
+
+BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
+
diff --git a/target/board/generic_arm64_a/system.prop b/target/board/generic_arm64_a/system.prop
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/target/board/generic_arm64_a/system.prop
diff --git a/target/board/generic_arm64_ab/BoardConfig.mk b/target/board/generic_arm64_ab/BoardConfig.mk
new file mode 100644
index 0000000..cf79019
--- /dev/null
+++ b/target/board/generic_arm64_ab/BoardConfig.mk
@@ -0,0 +1,85 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# Common boardconfig settings for generic AOSP products targetting mobile
+# (phone/table) devices.
+
+# Bootloader is not part of generic AOSP image
+TARGET_NO_BOOTLOADER := true
+
+# Kernel is also not part of generic AOSP image
+TARGET_NO_KERNEL := true
+
+# system.img is always ext4 with sparse option
+TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
+TARGET_USES_MKE2FS := true
+
+# Enable dex pre-opt to speed up initial boot
+ifeq ($(HOST_OS),linux)
+  ifeq ($(WITH_DEXPREOPT),)
+    WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_PIC := true
+    ifneq ($(TARGET_BUILD_VARIANT),user)
+      # Retain classes.dex in APK's for non-user builds
+      DEX_PREOPT_DEFAULT := nostripping
+    endif
+  endif
+endif
+
+# Generic AOSP image always requires separate vendor.img
+BOARD_USES_VENDORIMAGE := true
+TARGET_COPY_OUT_VENDOR := vendor
+
+# Generic AOSP image does NOT support HWC1
+TARGET_USES_HWC2 := true
+
+TARGET_ARCH := arm64
+TARGET_ARCH_VARIANT := armv8-a
+TARGET_CPU_ABI := arm64-v8a
+TARGET_CPU_ABI2 :=
+TARGET_CPU_VARIANT := generic
+
+TARGET_2ND_ARCH := arm
+TARGET_2ND_ARCH_VARIANT := armv7-a-neon
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+# TODO(jiyong) can we set krait here?
+TARGET_2ND_CPU_VARIANT := cortex-a15
+
+TARGET_USES_64_BIT_BINDER := true
+
+# Enable A/B update
+TARGET_NO_RECOVERY := true
+BOARD_BUILD_SYSTEM_ROOT_IMAGE := true
+
+# TODO(jiyong) These might be SoC specific.
+BOARD_ROOT_EXTRA_FOLDERS := bt_firmware firmware firmware/radio persist
+BOARD_ROOT_EXTRA_SYMLINKS := /vendor/lib/dsp:/dsp
+
+# TODO(b/35603549): this is currently set to 2.5GB to support sailfish/marlin
+# Fix this!
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648
+
+# TODO(b/35790399): remove when b/35790399 is fixed.
+BOARD_NAND_SPARE_SIZE := 0
+BOARD_FLASH_BLOCK_SIZE := 512
+
+BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
+
+# TODO(b/36764215): remove this setting when the generic system image
+# no longer has QCOM-specific directories under /.
+BOARD_SEPOLICY_DIRS += build/target/board/generic_arm64_ab/sepolicy
diff --git a/target/board/generic_arm64_ab/sepolicy/file.te b/target/board/generic_arm64_ab/sepolicy/file.te
new file mode 100644
index 0000000..4645533
--- /dev/null
+++ b/target/board/generic_arm64_ab/sepolicy/file.te
@@ -0,0 +1,7 @@
+# TODO(b/36764215): remove this file when the generic system image
+# no longer has these directories
+type bt_firmware_file, file_type;
+type persist_file, file_type;
+
+# Default type for anything under /firmware.
+type firmware_file, fs_type, contextmount_type;
diff --git a/target/board/generic_arm64_ab/sepolicy/file_contexts b/target/board/generic_arm64_ab/sepolicy/file_contexts
new file mode 100644
index 0000000..92a4ff8
--- /dev/null
+++ b/target/board/generic_arm64_ab/sepolicy/file_contexts
@@ -0,0 +1,13 @@
+# TODO(b/36764215): remove this file when the generic system image
+# no longer has these directories. They are specific to QCOM.
+
+# /
+/bt_firmware(/.*)?      u:object_r:bt_firmware_file:s0
+/tombstones             u:object_r:rootfs:s0
+/dsp                    u:object_r:rootfs:s0
+
+# /persist
+/persist(/.*)?          u:object_r:persist_file:s0
+
+# files in firmware
+/firmware(/.*)?         u:object_r:firmware_file:s0
diff --git a/target/board/generic_arm64_ab/system.prop b/target/board/generic_arm64_ab/system.prop
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/target/board/generic_arm64_ab/system.prop
diff --git a/target/board/generic_arm_a/BoardConfig.mk b/target/board/generic_arm_a/BoardConfig.mk
new file mode 100644
index 0000000..6c1b36f
--- /dev/null
+++ b/target/board/generic_arm_a/BoardConfig.mk
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# Common boardconfig settings for generic AOSP products targetting mobile
+# (phone/table) devices.
+
+# Bootloader is not part of generic AOSP image
+TARGET_NO_BOOTLOADER := true
+
+# Kernel is also not part of generic AOSP image
+TARGET_NO_KERNEL := true
+
+# system.img is always ext4 with sparse option
+TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := false
+TARGET_USES_MKE2FS := true
+
+# Enable dex pre-opt to speed up initial boot
+ifeq ($(HOST_OS),linux)
+  ifeq ($(WITH_DEXPREOPT),)
+    WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_PIC := true
+    ifneq ($(TARGET_BUILD_VARIANT),user)
+      # Retain classes.dex in APK's for non-user builds
+      DEX_PREOPT_DEFAULT := nostripping
+    endif
+  endif
+endif
+
+# Generic AOSP image always requires separate vendor.img
+BOARD_USES_VENDORIMAGE := true
+TARGET_COPY_OUT_VENDOR := vendor
+
+# Generic AOSP image does NOT support HWC1
+TARGET_USES_HWC2 := true
+
+TARGET_ARCH := arm
+TARGET_ARCH_VARIANT := armv7-a-neon
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+TARGET_CPU_VARIANT := generic
+
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
+
+# TODO(b/35790399): remove when b/35790399 is fixed.
+BOARD_NAND_SPARE_SIZE := 0
+BOARD_FLASH_BLOCK_SIZE := 512
+
+BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
+
diff --git a/target/board/generic_arm_a/system.prop b/target/board/generic_arm_a/system.prop
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/target/board/generic_arm_a/system.prop
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
index 1152105..5cc3174 100644
--- a/target/board/generic_mips/BoardConfig.mk
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -42,9 +42,12 @@
 ifeq ($(HOST_OS),linux)
   ifeq ($(WITH_DEXPREOPT),)
     WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_BOOT_IMG_ONLY := false
   endif
 endif
 
+TARGET_USES_HWC2 := true
+
 # Build OpenGLES emulation guest and host libraries
 BUILD_EMULATOR_OPENGL := true
 
@@ -53,7 +56,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192  # 1.75 GB
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648  # 2 GB
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 734003200
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
diff --git a/target/board/generic_mips64/BoardConfig.mk b/target/board/generic_mips64/BoardConfig.mk
index ebc1675..d87c924 100644
--- a/target/board/generic_mips64/BoardConfig.mk
+++ b/target/board/generic_mips64/BoardConfig.mk
@@ -31,7 +31,10 @@
 TARGET_2ND_ARCH := mips
 ifeq (,$(TARGET_2ND_ARCH_VARIANT))
 ifeq ($(TARGET_ARCH_VARIANT),mips64r6)
-TARGET_2ND_ARCH_VARIANT :=  mips32r6
+# Imgtec builds use 32r6 arch variant with Imgtec-maintained prebuilts/ndk library:
+# TARGET_2ND_ARCH_VARIANT := mips32r6
+# Aosp builds lack full set of mips32r6 NDK prebuilts, so use 32r2 abi:
+TARGET_2ND_ARCH_VARIANT :=  mips32r2-fp
 else
 TARGET_2ND_ARCH_VARIANT :=  mips32r2-fp
 endif
@@ -54,9 +57,12 @@
 ifeq ($(HOST_OS),linux)
   ifeq ($(WITH_DEXPREOPT),)
     WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_BOOT_IMG_ONLY := false
   endif
 endif
 
+TARGET_USES_HWC2 := true
+
 # Build OpenGLES emulation guest and host libraries
 BUILD_EMULATOR_OPENGL := true
 
diff --git a/target/board/generic_mips64/system.prop b/target/board/generic_mips64/system.prop
index 326e4b7..aa03eae 100644
--- a/target/board/generic_mips64/system.prop
+++ b/target/board/generic_mips64/system.prop
@@ -2,5 +2,5 @@
 # system.prop for generic mips64 sdk
 #
 
-rild.libpath=/system/lib/libreference-ril.so
+rild.libpath=/system/lib64/libreference-ril.so
 rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 50ecb98..65c4fa5 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -22,8 +22,11 @@
 # of an SDK AVD. Note that this operation only works on Linux for now
 ifeq ($(HOST_OS),linux)
 WITH_DEXPREOPT ?= true
+WITH_DEXPREOPT_BOOT_IMG_ONLY ?= false
 endif
 
+TARGET_USES_HWC2 := true
+
 # Build OpenGLES emulation host and guest libraries
 BUILD_EMULATOR_OPENGL := true
 
@@ -32,7 +35,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk
index 283e9cc..88f6450 100755
--- a/target/board/generic_x86_64/BoardConfig.mk
+++ b/target/board/generic_x86_64/BoardConfig.mk
@@ -13,7 +13,7 @@
 
 TARGET_2ND_CPU_ABI := x86
 TARGET_2ND_ARCH := x86
-TARGET_2ND_ARCH_VARIANT := x86
+TARGET_2ND_ARCH_VARIANT := x86_64
 
 TARGET_USES_64_BIT_BINDER := true
 
@@ -28,8 +28,11 @@
 # of an SDK AVD. Note that this operation only works on Linux for now
 ifeq ($(HOST_OS),linux)
 WITH_DEXPREOPT ?= true
+WITH_DEXPREOPT_BOOT_IMG_ONLY ?= false
 endif
 
+TARGET_USES_HWC2 := true
+
 # Build OpenGLES emulation host and guest libraries
 BUILD_EMULATOR_OPENGL := true
 
@@ -38,7 +41,7 @@
 USE_OPENGL_RENDERER := true
 
 TARGET_USERIMAGES_USE_EXT4 := true
-BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2 GB
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2684354560 # 2.5 GB
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
diff --git a/target/board/generic_x86_64/system.prop b/target/board/generic_x86_64/system.prop
index 137a0f9..43d4a88 100644
--- a/target/board/generic_x86_64/system.prop
+++ b/target/board/generic_x86_64/system.prop
@@ -2,5 +2,5 @@
 # system.prop for generic sdk
 #
 
-rild.libpath=/system/lib/libreference-ril.so
+rild.libpath=/system/lib64/libreference-ril.so
 rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_x86_arm/BoardConfig.mk b/target/board/generic_x86_arm/BoardConfig.mk
new file mode 100644
index 0000000..4a2e159
--- /dev/null
+++ b/target/board/generic_x86_arm/BoardConfig.mk
@@ -0,0 +1,63 @@
+# Copyright (C) 2016 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.
+#
+
+# Configuration for generic_x86 + arm libraries needed by binary translation.
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_CPU_ABI := x86
+TARGET_ARCH := x86
+TARGET_ARCH_VARIANT := x86
+
+TARGET_2ND_ARCH := arm
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+TARGET_2ND_ARCH_VARIANT := armv7-a
+TARGET_2ND_CPU_VARIANT := generic
+
+# Tell the build system this isn't a typical 64bit+32bit multilib configuration.
+TARGET_TRANSLATE_2ND_ARCH := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+  ifeq ($(WITH_DEXPREOPT),)
+    WITH_DEXPREOPT := true
+    WITH_DEXPREOPT_BOOT_IMG_ONLY := false
+  endif
+endif
+
+TARGET_USES_HWC2 := true
+
+# Build OpenGLES emulation host and guest libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192  # 1.75 GB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index 69edc72..285fc39 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -51,12 +51,16 @@
     $(LOCAL_DIR)/generic_x86.mk \
     $(LOCAL_DIR)/generic_mips.mk \
     $(LOCAL_DIR)/aosp_arm.mk \
+    $(LOCAL_DIR)/aosp_arm_a.mk \
     $(LOCAL_DIR)/full.mk \
     $(LOCAL_DIR)/aosp_x86.mk \
+    $(LOCAL_DIR)/aosp_x86_arm.mk \
     $(LOCAL_DIR)/full_x86.mk \
     $(LOCAL_DIR)/aosp_mips.mk \
     $(LOCAL_DIR)/full_mips.mk \
     $(LOCAL_DIR)/aosp_arm64.mk \
+    $(LOCAL_DIR)/aosp_arm64_a.mk \
+    $(LOCAL_DIR)/aosp_arm64_ab.mk \
     $(LOCAL_DIR)/aosp_mips64.mk \
     $(LOCAL_DIR)/aosp_x86_64.mk \
     $(LOCAL_DIR)/sdk_phone_armv7.mk \
diff --git a/target/product/aosp_arm64_a.mk b/target/product/aosp_arm64_a.mk
new file mode 100644
index 0000000..535b3a4
--- /dev/null
+++ b/target/product/aosp_arm64_a.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# PRODUCT_PROPERTY_OVERRIDES cannot be used here because sysprops will be at
+# /vendor/[build|default].prop when build split is on. In order to have sysprops
+# on the generic system image, place them in build/make/target/board/generic_arm64_a/
+# system.prop.
+
+include build/make/target/product/treble_common.mk
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/verity.mk)
+
+PRODUCT_NAME := aosp_arm64_a
+PRODUCT_DEVICE := generic_arm64_a
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on ARM64
diff --git a/target/product/aosp_arm64_ab.mk b/target/product/aosp_arm64_ab.mk
new file mode 100644
index 0000000..442ac25
--- /dev/null
+++ b/target/product/aosp_arm64_ab.mk
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# PRODUCT_PROPERTY_OVERRIDES cannot be used here because sysprops will be at
+# /vendor/[build|default].prop when build split is on. In order to have sysprops
+# on the generic system image, place them in build/make/target/board/generic_arm64_ab/
+# system.prop.
+
+include build/make/target/product/treble_common.mk
+
+AB_OTA_UPDATER := true
+AB_OTA_PARTITIONS := system
+PRODUCT_PACKAGES += \
+    update_engine \
+    update_verifier
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/verity.mk)
+
+PRODUCT_NAME := aosp_arm64_ab
+PRODUCT_DEVICE := generic_arm64_ab
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on ARM64
diff --git a/target/product/aosp_arm_a.mk b/target/product/aosp_arm_a.mk
new file mode 100644
index 0000000..c3188e0
--- /dev/null
+++ b/target/product/aosp_arm_a.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# PRODUCT_PROPERTY_OVERRIDES cannot be used here because sysprops will be at
+# /vendor/[build|default].prop when build split is on. In order to have sysprops
+# on the generic system image, place them in build/make/target/board/generic_arm_a/
+# system.prop.
+
+include build/make/target/product/treble_common.mk
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/verity.mk)
+
+PRODUCT_NAME := aosp_arm_a
+PRODUCT_DEVICE := generic_arm_a
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on ARM32
diff --git a/target/product/aosp_x86_arm.mk b/target/product/aosp_x86_arm.mk
new file mode 100644
index 0000000..19f57e8
--- /dev/null
+++ b/target/product/aosp_x86_arm.mk
@@ -0,0 +1,43 @@
+#
+# Copyright 2016 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.
+#
+
+
+# aosp_x86 with arm libraries needed by binary translation.
+
+include $(SRC_TARGET_DIR)/product/full_x86.mk
+
+# arm libraries. This is the list of shared libraries included in the NDK.
+# Their dependency libraries will be automatically pulled in.
+PRODUCT_PACKAGES += \
+  libandroid_arm \
+  libaaudio_arm \
+  libc_arm \
+  libdl_arm \
+  libEGL_arm \
+  libGLESv1_CM_arm \
+  libGLESv2_arm \
+  libGLESv3_arm \
+  libjnigraphics_arm \
+  liblog_arm \
+  libm_arm \
+  libmediandk_arm \
+  libOpenMAXAL_arm \
+  libstdc++_arm \
+  libOpenSLES_arm \
+  libz_arm \
+
+PRODUCT_NAME := aosp_x86_arm
+PRODUCT_DEVICE := generic_x86_arm
diff --git a/target/product/base.mk b/target/product/base.mk
index 4d70664..89a2aaa 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -27,6 +27,7 @@
     app_process \
     applypatch \
     audioserver \
+    bit \
     blkid \
     bmgr \
     bugreport \
@@ -36,9 +37,13 @@
     dnsmasq \
     dpm \
     framework \
+    framework-sysconfig.xml \
     fsck_msdos \
     hid \
     ime \
+    incidentd \
+    incident \
+    incident_report \
     input \
     javax.obex \
     libandroid \
@@ -54,6 +59,7 @@
     libcamera2ndk \
     libdl \
     libdrmclearkeyplugin \
+    libclearkeycasplugin \
     libeffectproxy \
     libeffects \
     libinput \
@@ -98,11 +104,12 @@
     libmediandk \
     libvulkan \
     libwifi-service \
+    locksettings \
     media \
     media_cmd \
     mediadrmserver \
     mediaserver \
-    mediacodec \
+    mediametrics \
     mediaextractor \
     monkey \
     mtpd \
@@ -111,6 +118,7 @@
     ping \
     ping6 \
     platform.xml \
+    privapp-permissions-platform.xml \
     pppd \
     pm \
     racoon \
@@ -129,6 +137,17 @@
     vold \
     wm
 
+# Essential HAL modules
+PRODUCT_PACKAGES += \
+    [email protected]
+
+# XML schema files
+PRODUCT_PACKAGES += \
+    media_profiles_V1_0.dtd
+
+# Packages included only for eng or userdebug builds, previously debug tagged
+PRODUCT_PACKAGES_DEBUG := \
+    perfprofd
 
 PRODUCT_COPY_FILES := $(call add-to-product-copy-files-if-exists,\
     frameworks/base/preloaded-classes:system/etc/preloaded-classes)
diff --git a/target/product/core.mk b/target/product/core.mk
index 0a4e0fd..a2b0f1c 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -25,6 +25,7 @@
     BlockedNumberProvider \
     BookmarkProvider \
     Browser2 \
+    BuiltInPrintService \
     Calendar \
     CalendarProvider \
     CaptivePortalLogin \
@@ -57,6 +58,17 @@
     Telecom \
     TeleService \
     VpnDialogs \
+    vr \
     MmsService
 
+# The set of packages whose code can be loaded by the system server.
+PRODUCT_SYSTEM_SERVER_APPS += \
+    FusedLocation \
+    InputDevices \
+    KeyChain \
+    Telecom \
+
+# The set of packages we want to force 'speed' compilation on.
+PRODUCT_DEXPREOPT_SPEED_APPS += \
+
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_base.mk)
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index 009ca52..5a18c70 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -24,6 +24,7 @@
 
 PRODUCT_PACKAGES += \
     BackupRestoreConfirmation \
+    CompanionDeviceManager \
     CtsShimPrebuilt \
     CtsShimPrivPrebuilt \
     DownloadProvider \
@@ -36,6 +37,8 @@
     Shell \
     StatementService \
     WallpaperBackup \
+    android.hidl.base-V1.0-java \
+    android.hidl.manager-V1.0-java \
     bcc \
     bu \
     com.android.future.usb.accessory \
@@ -58,8 +61,9 @@
     gatekeeperd \
     keystore \
     keystore.default \
+    ld.config.txt \
     ld.mc \
-    libbcc \
+    libaaudio \
     libOpenMAXAL \
     libOpenSLES \
     libdownmix \
@@ -68,11 +72,14 @@
     libfilterfw \
     libkeystore \
     libgatekeeper \
+    libwebviewchromium_loader \
+    libwebviewchromium_plat_support \
     libwilhelm \
     logd \
     make_ext4fs \
     e2fsck \
     resize2fs \
+    tune2fs \
     screencap \
     sensorservice \
     telephony-common \
@@ -80,18 +87,24 @@
     uncrypt \
     voip-common \
     webview \
+    webview_zygote \
     wifi-service
 
 PRODUCT_COPY_FILES += \
     frameworks/native/data/etc/android.software.webview.xml:system/etc/permissions/android.software.webview.xml
 
+ifneq (REL,$(PLATFORM_VERSION_CODENAME))
+PRODUCT_COPY_FILES += \
+    frameworks/native/data/etc/android.software.preview_sdk.xml:system/etc/permissions/android.software.preview_sdk.xml
+endif
+
 # The order of PRODUCT_BOOT_JARS matters.
 PRODUCT_BOOT_JARS := \
     core-oj \
     core-libart \
     conscrypt \
     okhttp \
-    core-junit \
+    legacy-test \
     bouncycastle \
     ext \
     framework \
@@ -99,7 +112,9 @@
     voip-common \
     ims-common \
     apache-xml \
-    org.apache.http.legacy.boot
+    org.apache.http.legacy.boot \
+    android.hidl.base-V1.0-java \
+    android.hidl.manager-V1.0-java
 
 # The order of PRODUCT_SYSTEM_SERVER_JARS matters.
 PRODUCT_SYSTEM_SERVER_JARS := \
@@ -107,6 +122,11 @@
     ethernet-service \
     wifi-service
 
+# The set of packages whose code can be loaded by the system server.
+PRODUCT_SYSTEM_SERVER_APPS += \
+    SettingsProvider \
+    WallpaperBackup
+
 # Adoptable external storage supports both ext4 and f2fs
 PRODUCT_PACKAGES += \
     e2fsck \
@@ -122,27 +142,6 @@
 PRODUCT_COPY_FILES += \
     system/core/rootdir/etc/public.libraries.android.txt:system/etc/public.libraries.txt
 
-# Different dexopt types for different package update/install times.
-# On eng builds, make "boot" reasons do pure JIT for faster turnaround.
-ifeq (eng,$(TARGET_BUILD_VARIANT))
-    PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-        pm.dexopt.first-boot=verify-at-runtime \
-        pm.dexopt.boot=verify-at-runtime
-else
-    PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-        pm.dexopt.first-boot=interpret-only \
-        pm.dexopt.boot=verify-profile
-endif
-PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-    pm.dexopt.install=interpret-only \
-    pm.dexopt.bg-dexopt=speed-profile \
-    pm.dexopt.ab-ota=speed-profile \
-    pm.dexopt.nsys-library=speed \
-    pm.dexopt.shared-apk=speed \
-    pm.dexopt.forced-dexopt=speed \
-    pm.dexopt.core-app=speed
-
-
 # Enable boot.oat filtering of compiled classes to reduce boot.oat size. b/28026683
 PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\
     frameworks/base/compiled-classes-phone:system/etc/compiled-classes)
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index ec2fa41..e9920f2 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -31,7 +31,6 @@
 
 PRODUCT_PACKAGES += \
     audio.primary.default \
-    audio_policy.default \
     local_time.default \
     power.default
 
@@ -45,6 +44,8 @@
     SettingsProvider \
     Shell \
     WallpaperBackup \
+    android.hidl.base-V1.0-java \
+    android.hidl.manager-V1.0-java \
     bcc \
     bu \
     com.android.location.provider \
@@ -60,6 +61,7 @@
     keystore \
     keystore.default \
     ld.mc \
+    libaaudio \
     libOpenMAXAL \
     libOpenSLES \
     libdownmix \
@@ -72,6 +74,7 @@
     make_ext4fs \
     e2fsck \
     resize2fs \
+    tune2fs \
     nullwebview \
     screencap \
     sensorservice \
@@ -88,7 +91,7 @@
     core-libart \
     conscrypt \
     okhttp \
-    core-junit \
+    legacy-test \
     bouncycastle \
     ext \
     framework \
@@ -97,13 +100,25 @@
     ims-common \
     apache-xml \
     nullwebview \
-    org.apache.http.legacy.boot
+    org.apache.http.legacy.boot \
+    android.hidl.base-V1.0-java \
+    android.hidl.manager-V1.0-java
 
 # The order of PRODUCT_SYSTEM_SERVER_JARS matters.
 PRODUCT_SYSTEM_SERVER_JARS := \
     services \
     wifi-service
 
+# The set of packages whose code can be loaded by the system server.
+PRODUCT_SYSTEM_SERVER_APPS += \
+    FusedLocation \
+    InputDevices \
+    SettingsProvider \
+    WallpaperBackup \
+
+# The set of packages we want to force 'speed' compilation on.
+PRODUCT_DEXPREOPT_SPEED_APPS := \
+
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     ro.zygote=zygote32
 PRODUCT_COPY_FILES += \
@@ -112,26 +127,6 @@
 PRODUCT_PROPERTY_OVERRIDES += \
     ro.carrier=unknown
 
-# Different dexopt types for different package update/install times.
-# On eng builds, make "boot" reasons do pure JIT for faster turnaround.
-ifeq (eng,$(TARGET_BUILD_VARIANT))
-    PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-        pm.dexopt.first-boot=verify-at-runtime \
-        pm.dexopt.boot=verify-at-runtime
-else
-    PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-        pm.dexopt.first-boot=interpret-only \
-        pm.dexopt.boot=verify-profile
-endif
-PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
-    pm.dexopt.install=interpret-only \
-    pm.dexopt.bg-dexopt=speed-profile \
-    pm.dexopt.ab-ota=speed-profile \
-    pm.dexopt.nsys-library=speed \
-    pm.dexopt.shared-apk=speed \
-    pm.dexopt.forced-dexopt=speed \
-    pm.dexopt.core-app=speed
-
 $(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
 $(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 55de3b9..6217883 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -20,18 +20,22 @@
 PRODUCT_PACKAGES += \
     adb \
     adbd \
+    [email protected] \
+    [email protected] \
+    [email protected] \
     atrace \
     bootanimation \
     bootstat \
+    charger \
     cmd \
-    debuggerd \
+    crash_dump \
+    debuggerd\
     dumpstate \
     dumpsys \
     fastboot \
     gralloc.default \
-    grep \
-    gzip \
     healthd \
+    hwservicemanager \
     init \
     init.environ.rc \
     init.rc \
@@ -65,26 +69,44 @@
     lmkd \
     logcat \
     logwrapper \
-    mkshrc \
-    reboot \
+    lshal \
     recovery \
     service \
     servicemanager \
-    sh \
+    shell_and_utilities \
+    storaged \
     surfaceflinger \
-    toolbox \
-    toybox \
+    tombstoned \
     tzdatacheck \
+    vndservice \
+    vndservicemanager \
+    compatibility_matrix.xml \
+    manifest.xml \
+    system_manifest.xml \
+    system_compatibility_matrix.xml \
 
 # SELinux packages
 PRODUCT_PACKAGES += \
-    sepolicy \
-    file_contexts.bin \
-    seapp_contexts \
-    property_contexts \
-    mac_permissions.xml \
-    selinux_version \
-    service_contexts
+    nonplat_mac_permissions.xml \
+    nonplat_property_contexts \
+    nonplat_seapp_contexts \
+    nonplat_service_contexts \
+    nonplat_hwservice_contexts \
+    plat_mac_permissions.xml \
+    plat_property_contexts \
+    plat_seapp_contexts \
+    plat_service_contexts \
+    plat_hwservice_contexts \
+    selinux_policy \
+    vndservice_contexts
+
+# AID Generation for
+# <pwd.h> and <grp.h>
+PRODUCT_PACKAGES += \
+    passwd \
+    group \
+    fs_config_files \
+    fs_config_dirs
 
 # Ensure that this property is always defined so that bionic_systrace.cpp
 # can rely on it being initially set by init.
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index afa8389..5a5fb8e 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -47,20 +47,62 @@
     fingerprint.goldfish \
     sensors.goldfish \
     audio.primary.goldfish \
+    audio.primary.goldfish_legacy \
+    [email protected] \
     vibrator.goldfish \
     power.goldfish \
+    power.ranchu \
     fingerprint.ranchu \
-    fingerprintd \
-    sensors.ranchu
+    [email protected] \
+    sensors.ranchu \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    hwcomposer.goldfish \
+    hwcomposer.ranchu \
+    vintf \
+    CarrierConfig
+
+PRODUCT_PACKAGES += \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected]
+
+PRODUCT_PACKAGES += \
+	[email protected] \
+	[email protected]
+
+PRODUCT_PACKAGES += \
+    [email protected] \
+    [email protected]
+
+PRODUCT_PACKAGES += \
+	[email protected] \
+	[email protected]
+
+PRODUCT_PACKAGES += \
+    [email protected] \
+    [email protected]
+
+# camera service treble disable until all backwards compat is complete
+PRODUCT_PROPERTY_OVERRIDES += \
+    camera.disable_treble=1
 
 PRODUCT_COPY_FILES += \
     device/generic/goldfish/fstab.goldfish:root/fstab.goldfish \
     device/generic/goldfish/init.goldfish.rc:root/init.goldfish.rc \
     device/generic/goldfish/init.goldfish.sh:system/etc/init.goldfish.sh \
+    device/generic/goldfish/init.ranchu-core.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-core.sh \
+    device/generic/goldfish/init.ranchu-net.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-net.sh \
+    device/generic/goldfish/init.ranchu.rc:root/init.ranchu.rc \
     device/generic/goldfish/ueventd.goldfish.rc:root/ueventd.goldfish.rc \
     device/generic/goldfish/init.ranchu.rc:root/init.ranchu.rc \
     device/generic/goldfish/fstab.ranchu:root/fstab.ranchu \
     device/generic/goldfish/ueventd.ranchu.rc:root/ueventd.ranchu.rc \
+    device/generic/goldfish/manifest.xml:$(TARGET_COPY_OUT_VENDOR)/manifest.xml \
     device/generic/goldfish/input/goldfish_rotary.idc:system/usr/idc/goldfish_rotary.idc \
     frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml
 
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
index 5c48358..52819d2 100644
--- a/target/product/generic_no_telephony.mk
+++ b/target/product/generic_no_telephony.mk
@@ -24,6 +24,7 @@
     Gallery2 \
     Music \
     MusicFX \
+    NfcNci \
     OneTimeInitializer \
     Provision \
     SystemUI \
@@ -46,7 +47,6 @@
 
 PRODUCT_PACKAGES += \
     audio.primary.default \
-    audio_policy.default \
     local_time.default \
     vibrator.default \
     power.default
@@ -63,7 +63,6 @@
 $(call inherit-product-if-exists, external/google-fonts/coming-soon/fonts.mk)
 $(call inherit-product-if-exists, external/google-fonts/cutive-mono/fonts.mk)
 $(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
-$(call inherit-product-if-exists, external/naver-fonts/fonts.mk)
 $(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
 $(call inherit-product-if-exists, external/hyphenation-patterns/patterns.mk)
 $(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
diff --git a/target/product/languages_full.mk b/target/product/languages_full.mk
index 98d8c3c..36c3de8 100644
--- a/target/product/languages_full.mk
+++ b/target/product/languages_full.mk
@@ -21,4 +21,4 @@
 
 # These are all the locales that have translations and are displayable
 # by TextView in this branch.
-PRODUCT_LOCALES := en_US en_AU en_IN fr_FR it_IT es_ES et_EE de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN zh_HK ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR sv_SE bg_BG ca_ES en_GB fi_FI hi_IN hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH ar_EG fa_IR th_TH sw_TZ ms_MY af_ZA zu_ZA am_ET en_XA ar_XB fr_CA km_KH lo_LA ne_NP si_LK mn_MN hy_AM az_AZ ka_GE my_MM mr_IN ml_IN is_IS mk_MK ky_KG eu_ES gl_ES bn_BD ta_IN kn_IN te_IN uz_UZ ur_PK kk_KZ sq_AL gu_IN pa_IN be_BY bs_BA
+PRODUCT_LOCALES := en_US en_AU en_IN fr_FR it_IT es_ES et_EE de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN zh_HK ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR sv_SE bg_BG ca_ES en_GB fi_FI hi_IN hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH ar_EG fa_IR th_TH sw_TZ ms_MY af_ZA zu_ZA am_ET en_XA ar_XB fr_CA km_KH lo_LA ne_NP si_LK mn_MN hy_AM az_AZ ka_GE my_MM mr_IN ml_IN is_IS mk_MK ky_KG eu_ES gl_ES bn_BD ta_IN kn_IN te_IN uz_UZ ur_PK kk_KZ sq_AL gu_IN pa_IN be_BY bs_BA sr_Latn_RS
diff --git a/target/product/product_launched_with_l.mk b/target/product/product_launched_with_l.mk
index b86f424..8127bc3 100644
--- a/target/product/product_launched_with_l.mk
+++ b/target/product/product_launched_with_l.mk
@@ -1,2 +1,3 @@
 #PRODUCT_SHIPPING_API_LEVEL indicates the first api level, device has been commercially launced on.
 PRODUCT_SHIPPING_API_LEVEL := 21
+
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index 5fd4d7e..0755bf3 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -16,41 +16,63 @@
 
 # Provides a functioning ART environment without Android frameworks
 
+# Minimal boot classpath. This should be a subset of PRODUCT_BOOT_JARS, and equivalent to
+# TARGET_CORE_JARS.
 PRODUCT_PACKAGES += \
     apache-xml \
-    ahat \
     bouncycastle \
-    cacerts \
-    conscrypt \
     core-oj \
-    core-junit \
     core-libart \
-    dalvikvm \
-    dex2oat \
-    dexdeps \
-    dexdump \
-    dexlist \
-    dmtracedump \
-    dx \
+    conscrypt \
+    okhttp \
+
+# Additional mixins to the boot classpath.
+PRODUCT_PACKAGES += \
+    legacy-test \
+
+# Why are we pulling in ext, which is frameworks/base, depending on tagsoup and nist-sip?
+PRODUCT_PACKAGES += \
     ext \
-    hprof-conv \
-    libart \
-    libart_fake \
-    libcrypto \
+
+# Why are we pulling in expat, which is used in frameworks, only, it seem?
+PRODUCT_PACKAGES += \
     libexpat \
-    libicui18n \
-    libicuuc \
+
+# Libcore.
+PRODUCT_PACKAGES += \
     libjavacore \
     libopenjdk \
     libopenjdkjvm \
-    libnativehelper \
-    libssl \
-    libz \
-    oatdump \
-    okhttp \
+
+# Libcore ICU. TODO: Try to figure out if/why we need them explicitly.
+PRODUCT_PACKAGES += \
+    libicui18n \
+    libicuuc \
+
+# ART.
+PRODUCT_PACKAGES += \
+    dalvikvm \
+    dex2oat \
+    dexoptanalyzer \
+    libart \
+    libart_fake \
+    libopenjdkjvmti \
     patchoat \
     profman
 
+# ART/dex helpers.
+PRODUCT_PACKAGES += \
+    ahat \
+    dexdiag \
+    dexdump \
+    dexlist \
+    hprof-conv \
+    oatdump \
+
+# Certificates.
+PRODUCT_PACKAGES += \
+    cacerts \
+
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     dalvik.vm.image-dex2oat-Xms=64m \
     dalvik.vm.image-dex2oat-Xmx=64m \
@@ -59,4 +81,22 @@
     ro.dalvik.vm.native.bridge=0 \
     dalvik.vm.usejit=true \
     dalvik.vm.usejitprofiles=true \
+    dalvik.vm.dexopt.secondary=true \
     dalvik.vm.appimageformat=lz4
+
+# Different dexopt types for different package update/install times.
+# On eng builds, make "boot" reasons only extract for faster turnaround.
+ifeq (eng,$(TARGET_BUILD_VARIANT))
+    PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+        pm.dexopt.first-boot=extract \
+        pm.dexopt.boot=extract
+else
+    PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+        pm.dexopt.first-boot=quicken \
+        pm.dexopt.boot=verify
+endif
+
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+    pm.dexopt.install=quicken \
+    pm.dexopt.bg-dexopt=speed-profile \
+    pm.dexopt.ab-ota=speed-profile
diff --git a/target/product/sdk_base.mk b/target/product/sdk_base.mk
index fa257ae..0cdb05d 100644
--- a/target/product/sdk_base.mk
+++ b/target/product/sdk_base.mk
@@ -18,13 +18,14 @@
 
 PRODUCT_PACKAGES := \
 	ApiDemos \
+	CellBroadcastReceiver \
 	CubeLiveWallpapers \
 	CustomLocale \
 	Development \
 	Dialer \
 	EmulatorSmokeTests \
 	Fallback \
-	Gallery \
+	Gallery2 \
 	GestureBuilder \
 	Launcher3 \
 	LegacyCamera \
@@ -38,6 +39,7 @@
 	OpenWnn \
 	Protips \
 	rild \
+	screenrecord \
 	SdkSetup \
 	SmokeTest \
 	SmokeTestApp \
@@ -45,6 +47,7 @@
 	sqlite3 \
 	SystemUI \
 	EasterEgg \
+	WallpaperPicker \
 	WidgetPreview
 
 # Define the host tools and libs that are parts of the SDK.
@@ -54,9 +57,32 @@
 # audio libraries.
 PRODUCT_PACKAGES += \
 	audio.primary.goldfish \
-	audio_policy.default \
+	audio.r_submix.default \
 	local_time.default
 
+# CDD mandates following codecs
+PRODUCT_PACKAGES += \
+    libstagefright_soft_aacdec \
+    libstagefright_soft_aacenc \
+    libstagefright_soft_amrdec \
+    libstagefright_soft_amrnbenc \
+    libstagefright_soft_amrwbenc \
+    libstagefright_soft_avcdec \
+    libstagefright_soft_avcenc \
+    libstagefright_soft_flacenc \
+    libstagefright_soft_g711dec \
+    libstagefright_soft_gsmdec \
+    libstagefright_soft_hevcdec \
+    libstagefright_soft_mp3dec \
+    libstagefright_soft_mpeg2dec \
+    libstagefright_soft_mpeg4dec \
+    libstagefright_soft_mpeg4enc \
+    libstagefright_soft_opusdec \
+    libstagefright_soft_rawdec \
+    libstagefright_soft_vorbisdec \
+    libstagefright_soft_vpxdec \
+    libstagefright_soft_vpxenc
+
 PRODUCT_PACKAGE_OVERLAYS := development/sdk_overlay
 
 PRODUCT_COPY_FILES := \
@@ -69,13 +95,14 @@
 	device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
 	frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
 	frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
-	frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+	device/generic/goldfish/camera/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
 	device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
+	device/generic/goldfish/camera/media_codecs_performance.xml:system/etc/media_codecs_performance.xml \
 	frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \
-	frameworks/native/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \
+	frameworks/native/data/etc/android.hardware.camera.xml:system/etc/permissions/android.hardware.camera.xml \
 	frameworks/native/data/etc/android.hardware.fingerprint.xml:system/etc/permissions/android.hardware.fingerprint.xml \
 	frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf \
-	hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
+	device/generic/goldfish/audio_policy.conf:system/etc/audio_policy.conf
 
 include $(SRC_TARGET_DIR)/product/emulator.mk
 
@@ -86,7 +113,6 @@
 $(call inherit-product-if-exists, external/google-fonts/coming-soon/fonts.mk)
 $(call inherit-product-if-exists, external/google-fonts/cutive-mono/fonts.mk)
 $(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
-$(call inherit-product-if-exists, external/naver-fonts/fonts.mk)
 $(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
 $(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
 $(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
diff --git a/target/product/telephony.mk b/target/product/telephony.mk
index e840ba1..38a8caa 100644
--- a/target/product/telephony.mk
+++ b/target/product/telephony.mk
@@ -19,6 +19,7 @@
 
 PRODUCT_PACKAGES := \
     CarrierConfig \
+    CarrierDefaultApp \
     Dialer \
     CallLogBackup \
     CellBroadcastReceiver \
diff --git a/target/product/treble_common.mk b/target/product/treble_common.mk
new file mode 100644
index 0000000..4567382
--- /dev/null
+++ b/target/product/treble_common.mk
@@ -0,0 +1,217 @@
+#
+# Copyright (C) 2017 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.
+#
+
+# Split selinux policy
+PRODUCT_FULL_TREBLE_OVERRIDE := true
+
+# HAL interfaces:
+#   Some of HAL interface libraries are automatically added by the dependencies
+#   from the framework. However, we list them all here to make it explicit and
+#   prevent possible mistake.
+PRODUCT_PACKAGES := \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    android.hardware.configstore-utils \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+    [email protected] \
+
+# VNDK:
+#   Some VNDK shared objects are automatically included indirectly.
+#   We list them all here to make it explicit and prevent possible mistakes.
+#   An example of one such mistake was libcurl, which is included in A/B
+#   devices because of update_engine, but not in non-A/B devices.
+PRODUCT_PACKAGES += \
+    libaudioroute \
+    libaudioutils \
+    libbinder \
+    libcamera_metadata \
+    libcap \
+    libcrypto \
+    libcrypto_utils \
+    libcups \
+    libcurl \
+    libdiskconfig \
+    libdumpstateutil \
+    libevent \
+    libexif \
+    libexpat \
+    libfmq \
+    libgatekeeper \
+    libgui \
+    libhardware_legacy \
+    libhidlmemory \
+    libicui18n \
+    libicuuc \
+    libjpeg \
+    libkeymaster1 \
+    libkeymaster_messages \
+    libldacBT_abr \
+    libldacBT_enc \
+    liblz4 \
+    liblzma \
+    libmdnssd \
+    libmemtrack \
+    libmemunreachable \
+    libmetricslogger \
+    libminijail \
+    libnetutils \
+    libnl \
+    libopus \
+    libpagemap \
+    libpcap \
+    libpcre2 \
+    libpcrecpp \
+    libpdfium \
+    libpiex \
+    libpower \
+    libprocessgroup \
+    libprocinfo \
+    libprotobuf-cpp-full \
+    libprotobuf-cpp-lite \
+    libradio_metadata \
+    libsoftkeymasterdevice \
+    libsonic \
+    libsonivox \
+    libspeexresampler \
+    libsqlite \
+    libssl \
+    libsuspend \
+    libsysutils \
+    libtinyalsa \
+    libtinyxml2 \
+    libui \
+    libusbhost \
+    libvixl-arm \
+    libvixl-arm64 \
+    libvorbisidec \
+    libwebrtc_audio_preprocessing \
+    libxml2 \
+    libyuv \
+    libziparchive \
+
+# VNDK-SP:
+PRODUCT_PACKAGES += \
+    vndk-sp \
+
+# LL-VNDK:
+PRODUCT_PACKAGES += \
+    libandroid_net \
+    libc \
+    libdl \
+    liblog \
+    libm \
+    libstdc++ \
+    libvndksupport \
+    libz \
+
+# SP-NDK:
+PRODUCT_PACKAGES += \
+    libEGL \
+    libGLESv1_CM \
+    libGLESv2 \
+    libGLESv3 \
+    libnativewindow \
+    libsync \
+    libvulkan \
+
+PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/bootdevice/by-name/system
+
+# Wifi:
+#   Wifi HAL ([email protected], wpa_supplicant,
+#   and wpa_supplicant.conf) is not here. They are in vendor.img
+PRODUCT_PACKAGES += \
+    wificond \
+
+# Audio:
+USE_XML_AUDIO_POLICY_CONF := 1
+# The following policy XML files are used as fallback for
+# vendors/devices not using XML to configure audio policy.
+PRODUCT_COPY_FILES += \
+    frameworks/av/services/audiopolicy/config/audio_policy_configuration_generic.xml:system/etc/audio_policy_configuration.xml \
+    frameworks/av/services/audiopolicy/config/primary_audio_policy_configuration.xml:system/etc/primary_audio_policy_configuration.xml \
+    frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:system/etc/r_submix_audio_policy_configuration.xml \
+    frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:system/etc/audio_policy_volumes.xml \
+    frameworks/av/services/audiopolicy/config/default_volume_tables.xml:system/etc/default_volume_tables.xml \
+
+# Bluetooth:
+#   audio.a2dp.default is a system module. Generic system image includes
+#   audio.a2dp.default to support A2DP if board has the capability.
+PRODUCT_PACKAGES += \
+    audio.a2dp.default
+
+# May need to review why the followings are needed in generic system image.
+PRODUCT_COPY_FILES += \
+    device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml
+
diff --git a/tests/envsetup_tests.sh b/tests/envsetup_tests.sh
new file mode 100755
index 0000000..4aae255
--- /dev/null
+++ b/tests/envsetup_tests.sh
@@ -0,0 +1,36 @@
+#!/bin/bash -e
+
+source $(dirname $0)/../envsetup.sh
+
+unset TARGET_PRODUCT TARGET_BUILD_VARIANT TARGET_PLATFORM_VERSION
+
+function check_lunch
+(
+    echo lunch $1
+    set +e
+    lunch $1 > /dev/null 2> /dev/null
+    set -e
+    [ "$TARGET_PRODUCT" = "$2" ] || ( echo "lunch $1: expected TARGET_PRODUCT='$2', got '$TARGET_PRODUCT'" && exit 1 )
+    [ "$TARGET_BUILD_VARIANT" = "$3" ] || ( echo "lunch $1: expected TARGET_BUILD_VARIANT='$3', got '$TARGET_BUILD_VARIANT'" && exit 1 )
+    [ "$TARGET_PLATFORM_VERSION" = "$4" ] || ( echo "lunch $1: expected TARGET_PLATFORM_VERSION='$4', got '$TARGET_PLATFORM_VERSION'" && exit 1 )
+)
+
+default_version=$(get_build_var DEFAULT_PLATFORM_VERSION)
+valid_version=PPR1
+
+# lunch tests
+check_lunch "aosp_arm64"                                "aosp_arm64" "eng"       "$default_version"
+check_lunch "aosp_arm64-userdebug"                      "aosp_arm64" "userdebug" "$default_version"
+check_lunch "aosp_arm64-userdebug-$valid_version"       "aosp_arm64" "userdebug" "$valid_version"
+check_lunch "abc"                                       "" "" ""
+check_lunch "aosp_arm64-abc"                            "" "" ""
+check_lunch "aosp_arm64-userdebug-abc"                  "" "" ""
+check_lunch "aosp_arm64-abc-$valid_version"             "" "" ""
+check_lunch "abc-userdebug-$valid_version"              "" "" ""
+check_lunch "-"                                         "" "" ""
+check_lunch "--"                                        "" "" ""
+check_lunch "-userdebug"                                "" "" ""
+check_lunch "-userdebug-"                               "" "" ""
+check_lunch "-userdebug-$valid_version"                 "" "" ""
+check_lunch "aosp_arm64-userdebug-$valid_version-"      "" "" ""
+check_lunch "aosp_arm64-userdebug-$valid_version-abc"   "" "" ""
diff --git a/tools/acp/Android.bp b/tools/acp/Android.bp
new file mode 100644
index 0000000..faf2034
--- /dev/null
+++ b/tools/acp/Android.bp
@@ -0,0 +1,13 @@
+// Copyright 2005 The Android Open Source Project
+//
+// Custom version of cp.
+
+cc_binary_host {
+
+    srcs: ["acp.c"],
+
+    static_libs: ["libhost"],
+    name: "acp",
+    stl: "none",
+
+}
diff --git a/tools/acp/Android.mk b/tools/acp/Android.mk
deleted file mode 100644
index eec9c9d..0000000
--- a/tools/acp/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2005 The Android Open Source Project
-#
-# Custom version of cp.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    acp.c
-
-LOCAL_STATIC_LIBRARIES := libhost
-LOCAL_MODULE := acp
-LOCAL_ACP_UNAVAILABLE := true
-LOCAL_CXX_STL := none
-
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/atree/atree.cpp b/tools/atree/atree.cpp
index b134e01..7deca7e 100644
--- a/tools/atree/atree.cpp
+++ b/tools/atree/atree.cpp
@@ -92,7 +92,7 @@
 
 // Escape the filename so that it can be added to the makefile properly.
 static string
-escape_filename(const string name)
+escape_filename(const string& name)
 {
     ostringstream new_name;
     for (string::const_iterator iter = name.begin(); iter != name.end(); ++iter)
diff --git a/tools/brillo-clang-format b/tools/brillo-clang-format
new file mode 100644
index 0000000..a69d9d2
--- /dev/null
+++ b/tools/brillo-clang-format
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2016 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.
+#
+
+### DO NOT COPY THIS FILE TO YOUR PROJECT. ###
+
+#
+# This is the .clang-format file used by all Brillo projects, conforming to the
+# style guide defined by Brillo. To use this file create a *relative* symlink in
+# your project pointing to this file, as this repository is expected to be
+# present in all manifests.
+#
+# See go/brillo-c++-style for details about the style guide.
+#
+
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+BinPackArguments: false
+BinPackParameters: false
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+PointerAlignment: Left
+TabWidth: 2
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index dcb66bf..d214aab 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -30,7 +30,6 @@
 echo "ro.product.brand=$PRODUCT_BRAND"
 echo "ro.product.name=$PRODUCT_NAME"
 echo "ro.product.device=$TARGET_DEVICE"
-echo "ro.product.board=$TARGET_BOOTLOADER_BOARD_NAME"
 
 # These values are deprecated, use "ro.product.cpu.abilist"
 # instead (see below).
@@ -49,7 +48,6 @@
   echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
 fi
 echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"
-echo "ro.board.platform=$TARGET_BOARD_PLATFORM"
 
 echo "# ro.build.product is obsolete; use ro.product.device"
 echo "ro.build.product=$TARGET_DEVICE"
diff --git a/tools/check_link_type.py b/tools/check_link_type.py
new file mode 100755
index 0000000..40754ad
--- /dev/null
+++ b/tools/check_link_type.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016 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.
+
+"""Utility to verify modules link against acceptable module types"""
+
+from __future__ import print_function
+import argparse
+import os
+import sys
+
+WARNING_MSG = ('\033[1m%(makefile)s: \033[35mwarning:\033[0m\033[1m '
+    '%(module)s (%(type)s) should not link to %(dep_name)s (%(dep_type)s)'
+    '\033[0m')
+ERROR_MSG = ('\033[1m%(makefile)s: \033[31merror:\033[0m\033[1m '
+    '%(module)s (%(type)s) should not link to %(dep_name)s (%(dep_type)s)'
+    '\033[0m')
+
+def parse_args():
+    """Parse commandline arguments."""
+    parser = argparse.ArgumentParser(description='Check link types')
+    parser.add_argument('--makefile', help='Makefile defining module')
+    parser.add_argument('--module', help='The module being checked')
+    parser.add_argument('--type', help='The link type of module')
+    parser.add_argument('--allowed', help='Allow deps to use these types',
+                        action='append', default=[], metavar='TYPE')
+    parser.add_argument('--warn', help='Warn if deps use these types',
+                        action='append', default=[], metavar='TYPE')
+    parser.add_argument('deps', help='The dependencies to check',
+                        metavar='DEP', nargs='*')
+    return parser.parse_args()
+
+def print_msg(msg, args, dep_name, dep_type):
+    """Print a warning or error message"""
+    print(msg % {
+          "makefile": args.makefile,
+          "module": args.module,
+          "type": args.type,
+          "dep_name": dep_name,
+          "dep_type": dep_type}, file=sys.stderr)
+
+def main():
+    """Program entry point."""
+    args = parse_args()
+
+    failed = False
+    for dep in args.deps:
+        dep_name = os.path.basename(os.path.dirname(dep))
+        if dep_name.endswith('_intermediates'):
+            dep_name = dep_name[:len(dep_name)-len('_intermediates')]
+
+        with open(dep, 'r') as dep_file:
+            dep_types = dep_file.read().strip().split(' ')
+
+        for dep_type in dep_types:
+            if dep_type in args.allowed:
+                continue
+            if dep_type in args.warn:
+                print_msg(WARNING_MSG, args, dep_name, dep_type)
+            else:
+                print_msg(ERROR_MSG, args, dep_name, dep_type)
+                failed = True
+
+    if failed:
+        sys.exit(1)
+
+if __name__ == '__main__':
+    main()
diff --git a/tools/checkowners.py b/tools/checkowners.py
new file mode 100755
index 0000000..8f450e7
--- /dev/null
+++ b/tools/checkowners.py
@@ -0,0 +1,76 @@
+#!/usr/bin/python
+
+"""Parse and check syntax errors of a given OWNERS file."""
+
+import argparse
+import re
+import sys
+import urllib2
+
+parser = argparse.ArgumentParser(description='Check OWNERS file syntax')
+parser.add_argument('-v', '--verbose', dest='verbose',
+                    action='store_true', default=False,
+                    help='Verbose output to debug')
+parser.add_argument('-c', '--check_address', dest='check_address',
+                    action='store_true', default=False,
+                    help='Check email addresses')
+parser.add_argument(dest='owners', metavar='OWNERS', nargs='+',
+                    help='Path to OWNERS file')
+args = parser.parse_args()
+
+gerrit_server = 'https://android-review.googlesource.com'
+checked_addresses = {}
+
+
+def echo(msg):
+  if args.verbose:
+    print msg
+
+
+def find_address(address):
+  if address not in checked_addresses:
+    request = gerrit_server + '/accounts/?suggest&q=' + address
+    echo('Checking email address: ' + address)
+    result = urllib2.urlopen(request).read()
+    expected = '"email": "' + address + '"'
+    checked_addresses[address] = (result.find(expected) >= 0)
+  return checked_addresses[address]
+
+
+def main():
+  # One regular expression to check all valid lines.
+  noparent = 'set +noparent'
+  email = '([^@ ]+@[^ @]+|\\*)'
+  directive = '(%s|%s)' % (email, noparent)
+  glob = '[a-zA-Z0-9_\\.\\-\\*\\?]+'
+  perfile = 'per-file +' + glob + ' *= *' + directive
+  pats = '(|%s|%s|%s)$' % (noparent, email, perfile)
+  patterns = re.compile(pats)
+
+  # One pattern to capture email address.
+  email_address = '.*(@| |=|^)([^@ =]+@[^ @]+)'
+  address_pattern = re.compile(email_address)
+
+  error = 0
+  for fname in args.owners:
+    echo('Checking file: ' + fname)
+    num = 0
+    for line in open(fname, 'r'):
+      num += 1
+      stripped_line = re.sub('#.*$', '', line).strip()
+      if not patterns.match(stripped_line):
+        error = 1
+        print('%s:%d: ERROR: unknown line [%s]'
+              % (fname, num, line.strip()))
+      elif args.check_address and address_pattern.match(stripped_line):
+        address = address_pattern.match(stripped_line).group(2)
+        if find_address(address):
+          echo('Found email address: ' + address)
+        else:
+          error = 1
+          print('%s:%d: ERROR: unknown email address: %s'
+                % (fname, num, address))
+  sys.exit(error)
+
+if __name__ == '__main__':
+  main()
diff --git a/tools/diff_package_overlays.py b/tools/diff_package_overlays.py
deleted file mode 100755
index 0e2c773..0000000
--- a/tools/diff_package_overlays.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2012 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.
-
-"""
-Prints to stdout the package names that have overlay changes between
-current_overlays.txt and previous_overlays.txt.
-
-Usage: diff_package_overlays.py <current_packages.txt> <current_overlays.txt> <previous_overlays.txt>
-current_packages.txt contains all package names separated by space in the current build.
-This script modfies current_packages.txt if necessary: if there is a package in
-previous_overlays.txt but absent from current_packages.txt, we copy that line
-from previous_overlays.txt over to current_packages.txt. Usually that means we
-just don't care that package in the current build (for example we are switching
-from a full build to a partial build with mm/mmm), and we should carry on the
-previous overlay config so current_overlays.txt always reflects the current
-status of the entire tree.
-
-Format of current_overlays.txt and previous_overlays.txt:
-  <package_name> <resource_overlay> [resource_overlay ...]
-  <package_name> <resource_overlay> [resource_overlay ...]
-  ...
-"""
-
-import sys
-
-def main(argv):
-  if len(argv) != 4:
-    print >> sys.stderr, __doc__
-    sys.exit(1)
-
-  f = open(argv[1])
-  all_packages = set(f.read().split())
-  f.close()
-
-  def load_overlay_config(filename):
-    f = open(filename)
-    result = {}
-    for line in f:
-      line = line.strip()
-      if not line or line.startswith("#"):
-        continue
-      words = line.split()
-      result[words[0]] = " ".join(words[1:])
-    f.close()
-    return result
-
-  current_overlays = load_overlay_config(argv[2])
-  previous_overlays = load_overlay_config(argv[3])
-
-  result = []
-  carryon = []
-  for p in current_overlays:
-    if p not in previous_overlays:
-      result.append(p)
-    elif current_overlays[p] != previous_overlays[p]:
-      result.append(p)
-  for p in previous_overlays:
-    if p not in current_overlays:
-      if p in all_packages:
-        # overlay changed
-        result.append(p)
-      else:
-        # we don't build p in the current build.
-        carryon.append(p)
-
-  # Add carryon to the current overlay config file.
-  if carryon:
-    f = open(argv[2], "a")
-    for p in carryon:
-      f.write(p + " " + previous_overlays[p] + "\n")
-    f.close()
-
-  # Print out the package names that have overlay change.
-  for r in result:
-    print r
-
-if __name__ == "__main__":
-  main(sys.argv)
diff --git a/tools/droiddoc/README b/tools/droiddoc/README
new file mode 100644
index 0000000..ef28e63
--- /dev/null
+++ b/tools/droiddoc/README
@@ -0,0 +1,5 @@
+If you're looking for the templates-sdk/ files, they've moved
+to external/doclava/res/assets/.
+
+The remaining template files here should also be eventually removed
+so that we can unify the structure and style of all DocLava builds.
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/assets/css/default.css b/tools/droiddoc/templates-sac/assets/css/default.css
index 9b1fe5a..4eafa25 100644
--- a/tools/droiddoc/templates-sac/assets/css/default.css
+++ b/tools/droiddoc/templates-sac/assets/css/default.css
@@ -122,6 +122,10 @@
   padding-right:16px;
 }
 
+.nowrap {
+  white-space: nowrap;
+}
+
 img {
   border: none; }
 #jd-content img {
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/assets/GPL-LICENSE.txt b/tools/droiddoc/templates-sdk/assets/GPL-LICENSE.txt
deleted file mode 100644
index 66a0f18..0000000
--- a/tools/droiddoc/templates-sdk/assets/GPL-LICENSE.txt
+++ /dev/null
@@ -1,278 +0,0 @@
-       GNU GENERAL PUBLIC LICENSE
-           Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-          Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-        GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-          NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/LICENSE.txt b/tools/droiddoc/templates-sdk/assets/LICENSE.txt
deleted file mode 100644
index e84328b..0000000
--- a/tools/droiddoc/templates-sdk/assets/LICENSE.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2011 John Resig, http://jquery.com/
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/android-developer-docs.css b/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
deleted file mode 100644
index cd610f7..0000000
--- a/tools/droiddoc/templates-sdk/assets/android-developer-docs.css
+++ /dev/null
@@ -1,2768 +0,0 @@
-/* file: android-developer-core.css
-   author: smain
-   date: september 2008
-   info: core developer styles (developer.android.com)
-   Required by jdiff
-*/
-
-
-/* RESET STYLES */
-
-html,body,div,h1,h2,h3,h4,h5,h6,p,img,
-dl,dt,dd,ol,ul,li,table,caption,tbody,
-tfoot,thead,tr,th,td,form,fieldset,
-embed,object,applet {
-  margin: 0;
-  padding: 0;
-  border: 0;
-}
-
-/* BASICS */
-
-html, body {
-  overflow:hidden; /* keeps scrollbar off IE */
-  background-color:#fff;
-}
-
-body {
-  font-family:arial,sans-serif;
-  color:#000;
-  font-size:13px;
-  color:#333;
-  background-image:url(images/bg_fade.jpg);
-  background-repeat:repeat-x;
-}
-
-a, a code {
-  color:#006699;
-}
-
-a:active,
-a:active code {
-  color:#f00;
-} 
-
-a:visited,
-a:visited code {
-  color:#006699;
-}
-
-input, select,
-textarea, option, label {
-  font-family:inherit;
-  font-size:inherit;
-  padding:0;
-  margin:0;
-  vertical-align:middle;
-}
-
-option {
-  padding:0 4px;
-}
-
-p, form {
-  padding:0;
-  margin:0 0 1em;
-}
-
-code, pre {
-  color:#007000;
-  font-family:monospace;
-  line-height:1em;
-}
-
-var {
-  color:#007000;
-  font-style:italic;
-}
-
-pre {
-  border:1px solid #ccc;
-  background-color:#fafafa;
-  padding:10px;
-  margin:0 0 1em 1em;
-  overflow:auto;
-  line-height:inherit; /* fixes vertical scrolling in webkit */
-}
-
-h1,h2,h3,h4,h5 {
-  margin:1em 0;
-  padding:0;
-}
-
-p,ul,ol,dl,dd,dt,li {
-  line-height:1.3em;
-}
-
-ul,ol {
-  margin:0 0 .8em;
-  padding:0 0 0 2em;
-}
-
-li {
-  padding:0 0 .5em;
-}
-
-dl {
-  margin:0 0 1em 0;
-  padding:0;
-}
-
-dt {
-  margin:0;
-  padding:0;
-}
-
-dd {
-  margin:0 0 1em;
-  padding:0 0 0 2em;
-}
-
-li p {
-  margin:.5em 0 0;
-}
-
-dd p {
-  margin:1em 0 0;
-}
-
-li pre, li table, li img {
-  margin:.5em 0 0 1em;
-}
-
-dd pre,
-#jd-content dd table,
-#jd-content dd img {
-  margin:1em 0 0 1em;
-}
-
-li ul,
-li ol,
-dd ul,
-dd ol {
-  margin:0;
-  padding: 0 0 0 2em;
-}
-
-li li,
-dd li {
-  margin:0;
-  padding:.5em 0 0;
-}
-
-dl dl,
-ol dl,
-ul dl {
-  margin:0 0 1em;
-  padding:0;
-}
-
-table {
-  font-size:1em;
-  margin:0 0 1em;
-  padding:0;
-  border-collapse:collapse;
-  border-width:0;
-  empty-cells:show;
-}
-
-td,th {
-  border:1px solid #ccc;
-  padding:6px 12px;
-  text-align:left;
-  vertical-align:top;
-  background-color:inherit;
-}
-
-th {
-  background-color:#dee8f1;
-}
-
-td > p:last-child {
-  margin:0;
-}
-
-hr.blue {
-  background-color:#DDF0F2;
-  border:none;
-  height:5px;
-  margin:20px 0 10px;
-}
-
-blockquote {
-  margin: 0 0 1em 1em;
-  padding: 0 4em 0 1em;
-  border-left:2px solid #eee;
-}
-/* LAYOUT */
-
-#body-content {
-  /* "Preliminary" watermark for preview releases and interim builds.
-  background:transparent url(images/preliminary.png) repeat scroll 0 0; */
-  margin:0;
-  position:relative;
-  width:100%;
-}
-
-#header {
-  height: 114px;
-  position:relative;
-  z-index:100;
-  min-width:675px; /* min width for the tabs, before they wrap */
-  padding:0 10px;
-  border-bottom:3px solid #94b922;
-}
-
-#headerLeft{
-  padding: 25px 0 0;
-}
-
-#headerLeft img{
-  height:50px;
-  width:180px;
-}
-
-#headerRight {
-  position:absolute;
-  right:0;
-  top:0;
-  text-align:right;
-}
-
-/* Tabs in the header */
-
-#header ul {
-  list-style: none;
-  margin: 7px 0 0;
-  padding: 0;
-  height: 29px;
-}
-
-#header li {
-  float: left;
-  margin: 0px 2px 0px 0px;
-  padding:0;
-}
-
-#header li a {
-  text-decoration: none;
-  display: block;
-  background-image: url(images/bg_images_sprite.png);
-  background-position: 0 -58px;
-  background-repeat: no-repeat;
-  color: #666;
-  font-size: 13px;
-  font-weight: bold;
-  width: 94px;
-  height: 29px;
-  text-align: center;
-  margin: 0px;
-}
-
-#header li a:hover {
-  background-image: url(images/bg_images_sprite.png);
-  background-position: 0 -29px;
-  background-repeat: no-repeat;
-}
-
-#header li a span {
-  position:relative;
-  top:7px;
-}
-
-#header li a span+span {
-  display:none;
-}
-
-/* tab highlighting */
-
-.home #home-link a,
-.guide #guide-link a,
-.reference #reference-link a,
-.sdk #sdk-link a,
-.resources #resources-link a,
-.videos #videos-link a {
-  background-image: url(images/bg_images_sprite.png);
-  background-position: 0 0;
-  background-repeat: no-repeat;
-  color: #fff;
-  font-weight: bold;
-  cursor:default;
-}
-
-.home #home-link a:hover,
-.guide #guide-link a:hover,
-.reference #reference-link a:hover,
-.sdk #sdk-link a:hover,
-.resources #resources-link a:hover,
-.videos #videos-link  a:hover {
-  background-image: url(images/bg_images_sprite.png);
-  background-position: 0 0;
-}
-
-#headerLinks {
-  margin:10px 10px 0 0;
-  height:13px;
-  font-size: 11px;
-  vertical-align: top;
-}
-
-#headerLinks a {
-  color: #7FA9B5;
-}
-
-#headerLinks img {
-  vertical-align:middle;
-}
-
-#language {
-  margin:0 10px 0 4px;
-}
-
-#search {
-  height:45px;
-  margin:15px 10px 0 0;
-}
-
-/* MAIN BODY */
-
-#mainBodyFluid {
-  margin: 20px 10px;
-  color:#333;
-}
-
-#mainBodyFixed {
-  margin: 20px 10px;
-  color: #333;
-  width:930px;
-  position:relative;
-}
-
-#mainBodyFixed h3,
-#mainBodyFluid h3 {
-  color:#336666;
-  font-size:1.25em;
-  margin: 0em 0em 0em 0em;
-  padding-bottom:.5em;
-}
-
-#mainBodyFixed h2,
-#mainBodyFluid h2 {
-  color:#336666;
-  font-size:1.25em;
-  margin: 0;
-  padding-bottom:.5em;
-}
-
-#mainBodyFixed h1,
-#mainBodyFluid h1 {
-  color:#435A6E;
-  font-size:1.7em;
-  margin: 1em 0;
-}
-
-#mainBodyFixed .green,
-#mainBodyFluid .green,
-#jd-content .green {
-  color:#7BB026;
-  background-color:none;
-}
-
-#mainBodyLeft {
-  float: left;
-  width: 600px;
-  margin-right: 20px;
-  color: #333;
-  position:relative;
-}
-
-div.indent {
-  margin-left: 40px;
-  margin-right: 70px;
-}
-
-#mainBodyLeft p {
-  color: #333;
-  font-size: 13px;
-}
-
-#mainBodyLeft p.blue {
-  color: #669999;
-}
-
-#mainBodyLeft #communityDiv {
-  float: left;
-  background-image:url(images/bg_community_leftDiv.jpg);
-  background-repeat: no-repeat;
-  width: 581px;
-  height: 347px;
-  padding: 20px 0px 0px 20px;
-}
-
-#mainBodyRight {
-  float: left;
-  width: 300px;
-  color: #333;
-}
-
-#mainBodyRight p {
-  padding-right: 50px;
-  color: #333;
-}
-
-#mainBodyRight table {
-  width: 100%;
-}
-
-#mainBodyRight td {
-  border:0px solid #666;
-  padding:0px 5px;
-  text-align:left;
-}
-
-#mainBodyRight td p {
-  margin:0 0 1em 0;
-}
-
-#mainBodyRight .blueBorderBox {
-  border:5px solid #ddf0f2;
-  padding:18px 18px 18px 18px;
-  text-align:left;
-}
-
-#mainBodyFixed .seperator {
-  background-image:url(images/hr_gray_side.jpg);
-  background-repeat:no-repeat;
-  width: 100%;
-  float: left;
-  clear: both;
-}
-
-#mainBodyBottom {
-  float: left;
-  width: 100%;
-  clear:both;
-  color: #333;
-}
-
-#mainBodyBottom .seperator {
-  background-image:url(images/hr_gray_main.jpg);
-  background-repeat:no-repeat;
-  width: 100%;
-  float: left;
-  clear: both;
-}
-
-/* FOOTER */
-
-#footer {
-  float: left;
-  width:90%;
-  margin: 20px;
-  color: #aaa;
-  font-size: 11px;
-}
-
-#footer a {
-  color: #aaa;
-  font-size: 11px;
-}
-
-#footer a:hover {
-  text-decoration: underline;
-  color:#aaa;
-}
-
-#footerlinks {
-  margin-top:2px;
-}
-
-#footerlinks a,
-#footerlinks a:visited {
-  color:#006699;
-}
-
-/* SEARCH FILTER */
-
-#search_autocomplete {
-  color:#aaa;
-}
-
-#search-button {
-  display:inline;
-}
-
-#search_filtered_div {
-  position:absolute;
-  margin-top:-1px;
-  z-index:101;
-  border:1px solid #BCCDF0;
-  background-color:#fff;
-}
-
-#search_filtered {
-  min-width:100%;
-}
-#search_filtered td{
-  background-color:#fff;
-  border-bottom: 1px solid #669999;
-  line-height:1.5em;
-}
-
-#search_filtered .jd-selected {
-  background-color: #94b922;
-  cursor:pointer;
-}
-#search_filtered .jd-selected,
-#search_filtered .jd-selected a {
-  color:#fff;
-}
-
-.no-display {
-  display: none;
-}
-
-.jd-autocomplete {
-  font-family: Arial, sans-serif;
-  padding-left: 6px;
-  padding-right: 6px;
-  padding-top: 1px;
-  padding-bottom: 1px;
-  font-size: 0.81em;
-  border: none;
-  margin: 0;
-  line-height: 1.05em;
-}
-
-.show-row {
-  display: table-row;
-}
-.hide-row {
-  display: hidden;
-}
-
-/* SEARCH */
-
-/* restrict global search form width */
-#searchForm {
-  width:350px;
-}
-
-#searchTxt {
-  width:200px;
-}
-
-/* disable twiddle and size selectors for left column */
-#leftSearchControl div {
-  width: 100%;
-}
-
-#leftSearchControl .gsc-twiddle {
-  background-image : none;
-}
-
-#leftSearchControl td, #searchForm td {
-  border: 0px solid #000;
-}
-
-#leftSearchControl .gsc-resultsHeader .gsc-title {
-  padding-left : 0px;
-  font-weight : bold;
-  font-size : 13px;
-  color:#006699;
-  display : none;
-}
-
-#leftSearchControl .gsc-resultsHeader div.gsc-results-selector {
-  display : none;
-}
-
-#leftSearchControl .gsc-resultsRoot {
-  padding-top : 6px;
-}
-
-#leftSearchControl div.gs-visibleUrl-long {
-  display : block;
-  color:#006699;
-}
-
-.gsc-webResult div.gs-visibleUrl-short,
-table.gsc-branding,
-.gsc-clear-button {
-  display : none;
-}
-
-.gsc-cursor-box .gsc-cursor div.gsc-cursor-page,
-.gsc-cursor-box .gsc-trailing-more-results a.gsc-trailing-more-results,
-#leftSearchControl a,
-#leftSearchControl a b {
-  color:#006699;
-}
-
-.gsc-resultsHeader {
-  display: none;
-}
-
-/* Disable built in search forms */
-.gsc-control form.gsc-search-box {
-  display : none;
-}
-table.gsc-search-box {
-  margin:6px 0 0 0;
-  border-collapse:collapse;
-}
-
-td.gsc-input {
-  padding:0 2px;
-  width:100%;
-  vertical-align:middle;
-}
-
-input.gsc-input {
-  border:1px solid #BCCDF0;
-  width:99%;
-  padding-left:2px;
-  font-size:.95em;
-}
-
-td.gsc-search-button {
-  text-align: right;
-  padding:0;
-  vertical-align:top;
-}
-
-#search-button {
-  margin:0 0 0 2px;
-  font-size:11px;
-}
-
-/* search result tabs */
-
-#doc-content .gsc-control {
-  position:relative;
-}
-
-#doc-content .gsc-tabsArea {
-  position:relative;
-  white-space:nowrap;
-}
-
-#doc-content .gsc-tabHeader {
-  padding: 3px 6px;
-  position:relative;
-  width:auto;
-}
-
-#doc-content .gsc-tabHeader.gsc-tabhActive {
-  border-top: 2px solid #94B922;
-}
-
-#doc-content h2#searchTitle {
-  padding:0;
-}
-
-#doc-content .gsc-resultsbox-visible {
-  padding:1em 0 0 6px;
-}
-
-/* CAROUSEL */
-
-#homeMiddle {
-  padding: 0px 0px 0px 0px;
-  float: left;
-  width: 584px;
-  height: 627px;
-  position:relative;
-}
-
-#topAnnouncement {
-  background:url(images/home/bg_home_announcement.png) no-repeat 0 0;
-}
-  
-#homeTitle {
-  padding:15px 15px 0;
-  height:30px;
-}
-
-#homeTitle h2 {
-  padding:0;
-}
-
-#announcement-block {
-  padding:0 15px 0;
-  overflow:hidden;
-  background: url(images/hr_gray_side.jpg) no-repeat 15px 0;
-  zoom:1;
-}
-
-#announcement-block>* {
-  padding:15px 0 0;
-}
-
-#announcement-block img {
-  float:left;
-  margin:0 30px 0 0;
-}
-
-#announcement {
-  float:left;
-  margin:0;
-}
-
-#carousel {
-  background:url(images/home/bg_home_carousel.png) no-repeat 0 0;
-  position:relative;
-  height:400px;
-}
-
-#carouselMain {
-  background: url(images/home/bg_home_carousel_board.png) 0 0 no-repeat;
-  height:auto;
-  padding: 25px 21px 0;
-  overflow:hidden;
-  position:relative;
-  zoom:1; /*IE6*/
-}
-
-#carouselMain img {
-  margin:0;
-}
-
-#carouselMain .bulletinDesc h3 {
-  margin:0;
-  padding:0;
-}
-
-#carouselMain .bulletinDesc p {
-  margin:0;
-  padding:0.7em 0 0;
-}
-
-#carouselWheel {
-  background: url(images/home/bg_home_carousel_wheel.png) 0 0 no-repeat;
-  padding-top:40px;
-  height:150px;
-}
-
-.clearer { clear:both; }
-
-a#arrow-left, a#arrow-right {
-  float:left;
-  width:42px;
-  height:42px;
-  background-image:url(images/home/carousel_buttons_sprite.png);
-  background-repeat:no-repeat;
-}
-a#arrow-left {
-  margin:35px 3px 0 10px;
-}
-a#arrow-right {
-  margin:35px 10px 0 0;
-}
-a.arrow-left-off,
-a#arrow-left.arrow-left-off:hover {
-  background-position:0 0;
-}
-a.arrow-right-off,
-a#arrow-right.arrow-right-off:hover {
-  background-position:-42px 0;
-}
-a#arrow-left:hover {
-  background-position:0 -42px;
-}
-a#arrow-right:hover {
-  background-position:-42px -42px;
-}
-a.arrow-left-on {
-  background-position:0 0;
-}
-a.arrow-right-on {
-  background-position:-42px 0;
-}
-a.arrow-right-off,
-a.arrow-left-off {
-  cursor:default;
-}
-
-.app-list-container {
-  margin:0 20px;
-  position:relative;
-  width:100%;
-}
-
-div#list-clip {
-  height:110px;
-  width:438px;
-  overflow:hidden;
-  position:relative;
-  float:left;
-}
-
-div#app-list {
-  left:0;
-  z-index:1;
-  position:absolute;
-  margin:11px 0 0;
-  _margin-top:13px;
-  width:1000%;
-}
-
-#app-list a {
-  display:block;
-  float:left;
-  height:90px;
-  width:90px;
-  margin:0 24px 0;
-  padding:3px;
-  background:#99cccc;
-  -webkit-border-radius:7px;
-  -moz-border-radius:7px;
-  border-radius:7px;
-  text-decoration:none;
-  text-align:center;
-  font-size:11px;
-  line-height:11px;
-}
-
-#app-list a span {
-  position:relative;
-  top:-4px;
-}
-
-#app-list img {
-  width:90px;
-  height:70px;
-  margin:0;
-}
-
-#app-list a.selected,
-#app-list a:active.selected,
-#app-list a:hover.selected {
-  background:#A4C639;
-  color:#fff;
-  cursor:default;
-  text-decoration:none;
-}
-
-#app-list a:hover,
-#app-list a:active {
-  background:#ff9900;
-}
-
-#app-list a:hover span,
-#app-list a:active span {
-  text-decoration:underline;
-}
-
-#droid-name {
-  padding-top:.5em;
-  color:#666;
-  padding-bottom:.25em;
-}
-
-/*IE6*/
-* html #app-list a { zoom: 1; margin:0 24px 0 15px;}
-
-* html #list-clip {
-  width:430px !important;
-}
-
-/*carousel bulletin layouts*/
-/*460px width*/
-/*185px height*/
-.img-left {
-  float:left;
-  width:230px;
-  overflow:hidden;
-  padding:8px 0 8px 8px;
-}
-.desc-right {
-  float:left;
-  width:270px;
-  padding:10px;
-}
-.img-right {
-  float:right;
-  width:220px;
-  overflow:hidden;
-  padding:8px 8px 8px 0;
-}
-.desc-left {
-  float:right;
-  width:280px;
-  padding:10px;
-  text-align:right;
-}
-.img-top {
-  padding:20px 20px 0;
-}
-.desc-bottom {
-  padding:10px;
-}
-
-
-/* VIDEO PAGE */
-
-#mainBodyLeft.videoPlayer {
-  width:570px;
-}
-
-#mainBodyRight.videoPlayer {
-  width:330px;
-}
-
-/* player */
-
-#videoPlayerBox {
-  background-color: #DAF3FC;
-  border-radius:7px;
-  -moz-border-radius:7px;
-  -webkit-border-radius:7px;
-  width:530px;
-  padding:20px;
-  border:1px solid #d3ecf5;
-  box-shadow:2px 3px 1px #eee;
-  -moz-box-shadow:2px 3px 1px #eee;
-  -webkit-box-shadow:2px 3px 1px #eee;
-}
-
-#videoBorder {
-  background-color: #FFF;
-  min-height:399px;
-  height:auto !important;
-  border:1px solid #ccdada;
-  border-radius:7px 7px 0 0;
-  -moz-border-radius:7px 7px 0 0;
-  -webkit-border-top-left-radius:7px;
-  -webkit-border-top-right-radius:7px;
-}
-
-#videoPlayerTitle {
-  width:500px;
-  padding:15px 15px 0;
-}
-
-#videoPlayerTitle h2 {
-  font-weight:bold;
-  font-size:1.2em;
-  color:#336666;
-  margin:0;
-  padding:0;
-}
-
-#objectWrapper {
-  padding:15px 15px;
-  height:334px;
-  width:500px;
-}
-
-/* playlist tabs */
-
-ul#videoTabs {
-  list-style-type:none;
-  padding:0;
-  clear:both;
-  margin:0;
-  padding: 20px 0 0 15px;
-  zoom:1; /* IE7/8, otherwise top-padding is double */
-}
-
-ul#videoTabs li {
-  display:inline;
-  padding:0;
-  margin:0 3px 0 0;
-  line-height:2em;
-}
-
-ul#videoTabs li a {
-  border-radius:7px 7px 0 0;
-  -moz-border-radius:7px 7px 0 0;
-  -webkit-border-top-left-radius:7px;
-  -webkit-border-top-right-radius:7px;
-  background:#95c0d0;
-  color:#fff;
-  text-decoration:none;
-  padding:.45em 1.5em;
-  font-weight:bold;
-}
-
-ul#videoTabs li.selected a {
-  font-weight:bold;
-  text-decoration:none;
-  color:#555;
-  background:#daf3fc;
-  border-bottom:1px solid #daf3fc;
-}
-
-ul#videoTabs li:hover a {
-  background:#85acba;
-}
-
-ul#videoTabs li.selected:hover a {
-  background:#daf3fc;
-}
-
-/* playlists */
-
-#videos {
-  background:#daf3fc;
-  margin-bottom:1.5em;
-  padding:15px;
-  border-radius:5px;
-  -moz-border-radius:5px;
-  -webkit-border-radius:5px;
-  box-shadow:2px 3px 1px #eee;
-  -moz-box-shadow:2px 3px 1px #eee;
-  -webkit-box-shadow:2px 3px 1px #eee;
-}
-
-#videos div {
-  display:none;
-}
-
-#videos div.selected {
-  display:block;
-}
-
-ul.videoPreviews {
-  list-style:none;
-  padding:0;
-  margin:0;
-  zoom:1; /* IE, otherwise, layout doesn't update when showing 'more' */
-}
-
-ul.videoPreviews li {
-  margin:0 0 5px;
-  padding:0;
-  overflow:hidden;
-  position:relative;
-}
-
-#mainBodyFixed ul.videoPreviews h3 {
-  font-size: 12px;
-  margin:0 0 1em 130px;
-  padding:0;
-  font-weight:bold;
-  color:inherit;
-}
-
-ul.videoPreviews a {
-  margin:1px;
-  padding:10px;
-  text-decoration:none;
-  height:90px;
-  display:block;
-  border-radius:5px;
-  -moz-border-radius:5px;
-  -webkit-border-radius:5px;
-  background-color:transparent;
-}
-
-ul.videoPreviews a:hover {
-  background-color:#FFF;
-  border:none; /* IE8, otherwise, bg doesn't work */
-}
-
-ul.videoPreviews a.selected {
-  background-color: #FF9900;
-}
-
-ul.videoPreviews img {
-  float:left;
-  clear:left;
-  margin:0;
-}
-
-ul.videoPreviews h3 {
-  font-size:12px;
-  font-weight:bold;
-  text-decoration:none;
-  margin:0 0 1em 130px;
-  padding:0;
-}
-
-ul.videoPreviews p {
-  font-size: 12px;
-  text-decoration:none;
-  margin:0 0 1.2em 130px;
-}
-
-ul.videoPreviews p.full {
-  display:none;
-}
-
-ul.videoPreviews span.more {
-  padding:0 0 0 12px;
-  background:url(images/arrow_bluelink_down.png) 0 2px no-repeat;
-}
-
-ul.videoPreviews span.less {
-  padding:0 0 0 12px;
-  background:url(images/arrow_bluelink_up.png) 0 2px no-repeat;
-  display:none;
-}
-
-ul.videoPreviews p.toggle {
-  position:absolute;
-  margin:0;
-  margin-top:-23px; /* instead of bottom:23px, because IE won't do it correctly */
-  left:140px;
-}
-
-ul.videoPreviews p.toggle a {
-  height:auto;
-  margin:0;
-  padding:0;
-  zoom:1; /* IE6, otherwise the margin considers the img on redraws */
-}
-
-ul.videoPreviews p.toggle a:hover {
-  text-decoration:underline;
-  background:transparent; /* IE6, otherwise it inherits white */
-}
-
-/* featured videos */
-
-#mainBodyRight h2 {
-  padding:0 0 5px;
-}
-
-#mainBodyRight ul.videoPreviews {
-  margin:10px 0 0;
-}
-
-#mainBodyRight ul.videoPreviews li {
-  font-size:11px;
-  line-height:13px;
-  margin:0 0 5px;
-  padding:0;
-}
-
-#mainBodyRight ul.videoPreviews h3 {
-  padding:0;
-  margin:0;
-  font-size:100%;
-}
-
-#mainBodyRight ul.videoPreviews a {
-  text-decoration:none;
-  height:108px;
-  border:1px solid #FFF;
-}
-
-#mainBodyRight ul.videoPreviews a:hover {
-  border:1px solid #CCDADA;
-}
-
-#mainBodyRight ul.videoPreviews a.selected {
-  border:1px solid #FFF;
-}
-
-#mainBodyRight ul.videoPreviews p {
-  line-height:1.2em;
-  padding:0;
-  margin:4px 0 0 130px;
-}
-
-#mainBodyRight ul.videoPreviews img {
-  margin-top:5px;
-}
-
-/* Pretty printing styles. Used with prettify.js. */
-
-.str { color: #080; }
-.kwd { color: #008; }
-.com { color: #800; }
-.typ { color: #606; }
-.lit { color: #066; }
-.pun { color: #660; }
-.pln { color: #000; }
-dl.tag-list dt code,
-.tag { color: #008; }
-dl.atn-list dt code,
-.atn { color: #828; }
-.atv { color: #080; }
-.dec { color: #606; }
-
-@media print {
-  .str { color: #060; }
-  .kwd { color: #006; font-weight: bold; }
-  .com { color: #600; font-style: italic; }
-  .typ { color: #404; font-weight: bold; }
-  .lit { color: #044; }
-  .pun { color: #440; }
-  .pln { color: #000; }
-  .tag { color: #006; font-weight: bold; }
-  .atn { color: #404; }
-  .atv { color: #060; }
-}
-
-
-#title {
-  border-bottom: 4px solid #ccc;
-  display:none;
-}
-
-#title h1 {
-  color:#336666;
-  margin:0;
-  padding: 5px 10px;
-  font-size: 1em;
-  line-height: 15px;
-}
-
-#title h1 .small{
-  color:#000;
-  margin:0;
-  font-size: 13px;
-  padding:0 0 0 15px;
-}
-
-/* SIDE NAVIGATION */
-
-#side-nav {
-  padding:0 6px 0 0;
-  background-color: #fff;
-  font-size:12px;
-}
-
-#resize-packages-nav {
-/* keeps the resize handle below the h-scroll handle */
-  height:270px;
-  overflow:hidden;
-  max-height:100%;
-}
-
-#packages-nav {
-  height:270px;
-  max-height:inherit;
-  position:relative;
-  overflow:auto;
-}
-
-#classes-nav,
-#devdoc-nav {
-  overflow:auto;
-  position:relative;
-}
-
-#side-nav ul {
-  list-style: none;
-  margin: 0;
-  padding:5px 0;
-}
-
-#side-nav ul ul {
-  margin: .5em 0 0 0;
-  padding: 0;
-}
-
-#side-nav li {
-  padding:0;
-  padding:1px 0 1px 0;
-  zoom:1;
-}
-
-#side-nav li span.heading,
-#side-nav li h2 {
-  display:block;
-  font-size:12px;
-  font-weight: bold;
-  margin:.5em 0 0 0;
-  padding: 3px 0 1px 9px;
-}
-
-#side-nav li a {
-  display: inline-block; /* needed to apply padding to line-wraps */
-  text-decoration:none;
-  padding: 0 0 0 18px;
-  zoom:1;
-}
-
-#side-nav li a span+span {
-  display:none;
-}
-
-#side-nav li a:hover {
-  text-decoration:underline;
-}
-
-#side-nav li a+a {
-  padding: 0;
-}
-/*second level (nested) list*/
-#side-nav li li li a {
-  padding: 0 0 0 28px;
-}
-/*third level (nested) list*/
-#side-nav li li li li a {
-  padding: 0 0 0 38px;
-}
-
-#side-nav .selected {
-  background-color: #435a6e;
-  color: #fff;
-  font-weight:bold;
-}
-
-#side-nav .selected a {
-  color: #fff;
-  text-decoration:none;
-}
-
-#side-nav strong {
-  display:block;
-}
-
-#side-nav .toggle-list .toggle-img {
-  margin:0;
-  padding:0;
-  position:absolute;
-  top:0;
-  left:0;
-  height:16px;
-  width:15px;
-  outline-style:none;
-}
-/* second-level toggle */
-#side-nav .toggle-list .toggle-list .toggle-img {
-  left:10px;
-}
-
-#side-nav .closed .toggle-img,
-#side-nav .open .closed .toggle-img {
-  background:url('images/triangle-closed-small.png') 7px 4px no-repeat;
-}
-#side-nav .open .toggle-img {
-  background:url('images/triangle-opened-small.png') 7px 4px no-repeat;
-}
-
-#side-nav .toggle-list {
-  position:relative;
-}
-
-#side-nav .toggle-list ul {
-  margin:0;
-  display:none;
-}
-
-#side-nav .toggle-list div {
-  display:block;
-}
-
-#index-links .selected {
-  background-color: #fff;
-  color: #000;
-  font-weight:normal;
-  text-decoration:none;
-}
-
-#index-links {
-  padding:7px 0 4px 10px;
-}
-
-/* nav tree */
-
-#nav-tree ul {
-  padding:5px 0 1.5em;
-}
-
-#side-nav #nav-tree ul li a,
-#side-nav #nav-tree ul li span.no-children {
-  padding: 0 0 0 0;
-  margin: 0;
-}
-
-#nav-tree .plus {
-  margin: 0 3px 0 0;
-}
-
-#nav-tree ul ul {
-  list-style: none;
-  margin: 0;
-  padding: 0 0 0 0;
-}
-
-#nav-tree ul li {
-  margin: 0;
-  padding: 0 0 0 0;
-  white-space: nowrap;
-}
-
-#nav-tree .children_ul {
-  margin:0;
-}
-
-#nav-tree a.nolink {
-  color: black;
-  text-decoration: none;
-}
-
-#nav-tree span.label {
-  width: 100%;
-}
-
-#nav-tree {
-  overflow-x: auto;
-  overflow-y: scroll;
-}
-
-#nav-swap {
-  font-size:10px;
-  line-height:10px;
-  margin-left:1em;
-  text-decoration:none;
-  display:block;
-}
-
-#tree-link {
-
-}
-
-/* DOCUMENT BODY */
-
-#doc-content {
-  overflow:auto;
-}
-
-#jd-header {
-  background-color: #E2E2E2;
-  padding: 7px 15px;
-}
-
-#jd-header h1 {
-  margin: 0 0 10px;
-  font-size:1.7em;
-}
-
-#jd-header .crumb {
-  font-size:.9em;
-  line-height:1em;
-  color:#777;
-}
-
-#jd-header .crumb a,
-#jd-header .crumb a:visited {
-  text-decoration:none;
-  color:#777;
-}
-
-#jd-header .crumb a:hover {
-  text-decoration:underline;
-}
-
-#jd-header table {
-  margin:0;
-  padding:0;
-}
-
-#jd-header td {
-  border:none;
-  padding:0;
-  vertical-align:top;
-}
-
-#jd-header.guide-header {
-  background-color:#fff;
-  color:#435a6e;
-  height:50px;
-}
-
-#jd-descr {
-  position:relative;
-}
-
-/* summary tables for reference pages */
-.jd-sumtable {
-  margin: .5em 1em 1em 1em;
-  width:95%; /* consistent table widths; within IE's quirks */
-  font-size:.9em;
-}
-
-.jd-sumtable a {
-  text-decoration:none;
-}
-
-.jd-sumtable a:hover {
-  text-decoration:underline;
-}
-
-/* the link inside a sumtable for "Show All/Hide All" */
-.toggle-all {
-  display:block;
-  float:right;
-  font-weight:normal;
-  font-size:0.9em;
-}
-
-/* adjustments for in/direct subclasses tables */
-.jd-sumtable-subclasses {
-  margin: 1em 0 0 0;
-  max-width:968px;
-}
-
-/* extra space between end of method name and open-paren */
-.sympad {
-  margin-right: 2px;
-}
-
-/* right alignment for the return type in sumtable */
-.jd-sumtable .jd-typecol {
-  text-align:right;
-}
-
-/* adjustments for the expando table-in-table */
-.jd-sumtable-expando {
-  margin:.5em 0;
-  padding:0;
-}
-
-/* a div that holds a short description */
-.jd-descrdiv {
-  padding:3px 1em 0 1em;
-  margin:0;
-  border:0;
-}
-
-/* page-top-right container for reference pages (holds
-links to summary tables) */
-#api-info-block {
-  font-size:.8em;
-  padding:6px 10px;
-  font-weight:normal;
-  float:right;
-  text-align:right;
-  color:#999;
-  max-width:70%;
-}
-
-#api-level-toggle {
-  padding:0 10px;
-  font-size:11px;
-  float:right;
-}
-
-#api-level-toggle label.disabled {
-  color:#999;
-}
-
-div.api-level {
-  font-size:.8em;
-  font-weight:normal;
-  color:#999;
-  float:right;
-  padding:0 7px 0;
-  margin-top:-25px;
-}
-
-#api-info-block div.api-level {
-  font-size:1.3em;
-  font-weight:bold;
-  float:none;
-  color:#444;
-  padding:0;
-  margin:0;
-}
-
-/* Force link colors for IE6 */
-div.api-level a {
-  color:#999;
-}
-#api-info-block div.api-level a:link {
-  color:#444;
-}
-#api-level-toggle a {
-  color:#999;
-}
-
-div#deprecatedSticker {
-  display:none;
-  z-index:99;
-  position:fixed;
-  right:15px;
-  top:114px;
-  margin:0;
-  padding:1em;
-  background:#FFF;
-  border:1px solid #dddd00;
-  box-shadow:-5px 5px 10px #ccc;
-  -moz-box-shadow:-5px 5px 10px #ccc;
-  -webkit-box-shadow:-5px 5px 10px #ccc;
-}
-
-div#naMessage {
-  display:none;
-  width:555px;
-  height:0;
-  margin:0 auto;
-}
-
-div#naMessage div {
-  z-index:99;
-  width:450px;
-  position:fixed;
-  margin:50px 0;
-  padding:4em 4em 3em;
-  background:#FFF;
-  border:1px solid #dddd00;
-  box-shadow:-10px 10px 40px #888;
-  -moz-box-shadow:-10px 10px 40px #888;
-  -webkit-box-shadow:-10px 10px 40px #888;
-}
-/* IE6 can't position fixed */
-* html div#naMessage div { position:absolute; }
-
-div#naMessage strong {
-  font-size:1.1em;
-}
-
-.absent,
-.absent a:link,
-.absent a:visited,
-.absent a:hover,
-.absent * {
-  color:#bbb !important;
-  cursor:default !important;
-  text-decoration:none !important;
-}
-
-#api-level-toggle a,
-.api-level a {
-  color:inherit;
-  text-decoration:none;
-}
-
-#api-level-toggle a:hover,
-.api-level a:hover {
-  color:inherit;
-  text-decoration:underline !important;
-  cursor:pointer !important;
-}
-
-#side-nav li.absent.selected,
-#side-nav li.absent.selected *,
-#side-nav div.label.absent.selected,
-#side-nav div.label.absent.selected * {
-  background-color:#eaeaea !important;
-}
-/* IE6 quirk (won't chain classes, so just keep background blue) */
-* html #side-nav li.selected,
-* html #side-nav li.selected *,
-* html #side-nav div.label.selected,
-* html #side-nav div.label.selected * {
-  background-color: #435a6e !important;
-}
-
-
-.absent h4.jd-details-title,
-.absent h4.jd-details-title * {
-  background-color:#f6f6f6 !important;
-}
-
-.absent img {
-  opacity: .3;
-  filter: alpha(opacity=30);
-  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
-}
-
-
-/* applies to a div containing links to summary tables */
-.sum-details-links {
-  padding:0;
-  font-weight:normal;
-}
-
-.sum-details-links a {
-  text-decoration:none;
-}
-
-.sum-details-links a:hover {
-  text-decoration:underline;
-}
-
-
-/* inheritance table */
-.jd-inheritance-table {
-  border-spacing:0;
-  margin:0;
-  padding:0;
-  font-size:.9em;
-}
-.jd-inheritance-table td {
-  border: none;
-  margin: 0;
-  padding: 0;
-}
-.jd-inheritance-table .jd-inheritance-space {
-  font-weight:bold;
-  width:1em;
-}
-.jd-inheritance-table .jd-inheritance-interface-cell {
-  padding-left: 17px;
-}
-
-#jd-content {
-  padding: 18px 15px;
-}
-
-hr {
-  background-color:#ccc;
-  border-color:#fff;
-  margin:2em 0 1em;
-}
-
-/* DOC CLASSES */
-
-#jd-content h1 {
-/*sdk page*/
-  font-size:1.6em;
-  color:#336666;
-  margin:0 0 .5em;
-}
-
-#jd-content h2 {
-  font-size:1.45em;
-  color:#111;
-  border-top:2px solid #ccc;
-  padding: .5em 0 0;
-  margin: 2em 0 1em 0;
-}
-
-#jd-content h3 {
-  font-size:1.3em;
-  color:#3a3a3a;
-  padding: 0;
-  margin: 1.5em 0 .65em 0;
-}
-
-#jd-content h4 {
-  font-size:1.1em;
-  color:#3a3a3a;
-  padding: 0;
-  margin: 1.25em 0 .65em 0;
-}
-
-#jd-content h5 {
-  font-size:1.0em;
-  color:#3a3a3a;
-  padding: 0;
-  margin: 1em 0 .65em 0;
-}
-
-#jd-content .small-header {
-  font-size:1em;
-  color:#000;
-  font-weight:bold;
-  border:none;
-  padding:0;
-  margin:1em 0 .5em;
-  position:inherit;
-}
-
-#jd-content table {
-  margin: 0 0 1em 1em;
-}
-
-#jd-content img {
-  margin: 0 0 1em 1em;
-}
-
-#jd-content li img,
-#jd-content dd img {
-  margin:.5em 0 .5em 1em;
-}
-
-.nolist {
-  list-style:none;
-  padding:0;
-  margin:0 0 1em 1em;
-}
-
-.nolist li {
-  padding:0 0 2px;
-  margin:0;
-}
-
-h4 .normal {
-  font-size:.9em;
-  font-weight:normal;
-}
-
-.caps {
-  font-variant:small-caps;
-  font-size:1.2em;
-}
-
-dl.tag-list dl.atn-list {
-  padding:0 0 0 2em;
-}
-
-.jd-details {
-/*  border:1px solid #669999;
-  padding:4px; */
-  margin:0 0 1em;
-}
-
-/* API reference: a container for the
-.tagdata blocks that make up the detailed
-description */
-.jd-details-descr {
-  padding:0;
-  margin:.5em .25em;
-}
-
-/* API reference: a block containing
-a detailed description, a params table,
-seealso list, etc */
-.jd-tagdata {
-  margin:.5em 1em;
-}
-
-.jd-tagdata p {
-  margin:0 0 1em 1em;
-}
-
-/* API reference: adjustments to
-the detailed description block */
-.jd-tagdescr {
-  margin:.25em 0 .75em 0;
-  line-height:1em;
-}
-
-.jd-tagdescr p {
-  margin:.5em 0;
-  padding:0;
-
-}
-
-.jd-tagdescr ol,
-.jd-tagdescr ul {
-  margin:0 2.5em;
-  padding:0;
-}
-
-.jd-tagdescr table,
-.jd-tagdescr img {
-  margin:.25em 1em;
-}
-
-.jd-tagdescr li {
-margin:0 0 .25em 0;
-padding:0;
-}
-
-/* API reference: heading marking
-the details section for constants,
-attrs, methods, etc. */
-h4.jd-details-title {
-  font-size:1.15em;
-  background-color: #E2E2E2;
-  margin:1.5em 0 .6em;
-  padding:3px 95px 3px 3px; /* room for api-level */
-}
-
-h4.jd-tagtitle {
-  margin:0;
-}
-
-/* API reference: heading for "Parameters", "See Also", etc.,
-in details sections */
-h5.jd-tagtitle {
-  margin:0 0 .25em 0;
-  font-size:1em;
-}
-
-.jd-tagtable {
-  margin:0;
-}
-
-.jd-tagtable td,
-.jd-tagtable th {
-  border:none;
-  background-color:#fff;
-  vertical-align:top;
-  font-weight:normal;
-  padding:2px 10px;
-}
-
-.jd-tagtable th {
-  font-style:italic;
-}
-
-#jd-content table h2 {
-  background-color: #d6d6d6;
-  font-size: 1.1em;
-  margin:0 0 10px;
-  padding:5px;
-  left:0;
-  width:auto;
-}
-
-div.design-announce {
-  border-top:1px solid #33B5E5;
-  border-bottom:1px solid #33B5E5;
-  padding:5px 10px 10px 55px;
-  margin:2em 0;
-  background:url('images/icon_design.png') 5px 13px no-repeat;
-}
-
-div.design-announce p {
-  margin: .5em 0 0 0;
-}
-
-div.special {
-  padding: .5em 1em 1em 1em;
-  margin: 0 0 1em;
-  background-color: #DAF3FC;
-  border:1px solid #d3ecf5;
-  border-radius:5px;
-  -moz-border-radius:5px;
-  -webkit-border-radius:5px;
-}
-
-div.special p {
-  margin: .5em 0 0 0;
-}
-
-div.special ol {
-  margin: 0;
-}
-
-div.special ol li {
-  margin: 0;
-  padding: 0;
-}
-
-#jd-content div.special h2,
-#jd-content div.special h3 {
-  color:#669999;
-  font-size:1.2em;
-  border:none;
-  margin:0 0 .5em;
-  padding:0;
-}
-
-#jd-content div.special.reference h2,
-#jd-content div.special.reference h3,
-#jd-content div.special.reference h4 {
-  color:#000;
-  font-size:1em;
-  border:none;
-  font-weight:bold;
-  margin:.5em 0;
-  padding:0;
-}
-
-p.note, div.note,
-p.caution, div.caution,
-p.warning, div.warning {
-  margin: 1em;
-  padding: 0 0 0 .5em;
-  border-left: 4px solid;
-}
-
-p.special-note,
-div.special-note {
-  background-color:#EBF3DB;
-  padding:10px 20px;
-  margin:0 0 1em;
-}
-
-p.note,
-div.note {
- border-color: #99aacc;
-}
-
-p.warning,
-div.warning {
-  border-color: #aa0033;
-}
-
-p.caution,
-div.caution {
-  border-color: #ffcf00;
-}
-
-li .note,
-li .caution,
-li .warning {
-  margin: .5em 0 0 0;
-  padding: .2em .5em .2em .9em;
-}
-
-/* Makes sure the first paragraph does not add top-whitespace within the box*/
-li .note>p:first-child,
-li .caution>p:first-child,
-li .warning>p:first-child {
-  margin-top:0;
-  padding-top:0;
-}
-
-dl.xml dt {
-  font-variant:small-caps;
-  font-size:1.2em;
-}
-
-dl.xml dl {
-  padding:0;
-}
-
-dl.xml dl dt {
-  font-variant:normal;
-  font-size:1em;
-}
-
-.listhead li {
-  font-weight: bold;
-}
-
-.listhead li *, /*ie*/.listhead li li {
-  font-weight: normal;
-}
-
-ol.no-style,
-ul.no-style {
-  list-style:none;
-  padding-left:1em;
-}
-
-.new,
-.new-child {
-  font-size: .78em;
-  font-weight: bold;
-  color: #ff3d3d;
-  text-decoration: none;
-  vertical-align:top;
-  line-height:.9em;
-  white-space:nowrap;
-}
-
-.toggle-list.open .new-child {
-  display:none;
-}
-
-pre.classic {
-  background-color:transparent;
-  border:none;
-  padding:0;
-}
-
-p.img-caption {
-  margin: -0.5em 0 1em 1em; /* matches default img left-margin */
-}
-
-div.figure {
-  float:right;
-  clear:right;
-  margin:1em 0 0 0;
-  padding:0 0 0 3em;
-  background-color:#fff;
-  /* width must be defined w/ an inline style matching the image width */
-}
-
-#jd-content
-div.figure img {
-  margin: 0 0 1em;
-}
-
-div.figure p.img-caption {
-  margin: -0.5em 0 1em 0;
-}
-
-p.table-caption {
-  margin: 0 0 0.5em 1em; /* matches default table left-margin */
-}
-
-
-/* toggle for misc content (such as long sample code) 
-   see toggleContent() script in android-developer-docs.js */
-.toggle-content.closed .toggle-content-toggleme {
-  display:none;
-}
-
-.toggle-content a[href="#"] {
-  text-decoration:none;
-  color:inherit;
-}
-
-.toggle-content-toggleme {
-  padding-bottom:1px; /* fixes animation bounce due to margins */
-}
-
-#jd-content .toggle-content img.toggle-content-img {
-  margin:0;
-}
-
-
-/* BEGIN quickview sidebar element styles */
-
-#qv-wrapper {
-  float: right;
-  width:310px; /* +35px padding */
-  background-color:#fff;
-  margin:-48px 0 2px 0;
-  padding:0 0 20px 35px;
-}
-
-#qv {
-  background-color:#fff;
-  border:4px solid #dee8f1;
-  margin:0;
-  padding:0 5px 5px;
-  width:292px; /* +10px padding; +8px border */
-  font-size:.9em;
-}
-
-#qv ol {
-  list-style:none;
-  padding: 0;
-}
-
-#qv ol ol{
-  list-style:none;
-  padding: 0 0 0 12px;
-  margin:0;
-}
-
-#qv ul {
-  padding: 0 10px 0 2em;
-}
-
-#qv li {
-  padding: 0 10px 3px;
-  line-height: 1.2em;
-}
-
-#qv li li {
-  padding: 3px 10px 0;
-}
-
-#qv ul li {
-  padding: 0 10px 0 0;
-}
-
-#qv li.selected a {
-  color:#555;
-  text-decoration:none;
-}
-
-#qv a,
-#qv a code {
-  color:#cc6600;
-}
-
-#qv p {
-  margin:8px 0 0;
-  padding:0 10px;
-}
-
-#jd-content #qv h2 {
-  font-size:1.05em;
-  font-weight:bold;
-  margin:12px 0 .25em 0;
-  padding:0 10px;
-  background-color:transparent;
-  color:#7BB026;
-  border:none;
-  left:0;
-  z-index:1;
-}
-
-#qv-extra #rule {
-  padding: 0 10px;
-  margin: 0;
-}
-
-#qv-sub-rule {
-  padding: 5px 15px 10px;
-  margin: 0;
-}
-
-#jd-content
-#qv-sub-rule h2 {
-  margin: 0 0 .5em 0;
-}
-
-/* END quickview sidebar element styles */
-
-/* Begin sidebox sidebar element styles */
-
-.sidebox-wrapper {
-  float:right;
-  clear:right;
-  width:310px; /* +35px padding */
-  background-color:#fff;
-  margin:0;
-  padding:0 0 20px 35px;
-}
-
-.sidebox {
-  border-left:1px solid #dee8f1;
-  background-color:#ffffee;
-  margin:0;
-  padding:8px 12px;
-  font-size:0.9em;
-  width:285px; /* +24px padding; +1px border */
-}
-
-.sidebox p {
-  margin-bottom: .75em;
-}
-
-.sidebox ul {
-  padding: 0 0 0 1.5em;
-}
-
-.sidebox li ul {
-  margin-top:0;
-  margin-bottom:.1em;
-}
-
-.sidebox li {
-padding:0 0 0 0em;
-}
-
-#jd-content .sidebox h2,
-#jd-content .sidebox h3,
-#jd-content .sidebox h4,
-#jd-content .sidebox h5 {
-  border:none;
-  font-size:1em;
-  margin:0;
-  padding:0 0 8px;
-  left:0;
-  z-index:0;
-}
-
-.sidebox hr {
-  background-color:#ccc;
-  border:none;
-}
-
-/* End sidebox sidebar element styles */
-
-/* BEGIN developer training bar styles */
-
-div#tb-wrapper {
-  float: right;
-  clear:right;
-  width:380px; /* +25px padding = 405 */
-  background-color:#fff;
-  margin:0 0 2px 0;
-  padding:0 0 20px 25px;
-}
-
-div#tb {
-  margin:0;
-  padding:0 15px;
-  width:350px; /* +15px padding = 380 */
-  font-size:.9em;
-  background:#e9e9e9;
-  border:1px solid #aaa;
-  border-radius:5px;
-  -moz-border-radius:5px;
-  -webkit-border-radius:5px;
-  overflow:auto;
-}
-
-div#tb h2 {
-  font-size:1.3em;
-  font-weight:bold;
-  margin:1em 0;
-  padding:0;
-  background-color:transparent;
-  border:none;
-  clear:both;
-}
-
-div.download-box a.button {
-  color: #069;
-  font-size:1.1em;
-  font-weight:bold;
-  text-decoration:none;
-  height:27px;
-  line-height:27px;
-  text-align:center;
-  padding:5px 8px;
-  background-color: #fff;
-  border: 1px solid #aaa;
-  -webkit-border-radius: 2px;
-  -moz-border-radius: 2px;
-  border-radius: 2px;
-}
-
-div.download-box a.button:hover {
-  border-color: #09C;
-  background-color: #4CADCB;
-  background-image: -webkit-gradient(linear,left top,left bottom,from(#5dbcd9),to(#4cadcb));
-  background-image: -webkit-linear-gradient(top,#5dbcd9,#4cadcb);
-  background-image: -moz-linear-gradient(top,#5dbcd9,#4cadcb);
-  background-image: -ms-linear-gradient(top,#5dbcd9,#4cadcb);
-  background-image: -o-linear-gradient(top,#5dbcd9,#4cadcb);
-  background-image: linear-gradient(top,#5dbcd9,#4cadcb);
-  filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#5dbcd9',EndColorStr='#4cadcb');
-  color: #fff;
-}
-
-div.download-box a.button:active {
-  background-color: #1E799A;
-  background-image: none;
-  border-color: #30B7E6;
-}
-
-div.download-box p.filename {
-  font-size:0.85em;
-  color:#888;
-  margin:4px 0 1em 10px;
-}
-
-/* End developer training bar */
-
-/* Training nav bar (previous/next) */
-
-div.training-nav-top {
-  float: right;
-  width:380px; /* +25px padding = 405 */
-  margin:-58px 0 0 0;
-  padding:0 0 20px 25px;
-}
-
-div.training-nav-bottom {
-  padding:1px; /* for weird FF bug (scrollbar appears) */
-  margin:3em 0;
-  overflow:auto;
-}
-
-div.training-nav-button-next a,
-div.training-nav-button-previous a {
-  display:block;
-  width:160px;
-  height:55px;
-  padding:4px 7px;
-  border:1px solid #aaa;
-  border-radius:5px;
-  -moz-border-radius:5px;
-  -webkit-border-radius:5px;
-  text-decoration:none;
-  font-weight:bold;
-}
-
-div.training-nav-button-next a:hover,
-div.training-nav-button-previous a:hover {
-  border:1px solid #069; /* match link color */
-}
-
-div.training-nav-button-next a:active,
-div.training-nav-button-previous a:active {
-  border:1px solid #f00; /* match link color */
-}
-  
-div.training-nav-button-previous {
-  float:left;
-  text-align:left;
-}
-
-div.training-nav-button-next {
-  float:right;
-  text-align:right;
-}
-
-span.training-nav-button-title {
-  display:block;
-  font-size:.85em;
-  font-weight:normal;
-  line-height:1.3em;
-  margin:.5em 0 0;
-}
-
-/* End training nav bar */
-
-/* BEGIN image and caption styles (originally for UI Guidelines docs) */
-
-table.image-caption {
-  padding:0;
-  margin:.5em 0;
-  border:0;
-}
-
-td.image-caption-i {
-  font-size:92%;
-  padding:0 5px;
-  margin:0;
-  border:0;
-}
-
-td.image-caption-i img {
-  padding:0 1em;
-  margin:0;
-}
-
-.image-list {
-  width:24px;
-  text-align:center;
-}
-
-td.image-caption-c {
-  font-size:92%;
-  padding:1em 2px 2px 2px;
-  margin:0;
-  border:0;
-  width:350px;
-}
-
-.grad-rule-top {
-background-image:url(images/grad-rule-qv.png);
-background-repeat:no-repeat;
-padding-top:1em;
-margin-top:0;
-}
-
-.image-caption-nested {
-  margin-top:0;
-  padding:0 0 0 1em;
-}
-
-.image-caption-nested td {
-  padding:0 4px 2px 0;
-  margin:0;
-  border:0;
-}
-
-/* END image and caption styles */
-
-/* table of contents */
-
-ol.toc {
-  margin: 0 0 1em 0;
-  padding: 0;
-  list-style: none;
-  font-size:95%;
-}
-
-ol.toc li {
-  font-weight: bold;
-  margin: 0 0 .5em 1em;
-  padding: 0;
-}
-
-ol.toc li p {
-  font-weight: normal;
-}
-
-ol.toc li ol {
-  margin: 0;
-  padding: 0;
-}
-
-ol.toc li li {
-  padding: 0;
-  margin: 0 0 0 1em;
-  font-weight: normal;
-  list-style: none;
-}
-
-table ol.toc {
-  margin-left: 0;
-}
-
-.columns td {
-  padding:0 5px;
-  border:none;
-}
-
-/* link table */
-.jd-linktable {
-  margin: 0 0 1em;
-  border-bottom: 1px solid #888;
-}
-.jd-linktable th,
-.jd-linktable td {
-  padding: 3px 5px;
-  vertical-align: top;
-  text-align: left;
-  border:none;
-}
-.jd-linktable tr {
-  background-color: #fff;
-}
-.jd-linktable td {
-  border-top: 1px solid #888;
-  background-color: inherit;
-}
-.jd-linktable td  p {
-  padding: 0 0 5px;
-}
-.jd-linktable .jd-linkcol {
-}
-.jd-linktable .jd-descrcol {
-}
-.jd-linktable .jd-typecol {
-  text-align:right;
-}
-.jd-linktable .jd-valcol {
-}
-.jd-linktable .jd-commentrow {
-  border-top:none;
-  padding-left:25px;
-}
-.jd-deprecated-warning {
-  margin-top: 0;
-  margin-bottom: 10px;
-}
-
-tr.alt-color {
-  background-color: #f6f6f6;
-}
-
-/* expando trigger */
-#jd-content .jd-expando-trigger-img {
-  margin:0;
-}
-
-/* jd-expando */
-.jd-inheritedlinks {
-  padding:0 0 0 13px
-}
-
-/* SDK PAGE */
-table.download tr {
-  background-color:#d9d9d9;
-}
-
-table.download tr.alt-color {
-  background-color:#ededed;
-}
-
-table.download td,
-table.download th {
-  border:2px solid #fff;
-  padding:10px 5px;
-}
-
-table.download th {
-  background-color:#6d8293;
-  color:#fff;
-}
-
-/* INLAY 180 COPY and 240PX EXTENSION */
-/* modified to 43px so that all browsers eliminate the package panel h-scroll */
-.g-tpl-240 .g-unit,
-.g-unit .g-tpl-240 .g-unit,
-.g-unit .g-unit .g-tpl-240 .g-unit {
-  display: block;
-  margin: 0 0 0 243px;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-240 .g-first,
-.g-unit .g-tpl-240 .g-first,
-.g-tpl-240 .g-first {
-  display: block;
-  margin: 0;
-  width: 243px;
-  float: left;
-}
-/* 240px alt */
-.g-tpl-240-alt .g-unit,
-.g-unit .g-tpl-240-alt .g-unit,
-.g-unit .g-unit .g-tpl-240-alt .g-unit {
-  display: block;
-  margin: 0 243px 0 0;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-240-alt .g-first,
-.g-unit .g-tpl-240-alt .g-first,
-.g-tpl-240-alt .g-first {
-  display: block;
-  margin: 0;
-  width: 243px;
-  float: right;
-}
-
-/* 200px */
-.g-tpl-200 .g-unit,
-.g-unit .g-tpl-200 .g-unit,
-.g-unit .g-unit .g-tpl-200 .g-unit {
-  display: block;
-  margin: 0 0 0 200px;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-200 .g-first,
-.g-unit .g-tpl-200 .g-first,
-.g-tpl-200 .g-first {
-  display: block;
-  margin: 0;
-  width: 200px;
-  float: left;
-}
-/* 200px alt */
-.g-tpl-200-alt .g-unit,
-.g-unit .g-tpl-200-alt .g-unit,
-.g-unit .g-unit .g-tpl-200-alt .g-unit {
-  display: block;
-  margin: 0 200px 0 0;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-200-alt .g-first,
-.g-unit .g-tpl-200-alt .g-first,
-.g-tpl-200-alt .g-first {
-  display: block;
-  margin: 0;
-  width: 200px;
-  float: right;
-}
-
-/* 190px */
-.g-tpl-190 .g-unit,
-.g-unit .g-tpl-190 .g-unit,
-.g-unit .g-unit .g-tpl-190 .g-unit {
-  display: block;
-  margin: 0 0 0 190px;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-190 .g-first,
-.g-unit .g-tpl-190 .g-first,
-.g-tpl-190 .g-first {
-  display: block;
-  margin: 0;
-  width: 190px;
-  float: left;
-}
-/* 190px alt */
-.g-tpl-190-alt .g-unit,
-.g-unit .g-tpl-190-alt .g-unit,
-.g-unit .g-unit .g-tpl-190-alt .g-unit {
-  display: block;
-  margin: 0 190px 0 0;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-190-alt .g-first,
-.g-unit .g-tpl-190-alt .g-first,
-.g-tpl-190-alt .g-first {
-  display: block;
-  margin: 0;
-  width: 190px;
-  float: right;
-}
-
-/* 180px */
-.g-tpl-180 .g-unit,
-.g-unit .g-tpl-180 .g-unit,
-.g-unit .g-unit .g-tpl-180 .g-unit {
-  display: block;
-  margin: 0 0 0 180px;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-180 .g-first,
-.g-unit .g-tpl-180 .g-first,
-.g-tpl-180 .g-first {
-  display: block;
-  margin: 0;
-  width: 180px;
-  float: left;
-}
-/* 180px alt */
-.g-tpl-180-alt .g-unit,
-.g-unit .g-tpl-180-alt .g-unit,
-.g-unit .g-unit .g-tpl-180-alt .g-unit {
-  display: block;
-  margin: 0 180px 0 0;
-  width: auto;
-  float: none;
-}
-.g-unit .g-unit .g-tpl-180-alt .g-first,
-.g-unit .g-tpl-180-alt .g-first,
-.g-tpl-180-alt .g-first {
-  display: block;
-  margin: 0;
-  width: 180px;
-  float: right;
-}
-
-
-/* JQUERY RESIZABLE STYLES */
-.ui-resizable { position: relative; }
-.ui-resizable-handle { position: absolute; display: none; font-size: 0.1px; z-index:1; }
-.ui-resizable .ui-resizable-handle { display: block; }
-body .ui-resizable-disabled .ui-resizable-handle { display: none; }
-body .ui-resizable-autohide .ui-resizable-handle { display: none; }
-.ui-resizable-s { cursor: s-resize; height: 6px; width: 100%; bottom: 0px; left: 0px;
-  background: transparent url("images/resizable-s2.gif") repeat scroll center top; }
-.ui-resizable-e { cursor: e-resize; width: 6px; right: 0px; top: 0px; height: 100%;
-  background: transparent url("images/resizable-e2.gif") repeat scroll right center; }
-
-@media print {
-
-  body {
-    overflow:visible;
-  }
-
-  #header {
-    height:60px;
-  }
-
-  #headerLeft {
-    padding:0;
-  }
-
-  #header-tabs,
-  #headerRight,
-  #side-nav,
-  #api-info-block {
-    display:none;
-  }
-
-  #body-content {
-    position:inherit;
-  }
-
-  #doc-content {
-    margin-left:0 !important;
-    height:auto !important;
-    width:auto !important;
-    overflow:inherit;
-    display:inline;
-  }
-
-  #jd-header {
-    padding:10px 0;
-  }
-
-  #jd-content {
-    padding:15px 0 0;
-  }
-
-  #footer {
-    float:none;
-    margin:2em 0 0;
-  }
-
-  h4.jd-details-title {
-    border-bottom:1px solid #666;
-  }
-
-  pre {
-    /* these allow lines to break (if there's a white space) */
-    overflow: visible;
-    text-wrap: unrestricted;
-    white-space: -moz-pre-wrap; /* Moz */
-    white-space: -pre-wrap; /* Opera 4-6 */
-    white-space: -o-pre-wrap; /* Opera 7 */
-    white-space: pre-wrap; /* CSS3  */
-    word-wrap: break-word; /* IE 5.5+ */
-  }
-
-  h1, h2, h3, h4, h5, h6 {
-    page-break-after: avoid;
-  }
-
-  table, img {
-    page-break-inside: avoid;
-  }
-}
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
deleted file mode 100644
index 9e5df48..0000000
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ /dev/null
@@ -1,10450 +0,0 @@
-/* color definitions */
-/* 16 column layout */
-/* clearfix idiom */
-/* common mixins */
-/* page layout + top-level styles */
-::selection {
-  background-color: #0099cc;
-  color: #fff; }
-::-webkit-selection {
-  background-color: #0099cc;
-  color: #fff; }
-::-moz-selection {
-  background-color: #0099cc;
-  color: #fff; }
-
-html, body {
-  height: 100%;
-  margin: 0;
-  padding: 0;
-  background-color: #fff;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  /* prevent subpixel antialiasing, which thickens the text */
-  /* text-rendering: optimizeLegibility; */
-  /* turned off ligatures due to bug 5945455 */ }
-
-body {
-  color: #515151;
-  color: rgba(0, 0, 0, .68);
-  font: 14px/24px Roboto, sans-serif;
-  font-weight: 400;
-  letter-spacing:.1;
-  padding: 0 20px;
-}
-
-@media (max-width: 719px) {
-  html {
-    /* Disable accidental horizontal overflow. */
-    overflow-x: hidden;
-  }
-
-  body {
-    padding-left: 10px;
-    padding-right: 10px;
-  }
-}
-
-#page-container {
-  width: 940px;
-  margin: 0 40px; }
-
-#page-header {
-  height: 80px;
-  margin-bottom: 20px;
-  font-size: 48px;
-  line-height: 48px;
-  font-weight: 100;
-  padding-left: 10px; }
-  #page-header a {
-    display: block;
-    position: relative;
-    top: 20px;
-    text-decoration: none;
-    color: #555555 !important; }
-
-#main-row {
-  display: inline-block; }
-  #main-row:after {
-    content: ".";
-    display: block;
-    height: 0;
-    clear: both;
-    visibility: hidden; }
-  * html #main-row {
-    height: 1px; }
-
-#page-footer {
-  margin-left: 190px;
-  margin-top: 80px;
-  color: #999999;
-  padding-bottom: 40px;
-  font-size: 12px;
-  line-height: 15px; }
-  #page-footer a {
-    color: #777777; }
-  #page-footer #copyright {
-    margin-bottom: 10px; }
-
-.hide-text {
-  position: absolute;
-  text-indent: -9999px;
-}
-
-#nav-container {
-  width: 160px;
-  min-height: 10px;
-  margin-right: 20px;
-  float: left; }
-
-#devdoc-nav h2 {
-  border:0;
-}
-
-#devdoc-nav.fixed {
-  position: fixed;
-  margin:0;
-  top: 84px; /* sticky-header height + 20px gutter */
-}
-
-.dac-devdoc-toggle {
-  cursor: pointer;
-  padding: 8px 0;
-}
-
-.scroll-pane {
-  /* Match height of fixed parent. */
-  height: 100%;
-}
-
-#content {
-  width: 760px;
-  float: left; }
-
-
-/***** PREVIOUSLY style.css ******************/
-/* This should be close to the top, so it is easier to override. */
-[dir='rtl'] {
-  direction: rtl;
-}
-html {
-  line-height: 20px;
-}
-pre, table, input, textarea, code {
-  font-size: 1em;
-}
-address, abbr, cite {
-  font-style: normal;
-}
-[dir='rtl'] th {
-  text-align: right;
-}
-html[lang^=ja] blockquote, html[lang^=ja] q, html[lang^=ko] blockquote, html[lang^=ko] q,
-html[lang^=zh] blockquote, html[lang^=zh] q {
-  font-style: normal;
-}
-q {
-  font-style: italic;
-}
-fieldset, iframe, img {
-  border: 0;
-}
-img {
-  border: none;
-  -ms-interpolation-mode: bicubic;
-  max-width: 100%;
-  vertical-align: middle;
-}
-
-video {
-  cursor: pointer;
-  margin-bottom: 10px; /* same as img */
-  max-width: 100%;
-  object-fit: cover;
-}
-
-.video-wrapper {
-  line-height: 0;
-  margin-bottom: 10px; /* same as img */
-  position: relative;
-}
-
-.video-wrapper video {
-  margin:0;
-}
-
-.video-wrapper:before {
-  background: rgba(0, 0, 0, 0.5) url(//material-design.storage.googleapis.com/images/play.svg) no-repeat center center;
-  background-size: 72px 72px;
-  bottom: 0;
-  content: "";
-  left: 0;
-  position: absolute;
-  right: 0;
-  top: 0;
-  transition: opacity .2s;
-}
-
-.video-wrapper:hover:before {
-  opacity: .7;
-}
-
-.video-wrapper.playing:before {
-  opacity: 0;
-}
-
-q {
-  quotes: none;
-}
-sup, sub {
-  font-size: 11px;
-  line-height: 0;
-}
-
-table, fieldset {
-  margin: 0;
-}
-/* Biggest type */
-.display-1 {
-  font-size: 56px;
-  line-height: 68px;
-}
-@media (max-width: 719px) {
-  .display-1 {
-    font-size: 44px;
-    line-height: 56px;
-  }
-}
-h1, h2, h3 {
-  color: #212121;
-  color: rgba(0, 0, 0, .87);
-}
-h1 {
-  font-size: 44px;
-  line-height: 56px;
-  font-weight: 300;
-  margin: 0;
-  padding: 24px 0 12px;
-}
-h1.short {
-  padding-right:320px;
-}
-@media (max-width: 719px) {
-  h1 {
-    font-size: 36px;
-    line-height: 48px;
-  }
-}
-h2 {
-  clear: left;
-  font-size: 28px;
-  font-weight: 400;
-  line-height: 32px;
-  margin: 0;
-  padding: 12px 0 16px;
-}
-h3 {
-  font-size: 24px;
-  line-height: 32px;
-  font-weight: 400;
-  margin: 0;
-  padding: 8px 0 12px;
-}
-h4 {
-  font-size: 18px;
-  line-height: 24px;
-  margin: 0;
-  padding: 4px 0 8px;
-  font-weight: 500;
-}
-h5, h6 {
-  font-size: 16px;
-  line-height: 24px;
-  margin: 0;
-  padding: 4px 0 8px;
-}
-th>h3 {
-  font-size:inherit;
-  line-height:inherit;
-  font-weight:inherit;
-  margin:0;
-  padding:0;
-  color:inherit;
-}
-hr { /* applied to the bottom of h2 elements */
-  height: 1px;
-  margin: 7px 0 12px;
-  border: 0;
-  background: rgba(0, 0, 0, 0.1);
-}
-h2[id], h3[id], h4[id], h5[id], h6[id] {
-  margin-top: -64px;
-  border-top: 64px solid transparent;
-  -webkit-background-clip: padding-box;
-  -moz-background-clip: padding;
-  background-clip: padding-box;
-}
-p, pre, table, form {
-  margin: 0 0 12px;
-}
-small {
-  font-size: 11.5px;
-  color: #000;
-}
-ul, ol {
-  margin: 0 0 15px 20px;
-  padding: 0;
-}
-[dir='rtl'] ul, [dir='rtl'] ol {
-  margin: 10px 30px 10px 10px;
-}
-ul ul, ul ol, ol ul, ol ol {
-  margin-bottom: 0;
-  margin-top: 0;
-}
-li {
-  margin: 0 0 12px;
-}
-dt {
-  margin: 24px 0 12px;
-}
-dd {
-  margin:0 0 10px 40px;
-}
-dd p,
-dd pre,
-dd ul,
-dd ol,
-dd dl {
-  margin-top:10px;
-}
-li p,
-li pre,
-li ul,
-li ol,
-li dl,
-#body-content li img {
-  margin-top: 6px;
-  margin-bottom: 6px;
-}
-dl dd dl:first-child {
-  margin-top: 0;
-}
-pre strong, pre b, a strong, a b, a code {
-  color: inherit;
-}
-pre, code {
-  color: #060;
-  font: 13px/18px Consolas, "Liberation Mono", Menlo, Monaco, Courier, monospace;
-  -webkit-font-smoothing: subpixel-antialiased;
-  -moz-osx-font-smoothing: auto;
-}
-legend {
-  display: none;
-}
-a, .link-color {
-  color: #039BE5;
-  text-decoration: none;
-}
-a:focus, a:hover {
-  color: rgba(3, 155, 229, .7);
-  text-decoration: none;
-}
-a.white {
-  color: #fff;
-  text-decoration:underline;
-}
-a.white:hover, a.white:active {
-  color: #ccc;
-}
-strong, b {
-  font-weight: bold;
-}
-table {
-  border-collapse: collapse;
-  border-spacing: 0;
-  border:0;
-  margin: .5em 1em 1em 0;
-  width:100%; /* consistent table widths; within IE's quirks */
-  background-color:#f7f7f7;
-}
-th, td {
-  padding: 4px 12px;
-  vertical-align: top;
-  text-align: left;
-}
-td {
-  background-color:inherit;
-  border:solid 1px #DDD;
-}
-td *:last-child {
-  margin-bottom:0;
-}
-th {
-  background-color: #999;
-  color: #fff;
-  border:solid 1px #DDD;
-  font-weight: normal;
-}
-tr.alt th {
-  color:inherit;
-  background-color: #e0e0e0;
-}
-tr:first-of-type th:first-of-type:empty {
-  visibility: hidden;
-}
-
-a.external-link {
-  background:url('../images/styles/open_new_page.png') no-repeat 100% 50%;
-  padding-right:16px;
-}
-
-#body-content img {
-  margin-bottom:12px;
-}
-
-#body-content p>img {
-  margin-bottom:0;
-}
-
-#body-content img.inline-icon {
-  vertical-align:sub;
-  margin:0;
-  height:16px;
-}
-
-em {
-  font-style: italic; }
-
-acronym,
-.tooltip-link {
-  border-bottom: 1px dotted #555555;
-  cursor: help; }
-
-acronym:hover,
-.tooltip-link:hover {
-  color: #7aa1b0;
-  border-bottom-color: #7aa1b0; }
-
-img.with-shadow,
-video.with-shadow {
-  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); }
-
-/* disclosures mixin */
-/* content layout */
-/* This grid is deprecated in favor of .cols and .col-X */
-.layout-content-row {
-  display: inline-block;
-  margin-bottom: 10px; }
-  * html .layout-content-row {
-    height: 1px; }
-
-.layout-content-col {
-  float: left;
-  margin-left: 20px; }
-  .layout-content-col:first-child {
-    margin-left: 0; }
-  .layout-content-col h3,
-  .layout-content-col h4 {
-    padding-top:0; }
-
-.layout-content-col.span-1 {
-  width: 40px; }
-
-.layout-content-col.span-2 {
-  width: 100px; }
-
-.layout-content-col.span-3 {
-  width: 160px; }
-
-.layout-content-col.span-4 {
-  width: 220px; }
-
-.layout-content-col.span-5 {
-  width: 280px; }
-
-.layout-content-col.span-6 {
-  width: 340px; }
-
-.layout-content-col.span-7 {
-  width: 400px; }
-
-.layout-content-col.span-8 {
-  width: 460px; }
-
-.layout-content-col.span-9 {
-  width: 520px; }
-
-.layout-content-col.span-10 {
-  width: 580px; }
-
-.layout-content-col.span-11 {
-  width: 640px; }
-
-.layout-content-col.span-12 {
-  width: 700px; }
-
-.layout-content-col.span-13 {
-  width: 760px; }
-
-.vspace.size-1 {
-  height: 10px; }
-
-.vspace.size-2 {
-  height: 20px; }
-
-.vspace.size-3 {
-  height: 30px; }
-
-.vspace.size-4 {
-  height: 40px; }
-
-.vspace.size-5 {
-  height: 50px; }
-
-.vspace.size-6 {
-  height: 60px; }
-
-.vspace.size-7 {
-  height: 70px; }
-
-.vspace.size-8 {
-  height: 80px; }
-
-.vspace.size-9 {
-  height: 90px; }
-
-.vspace.size-10 {
-  height: 100px; }
-
-.vspace.size-11 {
-  height: 110px; }
-
-.vspace.size-12 {
-  height: 120px; }
-
-.vspace.size-13 {
-  height: 130px; }
-
-.vspace.size-14 {
-  height: 140px; }
-
-.vspace.size-15 {
-  height: 150px; }
-
-.vspace.size-16 {
-  height: 160px; }
-
-.new,
-.new-child {
-  font-size: .78em;
-  font-weight: bold;
-  color: #ff3d3d;
-  vertical-align:top;
-  white-space:nowrap;
-}
-
-/* content header */
-.content-header {
-  position: relative;
-}
-.content-header:before,
-.content-header:after {
-  content: '';
-  display: table;
-  /* Clear heading margins, to make absolutely positioned nav a bit more predictable. */
-}
-.content-header.just-links {
-  margin-bottom:0;
-  padding-bottom:0;}
-
-.content-footer {
-  margin-top: 10px;
-  padding-top:10px;
-  width:100%; }
-
-.content-footer .col-9 {
-  margin-left:0;
-}
-.content-footer .col-4 {
-  margin-right:0;
-}
-.content-footer.wrap {
-  max-width:940px;
-}
-.content-footer .plus-container {
-  margin:5px 0 0;
-  text-align:right;
-  float:right;
-}
-
-a.back-link {
-    text-decoration: none;
-    text-transform: uppercase;
-}
-
-.content-header .paging-links {
-  position: absolute;
-  right: 0;
-  top: 8px;
-  width: 220px;
-}
-.paging-links {
-  position: relative;
-  min-height:30px; }
-  .paging-links a,
-  .training-nav-top a {
-    text-decoration: none; }
-    .training-nav-top .prev-page-link:before,
-    a.back-link:before {
-      content: '';
-      background: transparent url(../images/styles/disclosure_left.png) no-repeat scroll 50% 50%;
-      width: 10px;
-      height: 10px;
-      display: inline-block;
-      margin-right: 5px; }
-    .training-nav-top .next-page-link:after,
-    .training-nav-top .start-class-link:after,
-    .training-nav-top .start-course-link:after,
-    .go-link:after {
-      content: '';
-      background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
-      width: 10px;
-      height: 10px;
-      display: inline-block;
-      margin-left: 5px; }
-    .prev-page-link.inline:before {
-      content: none; }
-    .next-page-link.inline:after {
-      content: none; }
-
-  .content-footer {
-    left:0;
-  }
-
-  .training-nav-top a {
-    border-bottom:0;
-    box-sizing: border-box;
-    color: inherit;
-    display:block;
-    float:left;
-    padding:10px 0;
-    line-height:30px;
-    text-align:center;
-    width: 50%;
-  }
-
-  .training-nav-top a.prev-page-link {
-    padding-left: 15px;
-    text-align: left;
-  }
-
-  .training-nav-top a.next-page-link {
-    padding-right: 15px;
-    text-align: right;
-  }
-
-  .paging-links a.disabled,
-  .training-nav-top a.disabled,
-  .content-footer a.disabled {
-    color:#bbb;
-  }
-
-  .paging-links a.disabled:hover,
-  .training-nav-top a.disabled:hover,
-  .content-footer a.disabled:hover {
-    cursor:default;
-    color:#bbb !important;
-  }
-
-  .training-nav-top a.start-class-link,
-  .training-nav-top a.start-course-link {
-    width:100%;
-  }
-
-  /* list of classes on course landing page */
-  ol.class-list {
-    counter-reset: class;
-    list-style: none;
-    margin: 60px 0 0;
-  }
-  ol.class-list>li {
-    box-shadow: 0px 2px 5px 0 rgba(0, 0, 0, 0.26);
-    margin: 0 0 20px;
-    overflow: hidden;
-  }
-  ol.class-list .title {
-    background: #00bcd4;
-    color: #fff;
-    display: block;
-    font-size: 20px;
-    font-weight: 500;
-    height: 32px;
-    padding: 52px 16px 12px;
-    position: relative;
-  }
-  ol.class-list .title:before {
-    border-bottom: 1px solid white;
-    box-sizing: border-box;
-    /* Disable the numbers for now, since vert few classes need to be taken in order. */
-    /* content: counter(class); */
-    counter-increment: class;
-    height: 40px;
-    left: 0;
-    padding: 10px 1px 0 5px;
-    position: absolute;
-    top: 0;
-    text-align: right;
-    min-width: 30px;
-  }
-  ol.class-list .title h2 {
-    color: currentColor;
-    font-size: inherit;
-    font-weight: inherit;
-    padding:0 0 10px;
-    display:block;
-    float:left;
-    width:675px;
-  }
-  ol.class-list .title span {
-    display:none;
-    float:left;
-    font-size:18px;
-    font-weight:bold;
-    background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
-    width: 10px;
-    height: 32px;
-  }
-
-  ol.class-list .description {
-    box-sizing: border-box;
-    float:left;
-    display:block;
-    margin:0;
-    padding: 16px 10px 16px 16px;
-    width: 50%;
-  }
-  ol.class-list .description.article {
-    width: 550px;
-  }
-  ol.class-list ol {
-    box-sizing: border-box;
-    float: left;
-    list-style: none;
-    margin: 0;
-    padding: 16px 16px 16px 10px;
-    width: 50%;
-  }
-  ol.class-list .lessons li {
-    margin: 0 0 6px;
-    line-height: 16px;
-  }
-
-  /* Class colors */
-  ol.class-list li:nth-child(10n+1) .title {
-    background: #00bcd4;
-  }
-  ol.class-list li:nth-child(10n+2) .title {
-    background: #4db6ac;
-  }
-  ol.class-list li:nth-child(10n+3) .title {
-    background: #66bb6a;
-  }
-  ol.class-list li:nth-child(10n+4) .title {
-    background: #7cb342;
-  }
-  ol.class-list li:nth-child(10n+5) .title {
-    background: #afb42b;
-  }
-  ol.class-list li:nth-child(10n+6) .title {
-    background: #ffb300;
-  }
-  ol.class-list li:nth-child(10n+7) .title {
-    background: #ff7043;
-  }
-  ol.class-list li:nth-child(10n+8) .title {
-    background: #ec407a;
-  }
-  ol.class-list li:nth-child(10n+9) .title {
-    background: #ab47bc;
-  }
-  ol.class-list li:nth-child(10n+10) .title {
-    background: #7e57c2;
-  }
-
-  @media (max-width: 719px) {
-    ol.class-list ol,
-    ol.class-list .description {
-      float: none;
-      margin: 16px;
-      padding: 0;
-      width: auto;
-    }
-  }
-
-
-  .hide {
-    display:none !important;
-  }
-
-
-
-  /* inner-doc tabs w/ title */
-
-div#title-tabs-wrapper {
-  border-bottom:1px solid #ccc;
-  margin:20px 0 30px;
-}
-h1.with-title-tabs {
-  display:inline-block;
-  margin-bottom: -1px;
-  padding:0 60px 0 0;
-  border-bottom:1px solid #F9F9F9;
-}
-ul#title-tabs {
-  list-style:none;
-  padding:0;
-  height:29px;
-  margin:0;
-  font-size:16px;
-  line-height:26px;
-  display:inline-block;
-  vertical-align:bottom;
-}
-ul#title-tabs li {
-  display:block;
-  float:left;
-  margin-right:40px;
-  border-bottom: 3px solid transparent;
-}
-ul#title-tabs li.selected {
-  border-bottom: 3px solid #93C;
-}
-ul#title-tabs li a {
-  color:#333;
-}
-ul#title-tabs li a:hover,
-ul#title-tabs li a:active {
-  color:#039BE5 !important;
-}
-
-
-
-/* content body */
-@-webkit-keyframes glowheader {
-  from {
-    background-color: #33b5e5;
-    color: #000;
-    border-bottom-color: #000; }
-
-  to {
-    background-color: transparent;
-    color: #33b5e5;
-    border-bottom-color: #33b5e5; } }
-
-@-moz-keyframes glowheader {
-  from {
-    background-color: #33b5e5;
-    color: #000;
-    border-bottom-color: #000; }
-
-  to {
-    background-color: transparent;
-    color: #33b5e5;
-    border-bottom-color: #33b5e5; } }
-
-@keyframes glowheader {
-  from {
-    background-color: #33b5e5;
-    color: #000;
-    border-bottom-color: #000; }
-
-  to {
-    background-color: transparent;
-    color: #33b5e5;
-    border-bottom-color: #33b5e5; } }
-
-h1:target,
-h2:target,
-h3:target {
-    -webkit-animation-name: glowheader;
-    -moz-animation-name: glowheader;
-    animation-name: glowheader;
-    -webkit-animation-duration: 0.7s;
-    -moz-animation-duration: 0.7s;
-    animation-duration: 0.7s;
-    -webkit-animation-timing-function: ease-out;
-    -moz-animation-timing-function: ease-out;
-    animation-timing-function: ease-out; }
-
-.design ol h4 {
-  padding-bottom:0;
-}
-.design ol {
-  counter-reset: item; }
-  .design ol>li {
-    font-size: 14px;
-    line-height: 20px;
-    list-style-type: none;
-    position: relative; }
-    .design ol>li:before {
-      content: counter(item) ". ";
-      counter-increment: item;
-      position: absolute;
-      left: -20px;
-      top: 0; }
-    .design ol li.value-1:before {
-      content: "1. "; }
-    .design ol li.value-2:before {
-      content: "2. "; }
-    .design ol li.value-3:before {
-      content: "3. "; }
-    .design ol li.value-4:before {
-      content: "4. "; }
-    .design ol li.value-5:before {
-      content: "5. "; }
-    .design ol li.value-6:before {
-      content: "6. "; }
-    .design ol li.value-7:before {
-      content: "7. "; }
-    .design ol li.value-8:before {
-      content: "8. "; }
-    .design ol li.value-9:before {
-      content: "9. "; }
-    .design ol li.value-10:before {
-      content: "10. "; }
-.design .with-callouts ol>li {
-  list-style-position: inside;
-  margin-left: 0; }
-  .design .with-callouts ol>li:before {
-    display: inline;
-    left: -20px;
-    float: left;
-    width: 17px;
-    color: #33b5e5;
-    font-weight: 500; }
-.design .with-callouts ul>li {
-  list-style-position: outside; }
-
-/* special list items */
-li.no-bullet {
-  list-style-type: none !important; }
-li.no-bullet *{
-  margin:0; }
-
-.design li.with-icon {
-  position: relative;
-  margin-left: 20px;
-  min-height: 30px; }
-  .design li.with-icon p {
-    margin-left: 0 !important; }
-  .design li.with-icon:before {
-    position: absolute;
-    left: -40px;
-    top: 0;
-    content: '';
-    width: 30px;
-    height: 30px; }
-  .design li.with-icon.tablet:before {
-    background-image: url(../images/styles/ico_phone_tablet.png); }
-  .design li.with-icon.web:before {
-    background-image: url(../images/styles/ico_web.png); }
-  .design li.with-icon.action:before {
-    background-image: url(../images/styles/ico_action.png); }
-  .design li.with-icon.use:before {
-    background-image: url(../images/styles/ico_use.png); }
-
-/* video  containers */
-.framed-galaxynexus-land-span-13 {
-  background: transparent url(../images/styles/device_galaxynexus_blank_land_span13.png) no-repeat
-scroll top left;
-  padding: 42px 122px 62px 126px;
-  overflow: hidden; }
-  .framed-galaxynexus-land-span-13, .framed-galaxynexus-land-span-13 video,
-.framed-galaxynexus-land-span-13 img {
-    width: 512px;
-    height: 286px; }
-
-
-.framed-galaxynexus-land-span-8{
-  background: transparent url(../images/styles/device_galaxynexus_blank_land_span8.png) no-repeat
-scroll top left;
-  padding: 26px 68px 38px 72px;
-  overflow: hidden; }
-  .framed-galaxynexus-land-span-8, .framed-galaxynexus-land-span-8 video,
-.framed-galaxynexus-land-span-8 img {
-    width: 320px;
-    height: 180px; }
-
-.framed-galaxynexus-port-span-9 {
-  background: transparent url(../images/styles/device_galaxynexus_blank_port_span9.png) no-repeat
-scroll top left;
-  padding: 95px 122px 107px 124px;
-  overflow: hidden; }
-  .framed-galaxynexus-port-span-9, .framed-galaxynexus-port-span-9 video,
-.framed-galaxynexus-port-span-9 img {
-    width: 274px;
-    height: 488px; }
-
-.framed-galaxynexus-port-span-5 {
-  background: transparent url(../images/styles/device_galaxynexus_blank_port_span5.png) no-repeat
-scroll top left;
-  padding: 75px 31px 76px 33px;
-  overflow: hidden; }
-  .framed-galaxynexus-port-span-5, .framed-galaxynexus-port-span-5 video,
-.framed-galaxynexus-port-span-5 img {
-    width: 216px;
-    height: 384px; }
-
-.framed-nexus4-port-216 {
-  background: transparent url(../images/styles/device_nexus4_blank_port_432.png) no-repeat
-scroll top left;
-  background-size:240px 465px;
-  padding: 52px 12px 52px 12px;
-  overflow: hidden; }
-  .framed-nexus4-port-216, .framed-nexus4-port-216 video,
-  .framed-nexus4-port-216 img {
-    width: 216px;
-    height: 360px; }
-
-.framed-nexus5-port-span-5 {
-  background: transparent url(../images/styles/device_nexus5_blank_port_span5.png) no-repeat
-  scroll top left;
-  padding: 52px 33px 69px 31px;
-  overflow: hidden;
-}
-
-.framed-nexus5-port-span-5,
-.framed-nexus5-port-span-5 video,
-.framed-nexus5-port-span-5 img {
-  width: 216px;
-  height: 384px;
-}
-
-.framed-nexus5-land-span-13 {
-  background: transparent url(../images/styles/device_nexus5_blank_land_span13.png) no-repeat scroll top left;
-  padding: 36px 119px 54px 108px;
-  overflow: hidden;
-}
-
-.framed-nexus5-land-span-13,
-.framed-nexus5-land-span-13 video,
-.framed-nexus5-land-span-13 img {
-  width: 533px;
-  height: 300px;
-}
-
-.framed-nexus5-port-span-5,
-.framed-nexus5-port-span-5 video,
-.framed-nexus5-port-span-5 img {
-  width: 216px;
-  height: 384px;
-}
-
-/* wear device frames */
-
-.framed-wear-square {
-  background: transparent url(../images/styles/device_wear_square.png) no-repeat scroll top left;
-  background-size: 302px 302px;
-  height:222px;
-  width:222px;
-  padding:40px;
-  overflow:hidden;
-}
-
-.framed-wear-square-small {
-  background: transparent url(../images/styles/device_wear_square_small.png) no-repeat scroll top left;
-  background-size: 169px 200px;
-  height:147px;
-  width:147px;
-  padding:27px 11px;
-  overflow:hidden;
-}
-
-#api-info-block {
-  color: #999;
-  float: right;
-  font-size: 12px;
-  font-weight: normal;
-  line-height: 14px;
-  margin: 20px 0 0;
-  max-width: 80%;
-  padding: 0 10px 6px;
-  text-align: right;
-}
-
-#api-info-block a,
-#api-info-block a:active,
-#api-info-block a:visited {
-  color: #222;
-}
-
-#jd-header {
-  font-size: 12px;
-  margin: 20px 0 12px;
-  padding: 0 0 12px;
-}
-
-#jd-header h1 {
-  margin: 0;
-  padding: 0 0 6px;
-}
-
-#jd-content
-.framed-wear-square img {
-  height:222px;
-  width: 222px;
-  padding:0;
-  margin:0;
-}
-
-#jd-content
-.framed-wear-square-small img {
-  height:147px;
-  width: 147px;
-  padding:0;
-  margin:0;
-}
-
-
-
-
-
-
-/* landing page disclosures */
-.landing-page-link {
-  text-decoration: none;
-  font-weight: 500;
-  color: #333333; }
-  .landing-page-link:after {
-    content: '';
-    background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
-    width: 10px;
-    height: 10px;
-    display: inline-block;
-    margin-left: 5px; }
-
-/* tooltips */
-.tooltip-box {
-  position: absolute;
-  background-color: rgba(0, 0, 0, 0.9);
-  border-radius: 2px;
-  font-size: 14px;
-  line-height: 20px;
-  color: #fff;
-  padding: 6px 10px;
-  max-width: 250px;
-  z-index: 10000; }
-  .tooltip-box.below:after {
-    position: absolute;
-    content: '';
-    line-height: 0;
-    display: block;
-    top: -10px;
-    left: 5px;
-    border: 5px solid transparent;
-    border-bottom-color: rgba(0, 0, 0, 0.9); }
-
-/* video note */
-.video-instructions {
-  margin-top: 10px;
-  margin-bottom: 10px; }
-  .video-instructions:before {
-    content: '';
-    background: transparent url(../images/styles/ico_movie_inline.png) no-repeat scroll top left;
-    display: inline-block;
-    width: 12px;
-    height: 12px;
-    margin-right: 8px; }
-  .video-instructions:after {
-    content: 'Click device screen to replay movie.'; }
-
-/* download buttons */
-.download-button {
-  display: block;
-  margin-bottom: 5px;
-  text-decoration: none;
-  background-color: #33b5e5;
-  color: #fff !important;
-  font-weight: 500;
-  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
-  padding: 6px 12px;
-  border-radius: 2px; }
-  .download-button:hover, .download-button:focus {
-    background-color: #0099cc;
-    color: #fff !important; }
-  .download-button:active {
-    background-color: #006699; }
-
-/* UI tables and other things found in Writing style and Settings pattern */
-.ui-table {
-  width: 100%;
-  background-color: #282828;
-  color: #fff;
-  border-radius: 2px;
-  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
-  border-collapse: separate; }
-  .ui-table th,
-  .ui-table td {
-    padding: 5px 10px;
-    background-color: inherit;
-    border:0;}
-  .ui-table thead th {
-    font-weight: bold; }
-  .ui-table tfoot td {
-    border-top: 1px solid #494949;
-    border-right: 1px solid #494949;
-    text-align: center; }
-    .ui-table tfoot td:last-child {
-      border-right: 0; }
-
-.layout-with-list-item-margins {
-  margin-left: 30px !important; }
-
-.emulate-content-left-padding {
-  margin-left: 10px; }
-
-.do-dont-label {
-  margin-bottom: 10px;
-  padding-left: 20px;
-  background: transparent none no-repeat scroll 0px 3px; }
-  .do-dont-label.bad {
-    background-image: url(../images/styles/ico_wrong.png); }
-  .do-dont-label.good {
-    background-image: url(../images/styles/ico_good.png); }
-
-
-
-
-/* --------------------------------------------------------------------------
-Footer
-*/
-.line {
-    clear: both;
-    background: #acbc00;
-    background: -moz-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
-    background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #acbc00),
-color-stop(50%, #acbc00), color-stop(50%, #bdde00), color-stop(100%, #bdde00));
-    background: -webkit-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
-    background: -o-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
-    background: -ms-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
-    background: linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
-    height: 2px;
-    margin-top: 150px;
-    position: relative;
-    z-index: 11;
-}
-#footer {
-    font-size:11px;
-    clear: both;
-    color: #999;
-    padding: 15px 0;
-    margin-top:10px;
-    width:auto;
-}
-#footer-local ul {
-  list-style: none;
-  margin: 5px 0 30px 0;
-}
-#footer-local li {
-    display: inline;
-}
-#footer-local li+li:before {
-    content: '|';
-    padding: 0 3px;
-  color: #e5e5e5;
-}
-#footer-global {
-    padding: 10px 15px;
-  background: #f5f5f5;
-}
-#footer-global {
-    border-top: 1px solid #ebebeb;
-    font-size: 11.5px;
-    line-height: 1.8;
-    list-style: none;
-}
-#footer-global ul {
-    margin: 0;
-}
-#footer-global li {
-    display: inline;
-    font-weight: bold;
-}
-#footer-global li+li:before {
-    content: '¬?';
-    padding: 0 3px;
-}
-* html #footer-global li {
-    margin: 0 13px 0 0;
-}
-* [dir='rtl'] #footer-global li {
-    margin: 0 0 0 13px;
-}
-*+html #footer-global li {
-    margin: 0 13px 0 0;
-}
-*+[dir='rtl'] #footer-global li {
-    margin: 0 0 0 13px;
-}
-#footer-global li a {
-    font-weight: normal;
-}
-.locales {
-  margin: 10px 0 0 0px;
-}
-[dir='rtl'] .locales {
-    background-position: right center;
-    float: left;
-    padding: 0 24px 0 0;
-}
-.locales form {
-    margin: 0;
-}
-
-.locales select,
-.locales option {
-  text-transform: capitalize;
-}
-
-.locales select, .sites select {
-  line-height: 3.08;
-  margin: 0px 0;
-  border: solid 1px #EBEBEB;
-  -webkit-appearance: none;
-  background: white url('../images/arrows-up-down.png') right center no-repeat;
-  height: 30px;
-  color: #222;
-  line-height: normal;
-  padding: 5px;
-  width: 230px;
-}
-}
-
-/* =============================================================================
-   Print Only
-   ========================================================================== */
-@media print {
-  /* configure printed page */
-  @page {
-      margin: 0.75in 1in;
-      widows: 4;
-      orphans: 4;
-  }
-
-  /* reset spacing metrics */
-  html, body, .wrap {
-      margin: 0 !important;
-      padding: 0 !important;
-      width: auto !important;
-  }
-
-  /* leave enough space on the left for bullets */
-  body {
-      padding-left: 20px !important;
-  }
-  #doc-col {
-      margin-left: 0;
-  }
-
-  /* hide a bunch of non-content elements */
-  #header, #footer, #nav-x, #side-nav,
-  .training-nav-top, .training-nav-bottom,
-  #doc-col .content-footer,
-  .nav-x, .nav-y,
-  .paging-links {
-      display: none !important;
-  }
-
-  /* remove extra space above page titles */
-  #doc-col .content-header {
-      margin-top: 0;
-  }
-
-  /* bump up spacing above subheadings */
-  h2 {
-      padding-top: 40px !important;
-  }
-
-  /* print link URLs where possible and give links default text color */
-  p a:after {
-      content: " (" attr(href) ")";
-      font-size: 80%;
-  }
-  p a {
-      word-wrap: break-word;
-  }
-  a {
-      color: inherit;
-  }
-
-  /* syntax highlighting rules */
-  .str { color: #060; }
-  .kwd { color: #006; font-weight: bold; }
-  .com { color: #600; font-style: italic; }
-  .typ { color: #404; font-weight: bold; }
-  .lit { color: #044; }
-  .pun { color: #440; }
-  .pln { color: #000; }
-  .tag { color: #006; font-weight: bold; }
-  .atn { color: #404; }
-  .atv { color: #060; }
-}
-
-/* =============================================================================
-   Layout
-   ========================================================================== */
-@media screen, projection, print {
-
-.training-nav-top {
-  border:1px solid #e5e5e5;
-  border-width: 1px 1px 0;
-  bottom: -56px;
-  box-sizing: border-box;
-  position: absolute;
-  right: 0;
-  width: 280px;
-}
-
-.training-nav-bottom {
-  float:right;
-  margin:0 0 0 20px;
-  padding:0 0 20px;
-}
-
-#tb-wrapper,
-#qv-wrapper {
-  float:right;
-  clear:right;
-  margin:6px 0 0 30px; /* negative top-margin to counter the content-header bottom margin */
-  padding:0 0 30px;
-}
-
-#tb-wrapper {
-  margin:56px 0 0 20px; /* negative top-margin to counter the content-header bottom margin */
-}
-
-#tb,
-#qv {
-  border: 1px solid #e5e5e5;
-  box-sizing: border-box;
-  float: right;
-  line-height: 16px;
-  padding: 5px 0;
-  width: 240px;
-}
-
-#tb {
-  width:280px;
-}
-
-#tb h2,
-#qv h2 {
-  border-top: 1px solid #e5e5e5;
-  color: inherit;
-  font-size: 16px;
-  line-height: 24px;
-  margin: 15px 0 4px;
-  padding: 10px 15px 0;
-}
-
-#tb h2:first-child,
-#qv h2:first-child {
-  border-top: 0;
-  padding-top: 0;
-  margin-top: 10px;
-}
-
-#tb .download-box,
-#qv .download-box {
-  padding:0 0 0 15px;
-}
-
-#tb .download-box .filename,
-#qv .download-box .filename {
-  font-size:11px;
-  margin:4px 4px 10px;
-}
-
-@media (max-width: 719px) {
-  .training-nav-top {
-    left: 0;
-    width: auto;
-  }
-
-  #tb-wrapper {
-    clear: none;
-    float: none;
-    margin-left: 0;
-  }
-
-  #tb {
-    float: none;
-    width: auto;
-  }
-
-  #qv-wrapper {
-    display: none;
-  }
-}
-
-
-/* Dev guide quicknav */
-
-.sidebox-wrapper {
-  float:right;
-  clear:right;
-  margin:0 0 0 20px;
-  padding:0 0 20px;
-}
-
-.sidebox {
-  width:226px;
-  font-size:13px;
-  line-height:18px;
-  border-left:3px solid #96ca7c;
-  border-left-color: rgba(106, 179, 68, .7); /* #6ab344 * 70% */
-  float:right;
-  padding:0 0 0 20px;
-  margin:0 0 1em 20px;
-}
-
-.sidebox h2,
-.sidebox h3,
-.sidebox h4,
-.sidebox h5 {
-  font-weight:bold;
-  padding: 0 0 10px;
-  line-height: 16px;
-}
-
-.sidebox * {
-  font-size:inherit;
-}
-
-.sidebox > *:last-child {
-  margin-bottom:0;
-}
-
-#tb ol,
-#tb ul,
-#tb p,
-#qv ul {
-  list-style-type: none;
-  margin:0 15px 10px 15px;
-}
-
-#tb li,
-#qv li {
-  margin: 8px 0;
-  padding: 0 0 0 16px;
-  position: relative;
-}
-
-#qv ol {
-  list-style:none;
-  margin:0 15px 15px;
-  font-size:inherit;
-  line-height:inherit;
-}
-
-#tb ol ol,
-#tb ul ul,
-#qv ol ol,
-#qv ul ul,
-.sidebox ol ol,
-.sidebox ul ul {
-  margin: 8px 0;
-}
-
-.sidebox p,
-#qv p {
-  margin: 0 0 10px;
-}
-
-/* related resources blocks in checklists */
-
-/* related resources sections that have dynamic content */
-
-
-
-h3.rel-resources {
-  padding:1.25em auto;
-}
-
-/* --------------------------------------------------------------------------
-Form
-*/
-.article form {
-    margin: 0 0 20px;
-}
-.article form .form-required {
-    color: #dd4b39;
-}
-.article form fieldset {
-    margin: 0 0 20px;
-    padding: 0;
-}
-.article form legend {
-    display: block;
-    line-height: 1.5;
-    margin: 0;
-    padding: 0;
-}
-/*
-.article form ol, .article form ul {
-    margin: 0 0 0 1em;
-    padding: 0 0 0 1em;
-}
-[dir='rtl'] .article form ol, [dir='rtl'] .article form ul {
-    margin: 0 1em 0 0;
-    padding: 0 1em 0 0;
-}
-.article form ol ul, .article form ul ul, [dir='rtl'] .article form ol ul, [dir='rtl'] .article form
-ul ul {
-    list-style: none;
-    margin: 0;
-    padding: 0;
-}
-.article form li {
-    margin: 0 0 20px;
-}
-.article form li li {
-    margin: 0 0 5px;
-}
-*/
-.article form label {
-    display: block;
-    margin: 0 0 5px;
-    padding: 0;
-}
-.article form input[type='text'], .article form select, .article form textarea, .article form
-.checkbox-group, .article form .radio-group {
-    margin-bottom: 15px;
-}
-.checkbox-group input {
-  width: 13px;
-  height: 13px;
-  background: #fff;
-  border: solid 1px #c6c6c6;
-  float: left;
-}
-.article form .checkbox-group, .article form .radio-group {
-  display: block
-}
-.article form select {
-    border: solid 1px #ebebeb;
-    border-top-color: #ddd;
-    -webkit-appearance: none;
-    background: #f3f3f3 url(../images/arrows-up-down.png) right center no-repeat;
-    height: 30px;
-    color: #222;
-    line-height: normal;
-    padding: 5px;
-    width: 130px;
-}
-
-.article form .browse .browse-msg {
-  font-size: 11.5px;
-}
-.article form .browse .button-secondary {
-  height: auto;
-  line-height: 25px;
-  font-size: 11px;
-  padding: 0 8px;
-  margin: 0 10px 15px 0;
-}
-.article form input[type='text'], .article form textarea {
-    border: 1px solid #ebebeb;
-    border-top-color: #dcdcdc;
-    color: #222;
-    line-height: normal;
-    padding: 6px 10px;
-    width: 300px;
-}
-.article form textarea {
-    height: 150px;
-}
-.article form input[type='text']:focus, .article form textarea:focus {
-    border-color: #33B5E5;
-    -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
-    -o-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
-    -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
-    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
-    outline: 0;
-}
-.article form input[disabled], .article form textarea[disabled], .article form label.form-disabled {
-    color: #999;
-}
-.article form input[type='text'][disabled], .article form textarea[disabled] {
-    background-color: #ebebeb;
-}
-form .form-error input[type='text'], form .form-error textarea {
-    border-color: #dd4b39;
-  margin-right: 20px;
-}
-.aside {
-    -moz-border-radius: 2px;
-    -webkit-border-radius: 2px;
-    border-radius: 2px;
-    margin: 10px 0;
-    padding: 20px;
-    position: relative;
-  background: #f9f9f9;
-}
-/*
-.aside, .notification, .promo {
-    -moz-border-radius: 2px;
-    -webkit-border-radius: 2px;
-    border-radius: 2px;
-    margin: 10px 0;
-    padding: 10px;
-    position: relative;
-}
-.aside>:first-child, .notification>:first-child, .promo>:first-child {
-    margin-top: 0;
-}
-.aside>:last-child, .notification>:last-child, .promo>:last-child {
-    margin-bottom: 0;
-}
-.aside {
-    background: #f9f9f9;
-}
-.notification {
-    background: #fffbe4;
-    border-color: #f8f6e6;
-}
-.promo {
-    background: #f6f9ff;
-    border-color: #eff2f9;
-}
-*/
-
-/* SDK TOS styles */
-
-div.sdk-terms {
-  white-space: pre-wrap;
-  word-wrap: break-word;
-  font-family: inherit;
-  font-size: inherit;
-  padding: 10px;
-  height: 370px;
-  width: 738px;
-  border: 1px solid #444;
-  background: transparent;
-  overflow:auto;
-  margin:0 0 10px;
-}
-
-div.sdk-terms.fullsize {
-  padding: 0;
-  height: auto;
-  width: auto;
-  border:none;
-}
-
-div.sdk-terms h3,
-div.sdk-terms h2 {
-  padding: 0;
-}
-
-div#sdk-terms-form {
-  padding:0 0 0 10px;
-}
-
-div#sdk-terms-form input {
-  display:inline;
-  margin:4px 4px 4px 0;
-}
-
-
-/* --------------------------------------------------------------------------
-Code Style
-*/
-pre {
-  margin:0 0 1em 0;
-  padding: 1em;
-  overflow: auto;
-  border: solid 1px #ddd;
-  background: #f7f7f7;
-}
-
-p.package-name {
-  margin:1em 0;
-}
-
-h1.api-title {
-  padding-bottom:0;
-}
-
-h2.api-section {
-  margin: 60px 0 0;
-}
-
-h2.api-section+hr {
-  margin-bottom: 30px;
-}
-
-h3.api-name {
-  margin: 80px 0 12px;
-  padding: 0;
-}
-
-/* remove top padding when this h3 (visibly) follows an h2.
-   This accounts for the variation in structure,
-   including the collapsed mobile headings */
-h2+hr+div>div>a+div>h3.api-name,
-h2+hr+a+div>h3.api-name,
-h2+hr+a+h3.api-name {
-  margin-top: 0;
-}
-
-pre.api-signature,
-code.api-signature {
-  color:inherit;
-  padding:0;
-  margin:1em 0;
-  border:0;
-  background:transparent;
-}
-
-.str { color: #800; } /* Code string */
-.kwd { color: #008; }
-.typ { color: #606; }
-.lit { color: #066; }
-.pun { color: #660; }
-.pln { color: #000; }
-.tag { color: #008; }
-.atn { color: #828; }
-.atv { color: #800; } /* XML string */
-.dec { color: #606; }
-
-/* --------------------------------------------------------------------------
-Three-Pane
-*/
-/* Package Nav & Classes Nav */
-.three-pane {
-  position: relative;
-  border-top: solid 1px #ebebeb;
-}
-#packages-nav .js-pane,
-#classes-nav .js-pane {
-  overflow:visible;
-}
-#packages-nav {
-        height:270px;
-  max-height: inherit;
-  overflow: hidden;
-  position: relative;
-}
-#classes-nav {
-  overflow: hidden;
-  position: relative;
-}
-#packages-nav ul, #classes-nav ul {
-  list-style-type: none;
-  margin: 10px 0 20px 0;
-  padding: 0;
-}
-#classes-nav li {
-  font-weight: bold;
-  margin: 5px 0;
-}
-#packages-nav li,
-#classes-nav li li {
-  margin: 0;
-}
-#packages-nav li a, #packages-nav li a:active, #packages-nav li a:visited,
-#classes-nav li a, #classes-nav li a:active, #classes-nav li a:visited {
-  padding: 0 0 0 4px;
-}
-#packages-nav li a, #packages-nav li a:active, #packages-nav li a:visited,
-#classes-nav li li a, #classes-nav li li a:active, #classes-nav li li a:visited {
-  color: #222;
-  font-weight: normal;
-}
-#packages-nav li a, #packages-nav li a:active, #packages-nav li a:visited,
-#classes-nav li li a, #classes-nav li li a:active, #classes-nav li li a:visited {
-  display: block;
-}
-#packages-nav li.selected a, #packages-nav li.selected a:active, #packages-nav li.selected
-a:visited,
-#classes-nav li li.selected a, #classes-nav li li.selected a:active, #classes-nav li li.selected
-a:visited {
-    font-weight: 500;
-    color: #0099cc;
-    background-color:#fff; }
-  #packages-nav li.selected ul li a,
-  #classes-nav li.selected ul li a {
-  /* don't highlight child items */
-    color: #555555; }
-
-#nav-swap {
-  height:30px;
-  border-top:1px solid #ccc;
-}
-#nav-swap a {
-  display:inline-block;
-  height:100%;
-  color: #222;
-  font-size: 12px;
-  padding: 5px 0 5px 5px;
-}
-
-#nav-swap .fullscreen {
-  float: right;
-  width: 24px;
-  height: 24px;
-  text-indent: -1000em;
-  padding:0;
-  margin:3px 5px 0;
-  background: url(../images/fullscreen.png) no-repeat -24px 0;
-}
-#nav-swap .fullscreen.disabled {
-  background-position: 0 0;
-}
-#nav-swap .fullscreen:hover,
-#nav-swap .fullscreen:focus {
-  cursor:pointer;
-}
-
-/* Content */
-#doc-col {
-  margin-right:0;
-}
-
-/* Uncomment this for preview release watermark
-#doc-col {
-  background: url('../images/preview.png') repeat;
-}
-*/
-
-#doc-content-container {
-  margin-left: 291px
-}
-
-#doc-header, #doc-content {
-  padding: 0;
-}
-
-#doc-header {
-  background: #f7f7f7;
-}
-
-#doc-header h1 {
-  line-height: 0;
-  padding-bottom: 15px;
-}
-
-
-#api-info-block {
-  float: right;
-  font-weight: bold;
-}
-
-#api-info-block a, #api-info-block a:active, #api-info-block a:visited {
-  color: #222;
-}
-
-#api-info-block a:hover, #api-info-block a:focus {
-  color: #33B5E5;
-}
-
-#api-nav-header {
-  height:19px; /* plus 16px padding = 35; same as #nav li */
-  font-size:14px;
-  padding: 8px 0;
-  margin: 0;
-  border-bottom: 1px solid #CCC;
-  background:#e9e9e9;
-  background: rgba(0, 0, 0, 0.05); /* matches #nav li.expanded */
-  line-height: 19px; /* Fix regression after page line-height is bumped to 24px */
-}
-
-#api-nav-title {
-  padding:0 5px;
-  white-space:nowrap;
-}
-
-#api-level-toggle {
-  float:right;
-  padding:0 5px;
-}
-
-#api-level-toggle label {
-  margin:0;
-  vertical-align:top;
-  line-height: 19px;
-  font-size:13px;
-  height: 19px;
-}
-
-#api-level-toggle .select-wrapper {
-  width: 35px;
-  display: inline-block;
-  overflow: hidden;
-}
-
-#api-level-toggle select {
-  border: 0;
-  appearance:none;
-  -moz-appearance:none;
-  -webkit-appearance: none;
-  background: transparent url(../images/arrows-up-down.png) 23px 5px no-repeat;
-  color: #222;
-  /* remove the lines below after xp testing
-     height: 19px;
-     line-height: 19px; */
-  padding: 0;
-  margin: .5px 0 0 0;
-  width:150%;
-  font-size:13px;
-  vertical-align:top;
-  outline:0;
-}
-
-
-/* Toggle for revision notes and stuff */
-div.toggle-content.closed .toggle-content-toggleme {
-  display:none;
-}
-
-#jd-content img.toggle-content-img {
-  margin:0 5px 5px 0;
-}
-
-div.toggle-content-toggleme {
-  padding:0 0 0 15px;
-}
-
-
-/* API LEVEL FILTERED MEMBERS */
-
-.absent,
-.absent a:link,
-.absent a:visited,
-.absent a:hover,
-.absent * {
-  color:#bbb !important;
-  cursor:default !important;
-  text-decoration:none !important;
-}
-#devdoc-nav li.absent.selected,
-#devdoc-nav li.absent.selected *,
-#devdoc-nav div.label.absent.selected,
-#devdoc-nav div.label.absent.selected * {
-  background-color:#eaeaea !important;
-}
-.absent h4.jd-details-title,
-.absent h4.jd-details-title * {
-  background-color:#f6f6f6 !important;
-}
-.absent img {
-  opacity: .3;
-  filter: alpha(opacity=30);
-  -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
-}
-
-
-
-
-
-
-
-
-
-/* JQUERY RESIZABLE STYLES */
-.ui-resizable { position: relative; }
-.ui-resizable-handle { position: absolute; display: none; font-size: 0.1px; z-index:1; }
-.ui-resizable .ui-resizable-handle { display: block; border-bottom: 1px solid #e4e4e4; }
-/*body .ui-resizable-disabled .ui-resizable-handle { display: none; }
-body .ui-resizable-autohide .ui-resizable-handle { display: none; }*/
-.ui-resizable-s { cursor: s-resize; height: 10px; width: 100% !important; bottom: -11px; left: 0;
-border-bottom: solid 1px #ededed;
-  background: #f7f7f7 url("../images/resizable-s2.png") no-repeat scroll center center; }
-/*
-.ui-resizable-e {
-cursor: e-resize; width: 10px; right: 0; top: 0; height: 100%; border-right: solid
-1px #ededed;background: #f7f7f7 url("../images/resizable-e2.png") no-repeat scroll center center; }
-*/
-
-/* --------------------------------------------------------------------------
-Lightbox
-*/
-.lightbox {
-  width: 769px;
-  padding: 1.5em;
-  margin: 0 auto;
-  border: solid 1px #dcdcdc;
-  background: #fff;
-  -moz-box-shadow: 1px 1px 5px rgba(0,0,0,0.1);
-  -webkit-box-shadow: 1px 1px 5px rgba(0,0,0,0.1);
-  box-shadow: 1px 1px 5px rgba(0,0,0,0.1)
-}
-.lightbox .header {
-  float: left;
-  width: 720px;
-  margin: -10px 20px 10px 0;
-}
-.lightbox .close {
-  float: right;
-  width: 10px;
-  height: 10px;
-  margin: -10px -10px 10px 0;
-  text-indent: -1000em;
-  background: url(../images/close.png) no-repeat 0 0;
-}
-.lightbox .close:hover, .lightbox .close:focus {
-  background-position: -10px 0;
-}
-
-/* --------------------------------------------------------------------------
-Styles for samples browser
-*/
-
-#codesample-wrapper {
-  width:100000px; /* super wide to contain floats, but doesn't cause scroll */
-  overflow:visible;
-}
-pre#codesample-block {
-  float:left;
-  overflow:visible;
-  background:transparent;
-  border:none;
-}
-pre#codesample-block a.number {
-  display:none;
-}
-pre#codesample-block .code-line:hover {
-  background:#e7e7e7;
-}
-pre#codesample-line-numbers {
-  float:left;
-  width:2em;
-  background:transparent;
-  border:none;
-  border-right:1px solid #ccc;
-  padding-left:0;
-  font-family:monospace;
-  text-align:right;
-  -webkit-touch-callout: none;
-  -webkit-user-select: none;
-  -khtml-user-select: none;
-  -moz-user-select: -moz-none;
-  -ms-user-select: none;
-  user-select: none;
-}
-pre#codesample-line-numbers a {
-  color:#999;
-}
-pre#codesample-line-numbers.hidden {
-  display:none;
-}
-pre#codesample-block span.code-line {
-  width:100%;
-  display:inline-block;
-}
-
-/*
-Styles for displaying image or video resources in samples browser.
-Resources are marked as no-display if they exceed the size limit.
-*/
-div#codesample-resource img, div#codesample-resource video {
-  border: 1px solid #ececec;
-}
-
-div#codesample-resource.noDisplay div {
-  border: 1px solid #ececec;
-  width:120px;
-  margin-bottom:4px;
-  padding:20px;
-}
-
-div#codesample-resource .noDisplay-message:after {
-  font-style:italic;
-  font-size:12px;
-  content: 'This resource is not available for browsing. To view it, please download the project.';
-}
-
-/*
-Styles for project structure (treeview) page
-*/
-.structure-dir {
-background-image:url(../images/folder.png);
-background-repeat:no-repeat;
-background-position:16px 2px;
-  margin:.25em 0 0 0;
-  padding:0 0 0 0;
-}
-
-.structure-toggleme {
-  margin:0 0 0 3em;
-  padding:0 0 0 0;
-  text-decoration:none;
-}
-
-.structure-java{
-background-image:url(../images/file-java.png);
-background-repeat:no-repeat;
-background-position:0px 2px;
-  margin:.3em 0 0 0;
-  padding:.3em 0 .3em 22px;
-}
-
-.structure-file {
-background-image:url(../images/file-generic.png);
-background-repeat:no-repeat;
-background-position:0px 2px;
-  margin:.3em 0 0 0;
-  padding:.3em 0 .3em 22px;
-}
-
-.structure-xml {
-background-image:url(../images/file-xml.png);
-background-repeat:no-repeat;
-background-position:0px 2px;
-  margin:.3em 0 0 0;
-  padding:.3em 0 .25em 22px;
-}
-
-.structure-img {
-background-image:url(../images/file-image.png);
-background-repeat:no-repeat;
-background-position:0px 2px;
-  margin:.3em 0 0 0;
-  padding:.3em 0 .25em 22px;
-}
-
-.structure-manifest {
-background-image:url(../images/file-manifest.png);
-background-repeat:no-repeat;
-  margin:.0 0 0 1.25em;
-  padding:0 0 0 22px;
-  text-decoration:none;
-}
-
-#jd-content .structure-toggle-img {
-  margin:.5em 0 0 0;
-padding-right:2.1em;
-}
-
-.dirInfo {
-  margin-left:2em;
-}
-
-.structure-dir a {
-  text-decoration:none;
-}
-
-.structure-manifest a {
-  text-decoration: none;
-}
-.structure-file a {
-  text-decoration: none;
-}
-
-.sampleEmbed {
-  background-color:rgb(249, 249, 249);
-}
-
-.sampleEmbed ol.lineNumbers {
-  list-style-type: decimal;
-  padding-left:1em;
-}
-
-.sampleEmbed ol.lineNumbers li {
-border-left:1px solid #ddd;
-border-right:1px solid #ddd;
-color:gray;
-background-color:#f7f7f7;
-margin:0 0 0 24px;
-padding: 2px 2px 2px 6px;
-}
-
-.sampleEmbed ol.lineNumbers li:hover {
-background: #efefef;
-}
-
-.samples-nav li a {
-  overflow: hidden;
-  text-overflow: ellipsis;
-  white-space: nowrap;
-}
-
-/* --------------------------------------------------------------------------
-Styles for raw formatted line numbers (not used with listformatted version)
-div.sampleLine div.lineNumber {
-  display: inline;
-}
-div.sampleLine div.lineCode {
-  display: inline;
-  padding-left:6px;
-}
-div.sampleLine {
-  padding:0;
-  margin:0;
-}*/
-
-/* --------------------------------------------------------------------------
-Misc and article typography
-*/
-
-
-.clearfix:before, .clearfix:after {
-  content: "";
-  display: table
-}
-.clearfix:after {
-  clear: both
-}
-.clearfix {
-  *zoom: 1
-}
-table.blank th, table.blank td {
-    border: 0;
-  background: none
-}
-.caption {
-  margin: 0.5em 0 2em 0;
-  color: #000;
-  font-size: 11.5px;
-}
-
-.nolist, .nolist ul, .nolist ol {
-  list-style:none;
-  margin-left:0;
-}
-
-ol.callouts {
-  counter-reset: item;
-  list-style-type: none;
-  margin-left:44px;
-}
-ol.callouts>li:before {
-  counter-increment: item;
-  content: counter(item);
-  position: absolute;
-  color:#fff;
-  font-weight:bold;
-  background-image:url(../images/styles/callout-bg_2x.png);
-  background-size:24px;
-  width:16px;
-  padding-left:8px;
-  margin-left:-34px;
-}
-
-#tb .nolist {
-  margin-left:15px;
-}
-
-dl.xml>dt {
-  text-transform:uppercase;
-}
-dl.xml dl.attr {
-  margin-top:0;
-}
-
-pre.classic {
-  background-color:transparent;
-  border:none;
-  padding:0;
-}
-
-p.img-caption {
-  margin: -10px 0 20px;
-  font-size: 13px;
-}
-
-/* figures and callouts */
-.figure {
-  position: relative;
-}
-
-.figure.pad-below {
-  margin-bottom: 20px;
-}
-
-.figure .figure-callout {
-  position: absolute;
-  color: #fff;
-  font-weight: 500;
-  font-size: 16px;
-  line-height: 23px;
-  text-align: center;
-  background: transparent url(../images/styles/callout.png) no-repeat scroll 50% 50%;
-  padding-right: 2px;
-  width: 30px;
-  height: 29px;
-  z-index: 1000;
-}
-
-.figure .figure-callout.top {
-  top: -9px;
-}
-
-.figure .figure-callout.right {
-  right: -5px;
-}
-
-.figure-caption {
-  margin: 0 10px 20px 0;
-  font-size: 14px;
-  line-height: 20px;
-  font-style: italic;
-}
-
-/* rows of figures */
-.figure-row {
-  font-size: 0;
-  line-height: 0;
-  /* to prevent space between figures */
-}
-
-.figure-row .figure {
-  display: inline-block;
-  vertical-align: top;
-}
-
-.figure-row .figure + .figure {
-  margin-left: 10px;
-  /* reintroduce space between figures */
-}
-
-.border-img {
-  border: 1px solid #CCC;
-}
-
-.center-img {
-  margin: auto;
-  text-align: center;
-}
-.center-img img {
-  margin-bottom: 15px;
-}
-
-.figure img,
-.figure-right img,
-.figure-left img,
-.figure-center img,
-.border-img {
-  margin-bottom: 15px;
-}
-
-.figure-center {
-  margin: 32px auto 24px;
-  max-width: 100%;
-}
-
-.figure,
-.figure-right {
-  clear: right;
-  float: right;
-  margin: 10px 0 0 0;
-  padding: 0 0 0 20px;
-  max-width: 50%;
-  /* width must be defined w/ an inline style matching the image width */
-}
-
-.figure-left {
-  clear: left;
-  float: left;
-  margin: 10px 0 0 0;
-  padding: 0 20px 0 0;
-  max-width: 50%;
-  /* width must be defined w/ an inline style matching the image width */
-}
-
-@media (max-width: 719px) {
-  /* Collapse on mobile. */
-  .figure,
-  .figure-right,
-  .figure-left {
-    float: none;
-    clear: none;
-    padding: 0;
-    margin: 32px auto 24px;
-    max-width: 100%;
-  }
-}
-
-img.frame {
-  border:1px solid #DDD;
-  padding:4px;
-}
-
-p.table-caption {
-  margin: 0 0 4px 0;
-  font-size:13px;
-}
-
-p.code-caption {
-  margin-bottom: 4px;
-  font: 12px/1.5 monospace;
-}
-
-p.note, div.note,
-p.caution, div.caution,
-p.warning, div.warning {
-  padding: 0 0 0 20px;
-  border-left: 3px solid;
-  margin: 16px 0;
-}
-
-p.note, div.note {
-  border-color: #4eb9ed;
-  border-color: rgba(3, 155, 229, .7); /* #039be5 * 70% */
-}
-
-p.caution, div.caution {
-  border-color: #ffbc4c;
-  border-color: rgba(255, 160, 0, .7); /* #ffa000 * 70% */
-}
-
-p.warning, div.warning {
-  border-color: #f48684;
-  border-color: rgba(239, 83, 80, .7); /* #ef5350 * 70% */
-}
-
-div.note.design {
-  border-left: 4px solid #00bcd4;
-}
-
-div.note.develop {
-  border-left: 4px solid #ff7043;
-}
-
-div.note.distribute {
-  border-left: 4px solid #afb42b;
-}
-
-.note p, .caution p, .warning p {
-  margin:0 0 5px;
-}
-
-.note p:last-child, .caution p:last-child, .warning p:last-child {
-  margin-bottom:0;
-}
-
-.summary-table {
-  background-color:#eceff1;
-  padding:1em;
-  margin-bottom:1.5em;
-}
-
-.summary-table h5 {
-  line-height:1em;
-  font-size:.98em;
-}
-
-body.about blockquote {
-  display:block;
-  float:right;
-  width:280px;
-  font-size:20px;
-  font-style:italic;
-  line-height:24px;
-  color:#33B5E5;
-  margin:0 0 20px 30px;
-}
-
-div.design-announce p {
-  margin:0 0 10px;
-}
-
-.expandable {
-  height:34px;
-  padding-left:20px;
-  position:relative;
-}
-.expandable:before {
-  content: '';
-  background-image: url(../images/styles/disclosure_down.png);
-  background-repeat:no-repeat;
-  background-position: -12px -9px;
-  width: 20px;
-  height: 20px;
-  display: inline-block;
-  position: absolute;
-  top: 0;
-  left: 0; }
-}
-.expandable.expanded:before {
-  background-image: url(../images/styles/disclosure_up.png);
-}
-
-/* notice box for cross links between Design/Develop docs */
-a.notice-developers-video,
-a.notice-developers,
-a.notice-designers-video,
-a.notice-designers {
-  float:right;
-  clear:right;
-  width:238px;
-  min-height:50px;
-  margin:0 0 20px 20px;
-  border:1px solid #ddd;
-}
-a.notice-developers-video.wide,
-a.notice-developers.wide,
-a.notice-designers-video.wide,
-a.notice-designers.wide {
-  width:278px;
-}
-a.notice-developers-video div,
-a.notice-developers div,
-a.notice-designers-video div,
-a.notice-designers div {
-  min-height:40px;
-  background:url('../images/styles/notice-developers_2x.png') no-repeat 10px 10px;
-  background-size:40px 40px;
-  padding:10px 10px 10px 60px;
-}
-a.notice-designers div {
-  background:url('../images/styles/notice-designers_2x.png') no-repeat 10px 10px;
-  background-size:40px 40px;
-}
-a.notice-designers-video div {
-  background:url('../images/styles/notice-designers-video_2x.png') no-repeat 10px 10px;
-  background-size:40px 40px;
-}
-a.notice-developers-video div {
-  background:url('../images/styles/notice-developers-video_2x.png') no-repeat 10px 10px;
-  background-size:40px 40px;
-}
-a.notice-developers-video:hover,
-a.notice-developers:hover,
-a.notice-designers-video:hover,
-a.notice-designers:hover {
-  background:#eee;
-}
-a.notice-developers-video h3,
-a.notice-developers h3,
-a.notice-designers-video h3,
-a.notice-designers h3 {
-  font-size:13px;
-  line-height:18px;
-  font-weight:bold;
-  text-transform:uppercase;
-  color:#000 !important;
-  padding:0 0 1px;
-}
-a.notice-developers-video p,
-a.notice-developers p,
-a.notice-designers-video p,
-a.notice-designers p {
-  margin:0;
-  line-height:14px;
-}
-a.notice-developers-video.left,
-a.notice-developers.left,
-a.notice-designers-video.left,
-a.notice-designers.left {
-  margin-left:0;
-  float:left;
-}
-
-
-/* hide nested list items; companion to hideNestedLists() */
-.hide-nested li ol,
-.hide-nested li ul {
-  display:none;
-}
-
-a.header-toggle {
-  display:block;
-  float:right;
-  text-transform:uppercase;
-  font-size:.8em !important;
-  font-weight:normal;
-  margin-top:2px;
-}
-
-
-/* for IDE instruction toggle (Studio/Eclipse/Other) */
-select.ide {
-  background: transparent;
-  border: 1px solid #bbb;
-  border-left: 0;
-  border-right: 0;
-  margin: 10px 0;
-  padding: 10px 0;
-  color:#666;
-}
-select.ide,
-select.ide option {
-  font-family: inherit;
-  font-size:16px;
-  font-weight:500;
-}
-/* hide all except studio by default */
-.select-ide.eclipse,
-.select-ide.other {
-  display:none;
-}
-/* ... unless studio also includes one of the others */
-.select-ide.studio.eclipse,
-.select-ide.studio.other {
-  display:none;
-}
-
-
-/* -----------------------------------------------
-good/bad example containers
-*/
-
-div.example-block {
-  background-repeat: no-repeat;
-  background-position:10px 8px;
-  background-color:#ccc;
-  padding:4px;
-  margin:.8em auto 1.5em 2em;
-  width:260px;
-  float:right;
-}
-/* red container */
-.example-block.bad {
-  background-image: url(/images/example-bad.png);
-  background-color:#f4cccc;
-}
-/* green container */
-.example-block.good {
-  background-image: url(/images/example-good.png);
-  background-color:#d9ead3;
-}
-/* container heading div */
-#jd-content .example-block .heading {
-  font-weight:bold;
-  margin:6px 0 9px 36px;
-  padding:6px auto;
-}
-/* container image (if any) */
-#jd-content .example-block img {
-  margin:0;
-  padding:0px;
-}
-
-.example-block table {
-  margin:0;
-}
-
-/* -----------------------------------------------
-Dialog box for popup messages
-*/
-
-div.dialog {
-  height:0;
-  margin:0 auto;
-}
-
-div.dialog>div {
-  z-index:99;
-  position:fixed;
-  margin:70px 0;
-  width: 391px;
-  height: 200px;
-  background: #F7F7F7;
--moz-box-shadow: 0 0 15px rgba(0,0,0,0.5);
--webkit-box-shadow: 0 0 15px rgba(0,0,0,0.5);
-box-shadow: 0 0 15px rgba(0,0,0,0.5);
-}
-/* IE6 can't position fixed */
-* html div.dialog div { position:absolute; }
-
-
-div#deprecatedSticker {
-  display:none;
-  z-index:99;
-  position:fixed;
-  right:15px;
-  top:114px;
-  margin:0;
-  padding:1em;
-  background:#FFF;
-  border:1px solid #dddd00;
-  box-shadow:-5px 5px 10px #ccc;
-  -moz-box-shadow:-5px 5px 10px #ccc;
-  -webkit-box-shadow:-5px 5px 10px #ccc;
-}
-
-div#langMessage,
-div#naMessage {
-  display:none;
-  width:555px;
-  height:0;
-  margin:0 auto;
-}
-
-
-div#langMessage>div,
-div#naMessage div {
-  z-index:99;
-  width:450px;
-  position:fixed;
-  margin:80px 0;
-  padding:4em 4em 3em;
-  background:#FFF;
-  border:1px solid #999;
-  box-shadow:-10px 10px 40px #888;
-  -moz-box-shadow:-10px 10px 40px #888;
-  -webkit-box-shadow:-10px 10px 40px #888;
-}
-/* IE6 can't position fixed */
-* html div#langMessage>div,
-* html div#naMessage div { position:absolute; }
-
-div#naMessage strong {
-  font-size:1.1em;
-}
-
-div#langMessage .lang {
-  display:none;
-}
-
-/* --------------------------------------------------------------------------
-Slideshow Controls & Next/Prev
-*/
-.slideshow-next, .slideshow-prev {
-  width: 20px;
-  height: 36px;
-  text-indent: -1000em;
-}
-.slideshow-container {
-  margin: 2em 0;
-}
-.slideshow-container:before, .slideshow-container:after {
-  content: "";
-  display: table;
-  clear: both;
-}
-a.slideshow-next, a.slideshow-next:visited {
-
-  float: right;
-
-  background: url(../images/arrow-right.png) no-repeat 0 0
-
-}
-
-a.slideshow-prev, a.slideshow-prev:visited {
-
-  float: left;
-
-  background: url(../images/arrow-left.png) no-repeat 0 0
-
-}
-
-.slideshow-next:hover, .slideshow-prev:hover, .slideshow-next:focus, .slideshow-prev:focus {
-
-  background-position: 0 -36px
-
-}
-
-.slideshow-next:active, .slideshow-prev:active {
-
-  background-position: 0 -72px
-
-}
-.slideshow-nav {
-  width: 74px;
-  margin: 0 auto;
-}
-.slideshow-nav a, .slideshow-nav a:visited {
-  display: inline-block;
-  width: 12px;
-  height: 12px;
-  margin: 0 2px 20px 2px;
-  background: #ccc;
-  -webkit-border-radius: 50%;
-  -moz-border-radius: 50%;
-  border-radius: 50%;
-}
-.slideshow-nav a:hover, .slideshow-nav a:focus {
-
-  background: #33B5E5
-}
-
-.slideshow-nav a:active {
-
-  background: #1e799a;
-  background: #ebebeb;
-  -webkit-box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
-  -moz-box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
-  box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
-}
-.slideshow-nav a.active, .slideshow-nav a.active:active, .slideshow-nav a.active:visited {
-  background: #33B5E5
-}
-/* --------------------------------------------------------------------------
-Tabs
-*/
-ul.tabs {
-  padding: 0;
-  margin: 2em 0 0 0;
-}
-ul.tabs:before, ul.tabs:after {
-  content: "";
-  display: table;
-  clear: both;
-}
-ul.tabs li {
-  list-style-type: none;
-  float: left;
-}
-ul.tabs li a, ul.tabs li a:active, ul.tabs li a:visited {
-  display: block;
-  height: 36px;
-  line-height: 36px;
-  padding: 0 15px;
-  margin-right: 2px;
-  color: #222;
-  -moz-border-radius-topleft: 2px;
-  -moz-border-radius-topright: 2px;
-  -moz-border-radius-bottomright: px;
-  -moz-border-radius-bottomleft: px;
-  -webkit-border-radius: 2px 2px px px;
-  border-radius: 2px 2px px px;
-  border-top: solid 1px #ebebeb;
-  border-left: solid 1px #ebebeb;
-  border-right: solid 1px #ebebeb;
-  background-color: #fff;
-    background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#fafafa));
-    background-image: -webkit-linear-gradient(top, #ffffff, #fafafa);
-    background-image: -moz-linear-gradient(top, #ffffff, #fafafa);
-    background-image: -ms-linear-gradient(top, #ffffff, #fafafa);
-    background-image: -o-linear-gradient(top, #ffffff, #fafafa);
-    background-image: linear-gradient(top, #ffffff, #fafafa);
-    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff',
-EndColorStr='#fafafa');
-}
-ul.tabs li a:hover {
-  color: #33B5E5;
-}
-ul.tabs li a.selected {
-  height: 37px;
-  color: #33B5E5;
-  background-color: #f7f7f7;
-  background-image: none;
-  border-color: #ddd;
-}
-.tab-content {
-  padding: 1.2em;
-  margin: -1px 0 2em 0;
-  -webkit-border-radius: 2px;
-    -moz-border-radius: 2px;
-    border-radius: 2px;
-  border: solid 1px #ddd;
-  background: #f7f7f7;
-}
-/* --------------------------------------------------------------------------
-Feature Boxes
-*/
-.feature-box {
-  width: 291px;
-  height: 200px;
-  position: relative;
-  background: #F7F7F7;
-}
-.box-border .top, .box-border .bottom, .box-border .left, .box-border .right {
-  z-index: 100;
-  position: absolute;
-  background-color: #aaa;
-}
-.box-border .top, .box-border .bottom {
-  width: 291px;
-  height: 1px;
-}
-.dialog .box-border .top,
-.dialog .box-border .bottom { width:391px; }
-
-.box-border .left, .box-border .right {
-  width: 1px;
-  height: 8px;
-}
-.box-border .top { top: 0; left: 0 }
-.box-border .top .left { top: 1px; left: 0 }
-.box-border .top .right { top: 1px; right: 0 }
-.box-border .bottom .left { top: -8px; left: 0 }
-.box-border .bottom { top: 200px; left: 0 }
-.box-border .bottom .right { top: -8px; right: 0 }
-
-.feature-box h4,
-.dialog h4 {
-    padding: 15px 18px 10px;
-}
-
-.feature-box p,
-.dialog p {
-    margin: 10px 18px;
-    padding:0;
-}
-.feature-box .link,
-.dialog .link {
-    border-top: 1px solid #dedede;
-    bottom: 0;
-    position: absolute;
-    width: inherit;
-}
-.feature-box a, .feature-box h4,
-.dialog a, .dialog h4 {
-    -webkit-transition: color .4s ease;
-    -moz-transition: color .4s ease;
-    -o-transition: color .4s ease;
-    transition: color .4s ease;
-}
-.feature-box:hover {
-  cursor: pointer;
-}
-.feature-box:hover .box-border .top, .feature-box:hover .box-border .bottom, .feature-box:hover
-.left, .feature-box:hover .right {
-  background-color: #33B5E5;
-}
-.feature-box:hover h4, .feature-box:hover a {
-  color: #33B5E5;
-}
-/* --------------------------------------------------------------------------
-Page-Specific Styles
-*/
-.colors {
-  position: relative;
-  float: left;
-  width: 92px;
-  margin: 40px 0 20px;
-}
-.colors div {
-  color: #fff;
-  font-size: 11.5px;
-  width: 82px;
-  height: 82px;
-  margin-top:-30px;
-  line-height: 82px;
-  text-align: center;
-  border: solid 5px #fff;
-  -webkit-border-radius: 50%;
-  -moz-border-radius: 50%;
-  border-radius: 50%;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* ########### REFERENCE DOCS ################## */
-
-#packages-nav h2,
-#classes-nav h2 {
-  font-size:18px;
-  margin:0;
-  padding:0 0 0 4px;
-}
-
-/* not sure if this is needed in the ref docs, disabling for now
-.jd-descr h2 {
-  margin:16px 0;
-}
-*/
-
-/* First paragraph of a content pages is a bit larger
-   - note the very specific selector. */
-.jd-descr > p:first-child,
-.jd-descr > #tb-wrapper + p,
-.jd-descr > #qv-wrapper + p {
-  font-size: 16px;
-  margin-bottom: 16px;
-}
-
-/* page-top-right container for reference pages (holds
-links to summary tables) */
-#api-info-block {
-  font-size:12px;
-  margin:20px 0 0;
-  font-weight:normal;
-  float:right;
-  text-align:right;
-  color:#999;
-  max-width:300px;
-  font-size: 12px;
-  line-height:14px;
-}
-
-#api-info-block div.api-level {
-  font-weight:bold;
-  font-size:inherit;
-  float:none;
-  color:#222;
-  padding:0;
-  margin:0;
-}
-
-/* inheritance table */
-table.inhtable>tbody>tr>td {
-  padding-left:0;
-}
-table.inhtable>tbody>tr>td div:first-of-type {
-  padding-left:12px;
-}
-
-.jd-inheritance-table {
-  border-spacing:0;
-  margin:1em 0;
-  padding:0;
-  background-color:transparent;
-}
-.jd-inheritance-table tr td {
-  border: none;
-  margin: 0;
-  padding: 0;
-  background-color:transparent;
-}
-.jd-inheritance-table .jd-inheritance-space {
-  width:2em;
-}
-.jd-inheritance-table .jd-inheritance-interface-cell {
-  padding-left: 17px;
-}
-
-
-/* the link inside a sumtable for "Show All/Hide All" */
-.toggle-all {
-  display:block;
-  float:right;
-  font-weight:normal;
-  font-size:0.9em;
-}
-
-/* adjustments for in/direct subclasses tables */
-.jd-sumtable-subclasses {
-  margin: 1em 0 0 0;
-  max-width:968px;
-  background-color:transparent;
-}
-
-/* extra space between end of method name and open-paren */
-.sympad {
-  margin-right: 2px;
-}
-
-/* adjustments for the expando table-in-table */
-.jd-sumtable-expando {
-  margin:.5em 0;
-  padding:0;
-}
-
-/* a div that holds a short description */
-.jd-descrdiv {
-  padding:3px 1em 0 1em;
-  margin:0;
-  border:0;
-}
-
-#jd-content img.jd-expando-trigger-img {
-  padding:0 4px 4px 0;
-  margin:0;
-}
-
-.jd-sumtable-subclasses div#subclasses-direct,
-.jd-sumtable-subclasses div#subclasses-indirect {
-  /* left margin matches width of the toggle image,
-     so this section aligns with the text above */
-  margin:0 0 0 34px;
-}
-
-
-
-/********* MEMBER REF *************/
-
-
-.jd-details {
-/*  border:1px solid #669999;
-  padding:4px; */
-  margin:0 0 1em;
-}
-
-/* API reference: a container for the
-.tagdata blocks that make up the detailed
-description */
-.jd-details-descr {
-  padding:0;
-  margin:.5em .25em;
-}
-
-/* API reference: a block containing
-a detailed description, a params table,
-seealso list, etc */
-.jd-tagdata {
-  margin:.5em 1em;
-}
-
-.jd-tagdata p {
-  margin:0 0 1em 1em;
-}
-
-/* API reference: adjustments to
-the detailed description block */
-.jd-tagdescr {
-  margin:.25em 0 .75em 0;
-}
-
-.jd-tagdescr ol,
-.jd-tagdescr ul {
-  margin:0 2.5em;
-  padding:0;
-}
-
-.jd-tagdescr table,
-.jd-tagdescr img {
-  margin:.25em 1em;
-}
-
-.jd-tagdescr li {
-margin:0 0 .25em 0;
-padding:0;
-}
-
-/* API reference: heading marking
-the details section for constants,
-attrs, methods, etc. */
-h4.jd-details-title {
-  font-size:1.15em;
-  background-color: #E2E2E2;
-  margin:1.5em 0 .6em;
-  padding:3px 95px 3px 3px; /* room for api-level */
-}
-body.google h4.jd-details-title {
-  background-color: #FFF;
-  padding-top:5px;
-  border-top: 1px solid #ccc;
-}
-
-h4.jd-tagtitle {
-  padding:0;
-}
-
-h4 .normal {
-  font-weight:normal;
-}
-
-/* API reference: heading for "Parameters", "See Also", etc.,
-in details sections */
-h5.jd-tagtitle {
-  padding:0 0 .25em 0;
-  font-size:1em;
-}
-
-.jd-tagtable {
-  margin:0;
-  background-color:transparent;
-  width:auto;
-}
-
-.jd-tagtable td,
-.jd-tagtable th {
-  border:none;
-  background-color:#fff;
-  vertical-align:top;
-  font-weight:normal;
-  padding:2px 10px;
-}
-
-.jd-tagtable th {
-  font-style:italic;
-}
-
-
-/* Inline api level indicator for methods */
-div.api-level {
-  font-size:.8em;
-  font-weight:normal;
-  color:#999;
-  float:right;
-  padding:0 8px 0;
-  margin-top:-35px;
-}
-
-table.jd-tagtable td,
-table.jd-tagtable th {
-  background-color:transparent;
-}
-
-table.jd-tagtable th {
-  color:inherit;
-}
-
-/************ STICKY NAV BAR ******************/
-
-#context {
-  clear: both;
-  padding-top: 14px;
-}
-#context .breadcrumb {
-  float: left;
-  margin-bottom: 10px;
-}
-#context .util {
-  float: right;
-  margin-right: 20px;
-}
-
-.breadcrumb {
-  list-style: none;
-  margin: 0;
-  padding: 0;
-  position: relative;
-}
-.breadcrumb li {
-  float: left;
-  padding: 0 20px 0 0;
-  color: #000;
-  white-space: nowrap;
-}
-.breadcrumb li a {
-  color: #000;
-}
-.breadcrumb li:after {
-  content: url(../images/breadcrumb.png);
-  position: relative;
-  top: 1px;
-  left: 10px;
-  width: 5px;
-  height: 10px;
-}
-.breadcrumb li.current {
-  font-weight: 700;
-}
-.breadcrumb li.current:after {
-  display: none;
-}
-
-/* offset the empty <a name=""> tags to account for sticky nav */
-body.reference a[name]:not(.nav-start-marker):empty {
-  visibility: hidden;
-  display: block;
-  position: relative;
-  top: -56px;
-}
-
-.nav-start-marker {
-  position: absolute;
-}
-
-/* Quicknav */
-.btn-quicknav {
-  width:20px;
-  height:28px;
-  float:left;
-  margin-left:6px;
-  padding-right:10px;
-  position:relative;
-  cursor:pointer;
-  border-right:1px solid #CCC;
-}
-
-.btn-quicknav a {
-  zoom:1;
-  position:absolute;
-  top:13px;
-  left:5px;
-  display:block;
-  text-indent:-9999em;
-  width:10px;
-  height:5px;
-  background:url(../images/quicknav_arrow.png) no-repeat;
-}
-
-.btn-quicknav a.arrow-active {
-  background-position: 0 -5px;
-  display:none;
-}
-
-#header-wrap.quicknav a.arrow-inactive {
-  display:none;
-}
-
-.btn-quicknav.active a.arrow-active {
-  display:block;
-}
-
-#header-wrap.quicknav .nav-x li {
-  min-width:160px;
-  margin-right:20px;
-}
-
-#header-wrap.quicknav li.last {
-  margin-right:0px;
-}
-
-#quicknav {
- float:none;
- clear:both;
- margin-left:0;
- margin-top:-30px;
- display:none;
- overflow:hidden;
-}
-
-#header-wrap.quicknav #quicknav {
-
-}
-
-#quicknav ul {
-  margin:10px 0;
-  padding:0;
-}
-
-#quicknav ul li.about {
-  border-top:1px solid #9933CC;
-}
-
-#quicknav ul li.design {
-  border-top:1px solid #33b5e5;
-}
-
-#quicknav ul li.develop {
-  border-top:1px solid #FF8800;
-}
-
-#quicknav ul li.distribute {
-  border-top:1px solid #99cc00;
-}
-
-#quicknav ul li {
-  display:block;
-  float:left;
-  margin:0 20px 0 0;
-  min-width:140px;
-}
-
-#quicknav ul li.last {
-  margin-right:0px;
-}
-
-#quicknav ul li ul li {
-  float:none;
-}
-
-#quicknav ul li ul li a {
-  color:#222;
-}
-
-#quicknav ul li li ul,
-#quicknav ul li li ul li {
-  margin:0;
-}
-
-#quicknav ul li li ul li:before {
-  content:"\21B3";
-}
-
-#header-wrap {
-   -webkit-transition: all 0.25s ease-out;
-      -moz-transition: all 0.25s ease-out;
-       -ms-transition: all 0.25s ease-out;
-        -o-transition: all 0.25s ease-out;
-           transition: all 0.25s ease-out;
-
-}
-
-#header-wrap.quicknav {
-  height:216px;
-
-}
-
-.moremenu {
-  float: right;
-  position: relative;
-  width: 50px;
-  height:28px;
-  display: block;
-  margin-top:-3px;
-  margin-bottom:7px;
-  overflow:hidden;
-  -webkit-transition: width 0.25s ease;
-     -moz-transition: width 0.25s ease;
-       -o-transition: width 0.25s ease;
-          transition: width 0.25s ease;
-}
-
-.moremenu #more-btn {
-  width:40px;
-  height:28px;
-  background:url(../images/icon_more.png) no-repeat;
-  border-left:1px solid #CCC;
-  float:left;
-  cursor:pointer;
-}
-
-.moremenu:hover #more-btn {
-  background-position:0 -28px;
-}
-
-.morehover {
-  position:absolute;
-  right:6px;
-  top:-9px;
-  width:40px;
-  height:35px;
-  z-index:99;
-  overflow:hidden;
-
-  -webkit-opacity:0;
-     -moz-opacity:0;
-       -o-opacity:0;
-          opacity:0;
-
-  -webkit-transform-origin:100% 0%;
-     -moz-transform-origin:100% 0%;
-       -o-transform-origin:100% 0%;
-          transform-origin:100% 0%;
-
-  -webkit-transition-property: -webkit-opacity;
-  -webkit-transition-duration: .25s;
-  -webkit-transition-timing-function:ease;
-
-  -moz-transition-property: -moz-opacity;
-  -moz-transition-duration: .25s;
-  -moz-transition-timing-function:ease;
-
-  -o-transition-property: -o-opacity;
-  -o-transition-duration: .25s;
-  -o-transition-timing-function:ease;
-
-  transition-property: opacity;
-  transition-duration: .25s;
-  transition-timing-function:ease;
-}
-
-.morehover:hover,
-.morehover.hover {
-  opacity:1;
-  height:385px;
-  width:268px;
-  -webkit-transition-property:height,  -webkit-opacity;
-}
-
-.morehover .top {
-  width:268px;
-  height:39px;
-  background:url(../images/more_top.png) no-repeat;
-}
-
-.morehover .mid {
-  width:228px;
-  background:url(../images/more_mid.png) repeat-y;
-  padding:10px 20px 0 20px;
-}
-
-.morehover .mid .header {
-  border-bottom:1px solid #ccc;
-  font-weight:bold;
-}
-
-.morehover .bottom {
-  width:268px;
-  height:6px;
-  background:url(../images/more_bottom.png) no-repeat;
-}
-
-.morehover ul {
-  margin:10px 10px 20px 0;
-}
-
-.morehover ul li {
-  list-style:none;
-}
-
-.morehover ul li.active a,
-.morehover ul li.active a:hover {
-  color:#222 !important;
-}
-
-.morehover ul li.active img {
-  margin-right:4px;
-}
-
-
-
-
-/* MARQUEE */
-.slideshow-container {
-  width:100%;
-  overflow:hidden;
-  position:relative;
-}
-.slideshow-container .slideshow-prev {
-  position:absolute;
-  top:50%;
-  left:0px;
-  margin-top:-36px;
-  z-index:99;
-}
-.slideshow-container .slideshow-next {
-  position:absolute;
-  top:50%;
-  margin-top:-36px;
-  z-index:99;
-  right:0px;
-}
-
-.slideshow-container .pagination {
-  position:absolute;
-  bottom:20px;
-  width:100%;
-  text-align:center;
-  z-index:99;
-}
-.slideshow-container .pagination ul {
-  margin:0;
-}
-.slideshow-container .pagination ul li{
-  display: inline-block;
-  width:12px;
-  height:12px;
-  text-indent:-8000px;
-  list-style:none;
-  margin: 0 3px;
-  border-radius:6px;
-  background-color:#ddd;
-  cursor:pointer;
-        -webkit-transition:color .5s ease-in;
-        -moz-transition:color .5s ease-in;
-        -o-transition:color .5s ease-in;
-        transition:color .5s ease-in;
-}
-.slideshow-container .pagination ul li:hover {
-  background-color:#bbb;
-}
-.slideshow-container .pagination ul li.active {
-  background-color:#6ab344;
-}
-.slideshow-container .pagination ul li.active:hover {
-  background-color:#6ab344;
-}
-.slideshow-container ul li {
-  display:inline;
-  list-style:none;
-}
-
-
-#landing h1 {
-  padding:17px 0 20px 0 !important;
-}
-
-a.download-sdk {
-    float:right;
-    margin:-10px 0;
-    height:30px;
-    padding-top:4px;
-    padding-bottom:0px;
-}
-
-#searchResults.wrap {
-    max-width:940px;
-    border-bottom:1px solid #e5e5e5;
-}
-
-#searchResults.wrap #leftSearchControl {
-  min-height:700px
-}
-
-
-
-
-
-
-
-
-
-
-/*
- * CSS Styles that are needed by jScrollPane for it to operate correctly.
- */
-
-.jspContainer {
-  overflow: hidden;
-  position: relative;
-}
-
-.jspPane {
-  position: absolute;
-  width:100% !important; /* to avoid cut-off api names in reference in horiz scroll */
-}
-
-.jspVerticalBar {
-  position: absolute;
-  top: 0;
-  right: 0;
-  width: 4px;
-  height: 100%;
-  background: #f5f5f5;
-}
-
-.jspHorizontalBar {
-  position: absolute;
-  bottom: 0;
-  left: 0;
-  width: 100%;
-  height: 4px;
-  background: #f5f5f5;
-}
-
-.jspVerticalBar *,
-.jspHorizontalBar * {
-  margin: 0;
-  padding: 0;
-}
-.jspCap {
-  display: block;
-}
-
-.jspVerticalBar .jspCap {
-  height: 4px;
-}
-
-.jspHorizontalBar .jspCap {
-  width: 0;
-  height: 100%;
-}
-
-.jspHorizontalBar .jspCap {
-  float: left;
-}
-
-.jspTrack {
-  position: relative;
-}
-
-.jspDrag {
-  background: #ccc;
-  position: relative;
-  top: 0;
-  left: 0;
-  cursor: pointer;
-}
-
-.jspDrag:hover,
-.jspDrag:active {
-  border-color: #09c;
-  background-color: #4cadcb;
-  background-image: -webkit-gradient(linear, left top, right top, from(#5dbcd9), to(#4cadcb));
-  background-image: -webkit-linear-gradient(left, #5dbcd9, #4cadcb);
-  background-image: -moz-linear-gradient(left, #5dbcd9, #4cadcb);
-  background-image: -ms-linear-gradient(left, #5dbcd9, #4cadcb);
-  background-image: -o-linear-gradient(left, #5dbcd9, #4cadcb);
-  background-image: linear-gradient(left, #5dbcd9, #4cadcb);
-  filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#5dbcd9', EndColorStr='#4cadcb');
-}
-
-.jspHorizontalBar .jspTrack,
-.jspHorizontalBar .jspDrag {
-  float: left;
-  height: 100%;
-}
-
-.jspArrow {
-  background: #999;
-  text-indent: -20000px;
-  display: block;
-  cursor: pointer;
-}
-
-.jspArrow.jspDisabled {
-  cursor: default;
-  background: #ccc;
-}
-
-.jspVerticalBar .jspArrow {
-  height: 16px;
-}
-
-.jspHorizontalBar .jspArrow {
-  width: 16px;
-  float: left;
-  height: 100%;
-}
-
-.jspVerticalBar .jspArrow:focus {
-  outline: none;
-}
-
-.jspCorner {
-  float: left;
-  height: 100%;
-}
-
-/* Yuk! CSS Hack for IE6 3 pixel bug :( */
-* html .jspCorner {
-  margin: 0 -3px 0 0;
-}
-/******* end of jscrollpane *********/
-
-
-
-
-
-/************ DEVELOP HOMEPAGE ******************/
-
-/* Slideshow */
-.slideshow-develop {
-  height: 316px;
-  width: 940px;
-  position: relative;
-  overflow:hidden;
-}
-.slideshow-develop .frame {
-  width: 940px;
-  height: 316px;
-}
-.slideshow-develop img.play {
-  max-width:350px;
-  max-height:240px;
-  margin:20px 0 0 90px;
-  -webkit-transform: perspective(800px ) rotateY( 35deg );
-  box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
-  -moz-box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
-  -webkit-box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
-}
-.slideshow-develop img.play.no-shadow {
-    box-shadow: none;
-    -moz-box-shadow: none;
-    -webkit-box-shadow: none;
-}
-.slideshow-develop img.play.no-transform {
-  -webkit-transform: none;
-}
-.slideshow-develop a.slideshow-next {
-  background: url(../images/arrow-right-develop.png);
-}
-.slideshow-develop a.slideshow-prev {
-  background: url(../images/arrow-left-develop.png);
-}
-.slideshow-develop .content-right {
-  float: left;
-}
-.slideshow-develop .content-right h2 {
-  padding:0;
-  padding-bottom:10px;
-  border:none;
-  font-size:24px;
-}
-.slideshow-develop .item {
-  height: 300px;
-  width: 940px;
-}
-.slideshow-develop .pagination ul li.active {
-  background-color: #F80;
-}
-.slideshow-develop .pagination ul li.active:hover {
-  background-color: #F80;
-}
-.slideshow-develop .item hr {
-  margin:5px 0 10px;
-}
-.slideshow-develop .item p {
-  margin:10px 0;
-}
-.slideshow-develop .item p.title-intro {
-  position:absolute;
-  margin:0;
-}
-
-/* Feeds */
-.feed ul {
-  margin: 0;
-}
-.feed .feed-nav {
-  height: 25px;
-  border-bottom: 1px solid #CCC;
-}
-.feed .feed-nav li {
-  list-style: none;
-  float: left;
-  height: 21px; /* +4px bottom border = 25px; same as .feed-nav */
-  margin-right: 25px;
-  cursor: pointer;
-}
-.feed .feed-nav li.active {
-  color: #000;
-  border-bottom: 4px solid #F80;
-}
-.feed .feed-container {
-  overflow: hidden;
-  width: 460px;
-}
-.feed .feed-container .feed-frame {
-  width: 1000px;
-}
-.feed .feed-container .feed-frame ul {
-  float: left;
-  width:460px;
-}
-.feed .feed-container .feed-frame ul ul {
-  float: none;
-  margin:10px 0 0 30px;
-}
-.feed .feed-container .feed-frame li {
-  list-style: none;
-  margin: 20px 0 20px 0;
-  width: 460px;
-  height:93px;
-}
-.feed .feed-container .feed-frame li.playlist {
-  height:auto;
-}
-.feed .feed-container .feed-frame li.playlist a {
-  height:93px;
-  display:block;
-}
-.feed .feed-container .feed-frame li.more {
-  height:20px;
-  margin:10px 0 5px 5px;
-}
-.feed .feed-container .feed-frame li.more a {
-  height:inherit;
-}
-.feed .feed-container .feed-frame li.playlist-video {
-  list-style: none;
-  margin: 0;
-  width: 460px;
-  height:55px;
-  font-size:12px;
-}
-.feed .feed-container .feed-frame li.playlist-video a {
-  height:45px;
-  padding:5px;
-}
-.feed .feed-container .feed-frame li.playlist-video h5 {
-  font-size:12px;
-  line-height:13px;
-  padding:0;
-}
-.feed .feed-container .feed-frame li.playlist-video p {
-  margin:5px 0 0;
-  line-height:15px;
-}
-.feed-container .feed-frame div.feed-image {
-  float: left;
-  border: 1px solid #999;
-  margin:0 20px 0 0;
-  width:122px;
-  height:92px;
-  background:url('../images/blog-default.png') no-repeat 0 0;
-  background-size:180px;
-}
-#jd-content .feed .feed-container .feed-frame li img {
-  float: left;
-  border: 1px solid #999;
-  margin:0 20px 0 0;
-  width:122px;
-  height:92px;
-}
-#jd-content .feed .feed-container .feed-frame li.playlist-video img {
-  width:inherit;
-  height:inherit;
-}
-
-.feed .feed-container .feed-frame li a,
-.feed .feed-container .feed-frame li a:active {
-  color:#555 !important;
-}
-
-.feed .feed-container .feed-frame li a:hover,
-.feed .feed-container .feed-frame li a:hover * {
-  color:#7AA1B0 !important;
-}
-
-/* Video player */
-#player-wrapper {
-  display:none;
-  margin: -1px auto 0;
-  position: relative;
-  max-width: 940px;
-  height: 0px;
-}
-#player-frame {
-  background: #EFEFEF;
-  border: 1px solid #CCC;
-  padding: 0px 207px;
-  z-index: 10; /* stay above marque, but below search suggestions */
-  width: 525px;
-  height: 330px;
-  position: relative;
-}
-#player-frame .close {
-  position: absolute;
-  right: 8px;
-  bottom: 4px;
-  width: 16px;
-  height: 16px;
-  margin: 0;
-  text-indent: -1000em;
-  top: 6px;
-  background: url(../images/close.png) no-repeat 0 0;
-  z-index:9999;
-}
-#player-frame .close:hover, #player-frame .close:focus {
-  background-position: -16px 0;
-  cursor:pointer;
-}
-
-
-
-/************ DEVELOP TOPIC CONTAINERS ************/
-
-.landing-banner,
-.landing-docs {
-  margin:20px 0;
-}
-.landing-banner > div:first-child,
-.landing-docs > div:first-child,
-.landing-docs > .col-12 {
-  margin-left:0;
-  min-height:280px;
-}
-.landing-banner.short > div {
-  min-height:50px;
-}
-.landing-banner > div:last-child,
-.landing-docs > div:last-child,
-.landing-docs > .col-12 {
-  margin-right:0;
-}
-
-.landing-banner > div > *:last-child {
-  margin-bottom:0;
-}
-.landing-banner h1 {
-  padding-top:16px;
-  padding-bottom:24px;
-}
-.landing-docs,
-.landing-banner {
-  clear:both;
-  overflow:hidden;
-}
-.landing-docs h3 {
-  font-size:14px;
-  line-height:21px;
-  color:#555;
-  text-transform:uppercase;
-  border-bottom:1px solid #CCC;
-  padding:0 0 20px;
-}
-.landing-docs a {
-  color:#333 !important;
-}
-
-.landing-docs a:hover,
-.landing-docs a:hover * {
-  color:#7AA1B0 !important
-}
-
-.landing-docs .normal-links a {
-  color:#039BE5 !important;
-}
-
-.plusone {
-  float:right;
-}
-
-
-
-.next-docs {
-  border-top:1px solid #ccc;
-  margin:40px 0 0;
-  padding:5px 0 0;
-  clear:left;
-  overflow:hidden;
-}
-.next-docs div:first-child {
-  margin-left:0;
-}
-.next-docs div:last-child {
-  margin-right:0;
-}
-
-.next-docs h2 {
-  font-size:14px;
-  line-height:21px;
-  color:#555;
-  text-transform:uppercase;
-  border-bottom:none;
-  padding:5px 0 1em;
-}
-
-
-
-/************* HOME/LANDING PAGE *****************/
-
-.slideshow-home {
-  height: 500px;
-  width: 940px;
-  border-bottom: 1px solid #CCC;
-  position: relative;
-  margin: 0;
-}
-.slideshow-home .frame {
-  width: 940px;
-  height: 500px;
-}
-.slideshow-home .content-left {
-  float: left;
-  text-align: center;
-  vertical-align: center;
-  margin: 0 0 0 35px;
-}
-.slideshow-home .content-right {
-  margin: 80px 0 0 0;
-}
-.slideshow-home .content-right p {
-  margin-bottom: 10px;
-}
-.slideshow-home .content-right p:last-child {
-  margin-top: 15px;
-}
-.slideshow-home .content-right h1 {
-  padding:0;
-}
-.slideshow-home .item {
-  height: 500px;
-  width: 940px;
-}
-.home-sections {
-  padding: 30px 20px 20px;
-  margin: 20px 0;
-  background: -webkit-linear-gradient(top, #F6F6F6,#F9F9F9);
-}
-.home-sections ul {
-  margin: 0;
-}
-.home-sections ul li {
-  float: left;
-  display: block;
-  list-style: none;
-  width: 170px;
-  height: 35px;
-  border: 1px solid #ccc;
-  background: white;
-  margin-right: 10px;
-  border-radius: 1px;
-  -webkit-border-radius: 1px;
-  -moz-border-radius: 1px;
-  box-shadow: 1px 1px 5px #EEE;
-  -webkit-box-shadow: 1px 1px 5px #EEE;
-  -moz-box-shadow: 1px 1px 5px #EEE;
-  background: white;
-}
-.home-sections ul li:hover {
-  background: #F9F9F9;
-  border: 1px solid #CCC;
-}
-.home-sections ul li a,
-.home-sections ul li a:hover {
-  font-weight: bold;
-  margin-top: 8px;
-  line-height: 18px;
-  float: left;
-  width: 100%;
-  text-align: center;
-  color: #039BE5 !important;
-}
-.home-sections ul li a {
-  font-weight: bold;
-  margin-top: 8px;
-  line-height: 18px;
-  float: left;
-  width:100%;
-  text-align:center;
-}
-.home-sections ul li img {
-  float: left;
-  margin: -8px 0 0 10px;
-}
-.home-sections ul li.last {
-  margin-right: 0px;
-}
-
-/************ DISTRIBUTE PAGES ******************/
-
-.article-detail #body-content {
-  padding-top: 10px;
-}
-
-/* A container for grid sets with uppercase h3 and rule */
-.dynamic-grid h3 {
-  font-size:14px;
-  line-height:21px;
-  color:#555;
-  text-transform:uppercase;
-  border-bottom:1px solid #CCC;
-  padding:8px 0 14px 1px;
-  clear:both;
-}
-
-.top-right-float {
-  float: right;
-}
-
-.clearfloat {
-  float: none;
-  clear: both;
-}
-
-
-/**
- * UTILITIES
- */
-
-
-.border-box {
-  box-sizing: border-box;
-}
-
-.vertical-center-outer {
-  display: table;
-  height: 100%;
-  width: 100%;
-}
-
-.vertical-center-inner {
-  display: table-cell;
-  vertical-align: middle;
-}
-
-/**
- * TYPE STYLES
- */
-
-.landing-h1 {
-  color: #44555d;
-  font-weight: 300;
-  font-size: 56px;
-  line-height: 80px;
-  text-align: center;
-  letter-spacing: -1px;
-  padding-bottom: 6px;
-}
-
-.landing-pre-h1 {
-  font-weight: 400;
-  font-size: 28px;
-  color: #93B73F;
-  line-height: 36px;
-  text-align: center;
-  letter-spacing: -1px;
-  text-transform: uppercase;
-}
-
-.landing-h1.hero {
-  text-align: left;
-  color: #fff;
-}
-
-.landing-h2 {
-  font-weight: 300;
-  font-size: 42px;
-  line-height: 64px;
-  text-align: center;
-}
-
-.landing-subhead {
-  color: #78868d;
-  font-size: 20px;
-  font-weight: 300;
-  line-height: 32px;
-  text-align: center;
-}
-.landing-subhead.hero {
-  text-align: left;
-  color: white;
-}
-
-.landing-hero-description {
-  text-align: left;
-  margin: 1em 0;
-}
-
-.landing-hero-description p {
-  font-weight: 300;
-  margin: 0;
-  font-size: 18px;
-  line-height: 24px;
-}
-
-.landing-body .landing-small {
-  font-size: 14px;
-  line-height: 19px;
-}
-
-.landing-body.landing-align-center {
-  text-align: center;
-}
-
-.landing-align-left {
-  text-align: left;
-}
-
-/**
- * LAYOUT
- */
-
-.landing-section {
-  background: #eceff1;
-  clear: both;
-  padding: 80px 20px 80px;
-  margin: 0 -20px;
-  text-rendering: optimizeLegibility;
-}
-
-@media (max-width: 719px) {
-  .landing-section {
-    margin-left: -10px;
-    margin-right: -10px;
-    padding-left: 10px;
-    padding-right: 10px;
-  }
-}
-
-.landing-short-section {
-  padding: 40px 10px 28px;
-}
-
-.landing-gray-background {
-  background-color: #b0bec5;
-}
-
-.landing-white-background {
-  background-color: white;
-}
-
-.landing-red-background {
-  color: white;
-  background-color: hsl(8, 70%, 54%);
-}
-
-.landing-red-background .landing-h1 {
-  color: white;
-}
-
-.landing-red-background .landing-subhead {
-  color: hsl(8, 71%, 84%);
-  text-align: left;
-}
-
-
-.preview-hero {
-  height: calc(100vh - 128px);
-  min-height: 504px;
-  padding-top: 0;
-  padding-bottom: 0;
-  background-image: url(../../preview/images/hero.jpg);
-  background-size: cover;
-  background-position: right center;
-  color: white;
-  position: relative;
-  overflow: hidden;
-}
-
-.wear-hero {
-  height: calc(100vh - 128px);
-  min-height: 504px;
-  padding-top: 0;
-  padding-bottom: 0;
-  background-image: url(../../wear/images/hero.jpg);
-  background-size: cover;
-  background-position: top center;
-  color: white;
-  position: relative;
-  overflow: hidden;
-}
-
-.tv-hero {
-  height: calc(100vh - 128px);
-  min-height: 504px;
-  padding-top: 0;
-  padding-bottom: 0;
-  background-image: url(../../tv/images/hero.jpg);
-  background-size: cover;
-  background-position: right center;
-  color: white;
-  position: relative;
-  overflow: hidden;
-}
-
-.auto-hero {
-  height: calc(100vh - 128px);
-  min-height: 504px;
-  padding-top: 0;
-  padding-bottom: 0;
-  background-image: url(../../auto/images/hero.jpg);
-  background-size: cover;
-  background-position: right center;
-  color: white;
-  position: relative;
-  overflow: hidden;
-}
-
-.landing-hero-scrim {
-  background: black;
-  height: 100%;
-  left: 0;
-  position: absolute;
-  opacity: .2;
-  width: 100%;
-}
-
-.landing-hero-wrap {
-  margin: 0 auto;
-  max-width: 940px;
-  clear: both;
-  height: 100%;
-  position: relative;
-}
-
-.landing-section-header {
-  margin-bottom: 40px;
-}
-
-.landing-hero-wrap .landing-section-header {
-  margin-bottom: 16px;
-}
-
-.landing-body {
-  font-size: 18px;
-  line-height: 24px;
-}
-
-.landing-video-link {
-  white-space: nowrap;
-  display: inline-block;
-  padding: 16px 32px 16px 82px;
-  font-size: 18px;
-  font-weight: 400;
-  line-height: 24px;
-  cursor: pointer;
-  color: hsla(0, 0%, 100%, .8);
-  -webkit-user-select: none;
-     -moz-user-select: none;
-       -o-user-select: none;
-  user-select: none;
-  -webkit-transition: .2s color ease-in-out;
-     -moz-transition: .2s color ease-in-out;
-       -o-transition: .2s color ease-in-out;
-  transition: .2s color ease-in-out;
-}
-
-.landing-video-link:before {
-  height: 64px;
-  width: 64px;
-  display: inline-block;
-  background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAFuklEQVR42u2dXWgcVRSAV9LWtBBTTZVWUhNqEQtq1QeroDRKFRFsROqTYPuo+JCiIoJKFC0USqlUfCiowRcfrBgVUUElefAPkW5T8aeaGn9aRbFsjP0x2cx8PuRMvFxmdjeb2Z17Z8+B85DsZPbO+eaec3/OPSkABdXsVI2gABSAqgJQAKoKQAGoKgAFoKoAFICqAlAAqgpAAai6DqDRAiwDeoFtwB7gPaAInABKwKToCWAMeB/YDdwJrAWWNLh9+QMAXABsBQ4A3wFTwAxQBmaBAAhjNJDPy3L938BXwAvArUCHAkh+kCXAVcA+YBw4bRg7MngtkgTlDPA98CywHmhTAP8/xCbgVeAvMZZpwDQllN7xB/AysKGlAQAXAvuBkzW85UVgCBgENlfQQbmuWAXELPAnsAvoaikAQBtwh/j3coLhS2LIfqCzzu/plL8fkvvFgZiR4L2lHrfkHQBgpQTFUwmGnwC212v0KjC2y/3jQPwDPA+05xYAcBHwubx1YZzhC02QBBBRbxgBzssdAOBy4JgRZE0ZTPuNr7FHDCbEhqNAd24AAN0yUbID7QSwsZChABut3hANXY8Bq70HIMb/Ocb4w81+66v0hmGrN0QQ1ngLQJYRvpWHMWWo4KDIaMnuCcVKgdlZAGL8t2J8vpPGrwChDLyWBMFlAA8D0z4ZvwKEs8D93gCQEc9Jy/jFgkdizaRDGUSs8wXAu1bQLQE9ngHosWbPAXDQeQAypT9rBd3+gociyxi2K9riLABZUj5iuZ6RgsciM2OzFxw2A7JrAO6VwGtKTwpG+Anoy9AVmb3gDHCPcwCAFcChRox6jPu9CazMeFQUAKNRL3AJwE2yopjq228BQPZ/d2bcCyaBTa4BeNGa8Q6naIA4GQWubiKEYWvBbp8zAGQt5VfL/fQ3GEAkTzXDLVkjokA2k5a7AuA2GaLNj/tTfvhq0pQgbcwLQtlQusYVALtlzSR191MjADNI9zbJDZWBR10BMGr5/4GMADQ0SAMDlht62xUAxy0AmzMEEMnhtIO0ZF2YAH5wITd0hQw/5wE04M1bjDyXZpC2hqMlYGnWAHqBf40APOEYgChI35VSWyasWfGqrAH0WVkOIw4CSC1IG2tDoSy7XJE1gPs8ArDoIG0BmJGk30wBDHgGYFFBOgbAtqwB7GxxAHerC8rOBU0Dt2gQzjYIb8gawDor+6HVhqFdrkzEwhabiAVOTMSkUb+06FLEUVfWgj5q0cW4g64AeNo66ZLlcnTDNmesBN4y8KArAG6QU42ttCEzBVzpCoAO4EfLDeV5SzIEvgHaXdqUP2BlQud1Ux55zj2uZUX02cPRnKalRLmu17qYmPWF5YbymJgVAh8Ay5wCII3ZEZOYm6fURGT2u9X43Mnk3CDHybmfmRVYXExPv9nKEcpLejqSC3SjdY2TBzTesHqB7wc0onTEV2KucxLApXKkJy9HlAI5anuJFwCkYQ/EuCJfD+mdBnYkXOssgHY53un7MdVZ4CVgqVcADAhjMafkfTioHc14P04yvvMApIEXy5F/+7S8y6UKolPyR4BVVf7Wi2IdawwIPhTrmAW+rmZ8bwBIQ7vloXwoVzNWS6UUrwAYy9YfOlqwKZDkgneA5Qu4l3cly84F9sqGhislywLmaozuYoGFXr0DII1ukxP1hxJ6QzR7HqLxRfumZaRzXZ3f4XXZyi7gCeB3kqsnzs+kSb9s5XHgMeD8RTxDLgq3rmeuYuFvNYCoR8wqujNi+L3UWBcu9wAMt3QZ8LiMlk5RuU50teq6kcEDgTolveIRYHUQBOek1O5cFu/ukLz7/ZJgNSm+OirebWpgaPS7slxfAr4EngGuX8jopqUBxGzyrAVuB54EXgc+lV4yLhO8cfn5E+ZqUD8kBu9sQvv0Hzj4rmoEBaAAVBWAAlBVAApAVQEoAFUFoABUFYACUFUACkC1CfofXVRJocowZVYAAAAASUVORK5CYII=);
-  background-size: contain;
-  position: absolute;
-  content: "";
-  opacity: .7;
-  margin-top: -19px;
-  margin-left: -64px;
-  -webkit-transition: .2s opacity ease-in-out;
-     -moz-transition: .2s opacity ease-in-out;
-       -o-transition: .2s opacity ease-in-out;
-  transition: .2s opacity ease-in-out;
-}
-
-.landing-video-link:hover {
-  color: hsla(0, 0%, 100%, 1);
-}
-
-.landing-video-link:hover:before {
-  opacity: 1;
-}
-
-.landing-social-image {
-  float: left;
-  margin-right: 14px;
-  height: 64px;
-  width: 64px;
-}
-
-.landing-social-copy {
-  padding-left: 78px;
-}
-
-.landing-scroll-down-affordance {
-  position: absolute;
-  bottom: 0;
-  width: 100%;
-  text-align: center;
-  z-index: 10;
-}
-
-.landing-down-arrow {
-  padding: 24px;
-  display: inline-block;
-  opacity: .5;
-  -webkit-transition: .2s opacity ease-in-out;
-     -moz-transition: .2s opacity ease-in-out;
-       -o-transition: .2s opacity ease-in-out;
-  transition: .2s opacity ease-in-out;
-
-  -webkit-animation-name: pulse-opacity;
-  -webkit-animation-duration: 4s;
-}
-
-.landing-down-arrow:hover {
-  opacity: 1;
-}
-
-.landing-down-arrow img {
-  height: 28px;
-  width: 28px;
-  margin: 0 auto;
-  display: block;
-}
-
-.landing-divider {
-  display: inline-block;
-  height: 2px;
-  background-color: white;
-  position: relative;
-  margin: 10px 0;
-}
-
-/* 3 CLOLUMN LAYOUT */
-
-.landing-breakout {
-  margin-top: 40px;
-  margin-bottom: 40px;
-}
-
-.landing-breakout img {
-  margin-bottom: 20px;
-}
-
-.landing-partners img {
-  margin-bottom: 20px;
-}
-
-.landing-breakout p {
-  padding: 0 23px;
-}
-
-.landing-breakout.landing-partners img {
-  margin-bottom: 20px;
-}
-
-/**
- * ANIMATION
- */
-
-@-webkit-keyframes pulse-opacity {
-  0% {
-    opacity: .5;
-  }
-  20% {
-    opacity: .5;
-  }
-  40% {
-    opacity: 1;
-  }
-  60% {
-    opacity: .5;
-  }
-  80% {
-    opacity: 1;
-  }
-  100% {
-    opacity: .5;
-  }
-}
-
-
-/******************
-Styles for d.a.c/index:
-*******************/
-
-
-
-/* Generic full screen carousel styling to be used across pages. */
-.fullscreen-carousel {
-  margin: 0 -20px;
-  overflow: hidden;
-  position: relative;
-}
-
-.fullscreen-carousel-content {
-  width: 100%;
-  height: 100%;
-  position: relative;
-  display: table; /* For vertical centering */
-}
-
-.fullscreen-carousel .vcenter {
-  display: table-cell;
-  vertical-align: middle;
-  position: relative;
-}
-
-.fullscreen-carousel .vcenter > div {
-  margin: 10px auto;
-}
-
-/* Styles for the full-bleed hero image type. */
-.fullscreen-carousel .hero, .fullscreen-carousel .hero h1 {
-  color: #fff;
-}
-
-.fullscreen-carousel .hero h1 {
-  font-weight: 300;
-  font-size: 60px;
-  line-height: 68px;
-  letter-spacing: -1px;
-  padding-top: 0;
-}
-
-.fullscreen-carousel .hero p {
-  font-weight: 300;
-  font-size: 18px;
-  line-height: 24px;
-}
-
-.fullscreen-carousel .hero .hero-bg {
-  background-size: cover;
-  width: 100%;
-  height: 100%;
-  position: absolute;
-  left: 0px;
-  top: 0px;
-}
-
-
-/* Full screen carousel styling for the resource flow layout type of content */
-.fullscreen-carousel .resource-flow-layout:after {
-  height: 0; /* Dont know why this is set at 10 in default.css */
-}
-
-.fullscreen-carousel .resource-flow-layout {
-  margin-bottom: 20px;
-}
-
-
-
-/* Generic Tab carousel styling to be used across multiple pages. */
-
-.tab-carousel .tab-nav {
-  list-style: none;
-  position: relative;
-  text-align: center;
-}
-
-.tab-carousel .tab-nav li {
-  display: inline-block;
-  font-size: 22px;
-  font-weight: 400;
-  line-height: 50px;
-  list-style: none;
-  margin: 0;
-  padding: 0 25px;
-  position: relative;
-}
-
-.tab-carousel .tab-nav li a,
-.tab-carousel .tab-nav li a:hover {
-  color: #333 !important;
-  padding: 10px 10px 13px 10px;
-  position: relative;
-  z-index: 1000;
-}
-
-.tab-carousel .tab-nav li:after {
-  background: #ddd;
-  bottom: 0;
-  content: '';
-  height: 4px;
-  left: 0;
-  position: absolute;
-  width: 100%;
-  z-index: 0;
-}
-
-.tab-carousel .tab-nav .highlight {
-  position: absolute;
-  height: 4px;
-  width: 100px;
-  bottom: 0;
-  background: #33b5e5;
-}
-
-.tab-carousel .tab-carousel-content {
-  position: relative;
-  overflow: hidden;
-  white-space: nowrap;
-}
-
-.tab-carousel .tab-carousel-content [data-tab] {
-  display: inline-block;
-  white-space: normal;
-}
-
-
-
-/*
-  Resource styling for the tab carousel. The tab carousel contains either
-  a 3 column layout of resources or a single full-width resource. The
-  latter has the 18x12 class applied to it and can be styled differently
-  that way.
-*/
-
-.tab-carousel .resource .image {
-  width: 100%;
-  height: 250px;
-  background-repeat: no-repeat;
-  background-size: contain;
-  background-position: 50% 50%;
-}
-
-.tab-carousel .resource .info .title {
-  font-size: 18px;
-  line-height: 24px;
-}
-
-.tab-carousel .resource .info .summary,
-.tab-carousel .resource .info .cta {
-  line-height: 24px;
-  font-size: 16px;
-}
-
-.tab-carousel .resource-card-18x12 {
-  position: relative;
-  padding-left: 450px;
-  box-sizing: border-box;
-  display: table-cell;
-  vertical-align: middle;
-}
-
-.tab-carousel .resource-card-18x12 .image {
-  position: absolute;
-  width: 420px;
-  height: 100%;
-  left: 0;
-  top: 0;
-}
-
-.tab-carousel .resource-card-18x12 .info {
-  display: inline-block;
-}
-
-.tab-carousel .resource-card-18x12 .info .title {
-  margin-bottom: 26px;
-}
-
-/*
-  Specific styles for new home page layout of the carousels.
-*/
-
-/* Big blue button */
-a.home-new-cta-btn,
-.home-new-carousel-1 .resource-card-18x6 .cta {
-  white-space: nowrap;
-  display: inline-block;
-  padding: 14px 32px;
-  font-size: 18px;
-  font-weight: 500;
-  line-height: 24px;
-  cursor: pointer;
-  background: #33b5e6;
-  border-radius: 4px;
-  margin-top: 20px;
-  color: #fff;
-  transition: 0.2s background-color ease-in-out;
-}
-
-.home-new-carousel-1 .resource-card-18x6 .cta:after {
-  display: none; /* Hide the entity for this button */
-}
-
-a.home-new-cta-btn:hover,
-.home-new-carousel-1 .resource-card-18x6 .cta:hover {
-  color: #fff !important;
-  background: #2d9fca;
-}
-
-.home-new-carousel-1 .resource-card-18x6 .cta {
-  position: absolute;
-  bottom: 20px;
-  left: 16px;
-}
-
-/* Fullscreen carousel. */
-.home-new-carousel-1 {
-  max-height: 700px; /* Set max height so doesn't get too long */
-}
-
-.home-new-carousel-1 .fullscreen-carousel-content {
-  min-height: 450px;  /* Set min height for all content */
-}
-
-.home-new-carousel-1 .hero {
-  background: #000;
-}
-
-.home-new-carousel-1 .hero-bg {
-  background-image: url(/home-new/images/hero.jpg);
-  background-position: right center;
-  opacity: 0.85;
-}
-
-/*
-  Styling for special top card of full screen layout resource layout.
-  We need to specifically style the 18x6 card to adjust its size and layout,
-  since it's not a standard card, not sure if this is unique to the home page
-  layout or should be namespaced within the fullscreen-carousel container.
-*/
-.home-new-carousel-1 .resource-flow-layout.col-16 .resource-card-18x6 {
-  height: 320px;
-  background-color:#F9F9F9;
-  border-radius: 0px;
-  box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
-
-}
-
-.home-new-carousel-1 .resource-card-18x6 .card-bg {
-  width: 636px;
-  height: 100%;
-}
-
-.home-new-carousel-1 .resource-card-18x6 .card-info {
-  right: 0px;
-  left: 636px;
-  height: 100%;
-  top: 0px;
-  padding: 15px 22px;
-}
-
-.home-new-carousel-1 .resource-card-18x6 .card-info .util {
-  display: none;
-}
-
-.home-new-carousel-1 .resource-card-18x6 .card-info .title {
-  font-size: 20px;
-  font-weight: 500;
-  margin-top: 15px;
-  margin-bottom: 15px;
-}
-
-.home-new-carousel-1 .resource-card-18x6 .card-info .text {
-  font-size: 15px;
-  line-height: 21px;
-}
-
-
-/* Tabbed carousel. */
-.home-new-carousel-2 {
-  margin: 35px auto 100px auto;
-}
-
-.home-new-carousel-2 h1 {
-  font-size: 47px;
-  font-weight: 100;
-  line-height: 54px;
-  text-align: center;
-}
-
-.annotation-message {
-    display: block;
-    font-style: italic;
-    color: #F80;
-}
-
-
-
-/* Helpouts widget */
-.resource-card-6x2.helpouts-card {
-  width: 255px;
-  height: 40px;
-  position:absolute;
-  z-index:999;
-  top:-8px;
-  right:1px;
-}
-
-.resource-card-6x2.helpouts-card > .card-info {
-  left:35px;
-  height:35px;
-  padding:4px 8px 4px 0;
-}
-
-.resource-card-6x2.helpouts-card > .card-info .helpouts-description {
-  display:block;
-  overflow:visible;
-  font-size:12px;
-  line-height:12px;
-  text-align:right;
-  color:#666;
-}
-
-.helpouts-description .link-color {
-  text-transform: uppercase;
-}
-
-.resource-card-6x2 > .card-bg.helpouts-card-bg {
-  width:35px;
-  height:35px;
-  margin:2px 0 0 0;
-  background-image: url(../images/styles/helpouts-logo-35_2x.png);
-  background-image: -webkit-image-set(url(../images/styles/helpouts-logo-35.png) 1x, url(../images/styles/helpouts-logo-35_2x.png) 2x);
-}
-
-.resource-card-6x2 > .card-bg.helpouts-card-bg:after {
-  display:none;
-}
-
-#tb li:before, #qv li:before {
-  background-position: 0px -196px;
-  height: 24px;
-  width: 24px;
-  content: '';
-  left: -8px;
-  opacity: .7;
-  position: absolute;
-  top: -4px;
-}
-
-/* CHANGE EXISTING SELECTOR FOR ANDROID M HERO ONLY
-   REMOVE THE BELOW STYLES WHEN THE ANDROID M CAROUSEL
-   GRAPHIC ON THE MAIN LANDING IS TAKEN DOWN */
-.dac-hero.mprev {
-  background-color: #fff;
-  background-position: 50% 53%;
-  background-size: cover;
-  background-image: url(../images/home/android_m_hero_1200.jpg);
-  box-sizing: border-box;
-  font-size: 16px;
-  min-height: 550px;
-  padding-top: 88px;
-}
-.dac-hero.dac-darken.mprev::before {
-  background: rgba(0, 0, 0, 0.3);
-  bottom: 0;
-  content: '';
-  display: block;
-  left: 0;
-  position: absolute;
-  right: 0;
-  top: 0;
-}
-
-.dac-hero.dac-darken.mprev::before {
-  background: -webkit-linear-gradient(top, rgba(0, 0, 0, .05), rgba(0, 0, 0, .05), #000 950px);
-  background: linear-gradient(to bottom, rgba(0, 0, 0, .05), rgba(0, 0, 0, 0.05), #000 950px);
-}
-
-@media (max-width: 719px) {
-  .dac-hero.dac-darken.mprev {
-    background-size: auto 600px;
-    background-position: 55% 0;
-    background-repeat: no-repeat;
-  }
-
-  .dac-hero-figure.mprev {
-    height: 10px;
-    margin: 15px 0;
-  }
-}
-
-@media (max-width: 719px) {
-  .dac-hero.dac-darken.mprev {
-    background-size: auto 600px;
-    background-position: 55% 0;
-    background-repeat: no-repeat;
-  }
-
-  .dac-hero-figure.mprev {
-    height: 10px;
-    margin: 15px 0;
-  }
-}
-
-@media (max-width: 1200px) {
-  .dac-hero.dac-darken.mprev {
-    background-size: auto 700px;
-    background-position: 55% 0;
-    background-repeat: no-repeat;
-  }
-
-  .dac-hero-cta.mprev {
-    white-space:nowrap;
-  }
-}
-
-@charset "UTF-8";
-/**
- * Fades out an element.
- * Applies visibility hidden when the transition is finished.
- *
- * Use opacity: 1; to show the element.
- */
-.dac-visible-mobile-block, .dac-mobile-only,
-.dac-visible-mobile-inline,
-.dac-visible-mobile-inline-block,
-.dac-visible-tablet-block,
-.dac-visible-tablet-inline,
-.dac-visible-tablet-inline-block,
-.dac-visible-desktop-block,
-.dac-visible-desktop-inline,
-.dac-visible-desktop-inline-block {
-  display: none !important;
-}
-
-@media (max-width: 719px) {
-  .dac-hidden-mobile {
-    display: none !important;
-  }
-
-  .dac-visible-mobile-block, .dac-mobile-only {
-    display: block !important;
-  }
-
-  .dac-visible-mobile-inline {
-    display: inline !important;
-  }
-
-  .dac-visible-mobile-inline-block {
-    display: inline-block !important;
-  }
-}
-
-@media (min-width: 720px) and (max-width: 979px) {
-  .dac-hidden-tablet {
-    display: none !important;
-  }
-
-  .dac-visible-tablet-block {
-    display: block !important;
-  }
-
-  .dac-visible-tablet-inline {
-    display: inline !important;
-  }
-
-  .dac-visible-tablet-inline-block {
-    display: inline-block !important;
-  }
-}
-
-@media (min-width: 980px) {
-  .dac-hidden-desktop {
-    display: none !important;
-  }
-
-  .dac-visible-desktop-block {
-    display: block !important;
-  }
-
-  .dac-visible-desktop-inline {
-    display: inline !important;
-  }
-
-  .dac-visible-desktop-inline-block {
-    display: inline-block !important;
-  }
-}
-
-.dac-offset-parent {
-  position: relative !important;
-}
-
-/**
- * Hide from browsers/screenreaders on all sizes.
- */
-.dac-hidden {
-  display: none !important;
-}
-
-/**
- * Break strings when their length exceeds the width of their container.
- */
-.dac-text-break {
-  word-wrap: break-word !important;
-}
-
-/**
- * Horizontal text alignment
- */
-.dac-text-center {
-  text-align: center !important;
-}
-
-.dac-text-left {
-  text-align: left !important;
-}
-
-.dac-text-right {
-  text-align: right !important;
-}
-
-/**
- * Prevent whitespace wrapping
- */
-.dac-text-no-wrap {
-  white-space: nowrap !important;
-}
-
-/**
- * Prevent text from wrapping onto multiple lines, instead truncate with an ellipsis.
- */
-.dac-text-truncate {
-  max-width: 100%;
-  overflow: hidden !important;
-  text-overflow: ellipsis !important;
-  white-space: nowrap !important;
-  word-wrap: normal !important;
-}
-
-/**
- * Floats
- */
-.dac-float-left {
-  float: left !important;
-}
-
-.dac-float-right {
-  float: right !important;
-}
-
-/**
- * New block formatting context
- *
- * This affords some useful properties to the element. It won't wrap under
- * floats. Will also contain any floated children.
- * N.B. This will clip overflow. Use the alternative method below if this is
- * problematic.
- */
-.dac-nbfc {
-  overflow: hidden !important; }
-
-/**
- * New block formatting context (alternative)
- *
- * Alternative method when overflow must not be clipped.
- *
- * N.B. This breaks down in some browsers when elements within this element
- * exceed its width.
- */
-.dac-nbfc-alt {
-  display: table-cell !important;
-  width: 10000px !important; }
-
-/* New CSS */
-/************ RESOURCE CARDS ******************/
-/* Basic card-styling with shadow */
-.resource-card {
-  background: #fff;
-  box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.21);
-  display: block;
-  position: relative; }
-
-/* Play button is only visible on 6by6 cards */
-.play-button {
-  background-color: #000;
-  border-radius: 50%;
-  box-sizing: border-box;
-  display: none;
-  height: 70px;
-  line-height: 65px;
-  padding-left: 4px;
-  position: absolute;
-  opacity: .6;
-  text-align: center;
-  -webkit-transition: opacity .5s;
-          transition: opacity .5s;
-  width: 70px;
-  z-index: 1; }
-  .resource-card-6x2 .play-button {
-    display: block;
-    left: 10px;
-    top: 15px;
-    -webkit-transform: scale(0.73);
-        -ms-transform: scale(0.73);
-            transform: scale(0.73); }
-  .resource-card-6x6 .play-button {
-    display: block;
-    left: 50%;
-    margin-left: -35px;
-    top: 50px; }
-
-/* Styling for background image including tinting and section icons in stacks */
-.card-bg {
-  bottom: 131px;
-  display: block;
-  position: absolute;
-  vertical-align: top;
-  width: 100%;
-  left: 0;
-  top: 0;
-  background-size: cover;
-  background-repeat: no-repeat;
-  background-position: center;
-  background-image: url(../images/resource-card-default-android.jpg); }
-  .card-bg:after {
-    content: "";
-    display: block;
-    height: 100%;
-    width: 100%;
-    opacity: 1;
-    background: rgba(0, 0, 0, 0.05);
-    -webkit-transition: opacity 0.5s;
-            transition: opacity 0.5s; }
-  .static .card-bg:after {
-    display: none; }
-  .card-bg .card-section-icon {
-    position: absolute;
-    top: 50%;
-    width: 100%;
-    margin-top: -35px;
-    text-align: center;
-    padding-top: 65px;
-    z-index: 100; }
-    .card-bg .card-section-icon .icon {
-      position: absolute;
-      left: 50%;
-      margin-left: -28px;
-      top: 0px;
-      width: 56px;
-      height: 56px;
-      background-repeat: no-repeat;
-      background-position: 50% 50%;
-      background-image: url(../images/stack-icon.png); }
-    .card-bg .card-section-icon .section {
-      text-transform: uppercase;
-      color: white;
-      font-size: 14px; }
-
-.card-info {
-  position: absolute;
-  box-sizing: border-box;
-  height: 131px;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  overflow: hidden;
-  background: #fefefe;
-  padding: 6px 12px;
-}
-
-.card-info .section {
-  color: #898989;
-  font-size: 11px;
-  font-weight: 700;
-  letter-spacing: .3px;
-  line-height: 20px;
-  text-transform: uppercase;
-}
-
-.card-info .title {
-  color: #333;
-  font-size: 18px;
-  font-weight: 500;
-  line-height: 23px;
-  margin-bottom: 7px;
-  max-height: 46px;
-  overflow: hidden;
-  text-overflow: ellipsis;
-  white-space: normal;
-}
-
-.card-info .description {
-  overflow: hidden;
-}
-
-.card-info .description .text {
-  color: #666;
-  font-size: 14px;
-  height: 60px;
-  line-height: 20px;
-  overflow: hidden;
-  width: 100%;
-}
-
-.card-info .description .util {
-  position: absolute;
-  right: 5px;
-  bottom: 70px;
-  opacity: 0;
-  -webkit-transition: opacity 0.5s;
-  transition: opacity 0.5s;
-}
-
-.card-info.empty-desc .title {
-  white-space: normal;
-  overflow: visible;
-}
-
-.card-info.empty-desc .description {
-  display: none;
-}
-
-/* Resource card with icon instead of bg image */
-.resource-widget-card-icon {
-  text-align: center;
-}
-
-.card-icon {
-  margin: 20px 0 0;
-}
-
-.resource-widget-card-icon .card-info {
-  height: 210px;
-}
-
-.resource-widget-card-icon .card-info .title {
-  color: #333;
-  line-height: 24px;
-}
-
-.resource-widget-card-icon .card-bg {
-  background: none;
-  bottom: 220px;
-  opacity: 1;
-  top: 30px;
-  -webkit-transition: opacity .3s;
-  transition: opacity .3s;
-}
-
-.resource-widget-card-icon .resource-card:hover .card-bg {
-  opacity: .5;
-}
-
-.resource-widget-card-icon .card-bg img {
-  max-height: 100%;
-}
-
-.resource-widget-card-icon .card-bg::after {
-  background: transparent;
-}
-
-@media (min-width: 1210px) {
-  .resource-widget-card-icon .resource {
-    height: 240px;
-  }
-  .resource-widget-card-icon .card-bg {
-    bottom: 160px;
-  }
-  .resource-widget-card-icon .card-info {
-    height: 160px;
-  }
-}
-
-@media (max-width: 979px) {
-  .resource-widget-card-icon .resource {
-    height: 240px;
-  }
-  .resource-widget-card-icon .card-bg {
-    bottom: 160px;
-  }
-
-  .resource-widget-card-icon .card-info {
-    height: 160px;
-  }
-}
-
-/* Truncate card summaries at bounding box and
- * and apply ellipsis at lower right */
-.ellipsis {
-  overflow: hidden;
-  float: right;
-  line-height: 15px;
-  width: 100%; }
-  .ellipsis:before {
-    content: "";
-    float: left;
-    width: 5px;
-    height: 100%; }
-  .ellipsis > *:first-child.text {
-    float: right;
-    width: 100% !important;
-    margin-left: -5px; }
-  .ellipsis:after {
-    content: "\02026";
-    height: 17px;
-    padding-bottom: 4px;
-    box-sizing: content-box;
-    float: right;
-    position: relative;
-    top: -16px;
-    left: 100%;
-    width: 4em;
-    margin-left: -4em;
-    padding-right: 5px;
-    background: -webkit-gradient(linear, left top, right top, from(rgba(255, 255, 255, 0)), to(white), color-stop(65%, white));
-    background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0), white 65%, white);
-    background: linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white); }
-  .ellipsis:after {
-    font-style: normal;
-    color: #aaa;
-    font-size: 13px;
-    text-align: right; }
-
-.resource-card:hover {
-  cursor: pointer; }
-  .static .resource-card:hover {
-    cursor: auto; }
-  .resource-card:hover .card-bg:after {
-    opacity: 0; }
-  .resource-card:hover .play-button {
-    opacity: .3; }
-  .resource-card:hover .card-info .description .util {
-    opacity: 1; }
-
-/* Carousel Layout */
-/* Carousel styles for landing page */
-.resource-carousel-layout {
-  height: 531px;
-  margin: 20px 0 20px 0;
-  padding: 0 !important;
-  position: relative;
-  overflow: hidden; }
-  .resource-carousel-layout .slideshow-prev, .resource-carousel-layout .slideshow-next {
-    display: none; }
-  .resource-carousel-layout .pagination {
-    bottom: 97px;
-    left: auto;
-    padding-right: 10px;
-    right: 0;
-    text-align: right;
-    width: 16.66666667%; }
-    .resource-carousel-layout .pagination ul li {
-      text-indent: 8000px; }
-  .resource-carousel-layout .frame li {
-    position: relative; }
-    .resource-carousel-layout .frame li .card-bg {
-      bottom: 131px; }
-    .resource-carousel-layout .frame li .card-info {
-      height: 131px;
-      padding: 6px 12px;
-      top: auto; }
-      .resource-carousel-layout .frame li .card-info .title {
-        font-size: 28px;
-        font-weight: 400;
-        line-height: 32px; }
-      .resource-carousel-layout .frame li .card-info .description .text {
-        height: 40px; }
-      .resource-carousel-layout .frame li .card-info .description .util {
-        bottom: 97px;
-        right: 4px; }
-
-/* Stack Layout */
-.resource-stack-layout {
-  display: inline-block;
-  padding: 0; }
-  .resource-stack-layout .section-card-menu > .card-info .section, .resource-stack-layout .section-card > .card-info .title {
-    /*text-transform: uppercase;*/
-    color: #898989;
-    font-size: 17px;
-    line-height: 23px;
-    margin-bottom: 6px; }
-  .resource-stack-layout .section-card {
-    height: 284px; }
-    .resource-stack-layout .section-card > .card-bg {
-      height: 192px; }
-    .resource-stack-layout .section-card > .card-info {
-      padding: 4px 12px 6px 12px;
-      top: 192px; }
-      .resource-stack-layout .section-card > .card-info .section {
-        display: none; }
-      .resource-stack-layout .section-card > .card-info .title {
-        font-size: 17px;
-        border-bottom: 1px solid #959595;
-        padding-bottom: 0px; }
-      .resource-stack-layout .section-card > .card-info .description {
-        font-size: 13px;
-        line-height: 15px; }
-        .resource-stack-layout .section-card > .card-info .description .text {
-          height: 30px; }
-  .resource-stack-layout .related-card {
-    height: 90px; }
-    .resource-stack-layout .related-card > .card-bg {
-      left: 0;
-      top: 0;
-      width: 90px;
-      height: 100%;
-      position: absolute;
-      display: block; }
-    .resource-stack-layout .related-card > .card-info {
-      left: 90px;
-      padding: 4px 12px 4px 12px; }
-      .resource-stack-layout .related-card > .card-info .section {
-        font-size: 12px;
-        margin-bottom: 1px;
-        display: none; }
-      .resource-stack-layout .related-card > .card-info .title {
-        font-size: 16px;
-        margin-bottom: -2px;
-        white-space: normal;
-        overflow: visible;
-        text-overflow: ellipsis; }
-        .resource-stack-layout .related-card > .card-info .title:after {
-          content: url(../images/link-out.png);
-          display: block; }
-      .resource-stack-layout .related-card > .card-info .description {
-        display: none; }
-  .resource-stack-layout .section-card-menu {
-    /* Flexible height */
-    display: block;
-    height: auto;
-    width: auto; }
-    .resource-stack-layout .section-card-menu .card-bg {
-      height: 155px;
-      /* Flexible height */
-      position: relative;
-      display: inline-block;
-      vertical-align: top; }
-    .resource-stack-layout .section-card-menu .card-info {
-      padding: 4px 12px 0px 12px;
-      /* Flexible height */
-      position: relative;
-      left: auto;
-      top: auto;
-      right: auto;
-      bottom: auto; }
-      .resource-stack-layout .section-card-menu .card-info ul {
-        list-style: none;
-        margin: 0; }
-        .resource-stack-layout .section-card-menu .card-info ul li {
-          list-style: none;
-          margin: 0;
-          padding: 15px 0;
-          border-top-width: 1px;
-          border-top-style: solid;
-          border-top-color: #959595; }
-          .resource-stack-layout .section-card-menu .card-info ul li a, .resource-stack-layout .section-card-menu .card-info ul li a:focus, .resource-stack-layout .section-card-menu .card-info ul li a:hover {
-            color: #333 !important; }
-          .resource-stack-layout .section-card-menu .card-info ul li:first-child {
-            border-top: none; }
-          .resource-stack-layout .section-card-menu .card-info ul li:hover .title:after {
-            opacity: 1;
-            -webkit-transition: opacity 0.5s;
-                    transition: opacity 0.5s; }
-          .resource-stack-layout .section-card-menu .card-info ul li:hover .description {
-            max-height: 30px;
-            opacity: 1;
-            -webkit-transition: max-height 0.5s, opacity 1s;
-                    transition: max-height 0.5s, opacity 1s; }
-      .resource-stack-layout .section-card-menu .card-info .title {
-        font-size: 16px;
-        margin-bottom: -2px;
-        position: relative; }
-        .resource-stack-layout .section-card-menu .card-info .title:after {
-          background: url(../images/stack-arrow-right.png);
-          content: '';
-          opacity: 0;
-          -webkit-transition: opacity 0.25s;
-                  transition: opacity 0.25s;
-          position: absolute;
-          right: 0px;
-          top: 3px;
-          width: 10px;
-          height: 15px; }
-      .resource-stack-layout .section-card-menu .card-info .title.more {
-        text-transform: uppercase;
-        color: #898989;
-        display: inline-block; }
-        .resource-stack-layout .section-card-menu .card-info .title.more:after {
-          background: url(../images/stack-arrow-right.png);
-          content: '';
-          display: block;
-          position: absolute;
-          right: -20px;
-          top: 3px;
-          width: 10px;
-          height: 15px; }
-      .resource-stack-layout .section-card-menu .card-info .description {
-        max-height: 0px;
-        opacity: 0;
-        overflow: hidden;
-        font-size: 13px;
-        line-height: 15px;
-        /* Hover off */
-        -webkit-transition: max-height 0.5s, opacity 0.5s;
-                transition: max-height 0.5s, opacity 0.5s; }
-        .resource-stack-layout .section-card-menu .card-info .description .text {
-          height: 30px; }
-  .resource-stack-layout:after {
-    content: ".";
-    display: block;
-    height: 0;
-    clear: both;
-    visibility: hidden; }
-
-.resource-card, .resource-card-stack {
-  margin-bottom: 20px; }
-
-.resource-card-row-stack-last {
-  margin-bottom: 0px !important; }
-
-.resource-card-col-stack-last {
-  margin-bottom: 0px !important; }
-
-.resource-card-3x6 {
-  height: 300px; }
-
-.resource-card-3x12 {
-  height: 620px; }
-
-.resource-card-3x18 {
-  height: 940px; }
-
-.resource-card-6x6 {
-  height: 300px; }
-
-.resource-card-6x12 {
-  height: 620px; }
-
-.resource-card-6x18 {
-  height: 940px; }
-
-.resource-card-9x6 {
-  height: 300px; }
-
-.resource-card-9x12 {
-  height: 620px; }
-
-.resource-card-9x18 {
-  height: 940px; }
-
-.resource-card-12x6 {
-  height: 300px; }
-
-.resource-card-12x12 {
-  height: 620px; }
-
-.resource-card-12x18 {
-  height: 940px; }
-
-.resource-card-15x6 {
-  height: 300px; }
-
-.resource-card-15x12 {
-  height: 620px; }
-
-.resource-card-15x18 {
-  height: 940px; }
-
-.resource-card-18x6 {
-  height: 300px; }
-
-.resource-card-18x12 {
-  height: 620px; }
-
-.resource-card-18x18 {
-  height: 940px; }
-
-.resource-card-3x2 {
-  height: 100px; }
-
-.resource-card-3x2x3 {
-  height: 90px;
-  margin-bottom: 15px; }
-
-.resource-card-3x3 {
-  height: 150px; }
-
-.resource-card-3x3x2 {
-  height: 142px;
-  margin-bottom: 16px; }
-
-.resource-card-6x2 {
-  height: 100px; }
-
-.resource-card-6x2x3 {
-  height: 90px;
-  margin-bottom: 15px; }
-
-.resource-card-6x3 {
-  height: 150px; }
-
-.resource-card-6x3x2 {
-  height: 142px;
-  margin-bottom: 16px; }
-
-.resource-card-9x2 {
-  height: 100px; }
-
-.resource-card-9x2x3 {
-  height: 90px;
-  margin-bottom: 15px; }
-
-.resource-card-9x3 {
-  height: 150px; }
-
-.resource-card-9x3x2 {
-  height: 142px;
-  margin-bottom: 16px; }
-
-.resource-card-12x2 {
-  height: 100px; }
-
-.resource-card-12x2x3 {
-  height: 90px;
-  margin-bottom: 15px; }
-
-.resource-card-12x3 {
-  height: 150px; }
-
-.resource-card-12x3x2 {
-  height: 142px;
-  margin-bottom: 16px; }
-
-.resource-card-15x2 {
-  height: 100px; }
-
-.resource-card-15x2x3 {
-  height: 90px;
-  margin-bottom: 15px; }
-
-.resource-card-15x3 {
-  height: 150px; }
-
-.resource-card-15x3x2 {
-  height: 142px;
-  margin-bottom: 16px; }
-
-.resource-card-18x2 {
-  height: 100px; }
-
-.resource-card-18x2x3 {
-  height: 90px;
-  margin-bottom: 15px; }
-
-.resource-card-18x3 {
-  height: 150px; }
-
-.resource-card-18x3x2 {
-  height: 142px;
-  margin-bottom: 16px; }
-
-/*
-  The following are styles for cards in the flowlayout above, styled by the number of rows they span
-*/
-/* Single row, 2 column items. */
-.resource-card-9x6 {
-  height: 390px; }
-
-/* Double row, 1 column items. Eg full width video thumbnails. */
-.resource-card-18x12 {
-  height: 558px; }
-
-/* 1/3 row items */
-.resource-card-3x2 > .card-bg,
-.resource-card-6x2 > .card-bg,
-.resource-card-9x2 > .card-bg,
-.resource-card-12x2 > .card-bg,
-.resource-card-15x2 > .card-bg,
-.resource-card-18x2 > .card-bg {
-  left: 0;
-  top: 0;
-  width: 90px;
-  height: 100%;
-  position: absolute;
-  display: block;
-}
-
-.resource-card-3x2 > .card-info, .resource-card-6x2 > .card-info, .resource-card-9x2 > .card-info, .resource-card-12x2 > .card-info, .resource-card-15x2 > .card-info, .resource-card-18x2 > .card-info {
-  height: 100%;
-  left: 90px;
-  padding: 6px 12px;
-  overflow: hidden;
-}
-
-.resource-card-3x2 > .card-info .title,
-.resource-card-6x2 > .card-info .title,
-.resource-card-9x2 > .card-info .title,
-.resource-card-12x2 > .card-info .title,
-.resource-card-15x2 > .card-info .title,
-.resource-card-18x2 > .card-info .title {
-  max-height: 69px;
-  white-space: normal;
-}
-
-.resource-card-3x2 > .card-info .description,
-.resource-card-6x2 > .card-info .description,
-.resource-card-9x2 > .card-info .description,
-.resource-card-12x2 > .card-info .description,
-.resource-card-15x2 > .card-info .description,
-.resource-card-18x2 > .card-info .description {
-  display: none;
-}
-
-.resource-card-3x2 > .card-info .text,
-.resource-card-6x2 > .card-info .text,
-.resource-card-9x2 > .card-info .text,
-.resource-card-12x2 > .card-info .text,
-.resource-card-15x2 > .card-info .text,
-.resource-card-18x2 > .card-info .text {
-  height: auto;
-}
-
-/* Override to show the description instead of the content section */
-.no-section .resource-card-3x2 > .card-info .section,
-.no-section .resource-card-6x2 > .card-info .section {
-  display: none; }
-
-.no-section .resource-card-3x2 > .card-info .description,
-.no-section .resource-card-6x2 > .card-info .description {
-  display: block; }
-
-/* 1/2 row items */
-.resource-card-3x3, .resource-card-6x3, .resource-card-9x3, .resource-card-12x3, .resource-card-15x3, .resource-card-18x3 {
-  height: 160px; }
-  .resource-card-3x3 > .card-bg, .resource-card-6x3 > .card-bg, .resource-card-9x3 > .card-bg, .resource-card-12x3 > .card-bg, .resource-card-15x3 > .card-bg, .resource-card-18x3 > .card-bg {
-    left: 0;
-    top: 0;
-    width: 90px;
-    height: 100%;
-    position: absolute;
-    display: block; }
-  .resource-card-3x3 > .card-info, .resource-card-6x3 > .card-info, .resource-card-9x3 > .card-info, .resource-card-12x3 > .card-info, .resource-card-15x3 > .card-info, .resource-card-18x3 > .card-info {
-    height: 100%;
-    left: 90px;
-    padding: 6px 12px; }
-    .resource-card-3x3 > .card-info .section, .resource-card-6x3 > .card-info .section, .resource-card-9x3 > .card-info .section, .resource-card-12x3 > .card-info .section, .resource-card-15x3 > .card-info .section, .resource-card-18x3 > .card-info .section {
-      display: none; }
-    .resource-card-3x3 > .card-info .title, .resource-card-6x3 > .card-info .title, .resource-card-9x3 > .card-info .title, .resource-card-12x3 > .card-info .title, .resource-card-15x3 > .card-info .title, .resource-card-18x3 > .card-info .title {
-      max-height: 92px;
-      white-space: normal; }
-    .resource-card-3x3 > .card-info .text, .resource-card-6x3 > .card-info .text, .resource-card-9x3 > .card-info .text, .resource-card-12x3 > .card-info .text, .resource-card-15x3 > .card-info .text, .resource-card-18x3 > .card-info .text {
-      height: auto; }
-    .resource-card-3x3 > .card-info .util, .resource-card-6x3 > .card-info .util, .resource-card-9x3 > .card-info .util, .resource-card-12x3 > .card-info .util, .resource-card-15x3 > .card-info .util, .resource-card-18x3 > .card-info .util {
-      display: none; }
-
-/* placement of plusone */
-.resource-card-6x12 > .card-info .description .util, .resource-card-9x12 > .card-info .description .util, .resource-card-12x12 > .card-info .description .util, .resource-card-15x12 > .card-info .description .util {
-  bottom: 2px; }
-
-.resource-card-18x12 > .card-info .description .util {
-  bottom: 2px; }
-
-/* Overrides for col-16 6x6 cards linking to local content on landing pages.
-   Suppresses "section". */
-.landing .card-info .section {
-  display: none; }
-
-/*
-  Generate a resource stack layout for a 3 column widget spanning 16 grid cols
-*/
-.resource-stack-layout.col-16 {
-  margin: 0 -14px 0 0;
-  width: 954px; }
-  .resource-stack-layout.col-16 .resource-card-stack {
-    margin: 0 14px 0 0;
-    width: 304px; }
-
-/* Example of card menu tinting */
-.resource-widget[data-section=distribute\/tools] .section-card-menu .card-bg:after {
-  background: rgba(126, 55, 148, 0.4) !important; }
-
-.resource-widget[data-section=distribute\/tools] .section-card-menu .card-section-icon .icon {
-  background-color: #7e3794 !important; }
-
-.resource-widget[data-section=distribute\/tools] .section-card-menu .card-info ul li {
-  border-top-color: #7e3794 !important; }
-
-/* tinting for stacks */
-div.jd-descr > .resource-widget[data-section=distribute\/tools]
-.section-card-menu .card-info ul li {
-  border-top-color: #7e3794 !important; }
-
-/* Show more/less */
-.dac-show-more,
-.dac-show-less {
-  display: none !important; }
-
-.dac-has-more .dac-show-more {
-  display: inline-block !important; }
-
-.dac-has-less .dac-show-less {
-  display: inline-block !important; }
-
-.dac-fab, .dac-button-social, .button, .landing-button,
-.dac-button {
-  background: transparent;
-  border: 0;
-  border-radius: 3px;
-  box-sizing: border-box;
-  color: currentColor;
-  cursor: pointer;
-  display: inline-block;
-  font-weight: 500;
-  font-size: 14px;
-  font-style: inherit;
-  font-variant: inherit;
-  font-family: inherit;
-  letter-spacing: .5px;
-  line-height: 24px;
-  margin: 6px 16px 6px 0;
-  min-width: 88px;
-  outline: 0;
-  padding: 6px 12px;
-  position: relative;
-  text-align: center;
-  text-decoration: none;
-  text-transform: uppercase;
-  -webkit-transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
-          transition: box-shadow 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), background-color 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
-  -webkit-user-select: none;
-     -moz-user-select: none;
-      -ms-user-select: none;
-          user-select: none;
-  white-space: nowrap; }
-
-.button, .landing-button,
-.dac-button.dac-raised {
-  background-color: #FAFAFA;
-  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26); }
-
-.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; }
-  .dac-button.dac-raised.dac-primary:active, .landing-secondary:active, .button:active {
-    background-color: #0277bd; }
-  .dac-button.dac-raised.dac-primary.disabled, .button.disabled {
-    background-color: #bbb; }
-
-.dac-button.dac-raised.dac-red, .landing-primary {
-  background-color: #bf3722; }
-  .dac-button.dac-raised.dac-red:hover, .landing-primary:hover {
-    background-color: #9c2d1c; }
-  .dac-button.dac-raised.dac-red:active, .landing-primary:active {
-    background-color: #822517; }
-
-.dac-button.dac-raised.dac-green, .landing-button.green {
-  background-color: #90c653; }
-  .dac-button.dac-raised.dac-green:hover, .landing-button.green:hover {
-    background-color: #79b03b; }
-  .dac-button.dac-raised.dac-green:active, .landing-button.green:active {
-    background-color: #699933; }
-
-.dac-button.dac-raised.dac-primary, .landing-secondary, .button,
-.dac-button.dac-raised.dac-red,
-.landing-primary,
-.dac-button.dac-raised.dac-green,
-.landing-button.green {
-  color: #fff; }
-
-.dac-button.dac-large, .landing-button {
-  padding: 12px 24px; }
-
-.landing-button-wrap {
-  float: left;
-  margin-right: 40px;
-  width: auto;
-}
-
-.dac-fab, .dac-button-social {
-  background: #fff;
-  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);
-  border-radius: 50%;
-  height: 36px;
-  line-height: 36px;
-  margin: 0;
-  min-width: 0;
-  overflow: hidden;
-  padding: 0;
-  vertical-align: middle;
-  width: 36px; }
-  .dac-fab:hover, .dac-button-social:hover,
-  a:hover > .dac-fab,
-  a:hover > .dac-button-social {
-    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.26); }
-  .dac-fab > .dac-sprite, .dac-button-social > .dac-sprite, .dac-fab > .dac-modal-header-close:before, .dac-button-social > .dac-modal-header-close:before, .paging-links .dac-fab > .prev-page-link:before, .paging-links .dac-button-social > .prev-page-link:before, .paging-links .dac-fab > .next-page-link:before, .paging-links .dac-button-social > .next-page-link:before, .paging-links .dac-fab > .next-class-link:before, .paging-links .dac-button-social > .next-class-link:before, .paging-links .dac-fab > .start-class-link:after, .paging-links .dac-button-social > .start-class-link:after {
-    margin-top: -2px; }
-  .dac-fab.dac-primary, .dac-primary.dac-button-social {
-    background: #00c7a0; }
-  .dac-fab.dac-large, .dac-large.dac-button-social {
-    height: 54px;
-    line-height: 54px;
-    width: 54px; }
-
-.dac-button-social {
-  background: #ccc;
-  box-shadow: none;
-  position: relative;
-  overflow: hidden; }
-  .dac-button-social::after {
-    background: rgba(0, 0, 0, 0.2);
-    border-radius: 50%;
-    bottom: 0;
-    content: '';
-    display: block;
-    left: 0;
-    opacity: 0;
-    position: absolute;
-    right: 0;
-    top: 0;
-    -webkit-transition: opacity .3s;
-            transition: opacity .3s; }
-  .dac-button-social:hover {
-    box-shadow: none; }
-  .dac-button-social:active::after {
-    opacity: 1; }
-  .dac-button-social:focus.dac-rss, .dac-button-social:hover.dac-rss {
-    background: #ff9800; }
-  .dac-button-social:focus.dac-youtube, .dac-button-social:hover.dac-youtube {
-    background: #f44336; }
-  .dac-button-social:focus.dac-gplus, .dac-button-social:hover.dac-gplus {
-    background: #f44336; }
-  .dac-button-social:focus.dac-twitter, .dac-button-social:hover.dac-twitter {
-    background: #55acee; }
-
-.dac-action {
-  display: inline-block;
-  margin: 0 16px; }
-  .dac-action-link {
-    color: inherit;
-    font-size: 24px;
-    font-weight: 300;
-    line-height: 50px;
-    -webkit-transition: opacity .3s;
-            transition: opacity .3s; }
-    .dac-action-link:hover {
-      color: inherit;
-      opacity: .54; }
-  .dac-action-sprite {
-    margin-left: -12px;
-    margin-right: -8px; }
-  .dac-actions {
-    list-style-type: none;
-    margin: 0;
-    padding-bottom: 24px;
-    padding-top: 24px;
-    text-align: center; }
-    @media (max-width: 719px) {
-      .dac-actions {
-        text-align: left; } }
-  @media (max-width: 719px) {
-    .dac-action {
-      display: block;
-      margin: 0; } }
-
-.dac-scroll-button {
-  height: 54px;
-  line-height: 54px;
-  margin: 0;
-  position: absolute;
-  right: 0;
-  top: -27px;
-  width: 54px;
-  z-index: 1; }
-  @media (max-width: 719px) {
-    .dac-scroll-button {
-      display: none; } }
-
-/* Footer component */
-.dac-footer {
-  background-color: #fff;
-  border-top: 1px solid #f0f0f0;
-  clear: both;
-  color: #999;
-  font-size: 12px;
-  margin-top: 96px;
-  padding-bottom: 20px;
-  position: relative;
-}
-
-.dac-footer a {
-  color: #999;
-}
-
-.dac-footer p {
-  margin: 7px 0 0;
-}
-
-.dac-footer-main {
-  padding: 30px 0;
-}
-
-.dac-footer-reachout {
-  text-align: right;
-}
-
-.dac-footer-contact,
-.dac-footer-social {
-  display: inline-block;
-}
-
-.dac-footer .dac-footer-getnews,
-.dac-footer .dac-footer-contact-link {
-  color: #000;
-  cursor: pointer;
-  font-size: 20px;
-  font-weight: 300;
-  margin: 8px 0;
-  vertical-align: middle;
-}
-
-.dac-footer .dac-footer-contact-link,
-.dac-footer .dac-footer-social-link {
-  margin-left: 16px;
-  margin-right: 0;
-}
-
-.dac-footer-getnews > .dac-fab, .dac-footer-getnews > .dac-button-social {
-  margin-left: 4px;
-}
-
-.dac-footer-separator {
-  background: #f0f0f0;
-  margin: 0 0 12px;
-}
-
-.dac-footer-links {
-  float: left;
-  margin: 10px 0 60px;
-  width: 50%;
-}
-
-.dac-footer-links a + a:before {
-  content: '|';
-  cursor: default;
-  margin: 0 10px 0 8px;
-}
-
-.devsite-utility-footer-language {
-  float: right;
-  margin: 10px 0 60px;
-  width: 50%;
-}
-
-.dac-footer .locales {
-  float: right;
-  margin: 0;
-}
-
-.dac-footer .locales select {
-  background-color: #f0f0f0;
-  border-radius: 3px;
-  font-size: 12px;
-  height: auto;
-  margin-top: -2px;
-  padding: 8px 12px;
-  width: 146px;
-}
-
-.dac-footer.dac-landing {
-  margin-top: 0;
-  border-top: 0;
-}
-
-@media (max-width: 719px) {
-  .dac-footer-reachout {
-    text-align: left;
-  }
-
-  .dac-footer-social {
-    display: block;
-  }
-
-  .dac-footer-social-link,
-  .dac-footer-contact-link {
-    display: inline-block;
-  }
-
-  .dac-footer .dac-footer-contact-link,
-  .dac-footer .dac-footer-social-link {
-    margin-left: 0;
-    margin-right: 16px;
-  }
-
-  .dac-footer-links {
-    display: block;
-    float: none;
-    width: 100%;
-  }
-
-  .devsite-utility-footer-language {
-    float: none;
-    margin: 0 0 20px;
-    width: 100%;
-  }
-
-  .dac-footer .locales {
-    display: block;
-    float: none;
-    margin-top: 15px;
-  }
-}
-
-/* =============================================================================
-   Columns
-   ========================================================================== */
-.wrap {
-  margin: 0 auto;
-  max-width: 940px;
-  clear: both;
-}
-
-.dac-fullscreen-mode .wrap {
-  max-width: none;
-}
-
-.dac-fullscreen-mode .dac-search-open .wrap {
-  max-width: 940px;
-}
-
-.cols {
-  margin-left: -10px;
-  margin-right: -10px;
-  /**
-   * For modern browsers
-   * 1. The space content is one way to avoid an Opera bug when the
-   *    contenteditable attribute is included anywhere else in the document.
-   *    Otherwise it causes space to appear at the top and bottom of elements
-   *    that are clearfixed.
-   * 2. The use of `table` rather than `block` is only necessary if using
-   *    `:before` to contain the top-margins of child elements.
-   */ }
-  .cols:before, .cols:after {
-    content: ' ';
-    /* 1 */
-    display: table;
-    /* 2 */ }
-  .cols:after {
-    clear: both; }
-
-[class*=col-] {
-  box-sizing: border-box;
-  float: left;
-  min-height: 1px;
-  padding-left: 10px;
-  padding-right: 10px;
-  position: relative; }
-
-.col-1 {
-  width: 6.25%; }
-
-.col-2 {
-  width: 12.5%; }
-
-.col-3 {
-  width: 18.75%; }
-
-.col-4 {
-  width: 25%; }
-
-.col-5 {
-  width: 31.25%; }
-
-.col-6 {
-  width: 37.5%; }
-
-.col-7 {
-  width: 43.75%; }
-
-.col-8 {
-  width: 50%; }
-
-.col-9 {
-  width: 56.25%; }
-
-.col-10 {
-  width: 62.5%; }
-
-.col-11 {
-  width: 68.75%; }
-
-.col-12 {
-  width: 75%; }
-
-.col-13 {
-  width: 81.25%; }
-
-.col-14 {
-  width: 87.5%; }
-
-.col-15 {
-  width: 93.75%; }
-
-.col-16 {
-  width: 100%; }
-
-.col-13 .col-1 {
-  width: 7.69230769%; }
-
-.col-13 .col-2 {
-  width: 15.38461538%; }
-
-.col-13 .col-3 {
-  width: 23.07692308%; }
-
-.col-13 .col-4 {
-  width: 30.76923077%; }
-
-.col-13 .col-5 {
-  width: 38.46153846%; }
-
-.col-13 .col-6 {
-  width: 46.15384615%; }
-
-.col-13 .col-7 {
-  width: 53.84615385%; }
-
-.col-13 .col-8 {
-  width: 61.53846154%; }
-
-.col-13 .col-9 {
-  width: 69.23076923%; }
-
-.col-13 .col-10 {
-  width: 76.92307692%; }
-
-.col-13 .col-11 {
-  width: 84.61538462%; }
-
-.col-13 .col-12 {
-  width: 92.30769231%; }
-
-.col-13 .col-13 {
-  width: 100%; }
-
-.col-12 .col-1 {
-  width: 8.33333333%; }
-
-.col-12 .col-2 {
-  width: 16.66666667%; }
-
-.col-12 .col-3 {
-  width: 25%; }
-
-.col-12 .col-4 {
-  width: 33.33333333%; }
-
-.col-12 .col-5 {
-  width: 41.66666667%; }
-
-.col-12 .col-6 {
-  width: 50%; }
-
-.col-12 .col-7 {
-  width: 58.33333333%; }
-
-.col-12 .col-8 {
-  width: 66.66666667%; }
-
-.col-12 .col-9 {
-  width: 75%; }
-
-.col-12 .col-10 {
-  width: 83.33333333%; }
-
-.col-12 .col-11 {
-  width: 91.66666667%; }
-
-.col-12 .col-12 {
-  width: 100%; }
-
-.col-1of1, .col-2of2, .col-3of3, .col-4of4, .col-5of5, .col-6of6, .col-8of8, .col-10of10, .col-12of12, .col-16of16 {
-  width: 100%; }
-
-.col-1of2, .col-2of4, .col-3of6, .col-4of8, .col-5of10, .col-6of12, .col-8of16 {
-  width: 50%; }
-
-.col-1of3, .col-2of6, .col-4of12 {
-  width: 33.33333333%; }
-
-.col-2of3, .col-4of6, .col-8of12 {
-  width: 66.66666667%; }
-
-.col-1of4, .col-2of8, .col-3of12, .col-4of16 {
-  width: 25%; }
-
-.col-3of4, .col-6of8, .col-9of12, .col-12of16 {
-  width: 75%; }
-
-.col-1of5, .col-2of10 {
-  width: 20%; }
-
-.col-2of5, .col-4of10 {
-  width: 40%; }
-
-.col-3of5, .col-6of10 {
-  width: 60%; }
-
-.col-4of5, .col-8of10 {
-  width: 80%; }
-
-.col-1of6, .col-2of12 {
-  width: 16.66666667%; }
-
-.col-5of6, .col-10of12 {
-  width: 83.33333333%; }
-
-.col-1of8, .col-2of16 {
-  width: 12.5%; }
-
-.col-3of8, .col-6of16 {
-  width: 37.5%; }
-
-.col-5of8, .col-10of16 {
-  width: 62.5%; }
-
-.col-7of8, .col-14of16 {
-  width: 87.5%; }
-
-.col-1of10 {
-  width: 10%; }
-
-.col-3of10 {
-  width: 30%; }
-
-.col-7of10 {
-  width: 70%; }
-
-.col-9of10 {
-  width: 90%; }
-
-.col-1of12 {
-  width: 8.33333333%; }
-
-.col-5of12 {
-  width: 41.66666667%; }
-
-.col-7of12 {
-  width: 58.33333333%; }
-
-.col-11of12 {
-  width: 91.66666667%; }
-
-.col-1of16 {
-  width: 6.25%; }
-
-.col-3of16 {
-  width: 18.75%; }
-
-.col-5of16 {
-  width: 31.25%; }
-
-.col-7of16 {
-  width: 43.75%; }
-
-.col-9of16 {
-  width: 56.25%; }
-
-.col-11of16 {
-  width: 68.75%; }
-
-.col-13of16 {
-  width: 81.25%; }
-
-.col-15of16 {
-  width: 93.75%; }
-
-.col-pull-1of1, .col-pull-2of2, .col-pull-3of3, .col-pull-4of4, .col-pull-5of5, .col-pull-6of6, .col-pull-8of8, .col-pull-10of10, .col-pull-12of12, .col-pull-16of16 {
-  left: -100%; }
-
-.col-pull-1of2, .col-pull-2of4, .col-pull-3of6, .col-pull-4of8, .col-pull-5of10, .col-pull-6of12, .col-pull-8of16 {
-  left: -50%; }
-
-.col-pull-1of3, .col-pull-2of6, .col-pull-4of12 {
-  left: -33.33333333%; }
-
-.col-pull-2of3, .col-pull-4of6, .col-pull-8of12 {
-  left: -66.66666667%; }
-
-.col-pull-1of4, .col-pull-2of8, .col-pull-3of12, .col-pull-4of16 {
-  left: -25%; }
-
-.col-pull-3of4, .col-pull-6of8, .col-pull-9of12, .col-pull-12of16 {
-  left: -75%; }
-
-.col-pull-1of5, .col-pull-2of10 {
-  left: -20%; }
-
-.col-pull-2of5, .col-pull-4of10 {
-  left: -40%; }
-
-.col-pull-3of5, .col-pull-6of10 {
-  left: -60%; }
-
-.col-pull-4of5, .col-pull-8of10 {
-  left: -80%; }
-
-.col-pull-1of6, .col-pull-2of12 {
-  left: -16.66666667%; }
-
-.col-pull-5of6, .col-pull-10of12 {
-  left: -83.33333333%; }
-
-.col-pull-1of8, .col-pull-2of16 {
-  left: -12.5%; }
-
-.col-pull-3of8, .col-pull-6of16 {
-  left: -37.5%; }
-
-.col-pull-5of8, .col-pull-10of16 {
-  left: -62.5%; }
-
-.col-pull-7of8, .col-pull-14of16 {
-  left: -87.5%; }
-
-.col-pull-1of10 {
-  left: -10%; }
-
-.col-pull-3of10 {
-  left: -30%; }
-
-.col-pull-7of10 {
-  left: -70%; }
-
-.col-pull-9of10 {
-  left: -90%; }
-
-.col-pull-1of12 {
-  left: -8.33333333%; }
-
-.col-pull-5of12 {
-  left: -41.66666667%; }
-
-.col-pull-7of12 {
-  left: -58.33333333%; }
-
-.col-pull-11of12 {
-  left: -91.66666667%; }
-
-.col-pull-1of16 {
-  left: -6.25%; }
-
-.col-pull-3of16 {
-  left: -18.75%; }
-
-.col-pull-5of16 {
-  left: -31.25%; }
-
-.col-pull-7of16 {
-  left: -43.75%; }
-
-.col-pull-9of16 {
-  left: -56.25%; }
-
-.col-pull-11of16 {
-  left: -68.75%; }
-
-.col-pull-13of16 {
-  left: -81.25%; }
-
-.col-pull-15of16 {
-  left: -93.75%; }
-
-.col-push-1of1, .col-push-2of2, .col-push-3of3, .col-push-4of4, .col-push-5of5, .col-push-6of6, .col-push-8of8, .col-push-10of10, .col-push-12of12, .col-push-16of16 {
-  left: 100%; }
-
-.col-push-1of2, .col-push-2of4, .col-push-3of6, .col-push-4of8, .col-push-5of10, .col-push-6of12, .col-push-8of16 {
-  left: 50%; }
-
-.col-push-1of3, .col-push-2of6, .col-push-4of12 {
-  left: 33.33333333%; }
-
-.col-push-2of3, .col-push-4of6, .col-push-8of12 {
-  left: 66.66666667%; }
-
-.col-push-1of4, .col-push-2of8, .col-push-3of12, .col-push-4of16 {
-  left: 25%; }
-
-.col-push-3of4, .col-push-6of8, .col-push-9of12, .col-push-12of16 {
-  left: 75%; }
-
-.col-push-1of5, .col-push-2of10 {
-  left: 20%; }
-
-.col-push-2of5, .col-push-4of10 {
-  left: 40%; }
-
-.col-push-3of5, .col-push-6of10 {
-  left: 60%; }
-
-.col-push-4of5, .col-push-8of10 {
-  left: 80%; }
-
-.col-push-1of6, .col-push-2of12 {
-  left: 16.66666667%; }
-
-.col-push-5of6, .col-push-10of12 {
-  left: 83.33333333%; }
-
-.col-push-1of8, .col-push-2of16 {
-  left: 12.5%; }
-
-.col-push-3of8, .col-push-6of16 {
-  left: 37.5%; }
-
-.col-push-5of8, .col-push-10of16 {
-  left: 62.5%; }
-
-.col-push-7of8, .col-push-14of16 {
-  left: 87.5%; }
-
-.col-push-1of10 {
-  left: 10%; }
-
-.col-push-3of10 {
-  left: 30%; }
-
-.col-push-7of10 {
-  left: 70%; }
-
-.col-push-9of10 {
-  left: 90%; }
-
-.col-push-1of12 {
-  left: 8.33333333%; }
-
-.col-push-5of12 {
-  left: 41.66666667%; }
-
-.col-push-7of12 {
-  left: 58.33333333%; }
-
-.col-push-11of12 {
-  left: 91.66666667%; }
-
-.col-push-1of16 {
-  left: 6.25%; }
-
-.col-push-3of16 {
-  left: 18.75%; }
-
-.col-push-5of16 {
-  left: 31.25%; }
-
-.col-push-7of16 {
-  left: 43.75%; }
-
-.col-push-9of16 {
-  left: 56.25%; }
-
-.col-push-11of16 {
-  left: 68.75%; }
-
-.col-push-13of16 {
-  left: 81.25%; }
-
-.col-push-15of16 {
-  left: 93.75%; }
-
-@media (max-width: 959px) and (min-width: 720px) {
-  .col-tablet-1of1, .col-tablet-2of2, .col-tablet-3of3, .col-tablet-4of4, .col-tablet-5of5, .col-tablet-6of6, .col-tablet-8of8, .col-tablet-10of10, .col-tablet-12of12, .col-tablet-16of16 {
-    width: 100%; }
-  .col-tablet-1of2, .col-tablet-2of4, .col-tablet-3of6, .col-tablet-4of8, .col-tablet-5of10, .col-tablet-6of12, .col-tablet-8of16 {
-    width: 50%; }
-  .col-tablet-1of3, .col-tablet-2of6, .col-tablet-4of12 {
-    width: 33.33333333%; }
-  .col-tablet-2of3, .col-tablet-4of6, .col-tablet-8of12 {
-    width: 66.66666667%; }
-  .col-tablet-1of4, .col-tablet-2of8, .col-tablet-3of12, .col-tablet-4of16 {
-    width: 25%; }
-  .col-tablet-3of4, .col-tablet-6of8, .col-tablet-9of12, .col-tablet-12of16 {
-    width: 75%; }
-  .col-tablet-1of5, .col-tablet-2of10 {
-    width: 20%; }
-  .col-tablet-2of5, .col-tablet-4of10 {
-    width: 40%; }
-  .col-tablet-3of5, .col-tablet-6of10 {
-    width: 60%; }
-  .col-tablet-4of5, .col-tablet-8of10 {
-    width: 80%; }
-  .col-tablet-1of6, .col-tablet-2of12 {
-    width: 16.66666667%; }
-  .col-tablet-5of6, .col-tablet-10of12 {
-    width: 83.33333333%; }
-  .col-tablet-1of8, .col-tablet-2of16 {
-    width: 12.5%; }
-  .col-tablet-3of8, .col-tablet-6of16 {
-    width: 37.5%; }
-  .col-tablet-5of8, .col-tablet-10of16 {
-    width: 62.5%; }
-  .col-tablet-7of8, .col-tablet-14of16 {
-    width: 87.5%; }
-  .col-tablet-1of10 {
-    width: 10%; }
-  .col-tablet-3of10 {
-    width: 30%; }
-  .col-tablet-7of10 {
-    width: 70%; }
-  .col-tablet-9of10 {
-    width: 90%; }
-  .col-tablet-1of12 {
-    width: 8.33333333%; }
-  .col-tablet-5of12 {
-    width: 41.66666667%; }
-  .col-tablet-7of12 {
-    width: 58.33333333%; }
-  .col-tablet-11of12 {
-    width: 91.66666667%; }
-  .col-tablet-1of16 {
-    width: 6.25%; }
-  .col-tablet-3of16 {
-    width: 18.75%; }
-  .col-tablet-5of16 {
-    width: 31.25%; }
-  .col-tablet-7of16 {
-    width: 43.75%; }
-  .col-tablet-9of16 {
-    width: 56.25%; }
-  .col-tablet-11of16 {
-    width: 68.75%; }
-  .col-tablet-13of16 {
-    width: 81.25%; }
-  .col-tablet-15of16 {
-    width: 93.75%; }
-  .col-tablet-pull-1of1, .col-tablet-pull-2of2, .col-tablet-pull-3of3, .col-tablet-pull-4of4, .col-tablet-pull-5of5, .col-tablet-pull-6of6, .col-tablet-pull-8of8, .col-tablet-pull-10of10, .col-tablet-pull-12of12, .col-tablet-pull-16of16 {
-    left: -100%; }
-  .col-tablet-pull-1of2, .col-tablet-pull-2of4, .col-tablet-pull-3of6, .col-tablet-pull-4of8, .col-tablet-pull-5of10, .col-tablet-pull-6of12, .col-tablet-pull-8of16 {
-    left: -50%; }
-  .col-tablet-pull-1of3, .col-tablet-pull-2of6, .col-tablet-pull-4of12 {
-    left: -33.33333333%; }
-  .col-tablet-pull-2of3, .col-tablet-pull-4of6, .col-tablet-pull-8of12 {
-    left: -66.66666667%; }
-  .col-tablet-pull-1of4, .col-tablet-pull-2of8, .col-tablet-pull-3of12, .col-tablet-pull-4of16 {
-    left: -25%; }
-  .col-tablet-pull-3of4, .col-tablet-pull-6of8, .col-tablet-pull-9of12, .col-tablet-pull-12of16 {
-    left: -75%; }
-  .col-tablet-pull-1of5, .col-tablet-pull-2of10 {
-    left: -20%; }
-  .col-tablet-pull-2of5, .col-tablet-pull-4of10 {
-    left: -40%; }
-  .col-tablet-pull-3of5, .col-tablet-pull-6of10 {
-    left: -60%; }
-  .col-tablet-pull-4of5, .col-tablet-pull-8of10 {
-    left: -80%; }
-  .col-tablet-pull-1of6, .col-tablet-pull-2of12 {
-    left: -16.66666667%; }
-  .col-tablet-pull-5of6, .col-tablet-pull-10of12 {
-    left: -83.33333333%; }
-  .col-tablet-pull-1of8, .col-tablet-pull-2of16 {
-    left: -12.5%; }
-  .col-tablet-pull-3of8, .col-tablet-pull-6of16 {
-    left: -37.5%; }
-  .col-tablet-pull-5of8, .col-tablet-pull-10of16 {
-    left: -62.5%; }
-  .col-tablet-pull-7of8, .col-tablet-pull-14of16 {
-    left: -87.5%; }
-  .col-tablet-pull-1of10 {
-    left: -10%; }
-  .col-tablet-pull-3of10 {
-    left: -30%; }
-  .col-tablet-pull-7of10 {
-    left: -70%; }
-  .col-tablet-pull-9of10 {
-    left: -90%; }
-  .col-tablet-pull-1of12 {
-    left: -8.33333333%; }
-  .col-tablet-pull-5of12 {
-    left: -41.66666667%; }
-  .col-tablet-pull-7of12 {
-    left: -58.33333333%; }
-  .col-tablet-pull-11of12 {
-    left: -91.66666667%; }
-  .col-tablet-pull-1of16 {
-    left: -6.25%; }
-  .col-tablet-pull-3of16 {
-    left: -18.75%; }
-  .col-tablet-pull-5of16 {
-    left: -31.25%; }
-  .col-tablet-pull-7of16 {
-    left: -43.75%; }
-  .col-tablet-pull-9of16 {
-    left: -56.25%; }
-  .col-tablet-pull-11of16 {
-    left: -68.75%; }
-  .col-tablet-pull-13of16 {
-    left: -81.25%; }
-  .col-tablet-pull-15of16 {
-    left: -93.75%; }
-  .col-tablet-push-1of1, .col-tablet-push-2of2, .col-tablet-push-3of3, .col-tablet-push-4of4, .col-tablet-push-5of5, .col-tablet-push-6of6, .col-tablet-push-8of8, .col-tablet-push-10of10, .col-tablet-push-12of12, .col-tablet-push-16of16 {
-    left: 100%; }
-  .col-tablet-push-1of2, .col-tablet-push-2of4, .col-tablet-push-3of6, .col-tablet-push-4of8, .col-tablet-push-5of10, .col-tablet-push-6of12, .col-tablet-push-8of16 {
-    left: 50%; }
-  .col-tablet-push-1of3, .col-tablet-push-2of6, .col-tablet-push-4of12 {
-    left: 33.33333333%; }
-  .col-tablet-push-2of3, .col-tablet-push-4of6, .col-tablet-push-8of12 {
-    left: 66.66666667%; }
-  .col-tablet-push-1of4, .col-tablet-push-2of8, .col-tablet-push-3of12, .col-tablet-push-4of16 {
-    left: 25%; }
-  .col-tablet-push-3of4, .col-tablet-push-6of8, .col-tablet-push-9of12, .col-tablet-push-12of16 {
-    left: 75%; }
-  .col-tablet-push-1of5, .col-tablet-push-2of10 {
-    left: 20%; }
-  .col-tablet-push-2of5, .col-tablet-push-4of10 {
-    left: 40%; }
-  .col-tablet-push-3of5, .col-tablet-push-6of10 {
-    left: 60%; }
-  .col-tablet-push-4of5, .col-tablet-push-8of10 {
-    left: 80%; }
-  .col-tablet-push-1of6, .col-tablet-push-2of12 {
-    left: 16.66666667%; }
-  .col-tablet-push-5of6, .col-tablet-push-10of12 {
-    left: 83.33333333%; }
-  .col-tablet-push-1of8, .col-tablet-push-2of16 {
-    left: 12.5%; }
-  .col-tablet-push-3of8, .col-tablet-push-6of16 {
-    left: 37.5%; }
-  .col-tablet-push-5of8, .col-tablet-push-10of16 {
-    left: 62.5%; }
-  .col-tablet-push-7of8, .col-tablet-push-14of16 {
-    left: 87.5%; }
-  .col-tablet-push-1of10 {
-    left: 10%; }
-  .col-tablet-push-3of10 {
-    left: 30%; }
-  .col-tablet-push-7of10 {
-    left: 70%; }
-  .col-tablet-push-9of10 {
-    left: 90%; }
-  .col-tablet-push-1of12 {
-    left: 8.33333333%; }
-  .col-tablet-push-5of12 {
-    left: 41.66666667%; }
-  .col-tablet-push-7of12 {
-    left: 58.33333333%; }
-  .col-tablet-push-11of12 {
-    left: 91.66666667%; }
-  .col-tablet-push-1of16 {
-    left: 6.25%; }
-  .col-tablet-push-3of16 {
-    left: 18.75%; }
-  .col-tablet-push-5of16 {
-    left: 31.25%; }
-  .col-tablet-push-7of16 {
-    left: 43.75%; }
-  .col-tablet-push-9of16 {
-    left: 56.25%; }
-  .col-tablet-push-11of16 {
-    left: 68.75%; }
-  .col-tablet-push-13of16 {
-    left: 81.25%; }
-  .col-tablet-push-15of16 {
-    left: 93.75%; } }
-
-.col-3-wide {
-  width: 33.3333333333%; }
-
-@media (max-width: 719px) {
-  /* Remove .col-12 and .col-13 backward compatibility support as soon as it's been removed. */
-[class*=col-],
-  .col-12 [class*=col-],
-  .col-13 [class*=col-] {
-  float: none;
-  left: 0;
-  width: auto;
-} }
-
-/**
- * Fades out an element.
- * Applies visibility hidden when the transition is finished.
- *
- * Use opacity: 1; to show the element.
- */
-/* Header component */
-.dac-header {
-  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.07);
-  box-sizing: border-box;
-  background: #6ab344;
-  height: 64px;
-  margin: 0;
-  left: 0;
-  position: fixed;
-  right: 0;
-  top: 0;
-  -webkit-transition: background 200ms;
-  transition: background 200ms;
-  z-index: 61;
-}
-
-.dac-ndk .dac-header {
-  background: #00bcd4;
-}
-
-.dac-studio .dac-header {
-  background: #424242;
-}
-
-.dac-search-mode .dac-header {
-  background: #b0bec5;
-  -webkit-transition: background 200ms;
-  transition: background 200ms;
-}
-
-.dac-search-mode .dac-header-logo,
-  .dac-search-mode .dac-header-console-btn {
-  opacity: 0;
-  visibility: hidden;
-  -webkit-transition: visibility 0s linear 200ms, opacity 200ms linear;
-  transition: visibility 0s linear 200ms, opacity 200ms linear;
-}
-
-.dac-header-logo {
-  display: block;
-  font-size: 20px;
-  font-weight: 400;
-  float: left;
-  letter-spacing: .3px;
-  line-height: 36px;
-  opacity: 1;
-  padding: 13px 48px 15px 0;
-}
-
-.dac-header-logo, .dac-header-logo:hover, .dac-header-logo:focus {
-  color: #fff;
-}
-
-@media (min-width: 980px) {
-  .dac-header-logo {
-    border-right: 1px solid rgba(0, 0, 0, 0.1);
-  }
-}
-
-@media (min-width: 720px) and (max-width: 979px) {
-  .dac-header-logo {
-    padding-right: 10px;
-  }
-}
-
-.dac-header-logo-image {
-  margin-right: 5px;
-  vertical-align: top;
-}
-
-.dac-header-tabs {
-  list-style: none;
-  margin: 0 10px;
-  display: none;
-  opacity: 1;
-  -webkit-transition: opacity 200ms linear 200ms;
-  transition: opacity 200ms linear 200ms;
-}
-
-@media (min-width: 720px) {
-  .dac-header-tabs {
-    display: inline-block;
-  }
-
-  /* Do not show nav toggle and up-nav button for left nav,
-     when header tabs are visible (when no sub navigation) */
-  body.no-subnav .dac-nav-back-button {
-    display:none;
-  }
-  body.no-subnav .dac-nav-sub {
-    top: 0 !important;
-  }
-}
-
-.dac-header-tabs li {
-  display: inline-block;
-}
-
-.dac-header-tab {
-  display: inline-block;
-  line-height: 64px;
-  height: 64px;
-  padding: 0 9px;
-  color: #fff;
-  color: rgba(255, 255, 255, 0.7);
-  font-size: 14px;
-  text-transform: uppercase;
-  font-weight: 500;
-}
-
-.dac-header-tab:hover,
-.dac-header-tab:focus {
-  color: #fff;
-}
-
-.dac-header-tab.selected {
-  border-bottom: 4px solid #fff;
-  height: 60px;
-  color: #fff;
-}
-
-.dac-search-mode .dac-header-tabs {
-  opacity: 0;
-  -webkit-transition: opacity 0ms linear 0ms;
-  transition: opacity 0ms linear 0ms;
-}
-
-.dac-header-console-btn {
-  border-radius: 3px;
-  box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.2);
-  float: right;
-  font-size: 14px;
-  font-weight: 500;
-  line-height: 28px;
-  margin: 13px 13px 12px 24px;
-  opacity: 1;
-  padding: 4px 10px;
-  position: relative;
-  text-transform: uppercase;
-  -webkit-transition: box-shadow .2s;
-  transition: box-shadow .2s;
-  z-index: 60;
-}
-
-@media (min-width: 720px) and (max-width: 979px) {
-  .dac-header-console-btn {
-    display: none;
-  }
-}
-
-.dac-header-console-btn > .dac-sprite, .dac-header-console-btn > .dac-modal-header-close:before, .paging-links .dac-header-console-btn > .prev-page-link:before, .paging-links .dac-header-console-btn > .next-page-link:before, .paging-links .dac-header-console-btn > .next-class-link:before, .paging-links .dac-header-console-btn > .start-class-link:after {
-  margin-right: 5px;
-}
-
-.dac-header-console-btn, .dac-header-console-btn:hover, .dac-header-console-btn:focus {
-  color: #fff;
-}
-
-.dac-header-console-btn:hover {
-  box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.3);
-}
-
-.dac-header-console-btn:focus {
-  background: rgba(63, 81, 181, 0.1);
-  outline: 0;
-}
-
-.dac-studio .dac-header-console-btn {
-  color:#fff;
-  background:rgba(255, 255, 255, 0.3);
-}
-.dac-studio .dac-header-console-btn:hover {
-  background:rgba(255, 255, 255, 0.5);
-}
-.dac-studio .dac-header-console-btn:focus {
-  background:rgba(255, 255, 255, 0.7);
-  color:#000;
-}
-
-@media (max-width: 719px) {
-  .dac-header {
-    text-align: center;
-  }
-
-  .dac-header-logo {
-    border-right: 0;
-    display: inline-block;
-    margin-right: 0;
-    float: none;
-    padding-left: 0;
-    padding-right: 0;
-  }
-
-  .dac-header-console-btn {
-    display: none;
-  }
-}
-
-/* Header Breadcrumbs component */
-.dac-header-crumbs {
-  list-style-type: none;
-  margin: 23px 0 -13px 0;
-  display: inline-block;
-}
-
-body.no-crumbs .dac-header-crumbs {
-  display:none;
-}
-
-.dac-header-crumbs.dac-has-content {
-  opacity: 1;
-}
-
-.dac-header-crumbs-item {
-  float: left;
-  position: relative;
-  margin: 0;
-  padding: 0;
-}
-
-.dac-header-crumbs-item i, .dac-header-crumbs-item .dac-nav-link-forward {
-  display: none;
-}
-
-.dac-header-crumbs-item:before {
-  content: '';
-  background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
-  width: 10px;
-  height: 10px;
-  display: inline-block;
-  position: absolute;
-  top: 12px;
-  left: -15px;
-}
-
-.dac-header-crumbs-item:first-child:before {
-  content: none;
-}
-
-.dac-header-crumbs-link {
-  display: block;
-  font-size: 16px;
-  line-height: 32px;
-  padding: 0 20px 0 0;
-}
-
-.dac-header-crumbs-link, .dac-header-crumbs-link:hover, .dac-header-crumbs-link:focus {
-  color: #666;
-}
-
-.dac-header-crumbs-link:focus {
-  outline: 0;
-  text-decoration: underline;
-}
-
-.dac-header-crumbs-link.current {
-  font-weight: 400;
-}
-
-/* Header site search component */
-.dac-header-search {
-  bottom: 64px;
-  position: absolute;
-  right: 220px;
-  top: 0;
-  width: 238px;
-  -webkit-transition: width 300ms, right 100ms, margin 100ms;
-  transition: width 300ms, right 100ms, margin 100ms;
-}
-
-.dac-studio .dac-header-search {
-  right: 20px; /* move searchbar farther right, because there's no button */
-}
-
-.dac-header-search-inner {
-  margin: 0 auto;
-  max-width: 940px;
-  position: relative;
-  width: 100%;
-}
-
-@media (min-width: 980px) {
-  .dac-header-search-inner::after {
-    background: -webkit-linear-gradient(right, #6ab344, rgba(106, 179, 68, 0));
-    background: linear-gradient(to left, #6ab344, rgba(106, 179, 68, 0));
-    content: '';
-    display: block;
-    height: 64px;
-    position: absolute;
-    right: 100%;
-    top: 0;
-    -webkit-transition: opacity 200ms, -webkit-transform 300ms;
-    transition: opacity 200ms, transform 300ms;
-    -webkit-transform-origin: right center;
-    -ms-transform-origin: right center;
-    transform-origin: right center;
-    width: 64px;
-  }
-  .dac-studio .dac-header-search-inner::after {
-    background: -webkit-linear-gradient(right, #424242, rgba(66, 66, 66, 0));
-    background: linear-gradient(to left, #424242, rgba(66, 66, 66, 0));
-  }
-
-  .dac-search-mode .dac-header-search-inner::after {
-    opacity: 0;
-    -webkit-transform: scaleX(0);
-    -ms-transform: scaleX(0);
-    transform: scaleX(0);
-  }
-}
-
-.dac-header-search-icon {
-  left: 8px;
-  pointer-events: none;
-  position: absolute;
-  top: 18px;
-}
-
-.dac-header-search-input {
-  background: #77be53;
-  border-radius: 3px;
-  border: none;
-  box-sizing: border-box;
-  color: #fff;
-  font-size: 14px;
-  font-weight: 600;
-  margin: 13px 0;
-  padding: 9px 36px 10px;
-  -webkit-transition: background 200ms, color 200ms;
-  transition: background 200ms, color 200ms;
-  width: 100%;
-}
-
-.dac-studio .dac-header-search-input {
-  background: rgba(255, 255, 255, 0.3);
-}
-
-.dac-header-search-close, .dac-header-search-clear {
-  background: none;
-  border: none;
-  cursor: pointer;
-  font-size: 0;
-  outline: none;
-  position: absolute;
-  margin: 0;
-}
-
-.dac-header-search-clear {
-  display: inline-block;
-  opacity: .4;
-  padding: 8px;
-  top: 15px;
-  right: 0;
-}
-
-.dac-header-search-clear:hover, .dac-header-search-clear:focus {
-  opacity: .8;
-}
-
-.dac-header-search-close {
-  left: -45px;
-  top: 20px;
-  -webkit-transform: translateX(45px);
-  -ms-transform: translateX(45px);
-  transform: translateX(45px);
-  visibility: hidden;
-}
-
-.dac-header-search ::-webkit-input-placeholder {
-  color: #fff;
-  font-weight: 300;
-  -webkit-transition: color 200ms;
-  transition: color 200ms;
-}
-
-.dac-header-search :-moz-placeholder {
-  color: #fff;
-  font-weight: 300;
-  transition: color 200ms;
-}
-
-.dac-header-search ::-moz-placeholder {
-  color: #fff;
-  font-weight: 300;
-  transition: color 200ms;
-}
-
-.dac-header-search :-ms-input-placeholder {
-  color: #fff;
-  font-weight: 300;
-  transition: color 200ms;
-}
-
-.dac-header-search-input:focus {
-  outline: 0;
-}
-
-.dac-search-mode .dac-header-search {
-  width: 940px;
-  right: 50%;
-  margin-right: -470px;
-}
-
-.dac-search-mode .dac-header-search .dac-header-search-input::after {
-  background: -webkit-linear-gradient(right, #b0bec5, rgba(176, 190, 197, 0));
-  background: linear-gradient(to left, #b0bec5, rgba(176, 190, 197, 0));
-}
-
-.dac-search-mode .dac-header-search .dac-header-search-close {
-  -webkit-transition: -webkit-transform 200ms ease-out 300ms;
-  transition: transform 200ms ease-out 300ms;
-  -webkit-transform: translateX(0);
-  -ms-transform: translateX(0);
-  transform: translateX(0);
-  visibility: visible;
-}
-
-.dac-search-mode .dac-header-search .dac-header-search-icon {
-  left: 23px;
-}
-
-.dac-search-mode .dac-header-search .dac-header-search-input {
-  background: #fff;
-  border-radius: 0;
-  font-size: 18px;
-  color: #666;
-  padding-left: 55px;
-  margin-top: 11px;
-}
-
-.dac-search-mode .dac-header-search ::-webkit-input-placeholder {
-  color: #505050;
-}
-
-.dac-search-mode .dac-header-search :-moz-placeholder {
-  color: #505050;
-}
-
-.dac-search-mode .dac-header-search ::-moz-placeholder {
-  color: #505050;
-}
-
-.dac-search-mode .dac-header-search :-ms-input-placeholder {
-  color: #505050;
-}
-
-@media (min-width: 720px) and (max-width: 979px) {
-  .dac-studio .dac-header-search,
-  .dac-header-search {
-    right: 20px;
-    width: 200px;
-    -webkit-transition: left 200ms, right 200ms, width 200ms;
-    transition: left 200ms, right 200ms, width 200ms;
-  }
-
-  .dac-search-mode .dac-header-search {
-    left: 60px;
-    right: 0;
-    width: 100%;
-  }
-
-  .dac-search-mode .dac-header-search .dac-header-search-inner {
-    margin: 0;
-    width: calc(100% - 60px - 10px);
-  }
-
-  .dac-header-search-close {
-    left: -42px;
-  }
-}
-
-@media (max-width: 719px) {
-  .dac-header-search {
-    bottom: 0;
-    border-radius: 0;
-    border-left: 1px solid rgba(0, 0, 0, 0.1);
-    cursor: pointer;
-    left: calc(100% - 64px);
-    margin: 0;
-    overflow: hidden;
-    padding-left: 10px;
-    padding-right: 10px;
-    position: absolute;
-    right: 0;
-    top: 0;
-  }
-
-  .dac-header-search-input {
-    background: none;
-    cursor: pointer;
-    opacity: 0;
-  }
-
-  .dac-search-mode .dac-header-search {
-    background: #b0bec5;
-    cursor: default;
-    overflow: visible;
-    left: 60px;
-    right: 0;
-    width: 100%;
-    -webkit-transition: left 200ms, right 200ms, width 200ms;
-    transition: left 200ms, right 200ms, width 200ms;
-    padding: 0;
-    border: none;
-  }
-
-  .dac-search-mode .dac-header-search .dac-header-search-inner {
-    margin: 0;
-    width: calc(100% - 60px - 10px);
-  }
-
-  .dac-search-mode .dac-header-search .dac-header-search-input {
-    opacity: 1;
-  }
-}
-
-.highlighted em {
-  color: #333;
-  font-style: normal;
-  font-weight: 700;
-}
-
-.card-info .title.highlighted {
-  color: #666;
-}
-
-/* Main navigation component */
-.dac-nav-sidebar {
-  background: #f5f8fa;
-  border-right: 1px solid rgba(0, 0, 0, 0.1);
-  bottom: 0;
-  left: 0;
-  overflow: hidden;
-  padding: 0;
-  position: fixed;
-  top: 64px;
-  -webkit-transform: translate(-100%, 0);
-  -ms-transform: translate(-100%, 0);
-  transform: translate(-100%, 0);
-  width: 250px;
-  z-index: 60;
-}
-
-.dac-nav-animating .dac-nav-sidebar {
-  -webkit-transition: -webkit-transform .3s;
-  transition: transform .3s;
-}
-
-.dac-nav-open .dac-nav-sidebar {
-  -webkit-transform: translate(0, 0);
-  -ms-transform: translate(0, 0);
-  transform: translate(0, 0);
-}
-
-.dac-search-mode .dac-nav-sidebar {
-  -webkit-transition: -webkit-transform .3s;
-  transition: transform .3s;
-  -webkit-transform: translate(-100%, 0);
-  -ms-transform: translate(-100%, 0);
-  transform: translate(-100%, 0);
-}
-
-.dac-nav .dac-swap-section {
-  -webkit-transition-duration: .3s;
-  transition-duration: .3s;
-}
-
-.dac-nav-back {
-  margin-top: -3px;
-  margin-right: 10px;
-}
-
-.dac-nav-fullscreen {
-  background: transparent;
-  border: none;
-  bottom: 100%;
-  cursor: pointer;
-  display: none;
-  opacity: .8;
-  outline: none;
-  padding: 20px 15px;
-  position: absolute;
-  right: 0;
-}
-
-@media (min-width: 980px) {
-  .dac-nav-fullscreen {
-    display: inline-block;
-  }
-}
-
-.dac-nav-fullscreen:hover {
-  opacity: 1;
-}
-
-.dac-nav-sub-slider {
-  cursor: pointer;
-  opacity: .5;
-  position: absolute;
-  right: 7px;
-  top: 5px;
-}
-
-.dac-nav-back-button {
-  background: #546e7a;
-  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
-  display: block;
-  font-weight: 500;
-  font-size: 18px;
-  left: 0;
-  margin: 0;
-  padding: 20px;
-  position: absolute !important;
-  right: 0;
-  top: 0;
-  z-index: 1;
-}
-
-.dac-nav-back-button,
-.dac-nav-back-button:hover,
-.dac-nav-back-button:active,
-.dac-nav-back-button:focus     {
-  color: rgba(255, 255, 255, 0.7);
-}
-
-/* The back button in Studio and NDK left nav */
-.dac-nav-back-button.back-to-dev {
-  background: none;
-  color: #444;
-  position: relative !important;
-  top: -16px;
-}
-
-.dac-nav-back-button.back-to-dev:hover,
-.dac-nav-back-button.back-to-dev:active,
-.dac-nav-back-button.back-to-dev:focus {
-  color: rgba(68, 68, 68, .7);
-}
-
-.dac-nav-back-button:focus .dac-nav-back {
-  outline-color: rgb(77, 144, 254);
-  outline-offset: 15px;
-  outline-style: auto;
-}
-
-.dac-nav-back-button > .dac-sprite, .dac-nav-back-button > .dac-modal-header-close:before, .paging-links .dac-nav-back-button > .prev-page-link:before, .paging-links .dac-nav-back-button > .next-page-link:before, .paging-links .dac-nav-back-button > .next-class-link:before, .paging-links .dac-nav-back-button > .start-class-link:after {
-  opacity: .7;
-}
-
-.dac-nav-logo {
-  font-size: 20px;
-  font-weight: 300;
-  letter-spacing: .3px;
-  line-height: 36px;
-  margin: 0;
-  padding: 14px 24px;
-}
-
-.dac-nav-logo, .dac-nav-logo:hover, .dac-nav-logo:focus {
-  color: #444;
-}
-
-.dac-nav-list {
-  bottom: 0;
-  left: 0;
-  list-style-type: none;
-  margin: 0;
-  -webkit-overflow-scrolling: touch;
-  overflow-y: scroll;
-  padding: 16px 0;
-  position: absolute !important;
-  right: 0;
-  top: 0 !important;
-  scrollbar-face-color: #b7baba;
-  scrollbar-track-color: #e5e8e9;
-}
-
-.dac-nav-list::-webkit-scrollbar {
-  width: 4px;
-  height: 4px;
-}
-
-.dac-nav-list::-webkit-scrollbar-thumb {
-  background: #b7baba;
-}
-
-.dac-nav-list::-webkit-scrollbar-track {
-  background: #e5e8e9;
-}
-
-.dac-nav-secondary {
-  margin: 0;
-}
-
-.dac-nav-item {
-  list-style-type: none;
-  margin: 0 0 10px;
-  position: relative;
-}
-
-.dac-nav-secondary .dac-nav-item {
-  margin-bottom: 0;
-}
-
-.dac-nav-head {
-  display: block;
-  font-size: 16px;
-  font-weight: 300;
-  letter-spacing: .24px;
-  line-height: 32px;
-  margin-bottom: 20px;
-  margin-top: 0;
-}
-
-.dac-nav-dimmer {
-  background: #000;
-  display: block;
-  height: 100%;
-  left: 0;
-  opacity: 0;
-  position: fixed;
-  top: 0;
-  -webkit-transform: translateZ(0);
-  transform: translateZ(0);
-  visibility: hidden;
-  width: 100%;
-  z-index: 60;
-}
-
-.dac-nav-animating .dac-nav-dimmer {
-  -webkit-transition: visibility 0s linear .3s, opacity .3s linear;
-  transition: visibility 0s linear .3s, opacity .3s linear;
-}
-
-.dac-nav-open .dac-nav-dimmer {
-  opacity: .8;
-  -webkit-transition-delay: 0s;
-  transition-delay: 0s;
-  visibility: visible;
-}
-
-@media (min-width: 980px) {
-  .dac-nav-dimmer {
-    display: none;
-  }
-}
-
-.dac-nav-hamburger {
-  display: inline-block;
-  float: left;
-  height: 15px;
-  padding: 22px 20px;
-  width: 18px;
-}
-
-@media (max-width: 719px) {
-  .dac-nav-hamburger {
-    border-right: 1px solid rgba(0, 0, 0, 0.1);
-    left: 0;
-    padding-bottom: 27px;
-    position: absolute;
-    top: 0;
-  }
-}
-
-.dac-nav-hamburger-top, .dac-nav-hamburger-mid, .dac-nav-hamburger-bot {
-  background: rgba(0, 0, 0, 0.4);
-  display: block;
-  height: 2px;
-  margin: 3px 0 0;
-  opacity: .5;
-  width: 100%;
-}
-
-.dac-studio .dac-nav-hamburger-top,
-.dac-studio .dac-nav-hamburger-mid,
-.dac-studio .dac-nav-hamburger-bot {
-  background: rgba(256, 256, 256, 0.4);
-}
-
-.dac-nav-animating .dac-nav-hamburger-top, .dac-nav-animating .dac-nav-hamburger-mid, .dac-nav-animating .dac-nav-hamburger-bot {
-  -webkit-transition: opacity .3s;
-  transition: opacity .3s;
-}
-
-@media (max-width: 719px) {
-  .dac-nav-hamburger-top, .dac-nav-hamburger-mid, .dac-nav-hamburger-bot {
-    background: #fff;
-    opacity: 1;
-  }
-}
-
-.dac-nav-open .dac-nav-hamburger-top,
-  .dac-nav-open .dac-nav-hamburger-mid,
-  .dac-nav-open .dac-nav-hamburger-bot {
-  opacity: 1;
-}
-
-.dac-search-mode .dac-nav-hamburger {
-  opacity: 0;
-  visibility: hidden;
-  -webkit-transition: visibility 0s linear 200ms, opacity 200ms linear;
-  transition: visibility 0s linear 200ms, opacity 200ms linear;
-}
-
-.dac-nav-link {
-  color: #444;
-  display: block;
-  font-size: 14px;
-  text-transform: uppercase;
-  font-weight: 500;
-  letter-spacing: .24px;
-  padding: 5px 20px;
-  -webkit-transition: background-color 0.35s cubic-bezier(0.35, 0, 0.25, 1);
-  transition: background-color 0.35s cubic-bezier(0.35, 0, 0.25, 1);
-}
-
-.dac-nav-link:hover, .dac-nav-link:focus {
-  color: rgba(68, 68, 68, 0.7);
-}
-
-.dac-nav-link:focus {
-  background: rgba(63, 81, 181, 0.1);
-  outline: 0;
-}
-
-.dac-nav-secondary .dac-nav-link {
-  font-size: 12px;
-  font-weight: 400;
-  padding-left: 40px;
-  text-transform: none;
-}
-
-.dac-nav-link.selected {
-  background: rgba(63, 81, 181, 0.1);
-  color: #039bef;
-  position: relative;
-}
-
-.dac-nav-link-forward {
-  background: #546E7A;
-  color: #fff;
-  cursor: pointer;
-  display: inline-block;
-  line-height: 34px;
-  padding: 0;
-  position: absolute;
-  right: 0;
-  top: 0;
-  text-align: center;
-  width: 34px;
-}
-
-.dac-nav-link-forward > .dac-nav-forward {
-  opacity: .7;
-  vertical-align: -3px;
-}
-
-.dac-nav-sub {
-  bottom: 0;
-  left: 0;
-  position: absolute !important;
-  top: 65px !important;
-  right: 0;
-  z-index: 1;
-}
-
-#body-content {
-  padding-top: 64px;
-}
-
-.dac-nav-animating #body-content {
-  -webkit-transition: padding .3s;
-  transition: padding .3s;
-}
-
-@media (min-width: 980px) {
-  .dac-nav-open #body-content {
-    padding-left: 250px;
-  }
-
-  /* Do not show nav toggle on large screens (when no subnav) */
-  body.no-subnav .dac-nav-toggle {
-    display:none;
-  }
-  body.no-subnav .dac-header-logo {
-    padding-left:20px;
-  }
-  /* ...If the page is also full-width, then don't show left nav at all */
-  body.no-subnav.full-width .dac-nav {
-    display: none;
-  }
-  body.no-subnav.full-width #body-content {
-    padding-left:0;
-  }
-}
-
-.dac-nav-open {
-  overflow: hidden;
-}
-
-@media (min-width: 980px) {
-  .dac-nav-open {
-    overflow: visible;
-  }
-}
-
-#devdoc-nav {
-  height: 100%;
-}
-
-.data-reference-resources-wrapper {
-  display: none;
-}
-
-.dac-reference-nav {
-  height: calc(100% - 36px);
-  overflow: hidden;
-  position: relative;
-}
-
-.dac-reference-nav ul,
-  .dac-reference-nav li {
-  margin: 0;
-  list-style-type: none;
-}
-
-.dac-reference-nav-list {
-  bottom: 0;
-  overflow: hidden;
-  overflow-y: scroll;
-  left: 0;
-  padding: 10px;
-  padding-left: 20px;
-  position: absolute;
-  right: 0;
-  top: 0;
-  scrollbar-face-color: #9da4a7;
-  scrollbar-track-color: #c4cdd1;
-}
-
-.dac-reference-nav-list::-webkit-scrollbar {
-  width: 4px;
-  height: 4px;
-}
-
-.dac-reference-nav-list::-webkit-scrollbar-thumb {
-  background: #9da4a7;
-}
-
-.dac-reference-nav-list::-webkit-scrollbar-track {
-  background: #c4cdd1;
-}
-
-.dac-reference-nav-resources {
-  display: none;
-  padding: 0 0 0 13px;
-}
-
-.dac-reference-nav-resource,
-.dac-reference-nav-toggle {
-  color: #505050;
-  cursor: pointer;
-  display: block;
-  font-size: 12px;
-  line-height: 1;
-  overflow: hidden;
-  margin: 0;
-  padding: 3px 0;
-  position: relative;
-  text-overflow: ellipsis;
-  white-space: nowrap;
-}
-
-.dac-reference-nav-toggle {
-  margin-left: -12px;
-  padding-left: 12px;
-}
-
-.selected > .dac-reference-nav-resource {
-  color: #039bef;
-  font-weight: 600;
-}
-
-.dac-reference-nav-toggle::before {
-  background: transparent url(../images/styles/disclosure_up.png) no-repeat center center;
-  content: '';
-  display: block;
-  height: 19px;
-  left: 0;
-  position: absolute;
-  top: 0;
-  width: 8px;
-}
-
-.dac-reference-nav-toggle.dac-closed::before {
-  -webkit-transform: scaleY(-1);
-  -ms-transform: scaleY(-1);
-  transform: scaleY(-1);
-}
-
-/* nav */
-#nav {
-  background: #cfd8dc;
-  bottom: 0;
-  left: 0;
-  margin: 0;
-  -webkit-overflow-scrolling: touch;
-  overflow-y: scroll;
-  position: absolute !important;
-  right: 0;
-  top: 0 !important;
-  padding: 10px;
-  scrollbar-face-color: #9da4a7;
-  scrollbar-track-color: #c4cdd1;
-  /* section header links */
-  /* nested nav headers */
-}
-
-#nav::-webkit-scrollbar {
-  width: 4px;
-  height: 4px;
-}
-
-#nav::-webkit-scrollbar-thumb {
-  background: #9da4a7;
-}
-
-#nav::-webkit-scrollbar-track {
-  background: #c4cdd1;
-}
-
-#nav li {
-  font-size: 12px;
-  line-height: 18px;
-  list-style-type: none;
-  margin: 0;
-  padding: 0;
-}
-
-#nav a {
-  color: #505050;
-  text-decoration: none;
-  word-wrap: break-word;
-}
-
-#nav .nav-section-header {
-  padding: 0 30px 0 0;
-  position: relative;
-  -webkit-transition: background-color .1s;
-  transition: background-color .1s;
-}
-
-#nav .nav-section-header.empty {
-  padding: 0;
-}
-
-#nav .nav-section-header.empty::after {
-  display: none;
-}
-
-#nav .nav-section-header .toggle-icon {
-  background: transparent url(../images/styles/disclosure_down.png) no-repeat scroll 50% 50%;
-  content: '';
-  height: 34px;
-  display: block;
-  position: absolute;
-  right: 0;
-  top: 1px;
-  width: 34px;
-}
-
-#nav li.selected a {
-  color: #0288D1;
-}
-
-#nav li.selected ul li a {
-  color: #505050;
-}
-
-#nav li.expanded .nav-section-header {
-  background: #bac2c6;
-}
-
-#nav li.expanded .nav-section-header.empty {
-  background: none;
-}
-
-#nav li.expanded li .nav-section-header {
-  background: none;
-}
-
-#nav li.expanded li ul {
-  padding: 0 10px;
-}
-
-#nav li.expanded > .nav-section-header .toggle-icon {
-  content: '';
-  background: transparent url(../images/styles/disclosure_up.png) no-repeat scroll 50% 50%;
-  width: 34px;
-  height: 34px;
-}
-
-#nav li.expanded li ul.tree-list-children {
-  padding: 0;
-}
-
-#nav li.expanded li ul.tree-list-children .tree-list-children {
-  padding: 0 0 0 10px;
-}
-
-#nav .nav-section .nav-section .nav-section-header {
-    /* no white line between second level sections */
-  margin-bottom: 0;
-}
-
-#nav > li > div > a {
-  display: block;
-  font-weight: 700;
-  padding: 10px;
-}
-
-#nav .nav-section .nav-section {
-  position: relative;
-  padding: 0;
-  margin: 0;
-}
-
-#nav .nav-section li a {
-    /* first gen child (2nd level li) */
-  display: block;
-  font-weight: 700;
-  text-transform: none;
-  padding: 10px;
-}
-
-#nav .nav-section li li a {
-    /* second gen child (3rd level li) */
-  font-weight: 400;
-  padding: 6px 6px 6px 10px;
-}
-
-#nav li span.tree-list-subtitle {
-  display: inline-block;
-  color: #555;
-  font-size: 12px;
-  padding: 10px;
-  text-transform: uppercase;
-}
-
-#nav li span.tree-list-subtitle:before {
-  content: '—';
-}
-
-#nav li span.tree-list-subtitle:after {
-  content: '—';
-}
-
-#nav li span.tree-list-subtitle.package {
-  padding-top: 15px;
-  cursor: default;
-}
-
-#nav li span.tree-list-subtitle.package:before {
-  content: '';
-}
-
-#nav li span.tree-list-subtitle.package:after {
-  content: '';
-}
-
-#nav li ul.tree-list-children.classes {
-  padding-left: 10px;
-}
-
-#nav li ul {
-  display: none;
-  overflow: hidden;
-  margin: 0;
-}
-
-#nav li ul.animate-height-in {
-  -webkit-transition: height 0.25s ease-in;
-  transition: height 0.25s ease-in;
-}
-
-#nav li ul.animate-height-out {
-  -webkit-transition: height 0.25s ease-out;
-  transition: height 0.25s ease-out;
-}
-
-#nav li ul li {
-  padding: 0;
-}
-
-#nav li li li {
-  padding: 0;
-}
-
-#nav li ul > li {
-  padding: 0;
-}
-
-#nav li ul > li:last-child {
-  padding-bottom: 5px;
-}
-
-#nav li ul.tree-list-children > li:last-child {
-  padding-bottom: 0;
-}
-
-#nav li.expanded ul > li {
-  background: #c4cdd1;
-}
-
-#nav li.expanded ul > li li {
-  background: inherit;
-}
-
-#nav li ul.tree-list-children ul {
-  display: block;
-}
-
-#nav.samples-nav li li li a {
-  padding-top: 3px;
-  padding-bottom: 3px;
-}
-
-#nav.samples-nav li li ul > li:last-child {
-  padding-bottom: 3px;
-}
-
-/* Hero carousel */
-.dac-hero {
-  background-color: #fff;
-  background-position: 50% 30%;
-  background-size: cover;
-  box-sizing: border-box;
-  font-size: 16px;
-  min-height: 550px;
-  padding-top: 88px;
-}
-
-.dac-hero.dac-darken::before {
-  background: rgba(0, 0, 0, 0.3);
-  bottom: 0;
-  content: '';
-  display: block;
-  left: 0;
-  position: absolute;
-  right: 0;
-  top: 0;
-}
-
-.dac-hero {
-  background-size: cover;
-  position: relative;
-}
-
-.dac-hero-headline {
-  background-color: #fff;
-  bottom: 25px;
-  float: none !important;
-  padding: 0 10px 10px;
-  position: absolute;
-  right: 0;
-  z-index: 2;
-}
-
-@media (max-width: 719px) {
-  .dac-hero-headline {
-    bottom: 0;
-  }
-
-  .dac-hero.dac-darken::before {
-    background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.9) 80%);
-    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.9) 80%);
-  }
-}
-
-.dac-hero.dac-darken .dac-hero-content {
-  position: relative;
-}
-
-@media (max-width: 719px) {
-  .dac-hero {
-    padding-bottom: 20px;
-    padding-top: 20px;
-  }
-}
-
-.dac-hero-tag {
-  font-size: 11px;
-  font-weight: 700;
-  letter-spacing: .07em;
-  margin-bottom: 2px;
-  text-transform: uppercase;
-}
-
-.dac-hero-title {
-  margin: 0 0 14px;
-}
-
-.dac-studio .dac-hero-title {
-  padding-top:0;
-}
-
-@media (max-width: 719px) {
-  .dac-hero-title {
-    font-size: 28px;
-    line-height: 35px;
-  }
-}
-
-.dac-hero-description {
-  margin-bottom: 16px;
-}
-
-@media (max-width: 719px) {
-  .dac-hero-description {
-    font-size: 14px;
-  }
-}
-
-.dac-hero-cta {
-  display: inline-block;
-  line-height: 40px;
-  margin-right: 20px;
-  -webkit-transition: opacity .3s;
-  transition: opacity .3s;
-}
-
-.dac-hero-cta:hover {
-  color: currentColor;
-  opacity: .54;
-}
-
-.dac-hero-cta .dac-sprite, .dac-hero-cta .dac-modal-header-close:before, .dac-hero-cta .paging-links .prev-page-link:before, .paging-links .dac-hero-cta .prev-page-link:before, .dac-hero-cta .paging-links .next-page-link:before, .paging-links .dac-hero-cta .next-page-link:before, .dac-hero-cta .paging-links .next-class-link:before, .paging-links .dac-hero-cta .next-class-link:before, .dac-hero-cta .paging-links .start-class-link:after, .paging-links .dac-hero-cta .start-class-link:after {
-  margin-left: -8px;
-}
-
-.dac-hero-cta.col-16 {
-  line-height: 1.4em;
-  margin-top: 20px;
-  padding-left: 0;
-  position: relative;
-}
-
-.dac-hero-cta.col-16 .dac-sprite {
-  position: absolute;
-  left: 0;
-  top: -3px;
-}
-
-.dac-hero-cta.col-16 .dac-sprite-text {
-  position: relative;
-  left: 12px;
-}
-
-@media (max-width: 719px) {
-  .dac-hero-cta {
-    line-height: 28px;
-  }
-}
-
-.dac-hero-figure {
-  text-align: center;
-}
-
-/* Android Studio download page */
-.dac-studio section#features {
-  padding-top:0;
-}
-.dac-studio .wrap.feature {
-  margin:80px auto;
-}
-.dac-studio .dac-section-links.feature-more {
-  margin-top:-20px;
-}
-.dac-studio .dac-toggle-content .wrap.feature {
-  margin-top:0;
-}
-
-@media (max-width: 719px) {
-  .dac-hero-figure {
-    height: 150px;
-    margin: 15px 0;
-  }
-
-  .dac-hero-figure img {
-    max-height: 150px;
-  }
-
-  /* Android Studio download page */
-  .dac-studio .feature .dac-hero-figure,
-  .dac-studio .feature .dac-hero-figure img {
-    height:auto;
-    max-height:none;
-  }
-  .dac-studio .feature .dac-hero-figure img {
-    width:90%;
-    margin:0 auto;
-  }
-}
-
-.dac-hero-carousel {
-  height: 550px;
-  position: relative;
-}
-
-.dac-hero-carousel > .dac-hero {
-  bottom: 0;
-  left: 0;
-  position: absolute;
-  right: 0;
-  top: 0;
-  will-change: opacity;
-}
-
-.dac-hero-carousel > .dac-hero,
-    .dac-hero-carousel > .dac-hero .wrap {
-  opacity: 0;
-}
-
-.dac-hero-carousel > .dac-hero.active {
-  opacity: 1;
-  -webkit-transition: opacity .5s;
-  transition: opacity .5s;
-  z-index: 1;
-}
-
-.dac-hero-carousel > .dac-hero.active .wrap {
-  opacity: 1;
-  -webkit-transition: opacity .5s .5s;
-  transition: opacity .5s .5s;
-}
-
-.dac-hero-carousel > .dac-hero.out,
-    .dac-hero-carousel > .dac-hero.out .wrap {
-  -webkit-transition: opacity 0s .5s;
-  transition: opacity 0s .5s;
-  opacity: 0;
-}
-
-.dac-hero-carousel-action {
-  bottom: 0;
-  display: block;
-  left: 0;
-  position: absolute;
-  right: 0;
-  top: 0;
-  z-index: 1;
-}
-
-.dac-hero-carousel .dac-hero-cta {
-  position: relative;
-  z-index: 1;
-}
-
-.dac-hero-carousel-pagination {
-  bottom: 33px;
-  left: 0;
-  position: absolute;
-  right: 0;
-}
-
-@media (max-width: 719px) {
-  .dac-hero-carousel-pagination {
-    text-align: center;
-    bottom: 20px;
-  }
-}
-
-.dac-hero-carousel-pagination .dac-pagination-item {
-  position: relative;
-  z-index: 1;
-}
-
-.dac-pagination {
-  list-style: none;
-  margin: 0 -6px;
-}
-
-.dac-pagination-item {
-  background-clip: content-box;
-  background-color: rgba(153, 153, 153, 0.4);
-  border-radius: 50%;
-  cursor: pointer;
-  display: inline-block;
-  height: 14px;
-  overflow: hidden;
-  padding: 6px;
-  pointer-events: all;
-  text-indent: 100%;
-  -webkit-transition: background-color .1s ease-in;
-  transition: background-color .1s ease-in;
-  white-space: nowrap;
-  width: 14px;
-  will-change: background-color;
-}
-
-.dac-pagination-item:hover {
-  background-color: rgba(153, 153, 153, 0.6);
-}
-
-.dac-pagination-item.active, .dac-pagination-item.active:hover {
-  background-color: #6ab344;
-}
-
-.dac-invert .dac-pagination-item {
-  background-color: rgba(204, 204, 204, 0.2);
-}
-
-.dac-invert .dac-pagination-item:hover {
-  background-color: rgba(153, 153, 153, 0.4);
-}
-
-@media (max-width: 719px) {
-  .dac-pagination-item {
-    height: 12px;
-    width: 12px;
-  }
-}
-
-/* Form component */
-.dac-form {
-  color: #505050;
-  font-size: 16px;
-  /* Modal Responsive */
-}
-
-.dac-form a {
-  color: #000;
-}
-
-.dac-form-aside {
-  display: inline-block;
-  font-size: 12px;
-  margin-top: 0;
-}
-
-.dac-form-required {
-  color: #ef4300;
-}
-
-.dac-form-fieldset {
-  padding: 0;
-}
-
-.dac-form-legend {
-  display: block;
-  color: #333;
-  font-weight: 500;
-  margin: 20px 0 12px;
-  padding: 0;
-  width: 100%;
-}
-
-.dac-form-legend > .dac-form-required {
-  float: right;
-  margin-top: 3px;
-}
-
-.dac-form-input {
-  border: 0 solid #e3e3e3;
-  border-bottom-width: 1px;
-  display: block;
-  outline: 0;
-  padding: 1px 0 8px;
-  -webkit-transition: border-color .2s;
-  transition: border-color .2s;
-  width: 100%;
-}
-
-.dac-form-input-group {
-  position: relative;
-}
-
-.dac-form-input-group > .dac-form-required {
-  display: block;
-  bottom: 3px;
-  position: absolute;
-  right: 0;
-}
-
-.dac-form-input:focus {
-  border-bottom-color: #09f;
-}
-
-.dac-form-floatlabel {
-  display: block;
-  cursor: text;
-  margin-top: 5px;
-  pointer-events: none;
-  -webkit-transform-origin: 0 100%;
-  -ms-transform-origin: 0 100%;
-  transform-origin: 0 100%;
-  -webkit-transform: translate3d(0, 22px, 0) scale(1);
-  transform: translate3d(0, 22px, 0) scale(1);
-  -webkit-transition: -webkit-transform .2s;
-  transition: transform .2s;
-}
-
-.dac-focused > .dac-form-floatlabel,
-    .dac-has-value > .dac-form-floatlabel {
-  cursor: default;
-  -webkit-transform: translate3d(0, 0, 0) scale(0.75);
-  transform: translate3d(0, 0, 0) scale(0.75);
-}
-
-.dac-form-radio, .dac-form-checkbox {
-  opacity: 0;
-  position: absolute;
-  visibility: hidden;
-}
-
-.dac-form-radio-group, .dac-form-checkbox-group {
-  display: table;
-}
-
-.dac-form-radio-group + .dac-form-radio-group, .dac-form-checkbox-group + .dac-form-radio-group, .dac-form-radio-group + .dac-form-checkbox-group, .dac-form-checkbox-group + .dac-form-checkbox-group {
-  margin-top: 10px;
-}
-
-.dac-form-radio-button, .dac-form-checkbox-button {
-  box-sizing: border-box;
-  cursor: pointer;
-  display: table-cell;
-  float: left;
-  height: 18px;
-  margin: 2px 10px 0 0;
-  position: relative;
-  width: 18px;
-}
-
-.dac-form-radio-button::after, .dac-form-radio-button::before, .dac-form-checkbox-button::after, .dac-form-checkbox-button::before {
-  box-sizing: border-box;
-  content: '';
-  display: block;
-  position: absolute;
-}
-
-.dac-form-radio-button::after, .dac-form-radio-button::before {
-  border-radius: 50%;
-  height: 100%;
-  width: 100%;
-}
-
-.dac-form-radio-button::before {
-  background: rgba(0, 0, 0, 0.7);
-  -webkit-transform: translateZ(0) scale(0);
-  transform: translateZ(0) scale(0);
-  -webkit-transition: -webkit-transform .3s;
-  transition: transform .3s;
-}
-
-.dac-form-radio-button::after {
-  border: 2px solid rgba(0, 0, 0, 0.7);
-}
-
-.dac-form-radio:checked + .dac-form-radio-button::before {
-  -webkit-transform: translateZ(0) scale(0.5);
-  transform: translateZ(0) scale(0.5);
-}
-
-.dac-form-radio:focus + .dac-form-radio-button::after {
-  border: 2px solid #09f;
-}
-
-.dac-form-checkbox-button::before {
-  border: 1px solid #6c6e6f;
-  border-radius: 3px;
-  height: 100%;
-  -webkit-transition: background .1s ease-out, box-shadow .3s ease-out;
-  transition: background .1s ease-out, box-shadow .3s ease-out;
-  width: 100%;
-}
-
-.dac-form-checkbox-button::after {
-  border-bottom: 2px solid #fff;
-  border-left: 2px solid #fff;
-  bottom: 7px;
-  height: 7px;
-  left: 3px;
-  -webkit-transform: rotate(-45deg);
-  -ms-transform: rotate(-45deg);
-  transform: rotate(-45deg);
-  width: 12px;
-}
-
-.dac-form-checkbox:checked + .dac-form-checkbox-button::before {
-  background: #6c6e6f;
-  -webkit-transition-timing-function: ease-in;
-  transition-timing-function: ease-in;
-}
-
-.dac-form-checkbox:focus + .dac-form-checkbox-button::before,
-  .dac-form-checkbox:active + .dac-form-checkbox-button::before {
-  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
-}
-
-.dac-form-label {
-  cursor: pointer;
-  -webkit-user-select: none;
-  -moz-user-select: none;
-  -ms-user-select: none;
-  user-select: none;
-}
-
-@media (max-width: 719px) {
-  .dac-form-legend {
-    margin-bottom: 0;
-  }
-}
-
-/* Filter Resources Component*/
-.dac-filter {
-  color: #505050;
-  margin-bottom: 20px;
-  position: relative;
-}
-
-.dac-filter.dac-filter-section {
-  margin-top: -45px;
-  text-align: right;
-}
-
-@media (max-width: 719px) {
-  .dac-filter.dac-filter-section {
-    margin-top: 0;
-    text-align: left;
-  }
-}
-
-.dac-filter-title {
-  color: #666;
-  cursor: default;
-  display: inline-block;
-  font-size: 12px;
-  font-weight: 500;
-  line-height: 24px;
-  margin: 0;
-  text-transform: uppercase;
-}
-
-@media (max-width: 719px) {
-  .dac-filter-title {
-    margin-bottom: 20px;
-  }
-}
-
-.dac-filter-message {
-  color: #78868d;
-  font-size: 18px;
-  margin: 0 10px 10px;
-}
-
-.dac-filter-count {
-  background: #6ab344;
-  border-radius: 50%;
-  color: #fff;
-  display: inline-block;
-  font-size: 12px;
-  font-weight: 600;
-  height: 24px;
-  text-align: center;
-  width: 24px;
-}
-
-.dac-filter-count.dac-disabled {
-  visibility: hidden;
-}
-
-.dac-filter-chip {
-  background: #bfc7cb;
-  border-radius: 15px;
-  color: #333;
-  cursor: default;
-  display: inline-block;
-  line-height: 21px;
-  margin: 0 10px 10px 0;
-  padding: 4px 26px 4px 10px;
-  position: relative;
-}
-
-.dac-filter-chip-close {
-  background-color: transparent;
-  border: none;
-  cursor: pointer;
-  outline: 0;
-  padding: 3px;
-  position: absolute;
-  right: 5px;
-  top: 5px;
-}
-
-.dac-filter-chip-close-icon {
-  opacity: .7;
-  margin-top: -2px;
-  -webkit-transform: scale(0.57142857);
-  -ms-transform: scale(0.57142857);
-  transform: scale(0.57142857);
-}
-
-.dac-filter-chip-close:hover > .dac-filter-chip-close-icon {
-  opacity: 1;
-}
-
-.dac-filter-chips {
-  border-top: 1px solid rgba(0, 0, 0, 0.1);
-  margin: 0;
-  list-style-type: none;
-  padding: 10px 0 0;
-  position: relative;
-  text-align: left;
-}
-
-.dac-filter-item {
-  box-sizing: border-box;
-  float: left;
-  margin-bottom: 20px;
-  padding: 0 10px;
-  width: 33.33333333%;
-}
-
-@media (min-width: 720px) and (max-width: 979px) {
-  .dac-filter-item {
-    width: 50%;
-  }
-}
-
-@media (max-width: 719px) {
-  .dac-filter-item {
-    width: 100%;
-  }
-}
-
-/* Media component */
-.dac-media {
-  display: table;
-  width: 100%;
-}
-
-.dac-media-body, .dac-media-figure {
-  display: table-cell;
-  vertical-align: top;
-}
-
-.dac-media-figure {
-  padding: 0;
-}
-
-.dac-media-body {
-  width: 100%;
-}
-
-.dac-swap {
-  overflow: hidden;
-  position: relative;
-}
-
-.dac-swap-section {
-  left: 0;
-  opacity: 0;
-  position: absolute;
-  top: 0;
-  width: 100%;
-  -webkit-transition: opacity 1s, -webkit-transform .5s;
-  transition: opacity 1s, transform .5s;
-}
-
-.dac-swap-section.dac-no-anim {
-  -webkit-transition: none;
-  transition: none;
-}
-
-.dac-swap-section.dac-up {
-  -webkit-transform: translateY(-100%);
-  -ms-transform: translateY(-100%);
-  transform: translateY(-100%);
-}
-
-.dac-swap-section.dac-down {
-  -webkit-transform: translateY(100%);
-  -ms-transform: translateY(100%);
-  transform: translateY(100%);
-}
-
-.dac-swap-section.dac-left {
-  -webkit-transform: translateX(-100%);
-  -ms-transform: translateX(-100%);
-  transform: translateX(-100%);
-}
-
-.dac-swap-section.dac-right {
-  -webkit-transform: translateX(100%);
-  -ms-transform: translateX(100%);
-  transform: translateX(100%);
-}
-
-.dac-swap-section.dac-active {
-  opacity: 1;
-  position: relative;
-  -webkit-transform: translate(0, 0);
-  -ms-transform: translate(0, 0);
-  transform: translate(0, 0);
-  width: auto;
-}
-
-/* Modal component */
-.dac-modal {
-  opacity: 0;
-  visibility: hidden;
-  -webkit-transition: visibility 0s linear 300ms, opacity 300ms linear;
-  transition: visibility 0s linear 300ms, opacity 300ms linear;
-  background: rgba(0, 0, 0, 0.8);
-  bottom: 0;
-  left: 0;
-  overflow-x: hidden;
-  overflow-y: auto;
-  position: fixed;
-  right: 0;
-  top: 0;
-  z-index: 70;
-}
-
-.dac-modal.dac-active {
-  opacity: 1;
-  -webkit-transition-delay: 0s;
-  transition-delay: 0s;
-  visibility: visible;
-}
-
-.dac-modal-open {
-  overflow: hidden;
-}
-
-.dac-modal-container {
-  -webkit-box-align: center;
-  -webkit-align-items: center;
-  -ms-flex-align: center;
-  align-items: center;
-  display: -webkit-box;
-  display: -webkit-flex;
-  display: -ms-flexbox;
-  display: flex;
-  -webkit-filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.4));
-  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.4));
-  -webkit-box-pack: center;
-  -webkit-justify-content: center;
-  -ms-flex-pack: center;
-  justify-content: center;
-  min-height: 100%;
-  width: 100%;
-}
-
-.dac-modal-window {
-  background: #fff;
-  box-sizing: border-box;
-  margin: 20px auto;
-  -webkit-transition: -webkit-transform .3s;
-  transition: transform .3s;
-  -webkit-transform: translate3d(0, -30px, 0);
-  transform: translate3d(0, -30px, 0);
-  width: 960px;
-}
-
-.dac-modal.dac-active .dac-modal-window {
-  -webkit-transform: translate3d(0, 0, 0);
-  transform: translate3d(0, 0, 0);
-}
-
-.dac-modal-header {
-  background: #00695c;
-  padding: 35px 35px 30px;
-  position: relative;
-}
-
-.dac-has-small-header .dac-modal-header {
-  padding: 10px 20px;
-}
-
-.dac-modal-header-actions {
-  padding: 8px;
-  position: absolute;
-  right: 5px;
-  top: 5px;
-}
-
-.dac-modal-header-open, .dac-modal-header-close {
-  background: none;
-  border: none;
-  cursor: pointer;
-  line-height: 0;
-  outline: 0;
-  opacity: .7;
-  -webkit-transition: background-color .3s;
-  transition: background-color .3s;
-}
-
-.dac-modal-header-open:active, .dac-modal-header-close:active {
-  background: rgba(255, 255, 255, 0.2);
-}
-
-.dac-modal-header-close:before {
-  content: '';
-  top: -1px;
-  position: relative;
-}
-
-.dac-modal-header-open {
-  margin: 10px;
-}
-
-.dac-modal-header-title {
-  color: #fff;
-  font-size: 24px;
-  font-weight: 300;
-  line-height: 32px;
-  padding: 0 150px 0 0;
-}
-
-.dac-has-small-header .dac-modal-header-title {
-  font-size: 16px;
-  font-weight: 500;
-}
-
-.dac-modal-header-subtitle {
-  bottom: 0;
-  color: #fff;
-  display: inline-block;
-  font: inherit;
-  font-size: 14px;
-  margin: 0;
-  opacity: .8;
-  position: absolute;
-  right: 0;
-}
-
-.dac-modal-content {
-  padding: 12px 35px;
-}
-
-.dac-modal-action {
-  margin: 0;
-}
-
-.dac-modal-footer {
-  padding: 24px 35px;
-}
-
-@media (max-width: 1000px) {
-  .dac-modal-window {
-    margin: 20px;
-    width: auto;
-  }
-
-  .dac-modal-container {
-    z-index: auto;
-  }
-}
-
-@media (max-width: 719px) {
-  .dac-modal-window {
-    margin: 10px;
-  }
-
-  .dac-modal-header {
-    padding: 35px 10px 10px;
-  }
-
-  .dac-modal-header-title {
-    font-size: 16px;
-    line-height: 24px;
-    padding: 0;
-  }
-
-  .dac-modal-header-subtitle {
-    display: block;
-    margin: 0;
-    position: static;
-    text-align: right;
-  }
-
-  .dac-modal-header-actions {
-    top: 1px;
-  }
-
-  .dac-modal-content {
-    padding: 10px;
-  }
-
-  .dac-modal-footer {
-    border-top: 1px solid #e3e3e3;
-    padding: 35px 10px;
-  }
-}
-
-.newsletter .dac-modal-footer {
-  padding-top: 0;
-  text-align: right;
-}
-
-.newsletter-checkboxes {
-  padding-top: 20px;
-}
-
-.newsletter-success-message {
-  font-size: 32px;
-  line-height: 1.4;
-  padding: 40px 30px;
-  text-align: center;
-}
-
-@media (max-width: 719px) {
-  .newsletter-success-message {
-    font-size: 16px;
-    padding: 12px 0 0;
-  }
-}
-
-@media (min-width: 720px) {
-  .newsletter-checkboxes {
-    padding-top: 46px;
-  }
-
-  .newsletter-leftCol {
-    padding-right: 40px;
-  }
-
-  .newsletter-rightCol {
-    padding-left: 40px;
-  }
-}
-
-@media (max-width: 719px) {
-  .newsletter .dac-modal-footer {
-    margin-top: 30px;
-    padding: 30px 10px;
-    text-align: center;
-  }
-}
-
-.dac-blog-reader {
-  padding: 50px 90px;
-}
-
-.dac-blog-reader-title {
-  color: #333;
-  font-size: 45px;
-  font-weight: 300;
-  line-height: 1.2;
-  padding: 10px 0;
-}
-
-.dac-blog-reader-date {
-  color: #b8b8b8;
-  font-size: 12px;
-  font-weight: 600;
-  line-height: 1;
-  text-transform: uppercase;
-}
-
-.dac-blog-reader-text > p:first-child i {
-  display: inline-block;
-  margin-bottom: 40px;
-}
-
-.dac-blog-reader-text li {
-  margin-bottom: 0;
-}
-
-.dac-blog-reader-text iframe {
-  margin-left: auto !important;
-  margin-right: auto !important;
-  max-width: 100%;
-}
-
-@media (max-width: 719px) {
-  .dac-blog-reader {
-    padding: 30px 20px;
-  }
-}
-
-.dac-custom-search {
-  background: #fff;
-  margin: 0 -10px;
-  padding: 20px 10px;
-  z-index: 1;
-}
-
-.dac-custom-search .dac-fab, .dac-custom-search .dac-button-social {
-  top: -48px;
-}
-
-.dac-custom-search-section-title {
-  color: #505050;
-}
-
-.dac-custom-search-entry {
-  margin-bottom: 36px;
-  margin-top: 24px;
-  margin-left:10px;
-}
-
-.dac-custom-search-entry.cols:after {
-    clear: none; }
-
-.dac-custom-search-image-wrapper {
-  float: left;
-  position: relative;
-}
-
-.dac-custom-search-image {
-  background-size: cover;
-  height: 112px;
-  width:150px;
-  margin-right:15px;
-}
-
-.dac-custom-search-text-wrapper {
-  position: relative;
-}
-
-.dac-custom-search-title {
-  color: #333;
-  font-size: 14px;
-  font-weight: 700;
-  line-height: 24px;
-  padding: 0;
-  clear:none;
-}
-
-.dac-custom-search-title a {
-  color: inherit;
-}
-
-.dac-custom-search-section {
-  color: #999;
-  font-size: 16px;
-  font-variant: small-caps;
-  font-weight: 700;
-  margin: -5px 0 0 0;
-}
-
-.dac-custom-search-snippet {
-  color: #666;
-  margin: 0;
-}
-
-.dac-custom-search-link {
-  font-weight: 500;
-  word-wrap: break-word;
-  width: 100%;
-}
-
-.dac-custom-search-load-more {
-  background: none;
-  border: none;
-  color: #333;
-  cursor: pointer;
-  display: block;
-  font-size: 14px;
-  font-weight: 700;
-  margin: 75px auto;
-  outline: none;
-  padding: 10px;
-}
-
-.dac-custom-search-load-more:hover {
-  opacity: 0.7;
-}
-
-.dac-custom-search-no-results {
-  color: #999;
-}
-
-.dac-search-hero {
-  font-size: 16px;
-  padding: 50px 0 14px 0;
-}
-
-.dac-search-results {
-  opacity: 0;
-  visibility: hidden;
-  -webkit-transition: visibility 0s linear 300ms, opacity 300ms linear;
-  transition: visibility 0s linear 300ms, opacity 300ms linear;
-  background-color: #fff;
-  bottom: 0;
-  left: 0;
-  overflow-y: auto;
-  padding: 0 10px;
-  position: fixed;
-  right: 0;
-  -webkit-transition: opacity 100ms;
-  transition: opacity 100ms;
-  top: 64px;
-  z-index: 50;
-}
-
-.dac-nav-animating .dac-search-results {
-  -webkit-transition: opacity 100ms, padding .3s;
-  transition: opacity 100ms, padding .3s;
-}
-
-.dac-search-results * {
-  box-sizing: border-box;
-}
-
-.dac-search-open .dac-search-results {
-  opacity: 1;
-  visibility: visible;
-}
-
-.dac-search-results-content {
-  background: #eceff1;
-  margin: 0 -10px;
-  padding: 0 10px;
-}
-
-.dac-search-results-for {
-  margin-bottom: -5px;
-  overflow: hidden;
-  padding-top: 5px;
-}
-
-.dac-search-results-for span {
-  color: #039bef;
-}
-
-.dac-search-mode .dac-search-results-for {
-  display: none;
-}
-
-.dac-search-results-history {
-  background: #eceff1;
-  min-height: 100%;
-  margin: 0 -10px;
-  padding: 0 10px;
-}
-
-.dac-search-results-hero {
-  padding-top: 20px;
-}
-
-.dac-search-results-metadata {
-  padding-bottom: 40px;
-}
-
-#dac-search-results-reference {
-  float:right;
-  z-index:999;
-}
-
-@media (max-width: 719px) {
-  #dac-search-results-reference {
-    float:none;
-  }
-}
-
-.dac-search-results-reference {
-  background: white;
-  box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.21);
-  margin: 0 0 20px 0;
-  overflow: hidden;
-  padding: 6px 0 4px;
-}
-
-.dac-search-results-reference .namespace {
-  color: #666;
-}
-
-.dac-search-results-reference.is-expanded {
-  height: auto;
-}
-
-.dac-search-results-reference-header {
-  color: #999;
-  font-size: 16px;
-  font-variant: small-caps;
-  font-weight: 700;
-  margin: 0;
-  padding: 18px 12px 0;
-  text-transform: lowercase;
-}
-
-.dac-search-results-reference-header:first-child {
-  padding-top: 0;
-}
-
-.dac-search-results-reference-entry {
-  margin: 0;
-}
-
-.dac-search-results-reference-entry a {
-  color: #333;
-  display: block;
-  font-size: 0.81em;
-  line-height: 1.5em;
-  padding: 0 12px 5px 12px;
-  width: 100%;
-  white-space: nowrap;
-}
-
-ul.dac-search-results-reference {
-list-style: none;
-}
-
-ul.dac-search-results-reference li[data-toggle="show-more"] {
-  cursor:pointer;
-}
-
-ul.dac-search-results-reference.is-expanded li[data-toggle="show-more"] {
-  display:none;
-}
-
-.dac-search-results-reference-entry a:hover {
-  background-color: #eceff1;
-}
-
-.dac-search-results-reference-entry em {
-  font-style: normal;
-  font-weight: 700;
-}
-
-.dac-search-results-reference-entry-empty {
-  color: #999;
-  font-size: 0.81em;
-  margin: 0;
-  padding: 2px 12px 14px;
-}
-
-.dac-search-results-resources {
-  margin: 0;
-}
-
-.dac-search-results-resources .resource-card {
-  border-right: 2px solid #999;
-}
-
-.dac-search-results-resources .resource-card-about {
-  border-right: 2px solid #6ab344;
-}
-
-.dac-search-results-resources .resource-card-about .section {
-  color: #6ab344;
-}
-
-.dac-search-results-resources .resource-card-develop {
-  border-right: 2px solid #ff7043;
-}
-
-.dac-search-results-resources .resource-card-develop .section {
-  color: #ff7043;
-}
-
-.dac-search-results-resources .resource-card-design {
-  border-right: 2px solid #00bcd4;
-}
-
-.dac-search-results-resources .resource-card-design .section {
-  color: #00bcd4;
-}
-
-.dac-search-results-resources .resource-card-distribute {
-  border-right: 2px solid #afb42b;
-}
-
-.dac-search-results-resources .resource-card-distribute .section {
-  color: #afb42b;
-}
-
-@media (max-width: 719px) {
-  .dac-search-results-reference.no-results {
-    display: none;
-  }
-}
-
-@media (min-width: 980px) {
-  .dac-nav-open.dac-search-open .dac-search-results {
-    padding-left: 260px;
-  }
-
-  .dac-search-mode.dac-search-open .dac-search-results {
-    padding-left: 10px;
-  }
-}
-
-.dac-selected {
-  color: #039bef !important;
-}
-
-.dac-selected em {
-  color: #039bef;
-}
-
-.resource-card.dac-selected {
-  box-shadow: 0px 1px 10px 0px rgba(3, 155, 239, 0.7);
-}
-
-.resource-card.dac-selected em {
-  color: #333;
-}
-
-.dac-expand, .dac-section {
-  margin-left: -20px;
-  margin-right: -20px;
-  padding-left: 20px;
-  padding-right: 20px;
-}
-
-@media (max-width: 719px) {
-  .dac-expand, .dac-section {
-    margin-left: -10px;
-    margin-right: -10px;
-    padding-left: 10px;
-    padding-right: 10px;
-  }
-}
-
-.dac-invert {
-  color: #b3b3b3;
-  color: rgba(255, 255, 255, 0.7);
-}
-
-.dac-invert h1, .dac-invert h2, .dac-invert h3 {
-  color: #fff;
-}
-
-.dac-light.dac-hero, .dac-light.dac-section {
-  background-color: #eceff1;
-}
-
-.dac-gray.dac-hero, .dac-gray.dac-section {
-  background-color: #d8dfe2;
-}
-
-.dac-gray-dark.dac-hero, .dac-gray-dark.dac-section {
-   background-color: #b0bec5;
-}
-
-.dac-dark.dac-hero, .dac-dark.dac-section {
-  background-color: #37474f;
-}
-
-.dac-red.dac-hero, .dac-red.dac-section {
-  background-color: #dc4d38;
-}
-
-.dac-blue.dac-hero,
-.dac-blue.dac-section {
-  background-color: #0277bd;
-}
-
-.dac-blue.dac-invert .dac-hero-description,
-.dac-blue.dac-invert .dac-section-subtitle {
-  color: #fff;
-}
-
-.dac-dark-gray.dac-hero,
-.dac-dark-gray.dac-section {
-  background-color: #455a64;
-}
-
-.dac-bg-opacity::after {
-  background-color: rgba(0, 0, 0, .3);
-  content : "";
-  display: block;
-  position: absolute;
-  top: 0;
-  left: 0;
-  width: 100%;
-  height: 100%;
-  z-index: 1;
-}
-
-.dac-hero-cta, .dac-section-title, .dac-section-links {
-  color: #212121;
-  color: rgba(0, 0, 0, 0.87);
-}
-
-.dac-invert .dac-hero-cta, .dac-invert .dac-section-title, .dac-invert .dac-section-links {
-  color: white;
-}
-
-.dac-hero-cta .dac-sprite, .dac-section-title .dac-sprite, .dac-section-links .dac-sprite, .dac-hero-cta .dac-modal-header-close:before, .dac-section-title .dac-modal-header-close:before, .dac-section-links .dac-modal-header-close:before, .dac-hero-cta .paging-links .prev-page-link:before, .paging-links .dac-hero-cta .prev-page-link:before, .dac-section-title .paging-links .prev-page-link:before, .paging-links .dac-section-title .prev-page-link:before, .dac-section-links .paging-links .prev-page-link:before, .paging-links .dac-section-links .prev-page-link:before, .dac-hero-cta .paging-links .next-page-link:before, .paging-links .dac-hero-cta .next-page-link:before, .dac-section-title .paging-links .next-page-link:before, .paging-links .dac-section-title .next-page-link:before, .dac-section-links .paging-links .next-page-link:before, .paging-links .dac-section-links .next-page-link:before, .dac-hero-cta .paging-links .next-class-link:before, .paging-links .dac-hero-cta .next-class-link:before, .dac-section-title .paging-links .next-class-link:before, .paging-links .dac-section-title .next-class-link:before, .dac-section-links .paging-links .next-class-link:before, .paging-links .dac-section-links .next-class-link:before, .dac-hero-cta .paging-links .start-class-link:after, .paging-links .dac-hero-cta .start-class-link:after, .dac-section-title .paging-links .start-class-link:after, .paging-links .dac-section-title .start-class-link:after, .dac-section-links .paging-links .start-class-link:after, .paging-links .dac-section-links .start-class-link:after {
-  opacity: .87;
-}
-
-.dac-invert .dac-hero-cta .dac-sprite, .dac-invert .dac-section-title .dac-sprite, .dac-invert .dac-section-links .dac-sprite, .dac-invert .dac-hero-cta .dac-modal-header-close:before, .dac-invert .dac-section-title .dac-modal-header-close:before, .dac-invert .dac-section-links .dac-modal-header-close:before, .dac-invert .dac-hero-cta .paging-links .prev-page-link:before, .paging-links .dac-invert .dac-hero-cta .prev-page-link:before, .dac-invert .dac-section-title .paging-links .prev-page-link:before, .paging-links .dac-invert .dac-section-title .prev-page-link:before, .dac-invert .dac-section-links .paging-links .prev-page-link:before, .paging-links .dac-invert .dac-section-links .prev-page-link:before, .dac-invert .dac-hero-cta .paging-links .next-page-link:before, .paging-links .dac-invert .dac-hero-cta .next-page-link:before, .dac-invert .dac-section-title .paging-links .next-page-link:before, .paging-links .dac-invert .dac-section-title .next-page-link:before, .dac-invert .dac-section-links .paging-links .next-page-link:before, .paging-links .dac-invert .dac-section-links .next-page-link:before, .dac-invert .dac-hero-cta .paging-links .next-class-link:before, .paging-links .dac-invert .dac-hero-cta .next-class-link:before, .dac-invert .dac-section-title .paging-links .next-class-link:before, .paging-links .dac-invert .dac-section-title .next-class-link:before, .dac-invert .dac-section-links .paging-links .next-class-link:before, .paging-links .dac-invert .dac-section-links .next-class-link:before, .dac-invert .dac-hero-cta .paging-links .start-class-link:after, .paging-links .dac-invert .dac-hero-cta .start-class-link:after, .dac-invert .dac-section-title .paging-links .start-class-link:after, .paging-links .dac-invert .dac-section-title .start-class-link:after, .dac-invert .dac-section-links .paging-links .start-class-link:after, .paging-links .dac-invert .dac-section-links .start-class-link:after {
-  opacity: 1;
-}
-
-.dac-hero-tag, .dac-hero-description, .dac-section-subtitle {
-  color: #757575;
-  color: rgba(0, 0, 0, 0.54);
-}
-
-.dac-invert .dac-hero-tag, .dac-invert .dac-hero-description, .dac-invert .dac-section-subtitle {
-  color: #b3b3b3;
-  color: rgba(255, 255, 255, 0.7);
-}
-
-.dac-hero.dac-no-min-height {
-  min-height: 0;
-}
-
-.dac-hero-half-bg {
-  background-size: cover;
-  background-repeat: no-repeat;
-  float: right;
-  height: 440px;
-}
-
-.dac-hero-half-bg-centered {
-  background-position: center;
-  background-repeat: no-repeat;
-  background-size: cover;
-  float: right;
-  height: 440px;
-}
-
-@media only screen and (-webkit-min-device-pixel-ratio: 2),
-only screen and (-moz-min-device-pixel-ratio: 2),
-only screen and (min-device-pixel-ratio: 2),
-only screen and (min-resolution: 192dpi),
-only screen and (min-resolution: 2dppx) {
-  .dac-hero-half-bg,
-  .dac-hero-half-bg-centered {
-    background-size: "" "";
-  }
-}
-
-@media (max-width: 719px) {
-  .dac-hero-half-bg,
-  .dac-hero-half-bg-centered {
-    background-position: center;
-    background-size: auto 100%;
-    float: none;
-    height: 200px;
-    margin-top: 32px;
-  }
-}
-
-.dac-section {
-  background-position: 50% 50%;
-  background-size: cover;
-  padding-bottom: 84px;
-  padding-top: 84px;
-  position: relative;
-}
-
-@media (max-width: 719px) {
-  .dac-section {
-    padding-bottom: 52px;
-    padding-top: 52px;
-  }
-}
-
-.dac-section.dac-small,
-.dac-hero.dac-small {
-  padding-bottom: 32px;
-  padding-top: 32px;
-}
-
-.dac-section.dac-slim {
-  padding-bottom: 0;
-  padding-top: 0;
-}
-
-.dac-section-title {
-  text-align: center;
-  padding-bottom: 40px;
-  padding-top: 0;
-}
-
-.dac-section-subtitle {
-  font-size: 16px;
-  padding-bottom: 40px;
-  margin-top: -24px;
-  text-align: center;
-}
-
-.dac-section-links {
-  font-size: 16px;
-  list-style: none;
-  line-height: 40px;
-  margin: 16px 0 0;
-  text-align: center;
-}
-
-@media (max-width: 719px) {
-  .dac-section-links {
-    margin-left: -8px;
-    text-align: left;
-  }
-}
-
-.dac-section-link {
-  cursor: pointer;
-  display: inline-block;
-  margin: 0 32px;
-  -webkit-transition: opacity .3s;
-  transition: opacity .3s;
-}
-
-.dac-section-link:hover {
-  opacity: .54;
-}
-
-@media (max-width: 719px) {
-  .dac-section-link {
-    display: block;
-    margin: 0;
-  }
-}
-
-.dac-section-link a {
-  color: inherit;
-}
-
-/*
-SCSS variables are information about icon's compiled state, stored under its original file name
-
-.icon-home {
-  width: $icon-home-width;
-}
-
-The large array-like variables contain all information about a single icon
-$icon-home: x y offset_x offset_y width height total_width total_height image_path;
-
-At the bottom of this section, we provide information about the spritesheet itself
-$spritesheet: width height image $spritesheet-sprites;
-*/
-.dac-sprite, .dac-modal-header-close:before, .paging-links .prev-page-link:before, .paging-links .next-page-link:before, .paging-links .next-class-link:before, .paging-links .start-class-link:after, .Video-button--picture-in-picture, .Video-button--close, a.video-shadowbox-button.white::after, #tb li:before,
-#qv li:before {
-  background-image: url(../images/sprite.png);
-  display: inline-block;
-  vertical-align: middle;
-}
-
-@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 1.5dppx), (min-resolution: 144px) {
-
-  .dac-sprite,
-  .dac-modal-header-close:before,
-  .paging-links .prev-page-link:before,
-  .paging-links .next-page-link:before,
-  .paging-links .next-class-link:before,
-  .paging-links .start-class-link:after,
-  .Video-button--picture-in-picture,
-  .Video-button--close,
-  a.video-shadowbox-button.white::after,
-  #tb li:before,
-  #qv li:before {
-    background-image: url(../images/sprite_2x.png);
-    background-size: 36px 900px;
-  }
-}
-
-.dac-chevron {
-  background-size: 9px 39px;
-  display: inline-block;
-  height: 13px;
-  text-indent: -9999px;
-  width: 9px;
-}
-
-.dac-sprite.dac-auto-chevron,
-.dac-auto-chevron.dac-modal-header-close:before,
-.paging-links .dac-auto-chevron.prev-page-link:before,
-.paging-links .dac-auto-chevron.next-page-link:before,
-.paging-links .dac-auto-chevron.next-class-link:before,
-.paging-links .dac-auto-chevron.start-class-link:after {
-  background-position: 0px -669px;
-  height: 24px;
-  width: 24px;
-  vertical-align: -6px;
-}
-
-.dac-invert .dac-sprite.dac-auto-chevron, .dac-invert .dac-auto-chevron.dac-modal-header-close:before, .dac-invert .paging-links .dac-auto-chevron.prev-page-link:before, .paging-links .dac-invert .dac-auto-chevron.prev-page-link:before, .dac-invert .paging-links .dac-auto-chevron.next-page-link:before, .paging-links .dac-invert .dac-auto-chevron.next-page-link:before, .dac-invert .paging-links .dac-auto-chevron.next-class-link:before, .paging-links .dac-invert .dac-auto-chevron.next-class-link:before, .dac-invert .paging-links .dac-auto-chevron.start-class-link:after, .paging-links .dac-invert .dac-auto-chevron.start-class-link:after {
-  background-position: 0px -513px;
-  height: 24px;
-  width: 24px;
-}
-
-.dac-sprite.dac-auto-chevron-large, .dac-auto-chevron-large.dac-modal-header-close:before, .paging-links .dac-auto-chevron-large.prev-page-link:before, .paging-links .dac-auto-chevron-large.next-page-link:before, .paging-links .dac-auto-chevron-large.next-class-link:before, .paging-links .dac-auto-chevron-large.start-class-link:after {
-  background-position: 0px -695px;
-  height: 36px;
-  width: 36px;
-  vertical-align: -10px;
-}
-
-.dac-invert .dac-sprite.dac-auto-chevron-large,
-.dac-invert .dac-auto-chevron-large.dac-modal-header-close:before,
-.dac-invert .paging-links .dac-auto-chevron-large.prev-page-link:before,
-.paging-links .dac-invert .dac-auto-chevron-large.prev-page-link:before,
-.dac-invert .paging-links .dac-auto-chevron-large.next-page-link:before,
-.paging-links .dac-invert .dac-auto-chevron-large.next-page-link:before,
-.dac-invert .paging-links .dac-auto-chevron-large.next-class-link:before,
-.paging-links .dac-invert .dac-auto-chevron-large.next-class-link:before,
-.dac-invert .paging-links .dac-auto-chevron-large.start-class-link:after,
-.paging-links .dac-invert .dac-auto-chevron-large.start-class-link:after {
-  background-position: 0px -771px;
-  height: 36px;
-  width: 36px;
-}
-
-.dac-sprite.dac-auto-unfold-less, .dac-auto-unfold-less.dac-modal-header-close:before, .paging-links .dac-auto-unfold-less.prev-page-link:before, .paging-links .dac-auto-unfold-less.next-page-link:before, .paging-links .dac-auto-unfold-less.next-class-link:before, .paging-links .dac-auto-unfold-less.start-class-link:after {
-  background-position: 0px -487px;
-  height: 24px;
-  width: 24px;
-  vertical-align: -6px; }
-  .dac-invert .dac-sprite.dac-auto-unfold-less, .dac-invert .dac-auto-unfold-less.dac-modal-header-close:before, .dac-invert .paging-links .dac-auto-unfold-less.prev-page-link:before, .paging-links .dac-invert .dac-auto-unfold-less.prev-page-link:before, .dac-invert .paging-links .dac-auto-unfold-less.next-page-link:before, .paging-links .dac-invert .dac-auto-unfold-less.next-page-link:before, .dac-invert .paging-links .dac-auto-unfold-less.next-class-link:before, .paging-links .dac-invert .dac-auto-unfold-less.next-class-link:before, .dac-invert .paging-links .dac-auto-unfold-less.start-class-link:after, .paging-links .dac-invert .dac-auto-unfold-less.start-class-link:after {
-    background-position: 0px -565px;
-    height: 24px;
-    width: 24px; }
-
-.dac-sprite.dac-auto-unfold-more, .dac-auto-unfold-more.dac-modal-header-close:before, .paging-links .dac-auto-unfold-more.prev-page-link:before, .paging-links .dac-auto-unfold-more.next-page-link:before, .paging-links .dac-auto-unfold-more.next-class-link:before, .paging-links .dac-auto-unfold-more.start-class-link:after {
-  background-position: 0px -539px;
-  height: 24px;
-  width: 24px;
-  vertical-align: -6px; }
-  .dac-invert .dac-sprite.dac-auto-unfold-more, .dac-invert .dac-auto-unfold-more.dac-modal-header-close:before, .dac-invert .paging-links .dac-auto-unfold-more.prev-page-link:before, .paging-links .dac-invert .dac-auto-unfold-more.prev-page-link:before, .dac-invert .paging-links .dac-auto-unfold-more.next-page-link:before, .paging-links .dac-invert .dac-auto-unfold-more.next-page-link:before, .dac-invert .paging-links .dac-auto-unfold-more.next-class-link:before, .paging-links .dac-invert .dac-auto-unfold-more.next-class-link:before, .dac-invert .paging-links .dac-auto-unfold-more.start-class-link:after, .paging-links .dac-invert .dac-auto-unfold-more.start-class-link:after {
-    background-position: 0px -305px;
-    height: 24px;
-    width: 24px; }
-
-.dac-sprite.dac-arrow-down-gray, .dac-arrow-down-gray.dac-modal-header-close:before, .paging-links .dac-arrow-down-gray.prev-page-link:before, .paging-links .dac-arrow-down-gray.next-page-link:before, .paging-links .dac-arrow-down-gray.next-class-link:before, .paging-links .dac-arrow-down-gray.start-class-link:after {
-  background-position: 0px 0px;
-  height: 11px;
-  width: 19px; }
-
-.dac-sprite.dac-arrow-right, .dac-arrow-right.dac-modal-header-close:before, .paging-links .dac-arrow-right.prev-page-link:before, .paging-links .dac-arrow-right.next-page-link:before, .paging-links .dac-arrow-right.next-class-link:before, .paging-links .dac-arrow-right.start-class-link:after {
-  background-position: 0px -215px;
-  height: 18px;
-  width: 11px; }
-
-.dac-sprite.dac-back-arrow, .dac-back-arrow.dac-modal-header-close:before, .paging-links .dac-back-arrow.prev-page-link:before, .paging-links .dac-back-arrow.next-page-link:before, .paging-links .dac-back-arrow.next-class-link:before, .paging-links .dac-back-arrow.start-class-link:after {
-  background-position: 0px -123px;
-  height: 16px;
-  width: 16px; }
-
-.dac-sprite.dac-chevron-large-right-black, .dac-chevron-large-right-black.dac-modal-header-close:before, .paging-links .dac-chevron-large-right-black.prev-page-link:before, .paging-links .dac-chevron-large-right-black.next-page-link:before, .paging-links .dac-chevron-large-right-black.next-class-link:before, .paging-links .dac-chevron-large-right-black.start-class-link:after {
-  background-position: 0px -695px;
-  height: 36px;
-  width: 36px; }
-
-.dac-sprite.dac-chevron-large-right-white, .dac-chevron-large-right-white.dac-modal-header-close:before, .paging-links .dac-chevron-large-right-white.prev-page-link:before, .paging-links .dac-chevron-large-right-white.next-page-link:before, .paging-links .dac-chevron-large-right-white.next-class-link:before, .paging-links .dac-chevron-large-right-white.start-class-link:after {
-  background-position: 0px -771px;
-  height: 36px;
-  width: 36px; }
-
-.dac-sprite.dac-chevron-right-black, .dac-chevron-right-black.dac-modal-header-close:before, .paging-links .dac-chevron-right-black.prev-page-link:before, .paging-links .dac-chevron-right-black.next-page-link:before, .paging-links .dac-chevron-right-black.next-class-link:before, .paging-links .dac-chevron-right-black.start-class-link:after {
-  background-position: 0px -669px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-chevron-right-white, .dac-chevron-right-white.dac-modal-header-close:before, .paging-links .dac-chevron-right-white.prev-page-link:before, .paging-links .dac-chevron-right-white.next-page-link:before, .paging-links .dac-chevron-right-white.next-class-link:before, .paging-links .dac-chevron-right-white.start-class-link:after {
-  background-position: 0px -513px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-close-black, .dac-close-black.dac-modal-header-close:before, .paging-links .dac-close-black.prev-page-link:before, .paging-links .dac-close-black.next-page-link:before, .paging-links .dac-close-black.next-class-link:before, .paging-links .dac-close-black.start-class-link:after {
-  background-position: 0px -89px;
-  height: 14px;
-  width: 14px; }
-
-.dac-sprite.dac-close-video-white, .dac-modal-header-close:before, .paging-links .dac-close-video-white.prev-page-link:before, .paging-links .prev-page-link.dac-modal-header-close:before, .paging-links .dac-close-video-white.next-page-link:before, .paging-links .next-page-link.dac-modal-header-close:before, .paging-links .dac-close-video-white.next-class-link:before, .paging-links .next-class-link.dac-modal-header-close:before, .paging-links .dac-close-video-white.start-class-link:after {
-  background-position: 0px -435px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-close, .dac-close.dac-modal-header-close:before, .paging-links .dac-close.prev-page-link:before, .paging-links .dac-close.next-page-link:before, .paging-links .dac-close.next-class-link:before, .paging-links .dac-close.start-class-link:after {
-  background-position: 0px -27px;
-  height: 12px;
-  width: 12px; }
-
-.dac-sprite.dac-enlarge-video-white, .dac-enlarge-video-white.dac-modal-header-close:before, .paging-links .dac-enlarge-video-white.prev-page-link:before, .paging-links .dac-enlarge-video-white.next-page-link:before, .paging-links .dac-enlarge-video-white.next-class-link:before, .paging-links .dac-enlarge-video-white.start-class-link:after {
-  background-position: 0px -409px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-expand-less-black, .dac-expand-less-black.dac-modal-header-close:before, .paging-links .dac-expand-less-black.prev-page-link:before, .paging-links .dac-expand-less-black.next-page-link:before, .paging-links .dac-expand-less-black.next-class-link:before, .paging-links .dac-expand-less-black.start-class-link:after {
-  background-position: 0px -383px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-expand-more-black, .dac-expand-more-black.dac-modal-header-close:before, .paging-links .dac-expand-more-black.prev-page-link:before, .paging-links .dac-expand-more-black.next-page-link:before, .paging-links .dac-expand-more-black.next-class-link:before, .paging-links .dac-expand-more-black.start-class-link:after {
-  background-position: 0px -357px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-fullscreen-exit, .dac-fullscreen-exit.dac-modal-header-close:before, .paging-links .dac-fullscreen-exit.prev-page-link:before, .paging-links .dac-fullscreen-exit.next-page-link:before, .paging-links .dac-fullscreen-exit.next-class-link:before, .paging-links .dac-fullscreen-exit.start-class-link:after {
-  background-position: 0px -331px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-fullscreen, .dac-fullscreen.dac-modal-header-close:before, .paging-links .dac-fullscreen.prev-page-link:before, .paging-links .dac-fullscreen.next-page-link:before, .paging-links .dac-fullscreen.next-class-link:before, .paging-links .dac-fullscreen.start-class-link:after {
-  background-position: 0px -279px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-google-play, .dac-google-play.dac-modal-header-close:before, .paging-links .dac-google-play.prev-page-link:before, .paging-links .dac-google-play.next-page-link:before, .paging-links .dac-google-play.next-class-link:before, .paging-links .dac-google-play.start-class-link:after {
-  background-position: 0px -235px;
-  height: 20px;
-  width: 17px; }
-
-.dac-sprite.dac-gplus, .dac-gplus.dac-modal-header-close:before, .paging-links .dac-gplus.prev-page-link:before, .paging-links .dac-gplus.next-page-link:before, .paging-links .dac-gplus.next-class-link:before, .paging-links .dac-gplus.start-class-link:after {
-  background-position: 0px -809px;
-  height: 36px;
-  width: 36px; }
-
-.dac-sprite.dac-mail, .dac-mail.dac-modal-header-close:before, .paging-links .dac-mail.prev-page-link:before, .paging-links .dac-mail.next-page-link:before, .paging-links .dac-mail.next-class-link:before, .paging-links .dac-mail.start-class-link:after {
-  background-position: 0px -13px;
-  height: 12px;
-  width: 16px; }
-
-.dac-sprite.dac-nav-back-blue, .dac-nav-back-blue.dac-modal-header-close:before, .paging-links .prev-page-link:before, .paging-links .dac-nav-back-blue.next-page-link:before, .paging-links .dac-nav-back-blue.next-class-link:before, .paging-links .dac-nav-back-blue.start-class-link:after {
-  background-position: 0px -105px;
-  height: 16px;
-  width: 16px; }
-
-.dac-sprite.dac-nav-back, .dac-nav-back.dac-modal-header-close:before, .paging-links .dac-nav-back.prev-page-link:before, .paging-links .dac-nav-back.next-page-link:before, .paging-links .dac-nav-back.next-class-link:before, .paging-links .dac-nav-back.start-class-link:after {
-  background-position: 0px -177px;
-  height: 16px;
-  width: 16px; }
-
-/* The back button in Studio and NDK left nav */
-.dac-nav-back-button.back-to-dev .dac-sprite.dac-nav-back {
-  background-position: 0px -884px;
-  height: 16px;
-  width: 16px;
-}
-
-.dac-sprite.dac-nav-forward-blue, .dac-nav-forward-blue.dac-modal-header-close:before, .paging-links .dac-nav-forward-blue.prev-page-link:before, .paging-links .next-page-link:before, .paging-links .next-class-link:before, .paging-links .start-class-link:after {
-  background-position: 0px -159px;
-  height: 16px;
-  width: 16px; }
-
-.dac-sprite.dac-nav-forward, .dac-nav-forward.dac-modal-header-close:before, .paging-links .dac-nav-forward.prev-page-link:before, .paging-links .dac-nav-forward.next-page-link:before, .paging-links .dac-nav-forward.next-class-link:before, .paging-links .dac-nav-forward.start-class-link:after {
-  background-position: 0px -141px;
-  height: 16px;
-  width: 16px; }
-
-.dac-sprite.dac-open-in-new, .dac-open-in-new.dac-modal-header-close:before, .paging-links .dac-open-in-new.prev-page-link:before, .paging-links .dac-open-in-new.next-page-link:before, .paging-links .dac-open-in-new.next-class-link:before, .paging-links .dac-open-in-new.start-class-link:after {
-  background-position: 0px -195px;
-  height: 18px;
-  width: 18px; }
-
-.dac-sprite.dac-picture-in-picture-white, .dac-picture-in-picture-white.dac-modal-header-close:before, .paging-links .dac-picture-in-picture-white.prev-page-link:before, .paging-links .dac-picture-in-picture-white.next-page-link:before, .paging-links .dac-picture-in-picture-white.next-class-link:before, .paging-links .dac-picture-in-picture-white.start-class-link:after {
-  background-position: 0px -461px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-play-circle-grey, .dac-play-circle-grey.dac-modal-header-close:before, .paging-links .dac-play-circle-grey.prev-page-link:before, .paging-links .dac-play-circle-grey.next-page-link:before, .paging-links .dac-play-circle-grey.next-class-link:before, .paging-links .dac-play-circle-grey.start-class-link:after {
-  background-position: 0px -733px;
-  height: 36px;
-  width: 36px; }
-
-.dac-sprite.dac-play-circle-white, .dac-play-circle-white.dac-modal-header-close:before, .paging-links .dac-play-circle-white.prev-page-link:before, .paging-links .dac-play-circle-white.next-page-link:before, .paging-links .dac-play-circle-white.next-class-link:before, .paging-links .dac-play-circle-white.start-class-link:after {
-  background-position: 0px -847px;
-  height: 36px;
-  width: 36px; }
-
-.dac-sprite.dac-play-white, .dac-play-white.dac-modal-header-close:before, .paging-links .dac-play-white.prev-page-link:before, .paging-links .dac-play-white.next-page-link:before, .paging-links .dac-play-white.next-class-link:before, .paging-links .dac-play-white.start-class-link:after {
-  background-position: 0px -257px;
-  height: 20px;
-  width: 16px; }
-
-.dac-sprite.dac-rss, .dac-rss.dac-modal-header-close:before, .paging-links .dac-rss.prev-page-link:before, .paging-links .dac-rss.next-page-link:before, .paging-links .dac-rss.next-class-link:before, .paging-links .dac-rss.start-class-link:after {
-  background-position: 0px -41px;
-  height: 14px;
-  width: 14px; }
-
-.dac-sprite.dac-search-white, .dac-search-white.dac-modal-header-close:before, .paging-links .dac-search-white.prev-page-link:before, .paging-links .dac-search-white.next-page-link:before, .paging-links .dac-search-white.next-class-link:before, .paging-links .dac-search-white.start-class-link:after {
-  background-position: 0px -591px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-search, .dac-search.dac-modal-header-close:before, .paging-links .dac-search.prev-page-link:before, .paging-links .dac-search.next-page-link:before, .paging-links .dac-search.next-class-link:before, .paging-links .dac-search.start-class-link:after {
-  background-position: 0px -617px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-star-outline, .dac-star-outline.dac-modal-header-close:before, .paging-links .dac-star-outline.prev-page-link:before, .paging-links .dac-star-outline.next-page-link:before, .paging-links .dac-star-outline.next-class-link:before, .paging-links .dac-star-outline.start-class-link:after {
-  background-position: 0px -643px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-twitter, .dac-twitter.dac-modal-header-close:before, .paging-links .dac-twitter.prev-page-link:before, .paging-links .dac-twitter.next-page-link:before, .paging-links .dac-twitter.next-class-link:before, .paging-links .dac-twitter.start-class-link:after {
-  background-position: 0px -73px;
-  height: 14px;
-  width: 16px; }
-
-.dac-sprite.dac-unfold-less-white, .dac-unfold-less-white.dac-modal-header-close:before, .paging-links .dac-unfold-less-white.prev-page-link:before, .paging-links .dac-unfold-less-white.next-page-link:before, .paging-links .dac-unfold-less-white.next-class-link:before, .paging-links .dac-unfold-less-white.start-class-link:after {
-  background-position: 0px -565px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-unfold-less, .dac-unfold-less.dac-modal-header-close:before, .paging-links .dac-unfold-less.prev-page-link:before, .paging-links .dac-unfold-less.next-page-link:before, .paging-links .dac-unfold-less.next-class-link:before, .paging-links .dac-unfold-less.start-class-link:after {
-  background-position: 0px -487px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-unfold-more-white, .dac-unfold-more-white.dac-modal-header-close:before, .paging-links .dac-unfold-more-white.prev-page-link:before, .paging-links .dac-unfold-more-white.next-page-link:before, .paging-links .dac-unfold-more-white.next-class-link:before, .paging-links .dac-unfold-more-white.start-class-link:after {
-  background-position: 0px -305px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-unfold-more, .dac-unfold-more.dac-modal-header-close:before, .paging-links .dac-unfold-more.prev-page-link:before, .paging-links .dac-unfold-more.next-page-link:before, .paging-links .dac-unfold-more.next-class-link:before, .paging-links .dac-unfold-more.start-class-link:after {
-  background-position: 0px -539px;
-  height: 24px;
-  width: 24px; }
-
-.dac-sprite.dac-youtube, .dac-youtube.dac-modal-header-close:before, .paging-links .dac-youtube.prev-page-link:before, .paging-links .dac-youtube.next-page-link:before, .paging-links .dac-youtube.next-class-link:before, .paging-links .dac-youtube.start-class-link:after {
-  background-position: 0px -57px;
-  height: 14px;
-  width: 18px; }
-
-/* Toast Component */
-.dac-toast {
-  background: #ffebc3;
-  border-top: 1px solid #e5d4a1;
-  display: none;
-  color: rgba(0, 0, 0, .87);
-  line-height: 1.4;
-  padding: 10px;
-}
-
-.dac-toast.dac-visible {
-  display: block;
-}
-
-.dac-toast-wrap {
-  box-sizing: border-box;
-  margin: 0 auto;
-  max-width: 940px;
-  padding-right: 20px;
-  position: relative;
-}
-
-.dac-toast-close-btn {
-  background-color: transparent;
-  border: none;
-  border-radius: 0;
-  cursor: pointer;
-  opacity: .4;
-  padding: 0;
-  position: absolute;
-  right: 0;
-  top: -2px;
-}
-
-.dac-toast-close-btn:hover,
-.dac-toast-close-btn:focus,
-.dac-toast-close-btn:active {
-  opacity: 1;
-  outline: none;
-}
-
-.dac-toast-close-btn .dac-button.dac-raised.dac-primary{
-  margin: 0;
-  padding: 0;
-}
-
-.dac-toast-group {
-  bottom: 0;
-  left: 0;
-  position: fixed;
-  right: 0;
-  z-index: 60;
-}
-
-.dac-toast.dac-danger {
-  background-color: #ffccbc;
-  border-top-color: #e5b7a9;
-}
-
-.dac-toast.dac-success {
-  background-color: #cdedc8;
-  border-top-color: #c6d5b4;
-}
-
-@media (max-width: 719px) {
-  .dac-toast-close-btn {
-    position: relative;
-    top: 0;
-    margin: 10px 0 0;
-    display: block;
-  }
-}
-
-.dac-tab-item {
-  box-sizing: border-box;
-  cursor: pointer;
-  display: table-cell;
-  margin: 0;
-  padding: 8px 12px;
-  position: relative;
-  text-align: left; }
-  @media (max-width: 719px) {
-    .dac-tab-item {
-      padding-right: 12px;
-      text-align: center;
-      width: 33.33333333%; } }
-
-.dac-tab-title {
-  color: #333;
-  display: inline-block;
-  font-size: 16px;
-  font-weight: 500;
-  margin: 0; }
-
-.dac-tab-arrow {
-  margin-top: -2px; }
-  @media (max-width: 719px) {
-    .dac-tab-arrow {
-      position: absolute;
-      visibility: hidden; } }
-
-.dac-tab-bar {
-  display: inline-block;
-  list-style-type: none;
-  margin: 0 0 0 12px;
-  vertical-align: middle;
-  overflow: hidden; }
-  @media (max-width: 719px) {
-    .dac-tab-bar {
-      display: table;
-      margin-left: 0;
-      width: 100%; } }
-
-.dac-tab-views {
-  list-style-type: none;
-  margin: 0; }
-
-.dac-tab-view {
-  background: #fff;
-  display: none;
-  overflow: hidden;
-  margin: 0 0 10px;
-  padding: 20px 10px 0;
-  text-align: left; }
-
-.dac-tab-item.dac-active {
-  background: #fff; }
-
-.dac-tab-item.dac-active .dac-tab-arrow {
-  -webkit-transform: scaleY(-1);
-      -ms-transform: scaleY(-1);
-          transform: scaleY(-1); }
-
-.dac-tab-view.dac-active {
-  display: block; }
-
-.dac-toggle-expand {
-  cursor: pointer;
-  display: inline-block; }
-
-.dac-toggle-collapse {
-  cursor: pointer;
-  display: none; }
-
-.dac-toggle.is-expanded .dac-toggle-expand {
-  display: none; }
-
-.dac-toggle.is-expanded .dac-toggle-collapse {
-  display: inline-block; }
-
-.dac-toggle-content {
-  clear: left;
-  overflow: hidden;
-  max-height: 0;
-  -webkit-transition: .3s max-height;
-          transition: .3s max-height; }
-
-.dac-toggle.is-expanded .dac-toggle-content {
-  max-height: none; }
-
-.dac-toggle.dac-mobile .dac-toggle-content {
-  max-height: none; }
-
-@media (max-width: 719px) {
-  .dac-toggle.dac-mobile .dac-toggle-content {
-    max-height: 0; }
-  .dac-toggle.is-expanded .dac-toggle-content {
-    max-height: none; } }
-
-/**
- * Fades out an element.
- * Applies visibility hidden when the transition is finished.
- *
- * Use opacity: 1; to show the element.
- */
-.dac-visible-mobile-block, .dac-mobile-only,
-.dac-visible-mobile-inline,
-.dac-visible-mobile-inline-block,
-.dac-visible-tablet-block,
-.dac-visible-tablet-inline,
-.dac-visible-tablet-inline-block,
-.dac-visible-desktop-block,
-.dac-visible-desktop-inline,
-.dac-visible-desktop-inline-block {
-  display: none !important; }
-
-@media (max-width: 719px) {
-  .dac-hidden-mobile {
-    display: none !important; }
-  .dac-visible-mobile-block, .dac-mobile-only {
-    display: block !important; }
-  .dac-visible-mobile-inline {
-    display: inline !important; }
-  .dac-visible-mobile-inline-block {
-    display: inline-block !important; } }
-
-@media (min-width: 720px) and (max-width: 979px) {
-  .dac-hidden-tablet {
-    display: none !important; }
-  .dac-visible-tablet-block {
-    display: block !important; }
-  .dac-visible-tablet-inline {
-    display: inline !important; }
-  .dac-visible-tablet-inline-block {
-    display: inline-block !important; } }
-
-@media (min-width: 980px) {
-  .dac-hidden-desktop {
-    display: none !important; }
-  .dac-visible-desktop-block {
-    display: block !important; }
-  .dac-visible-desktop-inline {
-    display: inline !important; }
-  .dac-visible-desktop-inline-block {
-    display: inline-block !important; } }
-
-.dac-offset-parent {
-  position: relative !important; }
-
-/**
- * Hide from browsers/screenreaders on all sizes.
- */
-.dac-hidden {
-  display: none !important; }
-
-/**
- * Break strings when their length exceeds the width of their container.
- */
-.dac-text-break {
-  word-wrap: break-word !important; }
-
-/**
- * Horizontal text alignment
- */
-.dac-text-center {
-  text-align: center !important; }
-
-.dac-text-left {
-  text-align: left !important; }
-
-.dac-text-right {
-  text-align: right !important; }
-
-/**
- * Prevent whitespace wrapping
- */
-.dac-text-no-wrap {
-  white-space: nowrap !important; }
-
-/**
- * Prevent text from wrapping onto multiple lines, instead truncate with an ellipsis.
- */
-.dac-text-truncate {
-  max-width: 100%;
-  overflow: hidden !important;
-  text-overflow: ellipsis !important;
-  white-space: nowrap !important;
-  word-wrap: normal !important; }
-
-/**
- * Floats
- */
-.dac-float-left {
-  float: left !important; }
-
-.dac-float-right {
-  float: right !important; }
-
-/**
- * New block formatting context
- *
- * This affords some useful properties to the element. It won't wrap under
- * floats. Will also contain any floated children.
- * N.B. This will clip overflow. Use the alternative method below if this is
- * problematic.
- */
-.dac-nbfc {
-  overflow: hidden !important;
-}
-
-/**
- * New block formatting context (alternative)
- *
- * Alternative method when overflow must not be clipped.
- *
- * N.B. This breaks down in some browsers when elements within this element
- * exceed its width.
- */
-.dac-nbfc-alt {
-  display: table-cell !important;
-  width: 10000px !important;
-}
-
-.Video {
-  display: none;
-}
-
-.Video-overlay {
-  background-color: rgba(0, 0, 0, 0.8);
-  width: 100%;
-  height: 100%;
-  position: fixed;
-  top: 0;
-  left: 0;
-  z-index: 9999;
-}
-
-.Video-container {
-  width: 90vw;
-  height: 50.625vw;
-  max-height: calc(90vh - 29.25px);
-  max-width: calc(160vh - 52px);
-  margin: auto;
-  position: fixed;
-  top: -52px;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  z-index: 9999;
-}
-
-@media (min-width: 1422.22222222px) and (min-height: 800px) {
-  .Video-container {
-    width: 1280px;
-    height: 720px;
-  }
-}
-
-.Video-controls {
-  background: #28655F;
-  height: 52px;
-  margin: 0 auto;
-  position: relative;
-  box-shadow: 2px 3px 12px 0px rgba(0, 0, 0, 0.4);
-}
-
-.Video-frame {
-  position: relative;
-  height: 100%;
-  background: black;
-  box-shadow: 2px 3px 12px 0px rgba(0, 0, 0, 0.4);
-}
-
-.Video-loading {
-  color: rgba(255, 255, 255, 0.35);
-  font-size: 16px;
-  position: absolute;
-  top: 50%;
-  left: 50%;
-  -webkit-transform: translate(-50%, -50%);
-  -ms-transform: translate(-50%, -50%);
-  transform: translate(-50%, -50%);
-}
-
-#youTubePlayer {
-  max-height: 720px;
-  position: absolute;
-  top: 0;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  width: 100%;
-  height: 100%;
-}
-
-.Video-button {
-  background-color: transparent;
-  border: none;
-  display: inline-block;
-  height: 100%;
-  width: 52px;
-  outline: none;
-  cursor: pointer;
-  -webkit-transition: opacity 200ms;
-  transition: opacity 200ms;
-}
-
-.Video-button:hover {
-  opacity: 0.8;
-}
-
-.Video-button--picture-in-picture {
-  background-position: 0px -461px;
-  height: 24px;
-  width: 24px;
-  display: none;
-  position: absolute;
-  right: 64px;
-  top: 14px;
-}
-
-.Video-button--close {
-  background-position: 0px -435px;
-  height: 24px;
-  width: 24px;
-  position: absolute;
-  right: 14px;
-  top: 14px;
-}
-
-@media (min-width: 720px) {
-  .Video--picture-in-picture .Video-overlay {
-    display: none;
-  }
-
-  .Video--picture-in-picture .Video-container {
-    top: auto;
-    left: auto;
-    bottom: 20px;
-    right: 20px;
-    width: 40%;
-    max-width: 420px;
-    height: auto;
-  }
-
-  .Video--picture-in-picture .Video-button--picture-in-picture {
-    background-position: 0px -409px;
-    height: 24px;
-    width: 24px;
-  }
-
-  .Video--picture-in-picture .Video-frame {
-    padding-bottom: 56.25%;
-  }
-
-  .Video-button--picture-in-picture {
-    display: inline-block;
-  }
-}
-
-a.video-shadowbox-button.white {
-  padding: 16px 42px 16px 8px;
-  font-size: 18px;
-  font-weight: 500;
-  line-height: 24px;
-  color: #fff;
-  text-decoration: none;
-}
-
-a.video-shadowbox-button.white::after {
-  content: '';
-  background-position: 0px -847px;
-  height: 36px;
-  width: 36px;
-}
-
-a.video-shadowbox-button.white:hover {
-  color: #bababa !important;
-}
-
-a.video-shadowbox-button.white:hover::after {
-  background-position: 0px -733px;
-  height: 36px;
-  width: 36px;
-}
-
-#video-frame, #video-container {
-  display: none;
-}
-
-@media (max-width: 720px) {
-  .wide-table {
-    overflow-x: auto;
-  }
-
-  .wide-table table {
-    display: inline-table;
-    margin-right: 0;
-  }
-}
-
-/* New CSS that isn't part of a component */
-.paging-links {
-  box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.2);
-  margin: 30px 0;
-  padding: 0 40px;
-  /* Start class link doesn't have a caption */ }
-
-.paging-links .start-class-link, .paging-links .next-class-link, .paging-links .prev-page-link, .paging-links .next-page-link {
-  font-size: 20px;
-  font-weight: 500;
-  display: inline-block;
-  width: calc(50% - 2px);
-  position: relative;
-  padding: 46px 0 36px 0;
-}
-
-@media (max-width: 719px) {
-  .paging-links .start-class-link, .paging-links .next-class-link, .paging-links .prev-page-link, .paging-links .next-page-link {
-    width: 100%;
-  }
-}
-
-.paging-links .start-class-link {
-  padding: 36px 0;
-}
-
-.paging-links .start-class-link, .paging-links .next-class-link {
-  text-align: center;
-  width: 100%;
-}
-
-.paging-links .prev-page-link .page-link-caption {
-  left: 0;
-}
-
-.paging-links .prev-page-link:before {
-  content: '';
-  left: -24px;
-  position: absolute;
-  bottom: 41px;
-}
-
-@media (max-width: 719px) {
-  .paging-links .prev-page-link {
-    display: none;
-  }
-}
-
-.paging-links .next-page-link, .paging-links .next-class-link {
-  text-align: right;
-}
-
-.paging-links .next-page-link .page-link-caption, .paging-links .next-class-link .page-link-caption {
-  right: 0;
-}
-
-.paging-links .next-page-link:before, .paging-links .next-class-link:before {
-  content: '';
-  right: -24px;
-  position: absolute;
-  bottom: 41px;
-}
-
-.paging-links .start-class-link:after {
-  content: '';
-  right: -12px;
-  position: relative;
-  bottom: 3px;
-}
-
-.paging-links .page-link-caption {
-  position: absolute;
-  top: 26px;
-  font-size: 14px;
-  font-weight: 700;
-  opacity: 0.54;
-}
-
-#tb li:before,
-#qv li:before {
-  background-position: 0px -669px;
-  height: 24px;
-  width: 24px;
-  content: '';
-  left: -8px;
-  opacity: .7;
-  position: absolute;
-  top: -4px;
-}
-
-#skip-to-main {
-  border: 0;
-  clip: rect(0 0 0 0);
-  height: 1px;
-  margin: -1px;
-  overflow: hidden;
-  padding: 0;
-  position: absolute;
-  width: 1px;
-}
-
-#skip-to-main:focus {
-  background: #fff;
-  clip: auto;
-  height: auto;
-  padding: 10px;
-  width: auto;
-  z-index: 10000;
-}
diff --git a/tools/droiddoc/templates-sdk/assets/css/fullscreen.css b/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
deleted file mode 100644
index 0f108e0..0000000
--- a/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
+++ /dev/null
@@ -1,20 +0,0 @@
-
-/* =============================================================================
-   Columns
-   ========================================================================== */
-/* Applied to body to debug layout alignments
-.grid {
-  width:100%;
-  height:100%;
-  background:url(../images/grid.png) center repeat-y;
-  top:0px;
-  margin:auto;
-  position:absolute;
-}   
-*/
-
-@media screen, projection, print {
-  .wrap {
-    max-width: none;
-  }
-}
diff --git a/tools/droiddoc/templates-sdk/assets/design/default.js b/tools/droiddoc/templates-sdk/assets/design/default.js
deleted file mode 100644
index 3ba8486..0000000
--- a/tools/droiddoc/templates-sdk/assets/design/default.js
+++ /dev/null
@@ -1,188 +0,0 @@
-$(document).ready(function() {
-  // prep nav expandos
-  var pagePath = document.location.pathname;
-  if (pagePath.indexOf(SITE_ROOT) == 0) {
-    pagePath = pagePath.substr(SITE_ROOT.length);
-    if (pagePath == '' || pagePath.charAt(pagePath.length - 1) == '/') {
-      pagePath += 'index.html';
-    }
-  }
-
-  if (SITE_ROOT.match(/\.\.\//) || SITE_ROOT == '') {
-    // If running locally, SITE_ROOT will be a relative path, so account for that by
-    // finding the relative URL to this page. This will allow us to find links on the page
-    // leading back to this page.
-    var pathParts = pagePath.split('/');
-    var relativePagePathParts = [];
-    var upDirs = (SITE_ROOT.match(/(\.\.\/)+/) || [''])[0].length / 3;
-    for (var i = 0; i < upDirs; i++) {
-      relativePagePathParts.push('..');
-    }
-    for (var i = 0; i < upDirs; i++) {
-      relativePagePathParts.push(pathParts[pathParts.length - (upDirs - i) - 1]);
-    }
-    relativePagePathParts.push(pathParts[pathParts.length - 1]);
-    pagePath = relativePagePathParts.join('/');
-  } else {
-    // Otherwise the page path should be an absolute URL.
-    pagePath = SITE_ROOT + pagePath;
-  }
-
-  // select current page in sidenav and set up prev/next links if they exist
-  var $selNavLink = $('.nav-y').find('a[href="' + pagePath + '"]');
-  if ($selNavLink.length) {
-    $selListItem = $selNavLink.closest('li');
-
-    $selListItem.addClass('selected');
-    $selListItem.closest('li>ul').addClass('expanded');
-
-    // set up prev links
-    var $prevLink = [];
-    var $prevListItem = $selListItem.prev('li');
-    if ($prevListItem.length) {
-      if ($prevListItem.hasClass('nav-section')) {
-        // jump to last topic of previous section
-        $prevLink = $prevListItem.find('a:last');
-      } else {
-        // jump to previous topic in this section
-        $prevLink = $prevListItem.find('a:eq(0)');
-      }
-    } else {
-      // jump to this section's index page (if it exists)
-      $prevLink = $selListItem.parents('li').find('a');
-    }
-
-    if ($prevLink.length) {
-      var prevHref = $prevLink.attr('href');
-      if (prevHref == SITE_ROOT + 'index.html') {
-        // Don't show Previous when it leads to the homepage
-        $('.prev-page-link').hide();
-      } else {
-        $('.prev-page-link').attr('href', prevHref).show();
-      }
-    } else {
-      $('.prev-page-link').hide();
-    }
-
-    // set up next links
-    var $nextLink = [];
-    if ($selListItem.hasClass('nav-section')) {
-      // we're on an index page, jump to the first topic
-      $nextLink = $selListItem.find('ul').find('a:eq(0)')
-    } else {
-      // jump to the next topic in this section (if it exists)
-      $nextLink = $selListItem.next('li').find('a:eq(0)');
-      if (!$nextLink.length) {
-        // no more topics in this section, jump to the first topic in the next section
-        $nextLink = $selListItem.parents('li').next('li.nav-section').find('a:eq(0)');
-      }
-    }
-    if ($nextLink.length) {
-      $('.next-page-link').attr('href', $nextLink.attr('href')).show();
-    } else {
-      $('.next-page-link').hide();
-    }
-  }
-
-  // Set up expand/collapse behavior
-  $('.nav-y li').has('ul').click(function() {
-    if ($(this).hasClass('expanded')) {
-      return;
-    }
-
-    // hide other
-    var $old = $('.nav-y li.expanded');
-    if ($old.length) {
-      var $oldUl = $old.children('ul');
-      $oldUl.css('height', $oldUl.height() + 'px');
-      window.setTimeout(function() {
-        $oldUl
-            .addClass('animate-height')
-            .css('height', '');
-      }, 0);
-      $old.removeClass('expanded');
-    }
-
-    // show me
-    $(this).addClass('expanded');
-    var $ul = $(this).children('ul');
-    var expandedHeight = $ul.height();
-    $ul
-        .removeClass('animate-height')
-        .css('height', 0);
-    window.setTimeout(function() {
-      $ul
-          .addClass('animate-height')
-          .css('height', expandedHeight + 'px');
-    }, 0);
-  });
-
-  // Stop expand/collapse behavior when clicking on nav section links (since we're navigating away
-  // from the page)
-  $('.nav-y li').has('ul').find('a:eq(0)').click(function(evt) {
-    window.location.href = $(this).attr('href');
-    return false;
-  });
-
-  // Set up play-on-hover <video> tags.
-  $('video.play-on-hover').bind('click', function(){
-    $(this).get(0).load(); // in case the video isn't seekable
-    $(this).get(0).play();
-  });
-
-  // Set up tooltips
-  var TOOLTIP_MARGIN = 10;
-  $('acronym').each(function() {
-    var $target = $(this);
-    var $tooltip = $('<div>')
-        .addClass('tooltip-box')
-        .text($target.attr('title'))
-        .hide()
-        .appendTo('body');
-    $target.removeAttr('title');
-
-    $target.hover(function() {
-      // in
-      var targetRect = $target.offset();
-      targetRect.width = $target.width();
-      targetRect.height = $target.height();
-
-      $tooltip.css({
-        left: targetRect.left,
-        top: targetRect.top + targetRect.height + TOOLTIP_MARGIN
-      });
-      $tooltip.addClass('below');
-      $tooltip.show();
-    }, function() {
-      // out
-      $tooltip.hide();
-    });
-  });
-
-  // Set up <h2> deeplinks
-  $('h2').click(function() {
-    var id = $(this).attr('id');
-    if (id) {
-      document.location.hash = id;
-    }
-  });
-
-  // Set up fixed navbar
-  var navBarIsFixed = false;
-  $(window).scroll(function() {
-    var scrollTop = $(window).scrollTop();
-    var navBarShouldBeFixed = (scrollTop > (100 - 40));
-    if (navBarIsFixed != navBarShouldBeFixed) {
-      if (navBarShouldBeFixed) {
-        $('#nav')
-            .addClass('fixed')
-            .prependTo('#page-container');
-      } else {
-        $('#nav')
-            .removeClass('fixed')
-            .prependTo('#nav-container');
-      }
-      navBarIsFixed = navBarShouldBeFixed;
-    }
-  });
-});
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/images/android-developers-logo.png b/tools/droiddoc/templates-sdk/assets/images/android-developers-logo.png
deleted file mode 100644
index 30a8f62..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/android-developers-logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/android.png b/tools/droiddoc/templates-sdk/assets/images/android.png
deleted file mode 100644
index 4040f3f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/android.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/android_logo.png b/tools/droiddoc/templates-sdk/assets/images/android_logo.png
deleted file mode 100644
index 53f59c6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/android_logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/[email protected] b/tools/droiddoc/templates-sdk/assets/images/[email protected]
deleted file mode 100644
index 85b9211..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk.png b/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk.png
deleted file mode 100644
index 3f39f4d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/[email protected] b/tools/droiddoc/templates-sdk/assets/images/[email protected]
deleted file mode 100644
index 8081ac5..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/android_wrench.png b/tools/droiddoc/templates-sdk/assets/images/android_wrench.png
deleted file mode 100644
index 6390a2d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/android_wrench.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow-left-develop.png b/tools/droiddoc/templates-sdk/assets/images/arrow-left-develop.png
deleted file mode 100644
index 5fdfaa3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow-left-develop.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow-left.png b/tools/droiddoc/templates-sdk/assets/images/arrow-left.png
deleted file mode 100644
index 43afec8..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow-left.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow-right-develop.png b/tools/droiddoc/templates-sdk/assets/images/arrow-right-develop.png
deleted file mode 100644
index c86f1f3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow-right-develop.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow-right.png b/tools/droiddoc/templates-sdk/assets/images/arrow-right.png
deleted file mode 100644
index 6f7d6db..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow-right.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_down.png b/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_down.png
deleted file mode 100755
index 58c248a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_down.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_up.png b/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_up.png
deleted file mode 100755
index 7d0f38e..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow_bluelink_up.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow_left_off.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_left_off.jpg
deleted file mode 100755
index fd32a64..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow_left_off.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow_left_on.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_left_on.jpg
deleted file mode 100755
index 143184b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow_left_on.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow_right_off.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_right_off.jpg
deleted file mode 100755
index 17d2efe..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow_right_off.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrow_right_on.jpg b/tools/droiddoc/templates-sdk/assets/images/arrow_right_on.jpg
deleted file mode 100755
index baa2af1..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrow_right_on.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/arrows-up-down.png b/tools/droiddoc/templates-sdk/assets/images/arrows-up-down.png
deleted file mode 100644
index a2a91ed..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/arrows-up-down.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/bg_community_leftDiv.jpg b/tools/droiddoc/templates-sdk/assets/images/bg_community_leftDiv.jpg
deleted file mode 100755
index a6d6f0e..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/bg_community_leftDiv.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/bg_fade.jpg b/tools/droiddoc/templates-sdk/assets/images/bg_fade.jpg
deleted file mode 100755
index c6c70b6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/bg_fade.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/bg_gradient.jpg b/tools/droiddoc/templates-sdk/assets/images/bg_gradient.jpg
deleted file mode 100644
index 884f8f5..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/bg_gradient.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/bg_images_sprite.png b/tools/droiddoc/templates-sdk/assets/images/bg_images_sprite.png
deleted file mode 100755
index 84437e7..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/bg_images_sprite.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/bg_logo.png b/tools/droiddoc/templates-sdk/assets/images/bg_logo.png
deleted file mode 100755
index 7cf0cb9..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/bg_logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/blog-default.png b/tools/droiddoc/templates-sdk/assets/images/blog-default.png
deleted file mode 100644
index f8ab6c3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/blog-default.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/body-gradient-tab.png b/tools/droiddoc/templates-sdk/assets/images/body-gradient-tab.png
deleted file mode 100644
index 5223ac3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/body-gradient-tab.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/body-gradient.png b/tools/droiddoc/templates-sdk/assets/images/body-gradient.png
deleted file mode 100755
index 9d59855..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/body-gradient.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/breadcrumb.png b/tools/droiddoc/templates-sdk/assets/images/breadcrumb.png
deleted file mode 100644
index 407a318..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/breadcrumb.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/close-grey.png b/tools/droiddoc/templates-sdk/assets/images/close-grey.png
deleted file mode 100644
index 1b0d7f1..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/close-grey.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/close-grey_2x.png b/tools/droiddoc/templates-sdk/assets/images/close-grey_2x.png
deleted file mode 100644
index 1355507..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/close-grey_2x.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/close-white.png b/tools/droiddoc/templates-sdk/assets/images/close-white.png
deleted file mode 100644
index ef02018..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/close-white.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/close-white_2x.png b/tools/droiddoc/templates-sdk/assets/images/close-white_2x.png
deleted file mode 100644
index 9b9c41d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/close-white_2x.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/close.png b/tools/droiddoc/templates-sdk/assets/images/close.png
deleted file mode 100644
index 6ae3391..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/close.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/dac_logo.png b/tools/droiddoc/templates-sdk/assets/images/dac_logo.png
deleted file mode 100644
index 0f11044..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/dac_logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/[email protected] b/tools/droiddoc/templates-sdk/assets/images/[email protected]
deleted file mode 100644
index 0f2784d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/developers-logo.png b/tools/droiddoc/templates-sdk/assets/images/developers-logo.png
deleted file mode 100755
index 08122ee..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/developers-logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/file-generic.png b/tools/droiddoc/templates-sdk/assets/images/file-generic.png
deleted file mode 100644
index 1802457..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/file-generic.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/file-image.png b/tools/droiddoc/templates-sdk/assets/images/file-image.png
deleted file mode 100644
index d3aec46..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/file-image.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/file-java.png b/tools/droiddoc/templates-sdk/assets/images/file-java.png
deleted file mode 100644
index ec85e4b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/file-java.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/file-manifest.png b/tools/droiddoc/templates-sdk/assets/images/file-manifest.png
deleted file mode 100644
index 332d066..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/file-manifest.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/file-xml.png b/tools/droiddoc/templates-sdk/assets/images/file-xml.png
deleted file mode 100644
index 3dd21b6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/file-xml.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/folder.png b/tools/droiddoc/templates-sdk/assets/images/folder.png
deleted file mode 100644
index 44c6100..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/folder.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/fullscreen.png b/tools/droiddoc/templates-sdk/assets/images/fullscreen.png
deleted file mode 100644
index 01f971c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/fullscreen.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/grad-rule-qv.png b/tools/droiddoc/templates-sdk/assets/images/grad-rule-qv.png
deleted file mode 100644
index bae2d18..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/grad-rule-qv.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/Android_Dev_Lab_l.png b/tools/droiddoc/templates-sdk/assets/images/home/Android_Dev_Lab_l.png
deleted file mode 100644
index 3c04f24..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/Android_Dev_Lab_l.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/GDC2011.png b/tools/droiddoc/templates-sdk/assets/images/home/GDC2011.png
deleted file mode 100644
index 82ce918..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/GDC2011.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/GTV_icon_large.png b/tools/droiddoc/templates-sdk/assets/images/home/GTV_icon_large.png
deleted file mode 100644
index 72d54ad..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/GTV_icon_large.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/GTV_icon_small.png b/tools/droiddoc/templates-sdk/assets/images/home/GTV_icon_small.png
deleted file mode 100644
index 3da1699..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/GTV_icon_small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/IO-logo-2011.png b/tools/droiddoc/templates-sdk/assets/images/home/IO-logo-2011.png
deleted file mode 100644
index 4a28447..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/IO-logo-2011.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/IO-logo.png b/tools/droiddoc/templates-sdk/assets/images/home/IO-logo.png
deleted file mode 100644
index 65334c8..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/IO-logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/adc2_l.png b/tools/droiddoc/templates-sdk/assets/images/home/adc2_l.png
deleted file mode 100644
index 0b101a4..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/adc2_l.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/adc2_s.png b/tools/droiddoc/templates-sdk/assets/images/home/adc2_s.png
deleted file mode 100644
index 0d36bdb..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/adc2_s.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/android_adc.png b/tools/droiddoc/templates-sdk/assets/images/home/android_adc.png
deleted file mode 100644
index 9fe7f8f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/android_adc.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/android_m_hero_1200.jpg b/tools/droiddoc/templates-sdk/assets/images/home/android_m_hero_1200.jpg
deleted file mode 100644
index 6b79295..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/android_m_hero_1200.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_announcement.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_announcement.png
deleted file mode 100755
index 91485ff..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_announcement.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_bottom.jpg b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_bottom.jpg
deleted file mode 100755
index dacd401..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_bottom.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel.png
deleted file mode 100755
index 5ce5e30..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_board.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_board.png
deleted file mode 100755
index c577e02..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_board.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_wheel.png b/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_wheel.png
deleted file mode 100755
index aa224ad..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/bg_home_carousel_wheel.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/carousel_buttons_sprite.png b/tools/droiddoc/templates-sdk/assets/images/home/carousel_buttons_sprite.png
deleted file mode 100755
index e98c942..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/carousel_buttons_sprite.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/devphone-large.png b/tools/droiddoc/templates-sdk/assets/images/home/devphone-large.png
deleted file mode 100644
index 0db0f6c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/devphone-large.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/devphone-small.png b/tools/droiddoc/templates-sdk/assets/images/home/devphone-small.png
deleted file mode 100644
index e10bfa9..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/devphone-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/donut-android.png b/tools/droiddoc/templates-sdk/assets/images/home/donut-android.png
deleted file mode 100755
index 6aba06b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/donut-android.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/eclair-android.png b/tools/droiddoc/templates-sdk/assets/images/home/eclair-android.png
deleted file mode 100644
index d476ce9..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/eclair-android.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/froyo-android.png b/tools/droiddoc/templates-sdk/assets/images/home/froyo-android.png
deleted file mode 100644
index c63f7f0..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/froyo-android.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/gdc-logo.png b/tools/droiddoc/templates-sdk/assets/images/home/gdc-logo.png
deleted file mode 100644
index 5fb53fb..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/gdc-logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/gingerdroid.png b/tools/droiddoc/templates-sdk/assets/images/home/gingerdroid.png
deleted file mode 100644
index 8399d84..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/gingerdroid.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/google-plus-small.png b/tools/droiddoc/templates-sdk/assets/images/home/google-plus-small.png
deleted file mode 100644
index 5bb7d7a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/google-plus-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/google-plus.png b/tools/droiddoc/templates-sdk/assets/images/home/google-plus.png
deleted file mode 100644
index 90871e1..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/google-plus.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/honeycomb-android.png b/tools/droiddoc/templates-sdk/assets/images/home/honeycomb-android.png
deleted file mode 100644
index 6cc5031..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/honeycomb-android.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/icon-about.png b/tools/droiddoc/templates-sdk/assets/images/home/icon-about.png
deleted file mode 100644
index 8339762..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/icon-about.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/icon-design.png b/tools/droiddoc/templates-sdk/assets/images/home/icon-design.png
deleted file mode 100644
index 0d31cdf..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/icon-design.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/icon-develop.png b/tools/droiddoc/templates-sdk/assets/images/home/icon-develop.png
deleted file mode 100644
index e02b20f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/icon-develop.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/icon-distribute.png b/tools/droiddoc/templates-sdk/assets/images/home/icon-distribute.png
deleted file mode 100644
index 4824072..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/icon-distribute.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/ics-android.png b/tools/droiddoc/templates-sdk/assets/images/home/ics-android.png
deleted file mode 100644
index be62ca8..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/ics-android.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/io-large.png b/tools/droiddoc/templates-sdk/assets/images/home/io-large.png
deleted file mode 100755
index 986053c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/io-large.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/io-small.png b/tools/droiddoc/templates-sdk/assets/images/home/io-small.png
deleted file mode 100755
index 3a22549..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/io-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/maps-large.png b/tools/droiddoc/templates-sdk/assets/images/home/maps-large.png
deleted file mode 100644
index b26f65a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/maps-large.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/maps-small.png b/tools/droiddoc/templates-sdk/assets/images/home/maps-small.png
deleted file mode 100644
index cc5f1fa..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/maps-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/market-large.png b/tools/droiddoc/templates-sdk/assets/images/home/market-large.png
deleted file mode 100644
index 069fee7..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/market-large.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/market-small.png b/tools/droiddoc/templates-sdk/assets/images/home/market-small.png
deleted file mode 100644
index fa1201c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/market-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/sdk-large.png b/tools/droiddoc/templates-sdk/assets/images/home/sdk-large.png
deleted file mode 100644
index 315a1bf..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/sdk-large.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/home/sdk-small.png b/tools/droiddoc/templates-sdk/assets/images/home/sdk-small.png
deleted file mode 100644
index 0f1670d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/home/sdk-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/hr_gray_main.jpg b/tools/droiddoc/templates-sdk/assets/images/hr_gray_main.jpg
deleted file mode 100755
index f7a0a2f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/hr_gray_main.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/hr_gray_side.jpg b/tools/droiddoc/templates-sdk/assets/images/hr_gray_side.jpg
deleted file mode 100755
index 6667476..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/hr_gray_side.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_contribute.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_contribute.jpg
deleted file mode 100755
index 1aa12b6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_contribute.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_design.png b/tools/droiddoc/templates-sdk/assets/images/icon_design.png
deleted file mode 100644
index c12907c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_design.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_download.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_download.jpg
deleted file mode 100755
index f8c1165..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_download.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_download2.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_download2.jpg
deleted file mode 100755
index c0af7a2..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_download2.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_guidelines_logo.png b/tools/droiddoc/templates-sdk/assets/images/icon_guidelines_logo.png
deleted file mode 100644
index 9362c8f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_guidelines_logo.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
deleted file mode 100644
index 0fbb197..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_market.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_more.png b/tools/droiddoc/templates-sdk/assets/images/icon_more.png
deleted file mode 100644
index 6cd03a3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_more.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_play.png b/tools/droiddoc/templates-sdk/assets/images/icon_play.png
deleted file mode 100644
index 8bfdc7b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_play.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_robot.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_robot.jpg
deleted file mode 100755
index ca0fd39..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_robot.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_search.png b/tools/droiddoc/templates-sdk/assets/images/icon_search.png
deleted file mode 100644
index ee90a12..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_search.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/icon_world.jpg b/tools/droiddoc/templates-sdk/assets/images/icon_world.jpg
deleted file mode 100755
index 65b8fa6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/icon_world.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/left_off.jpg b/tools/droiddoc/templates-sdk/assets/images/left_off.jpg
deleted file mode 100755
index fd32a64..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/left_off.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/left_on.jpg b/tools/droiddoc/templates-sdk/assets/images/left_on.jpg
deleted file mode 100755
index 143184b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/left_on.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/link-out.png b/tools/droiddoc/templates-sdk/assets/images/link-out.png
deleted file mode 100644
index aa55f9a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/link-out.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/locale.png b/tools/droiddoc/templates-sdk/assets/images/locale.png
deleted file mode 100644
index de3aae7..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/locale.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/logo_breadcrumbz.jpg b/tools/droiddoc/templates-sdk/assets/images/logo_breadcrumbz.jpg
deleted file mode 100755
index e743f86..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/logo_breadcrumbz.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/more_bottom.png b/tools/droiddoc/templates-sdk/assets/images/more_bottom.png
deleted file mode 100644
index 632546a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/more_bottom.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/more_check.png b/tools/droiddoc/templates-sdk/assets/images/more_check.png
deleted file mode 100644
index f2fcbfc..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/more_check.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/more_mid.png b/tools/droiddoc/templates-sdk/assets/images/more_mid.png
deleted file mode 100644
index 99bc999..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/more_mid.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/more_top.png b/tools/droiddoc/templates-sdk/assets/images/more_top.png
deleted file mode 100644
index 8ead1d3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/more_top.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/open_source.png b/tools/droiddoc/templates-sdk/assets/images/open_source.png
deleted file mode 100755
index 12bb1fb..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/open_source.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/preliminary.png b/tools/droiddoc/templates-sdk/assets/images/preliminary.png
deleted file mode 100644
index fe0da3d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/preliminary.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/preview.png b/tools/droiddoc/templates-sdk/assets/images/preview.png
deleted file mode 100644
index e5856db..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/preview.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/quicknav_arrow.png b/tools/droiddoc/templates-sdk/assets/images/quicknav_arrow.png
deleted file mode 100644
index 697ac82..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/quicknav_arrow.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/quicknav_btn_bg.png b/tools/droiddoc/templates-sdk/assets/images/quicknav_btn_bg.png
deleted file mode 100644
index b80c9a8..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/quicknav_btn_bg.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-e.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-e.gif
deleted file mode 100755
index f748097..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-e.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-e2.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-e2.gif
deleted file mode 100755
index e45d0c5..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-e2.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-eg.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-eg.gif
deleted file mode 100755
index 6196616..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-eg.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-s.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-s.gif
deleted file mode 100755
index 7f6a4eb..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-s.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-s2.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-s2.gif
deleted file mode 100755
index 99e869c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-s2.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-s2.png b/tools/droiddoc/templates-sdk/assets/images/resizable-s2.png
deleted file mode 100644
index f3a6d2d..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-s2.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resizable-sg.gif b/tools/droiddoc/templates-sdk/assets/images/resizable-sg.gif
deleted file mode 100755
index b4bea10..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resizable-sg.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-article.png b/tools/droiddoc/templates-sdk/assets/images/resource-article.png
deleted file mode 100644
index 416493f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-article.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-article.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-article.png
deleted file mode 100644
index 7273275..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-big-article.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-sample.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-sample.png
deleted file mode 100644
index 59b6b68..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-big-sample.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-tutorial.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-tutorial.png
deleted file mode 100644
index c32e89a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-big-tutorial.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-big-video.png b/tools/droiddoc/templates-sdk/assets/images/resource-big-video.png
deleted file mode 100644
index 59d46a0..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-big-video.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-card-default-android.jpg b/tools/droiddoc/templates-sdk/assets/images/resource-card-default-android.jpg
deleted file mode 100644
index 398030f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-card-default-android.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-sample.png b/tools/droiddoc/templates-sdk/assets/images/resource-sample.png
deleted file mode 100644
index f7a411c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-sample.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-tutorial.png b/tools/droiddoc/templates-sdk/assets/images/resource-tutorial.png
deleted file mode 100644
index 10a14fe..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-tutorial.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/resource-video.png b/tools/droiddoc/templates-sdk/assets/images/resource-video.png
deleted file mode 100644
index 8fd5cae..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/resource-video.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/right_off.jpg b/tools/droiddoc/templates-sdk/assets/images/right_off.jpg
deleted file mode 100755
index 17d2efe..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/right_off.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/right_on.jpg b/tools/droiddoc/templates-sdk/assets/images/right_on.jpg
deleted file mode 100755
index baa2af1..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/right_on.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/sidenav-rule.png b/tools/droiddoc/templates-sdk/assets/images/sidenav-rule.png
deleted file mode 100644
index eab9920..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/sidenav-rule.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_1.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_1.jpg
deleted file mode 100755
index 6d75be1..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_1.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_2.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_2.jpg
deleted file mode 100755
index aa994c2..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_2.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_3.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_3.jpg
deleted file mode 100755
index b04deb3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_3.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_large_1.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_large_1.jpg
deleted file mode 100755
index a992e92..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_large_1.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_large_2.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_large_2.jpg
deleted file mode 100755
index 9af63f4..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_large_2.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_large_3.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_large_3.jpg
deleted file mode 100755
index fcf236c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_large_3.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_off.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_off.jpg
deleted file mode 100755
index 5971227..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_off.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/slide_on.jpg b/tools/droiddoc/templates-sdk/assets/images/slide_on.jpg
deleted file mode 100755
index 7ca3577..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/slide_on.jpg
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/spacer.gif b/tools/droiddoc/templates-sdk/assets/images/spacer.gif
deleted file mode 100755
index f96b355..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/spacer.gif
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/sprite-2x.png b/tools/droiddoc/templates-sdk/assets/images/sprite-2x.png
deleted file mode 100644
index 185b7e8..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/sprite-2x.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/sprite.png b/tools/droiddoc/templates-sdk/assets/images/sprite.png
deleted file mode 100644
index 562b23c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/sprite.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/[email protected] b/tools/droiddoc/templates-sdk/assets/images/[email protected]
deleted file mode 100644
index 2019e02..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/stack-arrow-right.png b/tools/droiddoc/templates-sdk/assets/images/stack-arrow-right.png
deleted file mode 100644
index 46d6a50..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/stack-arrow-right.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/callout.png b/tools/droiddoc/templates-sdk/assets/images/styles/callout.png
deleted file mode 100644
index 5d49f34..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/callout.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_land_span13.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_land_span13.png
deleted file mode 100644
index bab6aca..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_land_span13.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_land_span8.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_land_span8.png
deleted file mode 100644
index cb180bf..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_land_span8.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_port_span5.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_port_span5.png
deleted file mode 100644
index bdccc2f..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_port_span5.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_port_span9.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_port_span9.png
deleted file mode 100644
index 5e0135b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_galaxynexus_blank_port_span9.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus4_blank_port_432.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus4_blank_port_432.png
deleted file mode 100644
index 9d41aa3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus4_blank_port_432.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_land_span13.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_land_span13.png
deleted file mode 100644
index 5d37121..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_land_span13.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_port_span5.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_port_span5.png
deleted file mode 100644
index df35117..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_nexus5_blank_port_span5.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_wear_square.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_wear_square.png
deleted file mode 100644
index 077a7e6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_wear_square.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/device_wear_square_small.png b/tools/droiddoc/templates-sdk/assets/images/styles/device_wear_square_small.png
deleted file mode 100644
index e7e1540..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/device_wear_square_small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_down.png b/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_down.png
deleted file mode 100644
index 6a0a8ee..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_down.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_left.png b/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_left.png
deleted file mode 100644
index e887b2a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_left.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_right.png b/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_right.png
deleted file mode 100644
index ced7fa4..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_right.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_up.png b/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_up.png
deleted file mode 100644
index ddd4ec9..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/disclosure_up.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/gototop.png b/tools/droiddoc/templates-sdk/assets/images/styles/gototop.png
deleted file mode 100644
index 5f09a29..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/gototop.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/helpouts-logo-35.png b/tools/droiddoc/templates-sdk/assets/images/styles/helpouts-logo-35.png
deleted file mode 100644
index 3c2dc1a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/helpouts-logo-35.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/helpouts-logo-35_2x.png b/tools/droiddoc/templates-sdk/assets/images/styles/helpouts-logo-35_2x.png
deleted file mode 100644
index e34be2e..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/helpouts-logo-35_2x.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_action.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_action.png
deleted file mode 100644
index 30e4cc7..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_action.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_good.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_good.png
deleted file mode 100644
index afebe1c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_good.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_movie_inline.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_movie_inline.png
deleted file mode 100644
index 7cfb5c5..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_movie_inline.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_phone_tablet.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_phone_tablet.png
deleted file mode 100644
index 003b876..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_phone_tablet.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_use.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_use.png
deleted file mode 100644
index 9d868b3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_use.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_web.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_web.png
deleted file mode 100644
index 0848e3c..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_web.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/ico_wrong.png b/tools/droiddoc/templates-sdk/assets/images/styles/ico_wrong.png
deleted file mode 100644
index b7d04ce..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/ico_wrong.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-video.png b/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-video.png
deleted file mode 100644
index eea3485..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-video.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected] b/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
deleted file mode 100644
index a5fdae3..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers.png b/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers.png
deleted file mode 100644
index 1fb22a2..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected] b/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
deleted file mode 100644
index bc2f74b..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/notice-developers-video.png b/tools/droiddoc/templates-sdk/assets/images/styles/notice-developers-video.png
deleted file mode 100644
index e9f8ed2..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/notice-developers-video.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected] b/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
deleted file mode 100644
index c067ac1..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/notice-developers.png b/tools/droiddoc/templates-sdk/assets/images/styles/notice-developers.png
deleted file mode 100644
index a29c31a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/notice-developers.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected] b/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
deleted file mode 100644
index d42f537..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/[email protected]
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/open_new_page.png b/tools/droiddoc/templates-sdk/assets/images/styles/open_new_page.png
deleted file mode 100644
index 6197e3a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/styles/open_new_page.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/triangle-closed-small.png b/tools/droiddoc/templates-sdk/assets/images/triangle-closed-small.png
deleted file mode 100644
index 002364a..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/triangle-closed-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/triangle-closed.png b/tools/droiddoc/templates-sdk/assets/images/triangle-closed.png
deleted file mode 100644
index 40a68d9..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/triangle-closed.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/triangle-opened-small.png b/tools/droiddoc/templates-sdk/assets/images/triangle-opened-small.png
deleted file mode 100644
index e1eb784..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/triangle-opened-small.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/triangle-opened.png b/tools/droiddoc/templates-sdk/assets/images/triangle-opened.png
deleted file mode 100644
index 789f5fa..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/triangle-opened.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/uiguidelines1.png b/tools/droiddoc/templates-sdk/assets/images/uiguidelines1.png
deleted file mode 100644
index 5ce1611..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/uiguidelines1.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/video-droid.png b/tools/droiddoc/templates-sdk/assets/images/video-droid.png
deleted file mode 100644
index 25163b6..0000000
--- a/tools/droiddoc/templates-sdk/assets/images/video-droid.png
+++ /dev/null
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/js/android_3p-bundle.js b/tools/droiddoc/templates-sdk/assets/js/android_3p-bundle.js
deleted file mode 100644
index 70d6c2f..0000000
--- a/tools/droiddoc/templates-sdk/assets/js/android_3p-bundle.js
+++ /dev/null
@@ -1,2772 +0,0 @@
-//third_party/javascript/google_code_prettify/src/prettify.js
-/**
- * @license Copyright (C) 2006 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * some functions for browser-side pretty printing of code contained in html.
- * <p>
- *
- * For a fairly comprehensive set of languages see the
- * <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs">README</a>
- * file that came with this source.  At a minimum, the lexer should work on a
- * number of languages including C and friends, Java, Python, Bash, SQL, HTML,
- * XML, CSS, Javascript, and Makefiles.  It works passably on Ruby, PHP and Awk
- * and a subset of Perl, but, because of commenting conventions, doesn't work on
- * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class.
- * <p>
- * Usage: <ol>
- * <li> include this source file in an html page via
- *   {@code <script type="text/javascript" src="/path/to/prettify.js"></script>}
- * <li> define style rules.  See the example page for examples.
- * <li> mark the {@code <pre>} and {@code <code>} tags in your source with
- *    {@code class=prettyprint.}
- *    You can also use the (html deprecated) {@code <xmp>} tag, but the pretty
- *    printer needs to do more substantial DOM manipulations to support that, so
- *    some css styles may not be preserved.
- * </ol>
- * That's it.  I wanted to keep the API as simple as possible, so there's no
- * need to specify which language the code is in, but if you wish, you can add
- * another class to the {@code <pre>} or {@code <code>} element to specify the
- * language, as in {@code <pre class="prettyprint lang-java">}.  Any class that
- * starts with "lang-" followed by a file extension, specifies the file type.
- * See the "lang-*.js" files in this directory for code that implements
- * per-language file handlers.
- * <p>
- * Change log:<br>
- * cbeust, 2006/08/22
- * <blockquote>
- *   Java annotations (start with "@") are now captured as literals ("lit")
- * </blockquote>
- * @requires console
- */
-
-// JSLint declarations
-/*global console, document, navigator, setTimeout, window */
-
-/**
- * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
- * UI events.
- * If set to {@code false}, {@code prettyPrint()} is synchronous.
- */
-window['PR_SHOULD_USE_CONTINUATION'] = true;
-
-/** the number of characters between tab columns */
-window['PR_TAB_WIDTH'] = 8;
-
-/** Walks the DOM returning a properly escaped version of innerHTML.
-  * @param {Node} node
-  * @param {Array.<string>} out output buffer that receives chunks of HTML.
-  */
-window['PR_normalizedHtml']
-
-/** Contains functions for creating and registering new language handlers.
-  * @type {Object}
-  */
-  = window['PR']
-
-/** Pretty print a chunk of code.
-  *
-  * @param {string} sourceCodeHtml code as html
-  * @return {string} code as html, but prettier
-  */
-  = window['prettyPrintOne']
-/** Find all the {@code <pre>} and {@code <code>} tags in the DOM with
-  * {@code class=prettyprint} and prettify them.
-  * @param {Function?} opt_whenDone if specified, called when the last entry
-  *     has been finished.
-  */
-  = window['prettyPrint'] = void 0;
-
-/** browser detection. @extern @returns false if not IE, otherwise the major version. */
-window['_pr_isIE6'] = function () {
-  var ieVersion = navigator && navigator.userAgent &&
-      navigator.userAgent.match(/\bMSIE ([678])\./);
-  ieVersion = ieVersion ? +ieVersion[1] : false;
-  window['_pr_isIE6'] = function () { return ieVersion; };
-  return ieVersion;
-};
-
-
-(function () {
-  // Keyword lists for various languages.
-  var FLOW_CONTROL_KEYWORDS =
-      "break continue do else for if return while ";
-  var C_KEYWORDS = FLOW_CONTROL_KEYWORDS + "auto case char const default " +
-      "double enum extern float goto int long register short signed sizeof " +
-      "static struct switch typedef union unsigned void volatile ";
-  var COMMON_KEYWORDS = C_KEYWORDS + "catch class delete false import " +
-      "new operator private protected public this throw true try typeof ";
-  var CPP_KEYWORDS = COMMON_KEYWORDS + "alignof align_union asm axiom bool " +
-      "concept concept_map const_cast constexpr decltype " +
-      "dynamic_cast explicit export friend inline late_check " +
-      "mutable namespace nullptr reinterpret_cast static_assert static_cast " +
-      "template typeid typename using virtual wchar_t where ";
-  var JAVA_KEYWORDS = COMMON_KEYWORDS +
-      "abstract boolean byte extends final finally implements import " +
-      "instanceof null native package strictfp super synchronized throws " +
-      "transient ";
-  var CSHARP_KEYWORDS = JAVA_KEYWORDS +
-      "as base by checked decimal delegate descending dynamic event " +
-      "fixed foreach from group implicit in interface internal into is lock " +
-      "object out override orderby params partial readonly ref sbyte sealed " +
-      "stackalloc string select uint ulong unchecked unsafe ushort var ";
-  var COFFEE_KEYWORDS = "all and by catch class else extends false finally " +
-      "for if in is isnt loop new no not null of off on or return super then " +
-      "true try unless until when while yes ";
-  var JSCRIPT_KEYWORDS = COMMON_KEYWORDS +
-      "debugger eval export function get null set undefined var with " +
-      "Infinity NaN ";
-  var PERL_KEYWORDS = "caller delete die do dump elsif eval exit foreach for " +
-      "goto if import last local my next no our print package redo require " +
-      "sub undef unless until use wantarray while BEGIN END ";
-  var PYTHON_KEYWORDS = FLOW_CONTROL_KEYWORDS + "and as assert class def del " +
-      "elif except exec finally from global import in is lambda " +
-      "nonlocal not or pass print raise try with yield " +
-      "False True None ";
-  var RUBY_KEYWORDS = FLOW_CONTROL_KEYWORDS + "alias and begin case class def" +
-      " defined elsif end ensure false in module next nil not or redo rescue " +
-      "retry self super then true undef unless until when yield BEGIN END ";
-  var SH_KEYWORDS = FLOW_CONTROL_KEYWORDS + "case done elif esac eval fi " +
-      "function in local set then until ";
-  var ALL_KEYWORDS = (
-      CPP_KEYWORDS + CSHARP_KEYWORDS + JSCRIPT_KEYWORDS + PERL_KEYWORDS +
-      PYTHON_KEYWORDS + RUBY_KEYWORDS + SH_KEYWORDS);
-
-  // token style names.  correspond to css classes
-  /** token style for a string literal */
-  var PR_STRING = 'str';
-  /** token style for a keyword */
-  var PR_KEYWORD = 'kwd';
-  /** token style for a comment */
-  var PR_COMMENT = 'com';
-  /** token style for a type */
-  var PR_TYPE = 'typ';
-  /** token style for a literal value.  e.g. 1, null, true. */
-  var PR_LITERAL = 'lit';
-  /** token style for a punctuation string. */
-  var PR_PUNCTUATION = 'pun';
-  /** token style for a punctuation string. */
-  var PR_PLAIN = 'pln';
-
-  /** token style for an sgml tag. */
-  var PR_TAG = 'tag';
-  /** token style for a markup declaration such as a DOCTYPE. */
-  var PR_DECLARATION = 'dec';
-  /** token style for embedded source. */
-  var PR_SOURCE = 'src';
-  /** token style for an sgml attribute name. */
-  var PR_ATTRIB_NAME = 'atn';
-  /** token style for an sgml attribute value. */
-  var PR_ATTRIB_VALUE = 'atv';
-
-  /**
-   * A class that indicates a section of markup that is not code, e.g. to allow
-   * embedding of line numbers within code listings.
-   */
-  var PR_NOCODE = 'nocode';
-
-  /** A set of tokens that can precede a regular expression literal in
-    * javascript.
-    * http://www.mozilla.org/js/language/js20/rationale/syntax.html has the full
-    * list, but I've removed ones that might be problematic when seen in
-    * languages that don't support regular expression literals.
-    *
-    * <p>Specifically, I've removed any keywords that can't precede a regexp
-    * literal in a syntactically legal javascript program, and I've removed the
-    * "in" keyword since it's not a keyword in many languages, and might be used
-    * as a count of inches.
-    *
-    * <p>The link a above does not accurately describe EcmaScript rules since
-    * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
-    * very well in practice.
-    *
-    * @private
-    */
-  var REGEXP_PRECEDER_PATTERN = function () {
-      var preceders = [
-          "!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=",
-          "&=", "(", "*", "*=", /* "+", */ "+=", ",", /* "-", */ "-=",
-          "->", /*".", "..", "...", handled below */ "/", "/=", ":", "::", ";",
-          "<", "<<", "<<=", "<=", "=", "==", "===", ">",
-          ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[",
-          "^", "^=", "^^", "^^=", "{", "|", "|=", "||",
-          "||=", "~" /* handles =~ and !~ */,
-          "break", "case", "continue", "delete",
-          "do", "else", "finally", "instanceof",
-          "return", "throw", "try", "typeof"
-          ];
-      var pattern = '(?:^^|[+-]';
-      for (var i = 0; i < preceders.length; ++i) {
-        pattern += '|' + preceders[i].replace(/([^=<>:&a-z])/g, '\\$1');
-      }
-      pattern += ')\\s*';  // matches at end, and matches empty string
-      return pattern;
-      // CAVEAT: this does not properly handle the case where a regular
-      // expression immediately follows another since a regular expression may
-      // have flags for case-sensitivity and the like.  Having regexp tokens
-      // adjacent is not valid in any language I'm aware of, so I'm punting.
-      // TODO: maybe style special characters inside a regexp as punctuation.
-    }();
-
-  // Define regexps here so that the interpreter doesn't have to create an
-  // object each time the function containing them is called.
-  // The language spec requires a new object created even if you don't access
-  // the $1 members.
-  var pr_amp = /&/g;
-  var pr_lt = /</g;
-  var pr_gt = />/g;
-  var pr_quot = /\"/g;
-  /** like textToHtml but escapes double quotes to be attribute safe. */
-  function attribToHtml(str) {
-    return str.replace(pr_amp, '&amp;')
-        .replace(pr_lt, '&lt;')
-        .replace(pr_gt, '&gt;')
-        .replace(pr_quot, '&quot;');
-  }
-
-  /** escapest html special characters to html. */
-  function textToHtml(str) {
-    return str.replace(pr_amp, '&amp;')
-        .replace(pr_lt, '&lt;')
-        .replace(pr_gt, '&gt;');
-  }
-
-
-  var pr_ltEnt = /&lt;/g;
-  var pr_gtEnt = /&gt;/g;
-  var pr_aposEnt = /&apos;/g;
-  var pr_quotEnt = /&quot;/g;
-  var pr_ampEnt = /&amp;/g;
-  var pr_nbspEnt = /&nbsp;/g;
-  /** unescapes html to plain text. */
-  function htmlToText(html) {
-    var pos = html.indexOf('&');
-    if (pos < 0) { return html; }
-    // Handle numeric entities specially.  We can't use functional substitution
-    // since that doesn't work in older versions of Safari.
-    // These should be rare since most browsers convert them to normal chars.
-    for (--pos; (pos = html.indexOf('&#', pos + 1)) >= 0;) {
-      var end = html.indexOf(';', pos);
-      if (end >= 0) {
-        var num = html.substring(pos + 3, end);
-        var radix = 10;
-        if (num && num.charAt(0) === 'x') {
-          num = num.substring(1);
-          radix = 16;
-        }
-        var codePoint = parseInt(num, radix);
-        if (!isNaN(codePoint)) {
-          html = (html.substring(0, pos) + String.fromCharCode(codePoint) +
-                  html.substring(end + 1));
-        }
-      }
-    }
-
-    return html.replace(pr_ltEnt, '<')
-        .replace(pr_gtEnt, '>')
-        .replace(pr_aposEnt, "'")
-        .replace(pr_quotEnt, '"')
-        .replace(pr_nbspEnt, ' ')
-        .replace(pr_ampEnt, '&');
-  }
-
-  /** is the given node's innerHTML normally unescaped? */
-  function isRawContent(node) {
-    return 'XMP' === node.tagName;
-  }
-
-  var newlineRe = /[\r\n]/g;
-  /**
-   * Are newlines and adjacent spaces significant in the given node's innerHTML?
-   */
-  function isPreformatted(node, content) {
-    // PRE means preformatted, and is a very common case, so don't create
-    // unnecessary computed style objects.
-    if ('PRE' === node.tagName) { return true; }
-    if (!newlineRe.test(content)) { return true; }  // Don't care
-    var whitespace = '';
-    // For disconnected nodes, IE has no currentStyle.
-    if (node.currentStyle) {
-      whitespace = node.currentStyle.whiteSpace;
-    } else if (window.getComputedStyle) {
-      // Firefox makes a best guess if node is disconnected whereas Safari
-      // returns the empty string.
-      whitespace = window.getComputedStyle(node, null).whiteSpace;
-    }
-    return !whitespace || whitespace === 'pre';
-  }
-
-  function normalizedHtml(node, out, opt_sortAttrs) {
-    switch (node.nodeType) {
-      case 1:  // an element
-        var name = node.tagName.toLowerCase();
-
-        out.push('<', name);
-        var attrs = node.attributes;
-        var n = attrs.length;
-        if (n) {
-          if (opt_sortAttrs) {
-            var sortedAttrs = [];
-            for (var i = n; --i >= 0;) { sortedAttrs[i] = attrs[i]; }
-            sortedAttrs.sort(function (a, b) {
-                return (a.name < b.name) ? -1 : a.name === b.name ? 0 : 1;
-              });
-            attrs = sortedAttrs;
-          }
-          for (var i = 0; i < n; ++i) {
-            var attr = attrs[i];
-            if (!attr.specified) { continue; }
-            out.push(' ', attr.name.toLowerCase(),
-                     '="', attribToHtml(attr.value), '"');
-          }
-        }
-        out.push('>');
-        for (var child = node.firstChild; child; child = child.nextSibling) {
-          normalizedHtml(child, out, opt_sortAttrs);
-        }
-        if (node.firstChild || !/^(?:br|link|img)$/.test(name)) {
-          out.push('<\/', name, '>');
-        }
-        break;
-      case 3: case 4: // text
-        out.push(textToHtml(node.nodeValue));
-        break;
-    }
-  }
-
-  /**
-   * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
-   * matches the union o the sets o strings matched d by the input RegExp.
-   * Since it matches globally, if the input strings have a start-of-input
-   * anchor (/^.../), it is ignored for the purposes of unioning.
-   * @param {Array.<RegExp>} regexs non multiline, non-global regexs.
-   * @return {RegExp} a global regex.
-   */
-  function combinePrefixPatterns(regexs) {
-    var capturedGroupIndex = 0;
-
-    var needToFoldCase = false;
-    var ignoreCase = false;
-    for (var i = 0, n = regexs.length; i < n; ++i) {
-      var regex = regexs[i];
-      if (regex.ignoreCase) {
-        ignoreCase = true;
-      } else if (/[a-z]/i.test(regex.source.replace(
-                     /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
-        needToFoldCase = true;
-        ignoreCase = false;
-        break;
-      }
-    }
-
-    function decodeEscape(charsetPart) {
-      if (charsetPart.charAt(0) !== '\\') { return charsetPart.charCodeAt(0); }
-      switch (charsetPart.charAt(1)) {
-        case 'b': return 8;
-        case 't': return 9;
-        case 'n': return 0xa;
-        case 'v': return 0xb;
-        case 'f': return 0xc;
-        case 'r': return 0xd;
-        case 'u': case 'x':
-          return parseInt(charsetPart.substring(2), 16)
-              || charsetPart.charCodeAt(1);
-        case '0': case '1': case '2': case '3': case '4':
-        case '5': case '6': case '7':
-          return parseInt(charsetPart.substring(1), 8);
-        default: return charsetPart.charCodeAt(1);
-      }
-    }
-
-    function encodeEscape(charCode) {
-      if (charCode < 0x20) {
-        return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
-      }
-      var ch = String.fromCharCode(charCode);
-      if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
-        ch = '\\' + ch;
-      }
-      return ch;
-    }
-
-    function caseFoldCharset(charSet) {
-      var charsetParts = charSet.substring(1, charSet.length - 1).match(
-          new RegExp(
-              '\\\\u[0-9A-Fa-f]{4}'
-              + '|\\\\x[0-9A-Fa-f]{2}'
-              + '|\\\\[0-3][0-7]{0,2}'
-              + '|\\\\[0-7]{1,2}'
-              + '|\\\\[\\s\\S]'
-              + '|-'
-              + '|[^-\\\\]',
-              'g'));
-      var groups = [];
-      var ranges = [];
-      var inverse = charsetParts[0] === '^';
-      for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
-        var p = charsetParts[i];
-        switch (p) {
-          case '\\B': case '\\b':
-          case '\\D': case '\\d':
-          case '\\S': case '\\s':
-          case '\\W': case '\\w':
-            groups.push(p);
-            continue;
-        }
-        var start = decodeEscape(p);
-        var end;
-        if (i + 2 < n && '-' === charsetParts[i + 1]) {
-          end = decodeEscape(charsetParts[i + 2]);
-          i += 2;
-        } else {
-          end = start;
-        }
-        ranges.push([start, end]);
-        // If the range might intersect letters, then expand it.
-        if (!(end < 65 || start > 122)) {
-          if (!(end < 65 || start > 90)) {
-            ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
-          }
-          if (!(end < 97 || start > 122)) {
-            ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
-          }
-        }
-      }
-
-      // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
-      // -> [[1, 12], [14, 14], [16, 17]]
-      ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1]  - a[1]); });
-      var consolidatedRanges = [];
-      var lastRange = [NaN, NaN];
-      for (var i = 0; i < ranges.length; ++i) {
-        var range = ranges[i];
-        if (range[0] <= lastRange[1] + 1) {
-          lastRange[1] = Math.max(lastRange[1], range[1]);
-        } else {
-          consolidatedRanges.push(lastRange = range);
-        }
-      }
-
-      var out = ['['];
-      if (inverse) { out.push('^'); }
-      out.push.apply(out, groups);
-      for (var i = 0; i < consolidatedRanges.length; ++i) {
-        var range = consolidatedRanges[i];
-        out.push(encodeEscape(range[0]));
-        if (range[1] > range[0]) {
-          if (range[1] + 1 > range[0]) { out.push('-'); }
-          out.push(encodeEscape(range[1]));
-        }
-      }
-      out.push(']');
-      return out.join('');
-    }
-
-    function allowAnywhereFoldCaseAndRenumberGroups(regex) {
-      // Split into character sets, escape sequences, punctuation strings
-      // like ('(', '(?:', ')', '^'), and runs of characters that do not
-      // include any of the above.
-      var parts = regex.source.match(
-          new RegExp(
-              '(?:'
-              + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]'  // a character set
-              + '|\\\\u[A-Fa-f0-9]{4}'  // a unicode escape
-              + '|\\\\x[A-Fa-f0-9]{2}'  // a hex escape
-              + '|\\\\[0-9]+'  // a back-reference or octal escape
-              + '|\\\\[^ux0-9]'  // other escape sequence
-              + '|\\(\\?[:!=]'  // start of a non-capturing group
-              + '|[\\(\\)\\^]'  // start/emd of a group, or line start
-              + '|[^\\x5B\\x5C\\(\\)\\^]+'  // run of other characters
-              + ')',
-              'g'));
-      var n = parts.length;
-
-      // Maps captured group numbers to the number they will occupy in
-      // the output or to -1 if that has not been determined, or to
-      // undefined if they need not be capturing in the output.
-      var capturedGroups = [];
-
-      // Walk over and identify back references to build the capturedGroups
-      // mapping.
-      for (var i = 0, groupIndex = 0; i < n; ++i) {
-        var p = parts[i];
-        if (p === '(') {
-          // groups are 1-indexed, so max group index is count of '('
-          ++groupIndex;
-        } else if ('\\' === p.charAt(0)) {
-          var decimalValue = +p.substring(1);
-          if (decimalValue && decimalValue <= groupIndex) {
-            capturedGroups[decimalValue] = -1;
-          }
-        }
-      }
-
-      // Renumber groups and reduce capturing groups to non-capturing groups
-      // where possible.
-      for (var i = 1; i < capturedGroups.length; ++i) {
-        if (-1 === capturedGroups[i]) {
-          capturedGroups[i] = ++capturedGroupIndex;
-        }
-      }
-      for (var i = 0, groupIndex = 0; i < n; ++i) {
-        var p = parts[i];
-        if (p === '(') {
-          ++groupIndex;
-          if (capturedGroups[groupIndex] === undefined) {
-            parts[i] = '(?:';
-          }
-        } else if ('\\' === p.charAt(0)) {
-          var decimalValue = +p.substring(1);
-          if (decimalValue && decimalValue <= groupIndex) {
-            parts[i] = '\\' + capturedGroups[groupIndex];
-          }
-        }
-      }
-
-      // Remove any prefix anchors so that the output will match anywhere.
-      // ^^ really does mean an anchored match though.
-      for (var i = 0, groupIndex = 0; i < n; ++i) {
-        if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
-      }
-
-      // Expand letters to groupts to handle mixing of case-sensitive and
-      // case-insensitive patterns if necessary.
-      if (regex.ignoreCase && needToFoldCase) {
-        for (var i = 0; i < n; ++i) {
-          var p = parts[i];
-          var ch0 = p.charAt(0);
-          if (p.length >= 2 && ch0 === '[') {
-            parts[i] = caseFoldCharset(p);
-          } else if (ch0 !== '\\') {
-            // TODO: handle letters in numeric escapes.
-            parts[i] = p.replace(
-                /[a-zA-Z]/g,
-                function (ch) {
-                  var cc = ch.charCodeAt(0);
-                  return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
-                });
-          }
-        }
-      }
-
-      return parts.join('');
-    }
-
-    var rewritten = [];
-    for (var i = 0, n = regexs.length; i < n; ++i) {
-      var regex = regexs[i];
-      if (regex.global || regex.multiline) { throw new Error('' + regex); }
-      rewritten.push(
-          '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
-    }
-
-    return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
-  }
-
-  var PR_innerHtmlWorks = null;
-  function getInnerHtml(node) {
-    // inner html is hopelessly broken in Safari 2.0.4 when the content is
-    // an html description of well formed XML and the containing tag is a PRE
-    // tag, so we detect that case and emulate innerHTML.
-    if (null === PR_innerHtmlWorks) {
-      var testNode = document.createElement('PRE');
-      testNode.appendChild(
-          document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));
-      PR_innerHtmlWorks = !/</.test(testNode.innerHTML);
-    }
-
-    if (PR_innerHtmlWorks) {
-      var content = node.innerHTML;
-      // XMP tags contain unescaped entities so require special handling.
-      if (isRawContent(node)) {
-        content = textToHtml(content);
-      } else if (!isPreformatted(node, content)) {
-        content = content.replace(/(<br\s*\/?>)[\r\n]+/g, '$1')
-            .replace(/(?:[\r\n]+[ \t]*)+/g, ' ');
-      }
-      return content;
-    }
-
-    var out = [];
-    for (var child = node.firstChild; child; child = child.nextSibling) {
-      normalizedHtml(child, out);
-    }
-    return out.join('');
-  }
-
-  /** returns a function that expand tabs to spaces.  This function can be fed
-    * successive chunks of text, and will maintain its own internal state to
-    * keep track of how tabs are expanded.
-    * @return {function (string) : string} a function that takes
-    *   plain text and return the text with tabs expanded.
-    * @private
-    */
-  function makeTabExpander(tabWidth) {
-    var SPACES = '                ';
-    var charInLine = 0;
-
-    return function (plainText) {
-      // walk over each character looking for tabs and newlines.
-      // On tabs, expand them.  On newlines, reset charInLine.
-      // Otherwise increment charInLine
-      var out = null;
-      var pos = 0;
-      for (var i = 0, n = plainText.length; i < n; ++i) {
-        var ch = plainText.charAt(i);
-
-        switch (ch) {
-          case '\t':
-            if (!out) { out = []; }
-            out.push(plainText.substring(pos, i));
-            // calculate how much space we need in front of this part
-            // nSpaces is the amount of padding -- the number of spaces needed
-            // to move us to the next column, where columns occur at factors of
-            // tabWidth.
-            var nSpaces = tabWidth - (charInLine % tabWidth);
-            charInLine += nSpaces;
-            for (; nSpaces >= 0; nSpaces -= SPACES.length) {
-              out.push(SPACES.substring(0, nSpaces));
-            }
-            pos = i + 1;
-            break;
-          case '\n':
-            charInLine = 0;
-            break;
-          default:
-            ++charInLine;
-        }
-      }
-      if (!out) { return plainText; }
-      out.push(plainText.substring(pos));
-      return out.join('');
-    };
-  }
-
-  var pr_chunkPattern = new RegExp(
-      '[^<]+'  // A run of characters other than '<'
-      + '|<\!--[\\s\\S]*?--\>'  // an HTML comment
-      + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'  // a CDATA section
-      // a probable tag that should not be highlighted
-      + '|<\/?[a-zA-Z](?:[^>\"\']|\'[^\']*\'|\"[^\"]*\")*>'
-      + '|<',  // A '<' that does not begin a larger chunk
-      'g');
-  var pr_commentPrefix = /^<\!--/;
-  var pr_cdataPrefix = /^<!\[CDATA\[/;
-  var pr_brPrefix = /^<br\b/i;
-  var pr_tagNameRe = /^<(\/?)([a-zA-Z][a-zA-Z0-9]*)/;
-
-  /** split markup into chunks of html tags (style null) and
-    * plain text (style {@link #PR_PLAIN}), converting tags which are
-    * significant for tokenization (<br>) into their textual equivalent.
-    *
-    * @param {string} s html where whitespace is considered significant.
-    * @return {Object} source code and extracted tags.
-    * @private
-    */
-  function extractTags(s) {
-    // since the pattern has the 'g' modifier and defines no capturing groups,
-    // this will return a list of all chunks which we then classify and wrap as
-    // PR_Tokens
-    var matches = s.match(pr_chunkPattern);
-    var sourceBuf = [];
-    var sourceBufLen = 0;
-    var extractedTags = [];
-    if (matches) {
-      for (var i = 0, n = matches.length; i < n; ++i) {
-        var match = matches[i];
-        if (match.length > 1 && match.charAt(0) === '<') {
-          if (pr_commentPrefix.test(match)) { continue; }
-          if (pr_cdataPrefix.test(match)) {
-            // strip CDATA prefix and suffix.  Don't unescape since it's CDATA
-            sourceBuf.push(match.substring(9, match.length - 3));
-            sourceBufLen += match.length - 12;
-          } else if (pr_brPrefix.test(match)) {
-            // <br> tags are lexically significant so convert them to text.
-            // This is undone later.
-            sourceBuf.push('\n');
-            ++sourceBufLen;
-          } else {
-            if (match.indexOf(PR_NOCODE) >= 0 && isNoCodeTag(match)) {
-              // A <span class="nocode"> will start a section that should be
-              // ignored.  Continue walking the list until we see a matching end
-              // tag.
-              var name = match.match(pr_tagNameRe)[2];
-              var depth = 1;
-              var j;
-              end_tag_loop:
-              for (j = i + 1; j < n; ++j) {
-                var name2 = matches[j].match(pr_tagNameRe);
-                if (name2 && name2[2] === name) {
-                  if (name2[1] === '/') {
-                    if (--depth === 0) { break end_tag_loop; }
-                  } else {
-                    ++depth;
-                  }
-                }
-              }
-              if (j < n) {
-                extractedTags.push(
-                    sourceBufLen, matches.slice(i, j + 1).join(''));
-                i = j;
-              } else {  // Ignore unclosed sections.
-                extractedTags.push(sourceBufLen, match);
-              }
-            } else {
-              extractedTags.push(sourceBufLen, match);
-            }
-          }
-        } else {
-          var literalText = htmlToText(match);
-          sourceBuf.push(literalText);
-          sourceBufLen += literalText.length;
-        }
-      }
-    }
-    return { source: sourceBuf.join(''), tags: extractedTags };
-  }
-
-  /** True if the given tag contains a class attribute with the nocode class. */
-  function isNoCodeTag(tag) {
-    return !!tag
-        // First canonicalize the representation of attributes
-        .replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,
-                 ' $1="$2$3$4"')
-        // Then look for the attribute we want.
-        .match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/);
-  }
-
-  /**
-   * Apply the given language handler to sourceCode and add the resulting
-   * decorations to out.
-   * @param {number} basePos the index of sourceCode within the chunk of source
-   *    whose decorations are already present on out.
-   */
-  function appendDecorations(basePos, sourceCode, langHandler, out) {
-    if (!sourceCode) { return; }
-    var job = {
-      source: sourceCode,
-      basePos: basePos
-    };
-    langHandler(job);
-    out.push.apply(out, job.decorations);
-  }
-
-  /** Given triples of [style, pattern, context] returns a lexing function,
-    * The lexing function interprets the patterns to find token boundaries and
-    * returns a decoration list of the form
-    * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
-    * where index_n is an index into the sourceCode, and style_n is a style
-    * constant like PR_PLAIN.  index_n-1 <= index_n, and style_n-1 applies to
-    * all characters in sourceCode[index_n-1:index_n].
-    *
-    * The stylePatterns is a list whose elements have the form
-    * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
-    *
-    * Style is a style constant like PR_PLAIN, or can be a string of the
-    * form 'lang-FOO', where FOO is a language extension describing the
-    * language of the portion of the token in $1 after pattern executes.
-    * E.g., if style is 'lang-lisp', and group 1 contains the text
-    * '(hello (world))', then that portion of the token will be passed to the
-    * registered lisp handler for formatting.
-    * The text before and after group 1 will be restyled using this decorator
-    * so decorators should take care that this doesn't result in infinite
-    * recursion.  For example, the HTML lexer rule for SCRIPT elements looks
-    * something like ['lang-js', /<[s]cript>(.+?)<\/script>/].  This may match
-    * '<script>foo()<\/script>', which would cause the current decorator to
-    * be called with '<script>' which would not match the same rule since
-    * group 1 must not be empty, so it would be instead styled as PR_TAG by
-    * the generic tag rule.  The handler registered for the 'js' extension would
-    * then be called with 'foo()', and finally, the current decorator would
-    * be called with '<\/script>' which would not match the original rule and
-    * so the generic tag rule would identify it as a tag.
-    *
-    * Pattern must only match prefixes, and if it matches a prefix, then that
-    * match is considered a token with the same style.
-    *
-    * Context is applied to the last non-whitespace, non-comment token
-    * recognized.
-    *
-    * Shortcut is an optional string of characters, any of which, if the first
-    * character, gurantee that this pattern and only this pattern matches.
-    *
-    * @param {Array} shortcutStylePatterns patterns that always start with
-    *   a known character.  Must have a shortcut string.
-    * @param {Array} fallthroughStylePatterns patterns that will be tried in
-    *   order if the shortcut ones fail.  May have shortcuts.
-    *
-    * @return {function (Object)} a
-    *   function that takes source code and returns a list of decorations.
-    */
-  function createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns) {
-    var shortcuts = {};
-    var tokenizer;
-    (function () {
-      var allPatterns = shortcutStylePatterns.concat(fallthroughStylePatterns);
-      var allRegexs = [];
-      var regexKeys = {};
-      for (var i = 0, n = allPatterns.length; i < n; ++i) {
-        var patternParts = allPatterns[i];
-        var shortcutChars = patternParts[3];
-        if (shortcutChars) {
-          for (var c = shortcutChars.length; --c >= 0;) {
-            shortcuts[shortcutChars.charAt(c)] = patternParts;
-          }
-        }
-        var regex = patternParts[1];
-        var k = '' + regex;
-        if (!regexKeys.hasOwnProperty(k)) {
-          allRegexs.push(regex);
-          regexKeys[k] = null;
-        }
-      }
-      allRegexs.push(/[\0-\uffff]/);
-      tokenizer = combinePrefixPatterns(allRegexs);
-    })();
-
-    var nPatterns = fallthroughStylePatterns.length;
-    var notWs = /\S/;
-
-    /**
-     * Lexes job.source and produces an output array job.decorations of style
-     * classes preceded by the position at which they start in job.source in
-     * order.
-     *
-     * @param {Object} job an object like {@code
-     *    source: {string} sourceText plain text,
-     *    basePos: {int} position of job.source in the larger chunk of
-     *        sourceCode.
-     * }
-     */
-    var decorate = function (job) {
-      var sourceCode = job.source, basePos = job.basePos;
-      /** Even entries are positions in source in ascending order.  Odd enties
-        * are style markers (e.g., PR_COMMENT) that run from that position until
-        * the end.
-        * @type {Array.<number|string>}
-        */
-      var decorations = [basePos, PR_PLAIN];
-      var pos = 0;  // index into sourceCode
-      var tokens = sourceCode.match(tokenizer) || [];
-      var styleCache = {};
-
-      for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) {
-        var token = tokens[ti];
-        var style = styleCache[token];
-        var match = void 0;
-
-        var isEmbedded;
-        if (typeof style === 'string') {
-          isEmbedded = false;
-        } else {
-          var patternParts = shortcuts[token.charAt(0)];
-          if (patternParts) {
-            match = token.match(patternParts[1]);
-            style = patternParts[0];
-          } else {
-            for (var i = 0; i < nPatterns; ++i) {
-              patternParts = fallthroughStylePatterns[i];
-              match = token.match(patternParts[1]);
-              if (match) {
-                style = patternParts[0];
-                break;
-              }
-            }
-
-            if (!match) {  // make sure that we make progress
-              style = PR_PLAIN;
-            }
-          }
-
-          isEmbedded = style.length >= 5 && 'lang-' === style.substring(0, 5);
-          if (isEmbedded && !(match && typeof match[1] === 'string')) {
-            isEmbedded = false;
-            style = PR_SOURCE;
-          }
-
-          if (!isEmbedded) { styleCache[token] = style; }
-        }
-
-        var tokenStart = pos;
-        pos += token.length;
-
-        if (!isEmbedded) {
-          decorations.push(basePos + tokenStart, style);
-        } else {  // Treat group 1 as an embedded block of source code.
-          var embeddedSource = match[1];
-          var embeddedSourceStart = token.indexOf(embeddedSource);
-          var embeddedSourceEnd = embeddedSourceStart + embeddedSource.length;
-          if (match[2]) {
-            // If embeddedSource can be blank, then it would match at the
-            // beginning which would cause us to infinitely recurse on the
-            // entire token, so we catch the right context in match[2].
-            embeddedSourceEnd = token.length - match[2].length;
-            embeddedSourceStart = embeddedSourceEnd - embeddedSource.length;
-          }
-          var lang = style.substring(5);
-          // Decorate the left of the embedded source
-          appendDecorations(
-              basePos + tokenStart,
-              token.substring(0, embeddedSourceStart),
-              decorate, decorations);
-          // Decorate the embedded source
-          appendDecorations(
-              basePos + tokenStart + embeddedSourceStart,
-              embeddedSource,
-              langHandlerForExtension(lang, embeddedSource),
-              decorations);
-          // Decorate the right of the embedded section
-          appendDecorations(
-              basePos + tokenStart + embeddedSourceEnd,
-              token.substring(embeddedSourceEnd),
-              decorate, decorations);
-        }
-      }
-      job.decorations = decorations;
-    };
-    return decorate;
-  }
-
-  /** returns a function that produces a list of decorations from source text.
-    *
-    * This code treats ", ', and ` as string delimiters, and \ as a string
-    * escape.  It does not recognize perl's qq() style strings.
-    * It has no special handling for double delimiter escapes as in basic, or
-    * the tripled delimiters used in python, but should work on those regardless
-    * although in those cases a single string literal may be broken up into
-    * multiple adjacent string literals.
-    *
-    * It recognizes C, C++, and shell style comments.
-    *
-    * @param {Object} options a set of optional parameters.
-    * @return {function (Object)} a function that examines the source code
-    *     in the input job and builds the decoration list.
-    */
-  function sourceDecorator(options) {
-    var shortcutStylePatterns = [], fallthroughStylePatterns = [];
-    if (options['tripleQuotedStrings']) {
-      // '''multi-line-string''', 'single-line-string', and double-quoted
-      shortcutStylePatterns.push(
-          [PR_STRING,  /^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
-           null, '\'"']);
-    } else if (options['multiLineStrings']) {
-      // 'multi-line-string', "multi-line-string"
-      shortcutStylePatterns.push(
-          [PR_STRING,  /^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,
-           null, '\'"`']);
-    } else {
-      // 'single-line-string', "single-line-string"
-      shortcutStylePatterns.push(
-          [PR_STRING,
-           /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
-           null, '"\'']);
-    }
-    if (options['verbatimStrings']) {
-      // verbatim-string-literal production from the C# grammar.  See issue 93.
-      fallthroughStylePatterns.push(
-          [PR_STRING, /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null]);
-    }
-    var hc = options['hashComments'];
-    if (hc) {
-      if (options['cStyleComments']) {
-        if (hc > 1) {  // multiline hash comments
-          shortcutStylePatterns.push(
-              [PR_COMMENT, /^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/, null, '#']);
-        } else {
-          // Stop C preprocessor declarations at an unclosed open comment
-          shortcutStylePatterns.push(
-              [PR_COMMENT, /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,
-               null, '#']);
-        }
-        fallthroughStylePatterns.push(
-            [PR_STRING,
-             /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,
-             null]);
-      } else {
-        shortcutStylePatterns.push([PR_COMMENT, /^#[^\r\n]*/, null, '#']);
-      }
-    }
-    if (options['cStyleComments']) {
-      fallthroughStylePatterns.push([PR_COMMENT, /^\/\/[^\r\n]*/, null]);
-      fallthroughStylePatterns.push(
-          [PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null]);
-    }
-    if (options['regexLiterals']) {
-      var REGEX_LITERAL = (
-          // A regular expression literal starts with a slash that is
-          // not followed by * or / so that it is not confused with
-          // comments.
-          '/(?=[^/*])'
-          // and then contains any number of raw characters,
-          + '(?:[^/\\x5B\\x5C]'
-          // escape sequences (\x5C),
-          +    '|\\x5C[\\s\\S]'
-          // or non-nesting character sets (\x5B\x5D);
-          +    '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
-          // finally closed by a /.
-          + '/');
-      fallthroughStylePatterns.push(
-          ['lang-regex',
-           new RegExp('^' + REGEXP_PRECEDER_PATTERN + '(' + REGEX_LITERAL + ')')
-           ]);
-    }
-
-    var keywords = options['keywords'].replace(/^\s+|\s+$/g, '');
-    if (keywords.length) {
-      fallthroughStylePatterns.push(
-          [PR_KEYWORD,
-           new RegExp('^(?:' + keywords.replace(/\s+/g, '|') + ')\\b'), null]);
-    }
-
-    shortcutStylePatterns.push([PR_PLAIN,       /^\s+/, null, ' \r\n\t\xA0']);
-    fallthroughStylePatterns.push(
-        // TODO(mikesamuel): recognize non-latin letters and numerals in idents
-        [PR_LITERAL,     /^@[a-z_$][a-z_$@0-9]*/i, null],
-        [PR_TYPE,        /^@?[A-Z]+[a-z][A-Za-z_$@0-9]*/, null],
-        [PR_PLAIN,       /^[a-z_$][a-z_$@0-9]*/i, null],
-        [PR_LITERAL,
-         new RegExp(
-             '^(?:'
-             // A hex number
-             + '0x[a-f0-9]+'
-             // or an octal or decimal number,
-             + '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
-             // possibly in scientific notation
-             + '(?:e[+\\-]?\\d+)?'
-             + ')'
-             // with an optional modifier like UL for unsigned long
-             + '[a-z]*', 'i'),
-         null, '0123456789'],
-        [PR_PUNCTUATION, /^.[^\s\w\.$@\'\"\`\/\#]*/, null]);
-
-    return createSimpleLexer(shortcutStylePatterns, fallthroughStylePatterns);
-  }
-
-  var decorateSource = sourceDecorator({
-        'keywords': ALL_KEYWORDS,
-        'hashComments': true,
-        'cStyleComments': true,
-        'multiLineStrings': true,
-        'regexLiterals': true
-      });
-
-  /** Breaks {@code job.source} around style boundaries in
-    * {@code job.decorations} while re-interleaving {@code job.extractedTags},
-    * and leaves the result in {@code job.prettyPrintedHtml}.
-    * @param {Object} job like {
-    *    source: {string} source as plain text,
-    *    extractedTags: {Array.<number|string>} extractedTags chunks of raw
-    *                   html preceded by their position in {@code job.source}
-    *                   in order
-    *    decorations: {Array.<number|string} an array of style classes preceded
-    *                 by the position at which they start in job.source in order
-    * }
-    * @private
-    */
-  function recombineTagsAndDecorations(job) {
-    var sourceText = job.source;
-    var extractedTags = job.extractedTags;
-    var decorations = job.decorations;
-    var numberLines = job.numberLines;
-    var sourceNode = job.sourceNode;
-
-    var html = [];
-    // index past the last char in sourceText written to html
-    var outputIdx = 0;
-
-    var openDecoration = null;
-    var currentDecoration = null;
-    var tagPos = 0;  // index into extractedTags
-    var decPos = 0;  // index into decorations
-    var tabExpander = makeTabExpander(window['PR_TAB_WIDTH']);
-
-    var adjacentSpaceRe = /([\r\n ]) /g;
-    var startOrSpaceRe = /(^| ) /gm;
-    var newlineRe = /\r\n?|\n/g;
-    var trailingSpaceRe = /[ \r\n]$/;
-    var lastWasSpace = true;  // the last text chunk emitted ended with a space.
-
-    // See bug 71 and http://stackoverflow.com/questions/136443/why-doesnt-ie7-
-    var isIE678 = window['_pr_isIE6']();
-    var lineBreakHtml = (
-        isIE678
-        ? (sourceNode && sourceNode.tagName === 'PRE'
-           // Use line feeds instead of <br>s so that copying and pasting works
-           // on IE.
-           // See Issue 104 for the derivation of this mess.
-           ? (isIE678 === 6 ? '&#160;\r\n' :
-              isIE678 === 7 ? '&#160;<br />\r' :
-              isIE678 === 8 ? '&#160;<br />' : '&#160;\r')
-           // IE collapses multiple adjacent <br>s into 1 line break.
-           // Prefix every newline with '&#160;' to prevent such behavior.
-           // &nbsp; is the same as &#160; but works in XML as well as HTML.
-           : '&#160;<br />')
-        : '<br />');
-
-    var lineBreaker;
-    if (numberLines) {
-      var lineBreaks = [];
-      for (var i = 0; i < 10; ++i) {
-        lineBreaks[i] = lineBreakHtml + '</li><li class="L' + i + '">';
-      }
-      var lineNum = typeof numberLines === 'number'
-          ? numberLines - 1 /* number lines are 1 indexed */ : 0;
-      html.push('<ol class="linenums"><li class="L', (lineNum) % 10, '"');
-      if (lineNum) {
-        html.push(' value="', lineNum + 1, '"');
-      }
-      html.push('>');
-      lineBreaker = function () {
-        var lb = lineBreaks[++lineNum % 10];
-        // If a decoration is open, we need to close it before closing a list-item
-        // and reopen it on the other side of the list item.
-        return openDecoration
-            ? ('</span>' + lb + '<span class="' + openDecoration + '">') : lb;
-      };
-    } else {
-      lineBreaker = lineBreakHtml;
-    }
-
-    // A helper function that is responsible for opening sections of decoration
-    // and outputing properly escaped chunks of source
-    function emitTextUpTo(sourceIdx) {
-      if (sourceIdx > outputIdx) {
-        if (openDecoration && openDecoration !== currentDecoration) {
-          // Close the current decoration
-          html.push('</span>');
-          openDecoration = null;
-        }
-        if (!openDecoration && currentDecoration) {
-          openDecoration = currentDecoration;
-          html.push('<span class="', openDecoration, '">');
-        }
-        // This interacts badly with some wikis which introduces paragraph tags
-        // into pre blocks for some strange reason.
-        // It's necessary for IE though which seems to lose the preformattedness
-        // of <pre> tags when their innerHTML is assigned.
-        // http://stud3.tuwien.ac.at/~e0226430/innerHtmlQuirk.html
-        // and it serves to undo the conversion of <br>s to newlines done in
-        // chunkify.
-        var htmlChunk = textToHtml(
-            tabExpander(sourceText.substring(outputIdx, sourceIdx)))
-            .replace(lastWasSpace
-                     ? startOrSpaceRe
-                     : adjacentSpaceRe, '$1&#160;');
-        // Keep track of whether we need to escape space at the beginning of the
-        // next chunk.
-        lastWasSpace = trailingSpaceRe.test(htmlChunk);
-        html.push(htmlChunk.replace(newlineRe, lineBreaker));
-        outputIdx = sourceIdx;
-      }
-    }
-
-    while (true) {
-      // Determine if we're going to consume a tag this time around.  Otherwise
-      // we consume a decoration or exit.
-      var outputTag;
-      if (tagPos < extractedTags.length) {
-        if (decPos < decorations.length) {
-          // Pick one giving preference to extractedTags since we shouldn't open
-          // a new style that we're going to have to immediately close in order
-          // to output a tag.
-          outputTag = extractedTags[tagPos] <= decorations[decPos];
-        } else {
-          outputTag = true;
-        }
-      } else {
-        outputTag = false;
-      }
-      // Consume either a decoration or a tag or exit.
-      if (outputTag) {
-        emitTextUpTo(extractedTags[tagPos]);
-        if (openDecoration) {
-          // Close the current decoration
-          html.push('</span>');
-          openDecoration = null;
-        }
-        html.push(extractedTags[tagPos + 1]);
-        tagPos += 2;
-      } else if (decPos < decorations.length) {
-        emitTextUpTo(decorations[decPos]);
-        currentDecoration = decorations[decPos + 1];
-        decPos += 2;
-      } else {
-        break;
-      }
-    }
-    emitTextUpTo(sourceText.length);
-    if (openDecoration) {
-      html.push('</span>');
-    }
-    if (numberLines) { html.push('</li></ol>'); }
-    job.prettyPrintedHtml = html.join('');
-  }
-
-  /** Maps language-specific file extensions to handlers. */
-  var langHandlerRegistry = {};
-  /** Register a language handler for the given file extensions.
-    * @param {function (Object)} handler a function from source code to a list
-    *      of decorations.  Takes a single argument job which describes the
-    *      state of the computation.   The single parameter has the form
-    *      {@code {
-    *        source: {string} as plain text.
-    *        decorations: {Array.<number|string>} an array of style classes
-    *                     preceded by the position at which they start in
-    *                     job.source in order.
-    *                     The language handler should assigned this field.
-    *        basePos: {int} the position of source in the larger source chunk.
-    *                 All positions in the output decorations array are relative
-    *                 to the larger source chunk.
-    *      } }
-    * @param {Array.<string>} fileExtensions
-    */
-  function registerLangHandler(handler, fileExtensions) {
-    for (var i = fileExtensions.length; --i >= 0;) {
-      var ext = fileExtensions[i];
-      if (!langHandlerRegistry.hasOwnProperty(ext)) {
-        langHandlerRegistry[ext] = handler;
-      } else if ('console' in window) {
-        console['warn']('cannot override language handler %s', ext);
-      }
-    }
-  }
-  function langHandlerForExtension(extension, source) {
-    if (!(extension && langHandlerRegistry.hasOwnProperty(extension))) {
-      // Treat it as markup if the first non whitespace character is a < and
-      // the last non-whitespace character is a >.
-      extension = /^\s*</.test(source)
-          ? 'default-markup'
-          : 'default-code';
-    }
-    return langHandlerRegistry[extension];
-  }
-  registerLangHandler(decorateSource, ['default-code']);
-  registerLangHandler(
-      createSimpleLexer(
-          [],
-          [
-           [PR_PLAIN,       /^[^<?]+/],
-           [PR_DECLARATION, /^<!\w[^>]*(?:>|$)/],
-           [PR_COMMENT,     /^<\!--[\s\S]*?(?:-\->|$)/],
-           // Unescaped content in an unknown language
-           ['lang-',        /^<\?([\s\S]+?)(?:\?>|$)/],
-           ['lang-',        /^<%([\s\S]+?)(?:%>|$)/],
-           [PR_PUNCTUATION, /^(?:<[%?]|[%?]>)/],
-           ['lang-',        /^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],
-           // Unescaped content in javascript.  (Or possibly vbscript).
-           ['lang-js',      /^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],
-           // Contains unescaped stylesheet content
-           ['lang-css',     /^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],
-           ['lang-in.tag',  /^(<\/?[a-z][^<>]*>)/i]
-          ]),
-      ['default-markup', 'htm', 'html', 'mxml', 'xhtml', 'xml', 'xsl']);
-  registerLangHandler(
-      createSimpleLexer(
-          [
-           [PR_PLAIN,        /^[\s]+/, null, ' \t\r\n'],
-           [PR_ATTRIB_VALUE, /^(?:\"[^\"]*\"?|\'[^\']*\'?)/, null, '\"\'']
-           ],
-          [
-           [PR_TAG,          /^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],
-           [PR_ATTRIB_NAME,  /^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],
-           ['lang-uq.val',   /^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],
-           [PR_PUNCTUATION,  /^[=<>\/]+/],
-           ['lang-js',       /^on\w+\s*=\s*\"([^\"]+)\"/i],
-           ['lang-js',       /^on\w+\s*=\s*\'([^\']+)\'/i],
-           ['lang-js',       /^on\w+\s*=\s*([^\"\'>\s]+)/i],
-           ['lang-css',      /^style\s*=\s*\"([^\"]+)\"/i],
-           ['lang-css',      /^style\s*=\s*\'([^\']+)\'/i],
-           ['lang-css',      /^style\s*=\s*([^\"\'>\s]+)/i]
-           ]),
-      ['in.tag']);
-  registerLangHandler(
-      createSimpleLexer([], [[PR_ATTRIB_VALUE, /^[\s\S]+/]]), ['uq.val']);
-  registerLangHandler(sourceDecorator({
-          'keywords': CPP_KEYWORDS,
-          'hashComments': true,
-          'cStyleComments': true
-        }), ['c', 'cc', 'cpp', 'cxx', 'cyc', 'm']);
-  registerLangHandler(sourceDecorator({
-          'keywords': 'null true false'
-        }), ['json']);
-  registerLangHandler(sourceDecorator({
-          'keywords': CSHARP_KEYWORDS,
-          'hashComments': true,
-          'cStyleComments': true,
-          'verbatimStrings': true
-        }), ['cs']);
-  registerLangHandler(sourceDecorator({
-          'keywords': JAVA_KEYWORDS,
-          'cStyleComments': true
-        }), ['java']);
-  registerLangHandler(sourceDecorator({
-          'keywords': SH_KEYWORDS,
-          'hashComments': true,
-          'multiLineStrings': true
-        }), ['bsh', 'csh', 'sh']);
-  registerLangHandler(sourceDecorator({
-          'keywords': PYTHON_KEYWORDS,
-          'hashComments': true,
-          'multiLineStrings': true,
-          'tripleQuotedStrings': true
-        }), ['cv', 'py']);
-  registerLangHandler(sourceDecorator({
-          'keywords': PERL_KEYWORDS,
-          'hashComments': true,
-          'multiLineStrings': true,
-          'regexLiterals': true
-        }), ['perl', 'pl', 'pm']);
-  registerLangHandler(sourceDecorator({
-          'keywords': RUBY_KEYWORDS,
-          'hashComments': true,
-          'multiLineStrings': true,
-          'regexLiterals': true
-        }), ['rb']);
-  registerLangHandler(sourceDecorator({
-          'keywords': JSCRIPT_KEYWORDS,
-          'cStyleComments': true,
-          'regexLiterals': true
-        }), ['js']);
-  registerLangHandler(sourceDecorator({
-          'keywords': COFFEE_KEYWORDS,
-          'hashComments': 3,  // ### style block comments
-          'cStyleComments': true,
-          'multilineStrings': true,
-          'tripleQuotedStrings': true,
-          'regexLiterals': true
-        }), ['coffee']);
-  registerLangHandler(createSimpleLexer([], [[PR_STRING, /^[\s\S]+/]]), ['regex']);
-
-  function applyDecorator(job) {
-    var sourceCodeHtml = job.sourceCodeHtml;
-    var opt_langExtension = job.langExtension;
-
-    // Prepopulate output in case processing fails with an exception.
-    job.prettyPrintedHtml = sourceCodeHtml;
-
-    try {
-      // Extract tags, and convert the source code to plain text.
-      var sourceAndExtractedTags = extractTags(sourceCodeHtml);
-      /** Plain text. @type {string} */
-      var source = sourceAndExtractedTags.source;
-      job.source = source;
-      job.basePos = 0;
-
-      /** Even entries are positions in source in ascending order.  Odd entries
-        * are tags that were extracted at that position.
-        * @type {Array.<number|string>}
-        */
-      job.extractedTags = sourceAndExtractedTags.tags;
-
-      // Apply the appropriate language handler
-      langHandlerForExtension(opt_langExtension, source)(job);
-      // Integrate the decorations and tags back into the source code to produce
-      // a decorated html string which is left in job.prettyPrintedHtml.
-      recombineTagsAndDecorations(job);
-    } catch (e) {
-      if ('console' in window) {
-        console['log'](e && e['stack'] ? e['stack'] : e);
-      }
-    }
-  }
-
-  /**
-   * @param sourceCodeHtml {string} The HTML to pretty print.
-   * @param opt_langExtension {string} The language name to use.
-   *     Typically, a filename extension like 'cpp' or 'java'.
-   * @param opt_numberLines {number|boolean} True to number lines,
-   *     or the 1-indexed number of the first line in sourceCodeHtml.
-   */
-  function prettyPrintOne(sourceCodeHtml, opt_langExtension, opt_numberLines) {
-    var job = {
-      sourceCodeHtml: sourceCodeHtml,
-      langExtension: opt_langExtension,
-      numberLines: opt_numberLines
-    };
-    applyDecorator(job);
-    return job.prettyPrintedHtml;
-  }
-
-  function prettyPrint(opt_whenDone) {
-    function byTagName(tn) { return document.getElementsByTagName(tn); }
-    // fetch a list of nodes to rewrite
-    var codeSegments = [byTagName('pre'), byTagName('code'), byTagName('xmp')];
-    var elements = [];
-    for (var i = 0; i < codeSegments.length; ++i) {
-      for (var j = 0, n = codeSegments[i].length; j < n; ++j) {
-        elements.push(codeSegments[i][j]);
-      }
-    }
-    codeSegments = null;
-
-    var clock = Date;
-    if (!clock['now']) {
-      clock = { 'now': function () { return (new Date).getTime(); } };
-    }
-
-    // The loop is broken into a series of continuations to make sure that we
-    // don't make the browser unresponsive when rewriting a large page.
-    var k = 0;
-    var prettyPrintingJob;
-
-    function doWork() {
-      var endTime = (window['PR_SHOULD_USE_CONTINUATION'] ?
-                     clock.now() + 250 /* ms */ :
-                     Infinity);
-      for (; k < elements.length && clock.now() < endTime; k++) {
-        var cs = elements[k];
-        if (cs.className && cs.className.indexOf('prettyprint') >= 0) {
-          // If the classes includes a language extensions, use it.
-          // Language extensions can be specified like
-          //     <pre class="prettyprint lang-cpp">
-          // the language extension "cpp" is used to find a language handler as
-          // passed to PR.registerLangHandler.
-          var langExtension = cs.className.match(/\blang-(\w+)\b/);
-          if (langExtension) { langExtension = langExtension[1]; }
-
-          // make sure this is not nested in an already prettified element
-          var nested = false;
-          for (var p = cs.parentNode; p; p = p.parentNode) {
-            if ((p.tagName === 'pre' || p.tagName === 'code' ||
-                 p.tagName === 'xmp') &&
-                p.className && p.className.indexOf('prettyprint') >= 0) {
-              nested = true;
-              break;
-            }
-          }
-          if (!nested) {
-            // fetch the content as a snippet of properly escaped HTML.
-            // Firefox adds newlines at the end.
-            var content = getInnerHtml(cs);
-            content = content.replace(/(?:\r\n?|\n)$/, '');
-
-            // Look for a class like linenums or linenums:<n> where <n> is the
-            // 1-indexed number of the first line.
-            var numberLines = cs.className.match(/\blinenums\b(?::(\d+))?/);
-
-            // do the pretty printing
-            prettyPrintingJob = {
-              sourceCodeHtml: content,
-              langExtension: langExtension,
-              sourceNode: cs,
-              numberLines: numberLines
-                  ? numberLines[1] && numberLines[1].length ? +numberLines[1] : true
-                  : false
-            };
-            applyDecorator(prettyPrintingJob);
-            replaceWithPrettyPrintedHtml();
-          }
-        }
-      }
-      if (k < elements.length) {
-        // finish up in a continuation
-        setTimeout(doWork, 250);
-      } else if (opt_whenDone) {
-        opt_whenDone();
-      }
-    }
-
-    function replaceWithPrettyPrintedHtml() {
-      var newContent = prettyPrintingJob.prettyPrintedHtml;
-      if (!newContent) { return; }
-      var cs = prettyPrintingJob.sourceNode;
-
-      // push the prettified html back into the tag.
-      if (!isRawContent(cs)) {
-        // just replace the old html with the new
-        cs.innerHTML = newContent;
-      } else {
-        // we need to change the tag to a <pre> since <xmp>s do not allow
-        // embedded tags such as the span tags used to attach styles to
-        // sections of source code.
-        var pre = document.createElement('PRE');
-        for (var i = 0; i < cs.attributes.length; ++i) {
-          var a = cs.attributes[i];
-          if (a.specified) {
-            var aname = a.name.toLowerCase();
-            if (aname === 'class') {
-              pre.className = a.value;  // For IE 6
-            } else {
-              pre.setAttribute(a.name, a.value);
-            }
-          }
-        }
-        pre.innerHTML = newContent;
-
-        // remove the old
-        cs.parentNode.replaceChild(pre, cs);
-        cs = pre;
-      }
-    }
-
-    doWork();
-  }
-
-  window['PR_normalizedHtml'] = normalizedHtml;
-  window['prettyPrintOne'] = prettyPrintOne;
-  window['prettyPrint'] = prettyPrint;
-  window['PR'] = {
-        'combinePrefixPatterns': combinePrefixPatterns,
-        'createSimpleLexer': createSimpleLexer,
-        'registerLangHandler': registerLangHandler,
-        'sourceDecorator': sourceDecorator,
-        'PR_ATTRIB_NAME': PR_ATTRIB_NAME,
-        'PR_ATTRIB_VALUE': PR_ATTRIB_VALUE,
-        'PR_COMMENT': PR_COMMENT,
-        'PR_DECLARATION': PR_DECLARATION,
-        'PR_KEYWORD': PR_KEYWORD,
-        'PR_LITERAL': PR_LITERAL,
-        'PR_NOCODE': PR_NOCODE,
-        'PR_PLAIN': PR_PLAIN,
-        'PR_PUNCTUATION': PR_PUNCTUATION,
-        'PR_SOURCE': PR_SOURCE,
-        'PR_STRING': PR_STRING,
-        'PR_TAG': PR_TAG,
-        'PR_TYPE': PR_TYPE
-      };
-})();
-
-//third_party/javascript/google_code_prettify/src/lang-apollo.js
-/**
- * @license Copyright (C) 2009 Onno Hommes.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for the AGC/AEA Assembly Language as described
- * at http://virtualagc.googlecode.com
- * <p>
- * This file could be used by goodle code to allow syntax highlight for
- * Virtual AGC SVN repository or if you don't want to commonize
- * the header for the agc/aea html assembly listing.
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // A line comment that starts with ;
-         [PR['PR_COMMENT'],     /^#[^\r\n]*/, null, '#'],
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // A double quoted, possibly multi-line, string.
-         [PR['PR_STRING'],      /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"']
-        ],
-        [
-         [PR['PR_KEYWORD'], /^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,null],
-         [PR['PR_TYPE'], /^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],
-         // A single quote possibly followed by a word that optionally ends with
-         // = ! or ?.
-         [PR['PR_LITERAL'],
-          /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],
-         // Any word including labels that optionally ends with = ! or ?.
-         [PR['PR_PLAIN'],
-          /^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],
-         // A printable non-space non-special character
-         [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/]
-        ]),
-    ['apollo', 'agc', 'aea']);
-
-//third_party/javascript/google_code_prettify/src/lang-clj.js
-/**
- * @license Copyright (C) 2011 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Clojure.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-lisp">(my lisp code)</pre>
- * The lang-cl class identifies the language as common lisp.
- * This file supports the following language extensions:
- *     lang-clj - Clojure
- *
- *
- * I used lang-lisp.js as the basis for this adding the clojure specific
- * keywords and syntax.
- *
- * "Name"    = 'Clojure'
- * "Author"  = 'Rich Hickey'
- * "Version" = '1.2'
- * "About"   = 'Clojure is a lisp for the jvm with concurrency primitives and a richer set of types.'
- *
- *
- * I used <a href="http://clojure.org/Reference">Clojure.org Reference</a> as
- * the basis for the reserved word list.
- *
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // clojure has more paren types than minimal lisp.
-         ['opn',             /^[\(\{\[]+/, null, '([{'],
-         ['clo',             /^[\)\}\]]+/, null, ')]}'],
-         // A line comment that starts with ;
-         [PR['PR_COMMENT'],     /^;[^\r\n]*/, null, ';'],
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // A double quoted, possibly multi-line, string.
-         [PR['PR_STRING'],      /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"']
-        ],
-        [
-         // clojure has a much larger set of keywords
-         [PR['PR_KEYWORD'],     /^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/, null],
-         [PR['PR_TYPE'], /^:[0-9a-zA-Z\-]+/]
-        ]),
-    ['clj']);
-
-//third_party/javascript/google_code_prettify/src/lang-css.js
-/**
- * @license Copyright (C) 2009 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for CSS.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-css"></pre>
- *
- *
- * http://www.w3.org/TR/CSS21/grammar.html Section G2 defines the lexical
- * grammar.  This scheme does not recognize keywords containing escapes.
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // The space production <s>
-         [PR['PR_PLAIN'],       /^[ \t\r\n\f]+/, null, ' \t\r\n\f']
-        ],
-        [
-         // Quoted strings.  <string1> and <string2>
-         [PR['PR_STRING'],
-          /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null],
-         [PR['PR_STRING'],
-          /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null],
-         ['lang-css-str', /^url\(([^\)\"\']*)\)/i],
-         [PR['PR_KEYWORD'],
-          /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,
-          null],
-         // A property name -- an identifier followed by a colon.
-         ['lang-css-kw', /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],
-         // A C style block comment.  The <comment> production.
-         [PR['PR_COMMENT'], /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],
-         // Escaping text spans
-         [PR['PR_COMMENT'], /^(?:<!--|-->)/],
-         // A number possibly containing a suffix.
-         [PR['PR_LITERAL'], /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],
-         // A hex color
-         [PR['PR_LITERAL'], /^#(?:[0-9a-f]{3}){1,2}/i],
-         // An identifier
-         [PR['PR_PLAIN'],
-          /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],
-         // A run of punctuation
-         [PR['PR_PUNCTUATION'], /^[^\s\w\'\"]+/]
-        ]),
-    ['css']);
-PR['registerLangHandler'](
-    PR['createSimpleLexer']([],
-        [
-         [PR['PR_KEYWORD'],
-          /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]
-        ]),
-    ['css-kw']);
-PR['registerLangHandler'](
-    PR['createSimpleLexer']([],
-        [
-         [PR['PR_STRING'], /^[^\)\"\']+/]
-        ]),
-    ['css-str']);
-
-//third_party/javascript/google_code_prettify/src/lang-go.js
-/**
- * @license Copyright (C) 2010 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for the Go language..
- * <p>
- * Based on the lexical grammar at 
- * http://golang.org/doc/go_spec.html#Lexical_elements
- * <p>
- * Go uses a minimal style for highlighting so the below does not distinguish
- * strings, keywords, literals, etc. by design.
- * From a discussion with the Go designers:
- * <pre>
- * On Thursday, July 22, 2010, Mike Samuel <...> wrote:
- * > On Thu, Jul 22, 2010, Rob 'Commander' Pike <...> wrote:
- * >> Personally, I would vote for the subdued style godoc presents at http://golang.org
- * >>
- * >> Not as fancy as some like, but a case can be made it's the official style.
- * >> If people want more colors, I wouldn't fight too hard, in the interest of
- * >> encouragement through familiarity, but even then I would ask to shy away
- * >> from technicolor starbursts.
- * >
- * > Like http://golang.org/pkg/go/scanner/ where comments are blue and all
- * > other content is black?  I can do that.
- * </pre>
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace is made up of spaces, tabs and newline characters.
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // Not escaped as a string.  See note on minimalism above.
-         [PR['PR_PLAIN'],       /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])+(?:\'|$))/, null, '"\'']
-        ],
-        [
-         // Block comments are delimited by /* and */.
-         // Single-line comments begin with // and extend to the end of a line.
-         [PR['PR_COMMENT'],     /^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/],
-         [PR['PR_PLAIN'],       /^(?:[^\/\"\']|\/(?![\/\*]))+/i]
-        ]),
-    ['go']);
-
-//third_party/javascript/google_code_prettify/src/lang-hs.js
-/**
- * @license Copyright (C) 2009 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Haskell.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-hs">(my lisp code)</pre>
- * The lang-cl class identifies the language as common lisp.
- * This file supports the following language extensions:
- *     lang-cl - Common Lisp
- *     lang-el - Emacs Lisp
- *     lang-lisp - Lisp
- *     lang-scm - Scheme
- *
- *
- * I used http://www.informatik.uni-freiburg.de/~thiemann/haskell/haskell98-report-html/syntax-iso.html
- * as the basis, but ignore the way the ncomment production nests since this
- * makes the lexical grammar irregular.  It might be possible to support
- * ncomments using the lookbehind filter.
- *
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         // whitechar    ->    newline | vertab | space | tab | uniWhite
-         // newline      ->    return linefeed | return | linefeed | formfeed
-         [PR['PR_PLAIN'],       /^[\t\n\x0B\x0C\r ]+/, null, '\t\n\x0B\x0C\r '],
-         // Single line double and single-quoted strings.
-         // char         ->    ' (graphic<' | \> | space | escape<\&>) '
-         // string       ->    " {graphic<" | \> | space | escape | gap}"
-         // escape       ->    \ ( charesc | ascii | decimal | o octal
-         //                        | x hexadecimal )
-         // charesc      ->    a | b | f | n | r | t | v | \ | " | ' | &
-         [PR['PR_STRING'],      /^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,
-          null, '"'],
-         [PR['PR_STRING'],      /^\'(?:[^\'\\\n\x0C\r]|\\[^&])\'?/,
-          null, "'"],
-         // decimal      ->    digit{digit}
-         // octal        ->    octit{octit}
-         // hexadecimal  ->    hexit{hexit}
-         // integer      ->    decimal
-         //               |    0o octal | 0O octal
-         //               |    0x hexadecimal | 0X hexadecimal
-         // float        ->    decimal . decimal [exponent]
-         //               |    decimal exponent
-         // exponent     ->    (e | E) [+ | -] decimal
-         [PR['PR_LITERAL'],
-          /^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,
-          null, '0123456789']
-        ],
-        [
-         // Haskell does not have a regular lexical grammar due to the nested
-         // ncomment.
-         // comment      ->    dashes [ any<symbol> {any}] newline
-         // ncomment     ->    opencom ANYseq {ncomment ANYseq}closecom
-         // dashes       ->    '--' {'-'}
-         // opencom      ->    '{-'
-         // closecom     ->    '-}'
-         [PR['PR_COMMENT'],     /^(?:(?:--+(?:[^\r\n\x0C]*)?)|(?:\{-(?:[^-]|-+[^-\}])*-\}))/],
-         // reservedid   ->    case | class | data | default | deriving | do
-         //               |    else | if | import | in | infix | infixl | infixr
-         //               |    instance | let | module | newtype | of | then
-         //               |    type | where | _
-         [PR['PR_KEYWORD'],     /^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^a-zA-Z0-9\']|$)/, null],
-         // qvarid       ->    [ modid . ] varid
-         // qconid       ->    [ modid . ] conid
-         // varid        ->    (small {small | large | digit | ' })<reservedid>
-         // conid        ->    large {small | large | digit | ' }
-         // modid        ->    conid
-         // small        ->    ascSmall | uniSmall | _
-         // ascSmall     ->    a | b | ... | z
-         // uniSmall     ->    any Unicode lowercase letter
-         // large        ->    ascLarge | uniLarge
-         // ascLarge     ->    A | B | ... | Z
-         // uniLarge     ->    any uppercase or titlecase Unicode letter
-         [PR['PR_PLAIN'],  /^(?:[A-Z][\w\']*\.)*[a-zA-Z][\w\']*/],
-         // matches the symbol production
-         [PR['PR_PUNCTUATION'], /^[^\t\n\x0B\x0C\r a-zA-Z0-9\'\"]+/]
-        ]),
-    ['hs']);
-
-//third_party/javascript/google_code_prettify/src/lang-lisp.js
-/**
- * @license Copyright (C) 2008 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Common Lisp and related languages.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-lisp">(my lisp code)</pre>
- * The lang-cl class identifies the language as common lisp.
- * This file supports the following language extensions:
- *     lang-cl - Common Lisp
- *     lang-el - Emacs Lisp
- *     lang-lisp - Lisp
- *     lang-scm - Scheme
- *
- *
- * I used http://www.devincook.com/goldparser/doc/meta-language/grammar-LISP.htm
- * as the basis, but added line comments that start with ; and changed the atom
- * production to disallow unquoted semicolons.
- *
- * "Name"    = 'LISP'
- * "Author"  = 'John McCarthy'
- * "Version" = 'Minimal'
- * "About"   = 'LISP is an abstract language that organizes ALL'
- *           | 'data around "lists".'
- *
- * "Start Symbol" = [s-Expression]
- *
- * {Atom Char}   = {Printable} - {Whitespace} - [()"\'']
- *
- * Atom = ( {Atom Char} | '\'{Printable} )+
- *
- * [s-Expression] ::= [Quote] Atom
- *                  | [Quote] '(' [Series] ')'
- *                  | [Quote] '(' [s-Expression] '.' [s-Expression] ')'
- *
- * [Series] ::= [s-Expression] [Series]
- *            |
- *
- * [Quote]  ::= ''      !Quote = do not evaluate
- *            |
- *
- *
- * I used <a href="http://gigamonkeys.com/book/">Practical Common Lisp</a> as
- * the basis for the reserved word list.
- *
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         ['opn',             /^\(+/, null, '('],
-         ['clo',             /^\)+/, null, ')'],
-         // A line comment that starts with ;
-         [PR['PR_COMMENT'],     /^;[^\r\n]*/, null, ';'],
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // A double quoted, possibly multi-line, string.
-         [PR['PR_STRING'],      /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"']
-        ],
-        [
-         [PR['PR_KEYWORD'],     /^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, null],
-         [PR['PR_LITERAL'],
-          /^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],
-         // A single quote possibly followed by a word that optionally ends with
-         // = ! or ?.
-         [PR['PR_LITERAL'],
-          /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],
-         // A word that optionally ends with = ! or ?.
-         [PR['PR_PLAIN'],
-          /^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],
-         // A printable non-space non-special character
-         [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/]
-        ]),
-    ['cl', 'el', 'lisp', 'scm']);
-
-//third_party/javascript/google_code_prettify/src/lang-lua.js
-/**
- * @license Copyright (C) 2008 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Lua.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-lua">(my Lua code)</pre>
- *
- *
- * I used http://www.lua.org/manual/5.1/manual.html#2.1
- * Because of the long-bracket concept used in strings and comments, Lua does
- * not have a regular lexical grammar, but luckily it fits within the space
- * of irregular grammars supported by javascript regular expressions.
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // A double or single quoted, possibly multi-line, string.
-         [PR['PR_STRING'],      /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/, null, '"\'']
-        ],
-        [
-         // A comment is either a line comment that starts with two dashes, or
-         // two dashes preceding a long bracketed block.
-         [PR['PR_COMMENT'], /^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/],
-         // A long bracketed block not preceded by -- is a string.
-         [PR['PR_STRING'],  /^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/],
-         [PR['PR_KEYWORD'], /^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, null],
-         // A number is a hex integer literal, a decimal real literal, or in
-         // scientific notation.
-         [PR['PR_LITERAL'],
-          /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
-         // An identifier
-         [PR['PR_PLAIN'], /^[a-z_]\w*/i],
-         // A run of punctuation
-         [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/]
-        ]),
-    ['lua']);
-
-//third_party/javascript/google_code_prettify/src/lang-ml.js
-/**
- * @license Copyright (C) 2008 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for OCaml, SML, F# and similar languages.
- *
- * Based on the lexical grammar at
- * http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc270597388
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace is made up of spaces, tabs and newline characters.
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // #if ident/#else/#endif directives delimit conditional compilation
-         // sections
-         [PR['PR_COMMENT'],
-          /^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,
-          null, '#'],
-         // A double or single quoted, possibly multi-line, string.
-         // F# allows escaped newlines in strings.
-         [PR['PR_STRING'],      /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/, null, '"\'']
-        ],
-        [
-         // Block comments are delimited by (* and *) and may be
-         // nested. Single-line comments begin with // and extend to
-         // the end of a line.
-         // TODO: (*...*) comments can be nested.  This does not handle that.
-         [PR['PR_COMMENT'],     /^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],
-         [PR['PR_KEYWORD'],     /^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/],
-         // A number is a hex integer literal, a decimal real literal, or in
-         // scientific notation.
-         [PR['PR_LITERAL'],
-          /^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
-         [PR['PR_PLAIN'],       /^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],
-         // A printable non-space non-special character
-         [PR['PR_PUNCTUATION'], /^[^\t\n\r \xA0\"\'\w]+/]
-        ]),
-    ['fs', 'ml']);
-
-//third_party/javascript/google_code_prettify/src/lang-proto.js
-/**
- * @license Copyright (C) 2006 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Protocol Buffers as described at
- * http://code.google.com/p/protobuf/.
- *
- * Based on the lexical grammar at
- * http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc202383715
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](PR['sourceDecorator']({
-        keywords: (
-            'bool bytes default double enum extend extensions false fixed32 '
-            + 'fixed64 float group import int32 int64 max message option '
-            + 'optional package repeated required returns rpc service '
-            + 'sfixed32 sfixed64 sint32 sint64 string syntax to true uint32 '
-            + 'uint64'),
-        cStyleComments: true
-      }), ['proto']);
-
-//third_party/javascript/google_code_prettify/src/lang-scala.js
-/**
- * @license Copyright (C) 2010 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Scala.
- *
- * Derived from http://lampsvn.epfl.ch/svn-repos/scala/scala-documentation/trunk/src/reference/SyntaxSummary.tex
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // A double or single quoted string
-          // or a triple double-quoted multi-line string.
-         [PR['PR_STRING'],
-          /^(?:"(?:(?:""(?:""?(?!")|[^\\"]|\\.)*"{0,3})|(?:[^"\r\n\\]|\\.)*"?))/,
-          null, '"'],
-         [PR['PR_LITERAL'],     /^`(?:[^\r\n\\`]|\\.)*`?/, null, '`'],
-         [PR['PR_PUNCTUATION'], /^[!#%&()*+,\-:;<=>?@\[\\\]^{|}~]+/, null,
-          '!#%&()*+,-:;<=>?@[\\]^{|}~']
-        ],
-        [
-         // A symbol literal is a single quote followed by an identifier with no
-         // single quote following
-         // A character literal has single quotes on either side
-         [PR['PR_STRING'],      /^'(?:[^\r\n\\']|\\(?:'|[^\r\n']+))'/],
-         [PR['PR_LITERAL'],     /^'[a-zA-Z_$][\w$]*(?!['$\w])/],
-         [PR['PR_KEYWORD'],     /^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/],
-         [PR['PR_LITERAL'],     /^(?:true|false|null|this)\b/],
-         [PR['PR_LITERAL'],     /^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\.[0-9]+)?(?:E[+\-]?[0-9]+)?F?|L?))|\\.[0-9]+(?:E[+\-]?[0-9]+)?F?)/i],
-         // Treat upper camel case identifiers as types.
-         [PR['PR_TYPE'],        /^[$_]*[A-Z][_$A-Z0-9]*[a-z][\w$]*/],
-         [PR['PR_PLAIN'],       /^[$a-zA-Z_][\w$]*/],
-         [PR['PR_COMMENT'],     /^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],
-         [PR['PR_PUNCTUATION'], /^(?:\.+|\/)/]
-        ]),
-    ['scala']);
-
-//third_party/javascript/google_code_prettify/src/lang-sql.js
-/**
- * @license Copyright (C) 2008 Google Inc.
- *
- * 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.
- */
-
-
-/**
- * @fileoverview
- * Registers a language handler for SQL.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-sql">(my SQL code)</pre>
- *
- *
- * http://savage.net.au/SQL/sql-99.bnf.html is the basis for the grammar, and
- * http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx as the basis
- * for the keyword list.
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
-         // A double or single quoted, possibly multi-line, string.
-         [PR['PR_STRING'],      /^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/, null,
-          '"\'']
-        ],
-        [
-         // A comment is either a line comment that starts with two dashes, or
-         // two dashes preceding a long bracketed block.
-         [PR['PR_COMMENT'], /^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],
-         [PR['PR_KEYWORD'], /^(?:ADD|ALL|ALTER|AND|ANY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|NATIONAL|NOCHECK|NONCLUSTERED|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PERCENT|PLAN|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNION|UNIQUE|UPDATE|UPDATETEXT|USE|USER|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WRITETEXT)(?=[^\w-]|$)/i, null],
-         // A number is a hex integer literal, a decimal real literal, or in
-         // scientific notation.
-         [PR['PR_LITERAL'],
-          /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],
-         // An identifier
-         [PR['PR_PLAIN'], /^[a-z_][\w-]*/i],
-         // A run of punctuation
-         [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]
-        ]),
-    ['sql']);
-
-//third_party/javascript/google_code_prettify/src/lang-vb.js
-/**
- * @license Copyright (C) 2009 Google Inc.
- *
- * 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.
- */
-
-
-
-/**
- * @fileoverview
- * Registers a language handler for various flavors of basic.
- *
- *
- * To use, include prettify.js and this file in your HTML page.
- * Then put your code in an HTML tag like
- *      <pre class="prettyprint lang-vb"></pre>
- *
- *
- * http://msdn.microsoft.com/en-us/library/aa711638(VS.71).aspx defines the
- * visual basic grammar lexical grammar.
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t\n\r \xA0\u2028\u2029]+/, null, '\t\n\r \xA0\u2028\u2029'],
-         // A double quoted string with quotes escaped by doubling them.
-         // A single character can be suffixed with C.
-         [PR['PR_STRING'],      /^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i, null,
-          '"\u201C\u201D'],
-         // A comment starts with a single quote and runs until the end of the
-         // line.
-         [PR['PR_COMMENT'],     /^[\'\u2018\u2019][^\r\n\u2028\u2029]*/, null, '\'\u2018\u2019']
-        ],
-        [
-         [PR['PR_KEYWORD'], /^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i, null],
-         // A second comment form
-         [PR['PR_COMMENT'], /^REM[^\r\n\u2028\u2029]*/i],
-         // A boolean, numeric, or date literal.
-         [PR['PR_LITERAL'],
-          /^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],
-         // An identifier?
-         [PR['PR_PLAIN'], /^(?:(?:[a-z]|_\w)\w*|\[(?:[a-z]|_\w)\w*\])/i],
-         // A run of punctuation
-         [PR['PR_PUNCTUATION'],
-          /^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],
-         // Square brackets
-         [PR['PR_PUNCTUATION'], /^(?:\[|\])/]
-        ]),
-    ['vb', 'vbs']);
-
-//third_party/javascript/google_code_prettify/src/lang-vhdl.js
-/**
- * @fileoverview
- * Registers a language handler for VHDL '93.
- *
- * Based on the lexical grammar and keywords at
- * http://www.iis.ee.ethz.ch/~zimmi/download/vhdl93_syntax.html
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0']
-        ],
-        [
-         // String, character or bit string
-         [PR['PR_STRING'], /^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],
-         // Comment, from two dashes until end of line.
-         [PR['PR_COMMENT'], /^--[^\r\n]*/],
-         [PR['PR_KEYWORD'], /^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, null],
-         // Type, predefined or standard
-         [PR['PR_TYPE'], /^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i, null],
-         // Predefined attributes
-         [PR['PR_TYPE'], /^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i, null],
-         // Number, decimal or based literal
-         [PR['PR_LITERAL'], /^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i],
-         // Identifier, basic or extended
-         [PR['PR_PLAIN'], /^(?:[a-z]\w*|\\[^\\]*\\)/i],
-         // Punctuation
-         [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]
-        ]),
-    ['vhdl', 'vhd']);
-
-//third_party/javascript/google_code_prettify/src/lang-wiki.js
-/**
- * @license Copyright (C) 2009 Google Inc.
- *
- * 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.
- */
-
-/**
- * @fileoverview
- * Registers a language handler for Wiki pages.
- *
- * Based on WikiSyntax at http://code.google.com/p/support/wiki/WikiSyntax
- *
- * @author [email protected]
- */
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer'](
-        [
-         // Whitespace
-         [PR['PR_PLAIN'],       /^[\t \xA0a-gi-z0-9]+/, null,
-          '\t \xA0abcdefgijklmnopqrstuvwxyz0123456789'],
-         // Wiki formatting
-         [PR['PR_PUNCTUATION'], /^[=*~\^\[\]]+/, null, '=*~^[]']
-        ],
-        [
-         // Meta-info like #summary, #labels, etc.
-         ['lang-wiki.meta',  /(?:^^|\r\n?|\n)(#[a-z]+)\b/],
-         // A WikiWord
-         [PR['PR_LITERAL'],     /^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/
-          ],
-         // A preformatted block in an unknown language
-         ['lang-',           /^\{\{\{([\s\S]+?)\}\}\}/],
-         // A block of source code in an unknown language
-         ['lang-',           /^`([^\r\n`]+)`/],
-         // An inline URL.
-         [PR['PR_STRING'],
-          /^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i],
-         [PR['PR_PLAIN'],       /^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/]
-        ]),
-    ['wiki']);
-
-PR['registerLangHandler'](
-    PR['createSimpleLexer']([[PR['PR_KEYWORD'], /^#[a-z]+/i, null, '#']], []),
-    ['wiki.meta']);
-
-//third_party/javascript/google_code_prettify/src/lang-yaml.js
-/** Contributed by ribrdb @ code.google.com
- */
-
-/**
- * @fileoverview
- * Registers a language handler for YAML.
- *
- * @author ribrdb
- */
-
-PR['registerLangHandler'](
-  PR['createSimpleLexer'](
-    [
-      [PR['PR_PUNCTUATION'], /^[:|>?]+/, null, ':|>?'],
-      [PR['PR_DECLARATION'],  /^%(?:YAML|TAG)[^#\r\n]+/, null, '%'],
-      [PR['PR_TYPE'], /^[&]\S+/, null, '&'],
-      [PR['PR_TYPE'], /^!\S*/, null, '!'],
-      [PR['PR_STRING'], /^"(?:[^\\"]|\\.)*(?:"|$)/, null, '"'],
-      [PR['PR_STRING'], /^'(?:[^']|'')*(?:'|$)/, null, "'"],
-      [PR['PR_COMMENT'], /^#[^\r\n]*/, null, '#'],
-      [PR['PR_PLAIN'], /^\s+/, null, ' \t\r\n']
-    ],
-    [
-      [PR['PR_DECLARATION'], /^(?:---|\.\.\.)(?:[\r\n]|$)/],
-      [PR['PR_PUNCTUATION'], /^-/],
-      [PR['PR_KEYWORD'], /^\w+:[ \r\n]/],
-      [PR['PR_PLAIN'], /^\w+/]
-    ]), ['yaml', 'yml']);
-
-//third_party/javascript/jquery/v1_7_2/jquery-1.7.2.min.js
-/**
- * @license jQuery JavaScript Library v1.7.2
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Wed Mar 21 12:46:34 2012 -0700
- */
-(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function ca(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function b_(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bD.test(a)?d(a,e):b_(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&f.type(b)==="object")for(var e in b)b_(a+"["+e+"]",b[e],c,d);else d(a,b)}function b$(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function bZ(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bS,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=bZ(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=bZ(a,c,d,e,"*",g));return l}function bY(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bO),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bB(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?1:0,g=4;if(d>0){if(c!=="border")for(;e<g;e+=2)c||(d-=parseFloat(f.css(a,"padding"+bx[e]))||0),c==="margin"?d+=parseFloat(f.css(a,c+bx[e]))||0:d-=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0;return d+"px"}d=by(a,b);if(d<0||d==null)d=a.style[b];if(bt.test(d))return d;d=parseFloat(d)||0;if(c)for(;e<g;e+=2)d+=parseFloat(f.css(a,"padding"+bx[e]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+bx[e]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+bx[e]))||0);return d+"px"}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;b.nodeType===1&&(b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase(),c==="object"?b.outerHTML=a.outerHTML:c!=="input"||a.type!=="checkbox"&&a.type!=="radio"?c==="option"?b.selected=a.defaultSelected:c==="input"||c==="textarea"?b.defaultValue=a.defaultValue:c==="script"&&b.text!==a.text&&(b.text=a.text):(a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value)),b.removeAttribute(f.expando),b.removeAttribute("_submit_attached"),b.removeAttribute("_change_attached"))}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c,i[c][d])}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(O.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(H)return H.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h,i){var j,k=d==null,l=0,m=a.length;if(d&&typeof d=="object"){for(l in d)e.access(a,c,l,d[l],1,h,f);g=1}else if(f!==b){j=i===b&&e.isFunction(f),k&&(j?(j=c,c=function(a,b,c){return j.call(e(a),c)}):(c.call(a,f),c=null));if(c)for(;l<m;l++)c(a[l],d,j?f.call(a[l],l,c(a[l],d)):f,i);g=1}return g?a:k?c.call(a):m?c(a[0],d):h},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test("Â ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g={};f.Callbacks=function(a){a=a?g[a]||h(a):{};var c=[],d=[],e,i,j,k,l,m,n=function(b){var d,e,g,h,i;for(d=0,e=b.length;d<e;d++)g=b[d],h=f.type(g),h==="array"?n(g):h==="function"&&(!a.unique||!p.has(g))&&c.push(g)},o=function(b,f){f=f||[],e=!a.memory||[b,f],i=!0,j=!0,m=k||0,k=0,l=c.length;for(;c&&m<l;m++)if(c[m].apply(b,f)===!1&&a.stopOnFalse){e=!0;break}j=!1,c&&(a.once?e===!0?p.disable():c=[]:d&&d.length&&(e=d.shift(),p.fireWith(e[0],e[1])))},p={add:function(){if(c){var a=c.length;n(arguments),j?l=c.length:e&&e!==!0&&(k=a,o(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var f=0;f<c.length;f++)if(b[d]===c[f]){j&&f<=l&&(l--,f<=m&&m--),c.splice(f--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){c=[];return this},disable:function(){c=d=e=b;return this},disabled:function(){return!c},lock:function(){d=b,(!e||e===!0)&&p.disable();return this},locked:function(){return!d},fireWith:function(b,c){d&&(j?a.once||d.push([b,c]):(!a.once||!e)&&o(b,c));return this},fire:function(){p.fireWith(this,arguments);return this},fired:function(){return!!i}};return p};var i=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),d=f.Callbacks("memory"),e="pending",g={resolve:b,reject:c,notify:d},h={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){i.done(a).fail(b).progress(c);return this},always:function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()},promise:function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}},i=h.promise({}),j;for(j in g)i[j]=g[j].fire,i[j+"With"]=g[j].fireWith;i.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(i,i);return i},when:function(a){function m(a){return function(b){e[a]=arguments.length>1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&f.isFunction(b[c].promise)?b[c].promise().then(l(c),j.reject,m(c)):--g;g||j.resolveWith(j,b)}else j!==a&&j.resolveWith(j,d?[a]:[]);return k}}),f.support=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p=c.createElement("div"),q=c.documentElement;p.setAttribute("className","t"),p.innerHTML="   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="<div "+n+"display:block;'><div style='"+t+"0;display:block;overflow:hidden;'></div></div>"+"<table "+n+"' cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="<table><tr><td style='"+t+"0;display:none'></td><td>t</td></tr></table>",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="<div style='width:5px;'></div>",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e<g;e++)delete d[b[e]];if(!(c?m:f.isEmptyObject)(d))return}}if(!c){delete j[k].data;if(!m(j[k]))return}f.support.deleteExpando||!j.setInterval?delete j[k]:j[k]=null,i&&(f.support.deleteExpando?delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d,e,g,h,i,j=this[0],k=0,m=null;if(a===b){if(this.length){m=f.data(j);if(j.nodeType===1&&!f._data(j,"parsedAttrs")){g=j.attributes;for(i=g.length;k<i;k++)h=g[k].name,h.indexOf("data-")===0&&(h=f.camelCase(h.substring(5)),l(j,h,m[h]));f._data(j,"parsedAttrs",!0)}}return m}if(typeof a=="object")return this.each(function(){f.data(this,a)});d=a.split(".",2),d[1]=d[1]?"."+d[1]:"",e=d[1]+"!";return f.access(this,function(c){if(c===b){m=this.triggerHandler("getData"+e,[d[0]]),m===b&&j&&(m=f.data(j,a),m=l(j,a,m));return m===b&&d[1]?this.data(d[0]):m}d[1]=c,this.each(function(){var b=f(this);b.triggerHandler("setData"+e,d),f.data(this,a,c),b.triggerHandler("changeData"+e,d)})},null,c,arguments.length>1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length<d)return f.queue(this[0],a);return c===b?this:this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f.Callbacks("once memory"),!0))h++,l.add(m);m();return d.promise(c)}});var o=/[\n\t\r]/g,p=/\s+/,q=/\r/g,r=/^(?:button|input)$/i,s=/^(?:button|input|object|select|textarea)$/i,t=/^a(?:rea)?$/i,u=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,v=f.support.getSetAttribute,w,x,y;f.fn.extend({attr:function(a,b){return f.access(this,f.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(p);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(o," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(p);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(o," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c<d;c++){e=i[c];if(e.selected&&(f.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!f.nodeName(e.parentNode,"optgroup"))){b=f(e).val();if(j)return b;h.push(b)}}if(j&&!h.length&&i.length)return f(i[g]).val();return h},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i<g;i++)e=d[i],e&&(c=f.propFix[e]||e,h=u.test(e),h||f.attr(a,e,""),a.removeAttribute(v?e:c),h&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(r.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(w&&f.nodeName(a,"button"))return w.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(w&&f.nodeName(a,"button"))return w.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){h=i!==1||!f.isXMLDoc(a),h&&(c=f.propFix[c]||c,g=f.propHooks[c]);return d!==b?g&&"set"in g&&(e=g.set(a,d,c))!==b?e:a[c]=d:g&&"get"in g&&(e=g.get(a,c))!==null?e:a[c]}},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):s.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabindex=f.propHooks.tabIndex,x={get:function(a,c){var d,e=f.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},v||(y={name:!0,id:!0,coords:!0},w=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&(y[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=w.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})}),f.attrHooks.contenteditable={get:w.get,set:function(a,b,c){b===""&&(b="false"),w.set(a,b,c)}}),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.enctype||(f.propFix.enctype="encoding"),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(
-a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]||{},m=(g?s.delegateType:s.bindType)||m,s=f.event.special[m]||{},o=f.extend({type:m,origType:l[1],data:e,handler:d,guid:d.guid,selector:g,quick:g&&G(g),namespace:n.join(".")},p),r=j[m];if(!r){r=j[m]=[],r.delegateCount=0;if(!s.setup||s.setup.call(a,e,n,i)===!1)a.addEventListener?a.addEventListener(m,i,!1):a.attachEvent&&a.attachEvent("on"+m,i)}s.add&&(s.add.call(a,o),o.handler.guid||(o.handler.guid=d.guid)),g?r.splice(r.delegateCount++,0,o):r.push(o),f.event.global[m]=!0}a=null}},global:{},remove:function(a,b,c,d,e){var g=f.hasData(a)&&f._data(a),h,i,j,k,l,m,n,o,p,q,r,s;if(!!g&&!!(o=g.events)){b=f.trim(I(b||"")).split(" ");for(h=0;h<b.length;h++){i=A.exec(b[h])||[],j=k=i[1],l=i[2];if(!j){for(j in o)f.event.remove(a,j+b[h],c,d,!0);continue}p=f.event.special[j]||{},j=(d?p.delegateType:p.bindType)||j,r=o[j]||[],m=r.length,l=l?new RegExp("(^|\\.)"+l.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(n=0;n<r.length;n++)s=r[n],(e||k===s.origType)&&(!c||c.guid===s.guid)&&(!l||l.test(s.namespace))&&(!d||d===s.selector||d==="**"&&s.selector)&&(r.splice(n--,1),s.selector&&r.delegateCount--,p.remove&&p.remove.call(a,s));r.length===0&&m!==r.length&&((!p.teardown||p.teardown.call(a,l)===!1)&&f.removeEvent(a,j,g.handle),delete o[j])}f.isEmptyObject(o)&&(q=g.handle,q&&(q.elem=null),f.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){if(!e||e.nodeType!==3&&e.nodeType!==8){var h=c.type||c,i=[],j,k,l,m,n,o,p,q,r,s;if(E.test(h+f.event.triggered))return;h.indexOf("!")>=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l<r.length&&!c.isPropagationStopped();l++)m=r[l][0],c.type=r[l][1],q=(f._data(m,"events")||{})[c.type]&&f._data(m,"handle"),q&&q.apply(m,d),q=o&&m[o],q&&f.acceptData(m)&&q.apply(m,d)===!1&&c.preventDefault();c.type=h,!g&&!c.isDefaultPrevented()&&(!p._default||p._default.apply(e.ownerDocument,d)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)&&o&&e[h]&&(h!=="focus"&&h!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(e)&&(n=e[o],n&&(e[o]=null),f.event.triggered=h,e[h](),f.event.triggered=b,n&&(e[o]=n));return c.result}},dispatch:function(c){c=f.event.fix(c||a.event);var d=(f._data(this,"events")||{})[c.type]||[],e=d.delegateCount,g=[].slice.call(arguments,0),h=!c.exclusive&&!c.namespace,i=f.event.special[c.type]||{},j=[],k,l,m,n,o,p,q,r,s,t,u;g[0]=c,c.delegateTarget=this;if(!i.preDispatch||i.preDispatch.call(this,c)!==!1){if(e&&(!c.button||c.type!=="click")){n=f(this),n.context=this.ownerDocument||this;for(m=c.target;m!=this;m=m.parentNode||this)if(m.disabled!==!0){p={},r=[],n[0]=m;for(k=0;k<e;k++)s=d[k],t=s.selector,p[t]===b&&(p[t]=s.quick?H(m,s.quick):n.is(t)),p[t]&&r.push(s);r.length&&j.push({elem:m,matches:r})}}d.length>e&&j.push({elem:this,matches:d.slice(e)});for(k=0;k<j.length&&!c.isPropagationStopped();k++){q=j[k],c.currentTarget=q.elem;for(l=0;l<q.matches.length&&!c.isImmediatePropagationStopped();l++){s=q.matches[l];if(h||!c.namespace&&!s.namespace||c.namespace_re&&c.namespace_re.test(s.namespace))c.data=s.data,c.handleObj=s,o=((f.event.special[s.origType]||{}).handle||s.handler).apply(q.elem,g),o!==b&&(c.result=o,o===!1&&(c.preventDefault(),c.stopPropagation()))}}i.postDispatch&&i.postDispatch.call(this,c);return c.result}},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode);return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,d){var e,f,g,h=d.button,i=d.fromElement;a.pageX==null&&d.clientX!=null&&(e=a.target.ownerDocument||c,f=e.documentElement,g=e.body,a.pageX=d.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=d.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?d.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0);return a}},fix:function(a){if(a[f.expando])return a;var d,e,g=a,h=f.event.fixHooks[a.type]||{},i=h.props?this.props.concat(h.props):this.props;a=f.Event(g);for(d=i.length;d;)e=i[--d],a[e]=g[e];a.target||(a.target=g.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey===b&&(a.metaKey=a.ctrlKey);return h.filter?h.filter(a,g):a},special:{ready:{setup:f.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=f.extend(new f.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?f.event.trigger(e,null,b):f.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},f.event.handle=f.event.dispatch,f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!(this instanceof f.Event))return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?K:J):this.type=a,b&&f.extend(this,b),this.timeStamp=a&&a.timeStamp||f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=K;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=K;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=K,this.stopPropagation()},isDefaultPrevented:J,isPropagationStopped:J,isImmediatePropagationStopped:J},f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=this,d=a.relatedTarget,e=a.handleObj,g=e.selector,h;if(!d||d!==c&&!f.contains(c,d))a.type=e.origType,h=e.handler.apply(this,arguments),a.type=b;return h}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(){if(f.nodeName(this,"form"))return!1;f.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=f.nodeName(c,"input")||f.nodeName(c,"button")?c.form:b;d&&!d._submit_attached&&(f.event.add(d,"submit._submit",function(a){a._submit_bubble=!0}),d._submit_attached=!0)})},postDispatch:function(a){a._submit_bubble&&(delete a._submit_bubble,this.parentNode&&!a.isTrigger&&f.event.simulate("submit",this.parentNode,a,!0))},teardown:function(){if(f.nodeName(this,"form"))return!1;f.event.remove(this,"._submit")}}),f.support.changeBubbles||(f.event.special.change={setup:function(){if(z.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")f.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),f.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1,f.event.simulate("change",this,a,!0))});return!1}f.event.add(this,"beforeactivate._change",function(a){var b=a.target;z.test(b.nodeName)&&!b._change_attached&&(f.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&f.event.simulate("change",this.parentNode,a,!0)}),b._change_attached=!0)})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){f.event.remove(this,"._change");return z.test(this.nodeName)}}),f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){var d=0,e=function(a){f.event.simulate(b,a.target,f.event.fix(a),!0)};f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.fn.extend({on:function(a,c,d,e,g){var h,i;if(typeof a=="object"){typeof c!="string"&&(d=d||c,c=b);for(i in a)this.on(i,c,d,a[i],g);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=J;else if(!e)return this;g===1&&(h=e,e=function(a){f().off(a);return h.apply(this,arguments)},e.guid=h.guid||(h.guid=f.guid++));return this.each(function(){f.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,c,d){if(a&&a.preventDefault&&a.handleObj){var e=a.handleObj;f(a.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler);return this}if(typeof a=="object"){for(var g in a)this.off(g,c,a[g]);return this}if(c===!1||typeof c=="function")d=c,c=b;d===!1&&(d=J);return this.each(function(){f.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){f(this.context).on(a,this.selector,b,c);return this},die:function(a,b){f(this.context).off(a,this.selector||"**",b);return this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a,c)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f._data(this,"lastToggle"+a.guid)||0)%d;f._data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}if(j.nodeType===1){g||(j[d]=c,j.sizset=h);if(typeof b!="string"){if(j===b){k=!0;break}}else if(m.filter(b,[j]).length>0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}j.nodeType===1&&!g&&(j[d]=c,j.sizset=h);if(j.nodeName.toLowerCase()===b){k=j;break}j=j[a]}e[h]=k}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},m.matches=function(a,b){return m(a,null,null,b)},m.matchesSelector=function(a,b){return m(b,null,null,[a]).length>0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},m.filter=function(a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q)if(g==null)m.error(a);else break;q=a}return s},m.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)};var n=m.getText=function(a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9||d===11){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e},o=m.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!l.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&m.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&m.filter(b,a,!0)}},"":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("previousSibling",b,f,a,d,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(j,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}m.error(e)},CHILD:function(a,b){var c,e,f,g,h,i,j,k=b[1],l=a;switch(k){case"only":case"first":while(l=l.previousSibling)if(l.nodeType===1)return!1;if(k==="first")return!0;l=a;case"last":while(l=l.nextSibling)if(l.nodeType===1)return!1;return!0;case"nth":c=b[2],e=b[3];if(c===1&&e===0)return!0;f=b[0],g=a.parentNode;if(g&&(g[d]!==f||!a.nodeIndex)){i=0;for(l=g.firstChild;l;l=l.nextSibling)l.nodeType===1&&(l.nodeIndex=++i);g[d]=f}j=a.nodeIndex-e;return c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var u,v;c.documentElement.compareDocumentPosition?u=function(a,b){if(a===b){h=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(u=function(a,b){if(a===b){h=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],g=a.parentNode,i=b.parentNode,j=g;if(g===i)return v(a,b);if(!g)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return v(e[k],f[k]);return k===c?v(a,f[k],-1):v(e[k],b,1)},v=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h<i;h++)m(a,g[h],e,c);return m.filter(f,e)};m.attr=f.attr,m.selectors.attrMap={},f.find=m,f.expr=m.selectors,f.expr[":"]=f.expr.filters,f.unique=m.uniqueSort,f.text=m.getText,f.isXMLDoc=m.isXML,f.contains=m.contains}();var L=/Until$/,M=/^(?:parents|prevUntil|prevAll)/,N=/,/,O=/^.[^:#\[\.,]*$/,P=Array.prototype.slice,Q=f.expr.match.globalPOS,R={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(T(this,a,!1),"not",a)},filter:function(a){return this.pushStack(T(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?Q.test(a)?f(a,this.context).index(this[0])>=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d<a.length;d++)f(g).is(a[d])&&c.push({selector:a[d],elem:g,level:h});g=g.parentNode,h++}return c}var i=Q.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(i?i.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|style)/i,bb=/<(?:script|object|embed|option|style)/i,bc=new RegExp("<(?:"+V+")[\\s/>]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f
-.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(;d<e;d++)c=this[d]||{},c.nodeType===1&&(f.cleanData(c.getElementsByTagName("*")),c.innerHTML=a);c=0}catch(g){}}c&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bi(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,function(a,b){b.src?f.ajax({type:"GET",global:!1,url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)})}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i,j=a[0];b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1></$2>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]==="<table>"&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i<u;i++)bn(l[i]);else bn(l);l.nodeType?j.push(l):j=f.merge(j,l)}if(d){g=function(a){return!a.type||be.test(a.type)};for(k=0;j[k];k++){h=j[k];if(e&&f.nodeName(h,"script")&&(!h.type||be.test(h.type)))e.push(h.parentNode?h.parentNode.removeChild(h):h);else{if(h.nodeType===1){var v=f.grep(h.getElementsByTagName("script"),g);j.splice.apply(j,[k+1,0].concat(v))}d.appendChild(h)}}}return j},cleanData:function(a){var b,c,d=f.cache,e=f.event.special,g=f.support.deleteExpando;for(var h=0,i;(i=a[h])!=null;h++){if(i.nodeName&&f.noData[i.nodeName.toLowerCase()])continue;c=i[f.expando];if(c){b=d[c];if(b&&b.events){for(var j in b.events)e[j]?f.event.remove(i,j):f.removeEvent(i,j,b.handle);b.handle&&(b.handle.elem=null)}g?delete i[f.expando]:i.removeAttribute&&i.removeAttribute(f.expando),delete d[c]}}}});var bp=/alpha\([^)]*\)/i,bq=/opacity=([^)]*)/,br=/([A-Z]|^ms)/g,bs=/^[\-+]?(?:\d*\.)?\d+$/i,bt=/^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,bu=/^([\-+])=([\-+.\de]+)/,bv=/^margin/,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Top","Right","Bottom","Left"],by,bz,bA;f.fn.css=function(a,c){return f.access(this,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)},a,c,arguments.length>1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),(e===""&&f.css(d,"display")==="none"||!f.contains(d.ownerDocument.documentElement,d))&&f._data(d,"olddisplay",cu(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(ct("hide",3),a,b,c);var d,e,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(e=f.css(d,"display"),e!=="none"&&!f._data(d,"olddisplay")&&f._data(d,"olddisplay",e));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(ct("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){function g(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o,p,q;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]);if((k=f.cssHooks[g])&&"expand"in k){l=k.expand(a[g]),delete a[g];for(i in l)i in a||(a[i]=l[i])}}for(g in a){h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(!f.support.inlineBlockNeedsLayout||cu(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new f.fx(this,b,i),h=a[i],cm.test(h)?(q=f._data(this,"toggle"+i)||(h==="toggle"?d?"show":"hide":0),q?(f._data(this,"toggle"+i,q==="show"?"hide":"show"),j[q]()):j[h]()):(m=cn.exec(h),n=j.cur(),m?(o=parseFloat(m[2]),p=m[3]||(f.cssNumber[i]?"":"px"),p!=="px"&&(f.style(this,i,(o||1)+p),n=(o||1)/j.cur()*n,f.style(this,i,n+p)),m[1]&&(o=(m[1]==="-="?-1:1)*o+n),j.custom(n,o,p)):j.custom(n,h,""));return!0}var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return e.queue===!1?this.each(g):this.queue(e.queue,g)},stop:function(a,c,d){typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]);return this.each(function(){function h(a,b,c){var e=b[c];f.removeData(a,c,!0),e.stop(d)}var b,c=!1,e=f.timers,g=f._data(this);d||f._unmark(!0,this);if(a==null)for(b in g)g[b]&&g[b].stop&&b.indexOf(".run")===b.length-4&&h(this,g,b);else g[b=a+".run"]&&g[b].stop&&h(this,g,b);for(b=e.length;b--;)e[b].elem===this&&(a==null||e[b].queue===a)&&(d?e[b](!0):e[b].saveState(),c=!0,e.splice(b,1));(!d||!c)&&f.dequeue(this,a)})}}),f.each({slideDown:ct("show",1),slideUp:ct("hide",1),slideToggle:ct("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue?f.dequeue(this,d.queue):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a){return a},swing:function(a){return-Math.cos(a*Math.PI)/2+.5}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,c,d){function h(a){return e.step(a)}var e=this,g=f.fx;this.startTime=cq||cr(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(f.cssNumber[this.prop]?"":"px"),h.queue=this.options.queue,h.elem=this.elem,h.saveState=function(){f._data(e.elem,"fxshow"+e.prop)===b&&(e.options.hide?f._data(e.elem,"fxshow"+e.prop,e.start):e.options.show&&f._data(e.elem,"fxshow"+e.prop,e.end))},h()&&f.timers.push(h)&&!co&&(co=setInterval(g.tick,g.interval))},show:function(){var a=f._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||f.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f._data(this.elem,"fxshow"+this.prop)||f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=cq||cr(),g=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||f.fx.stop()},interval:13,stop:function(){clearInterval(co),co=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}}),f.each(cp.concat.apply([],cp),function(a,b){b.indexOf("margin")&&(f.fx.step[b]=function(a){f.style(a.elem,b,Math.max(0,a.now)+a.unit)})}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cv,cw=/^t(?:able|d|h)$/i,cx=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?cv=function(a,b,c,d){try{d=a.getBoundingClientRect()}catch(e){}if(!d||!f.contains(c,a))return d?{top:d.top,left:d.left}:{top:0,left:0};var g=b.body,h=cy(b),i=c.clientTop||g.clientTop||0,j=c.clientLeft||g.clientLeft||0,k=h.pageYOffset||f.support.boxModel&&c.scrollTop||g.scrollTop,l=h.pageXOffset||f.support.boxModel&&c.scrollLeft||g.scrollLeft,m=d.top+k-i,n=d.left+l-j;return{top:m,left:n}}:cv=function(a,b,c){var d,e=a.offsetParent,g=a,h=b.body,i=b.defaultView,j=i?i.getComputedStyle(a,null):a.currentStyle,k=a.offsetTop,l=a.offsetLeft;while((a=a.parentNode)&&a!==h&&a!==c){if(f.support.fixedPosition&&j.position==="fixed")break;d=i?i.getComputedStyle(a,null):a.currentStyle,k-=a.scrollTop,l-=a.scrollLeft,a===e&&(k+=a.offsetTop,l+=a.offsetLeft,f.support.doesNotAddBorder&&(!f.support.doesAddBorderForTableAndCells||!cw.test(a.nodeName))&&(k+=parseFloat(d.borderTopWidth)||0,l+=parseFloat(d.borderLeftWidth)||0),g=e,e=a.offsetParent),f.support.subtractsBorderForOverflowNotVisible&&d.overflow!=="visible"&&(k+=parseFloat(d.borderTopWidth)||0,l+=parseFloat(d.borderLeftWidth)||0),j=d}if(j.position==="relative"||j.position==="static")k+=h.offsetTop,l+=h.offsetLeft;f.support.fixedPosition&&j.position==="fixed"&&(k+=Math.max(c.scrollTop,h.scrollTop),l+=Math.max(c.scrollLeft,h.scrollLeft));return{top:k,left:l}},f.fn.offset=function(a){if(arguments.length)return a===b?this:this.each(function(b){f.offset.setOffset(this,a,b)});var c=this[0],d=c&&c.ownerDocument;if(!d)return null;if(c===d.body)return f.offset.bodyOffset(c);return cv(c,d,d.documentElement)},f.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window);
-
-//third_party/javascript/jquery_hashchange/jquery.hashchange.js
-/**
- * @license
- * jQuery hashchange 1.0.0
- * 
- * (based on jquery.history)
- *
- * Copyright (c) 2008 Chris Leishman (chrisleishman.com)
- * Dual licensed under the MIT (MIT-LICENSE.txt)
- * and GPL (GPL-LICENSE.txt) licenses.
- */
-(function($) {
-
-$.fn.extend({
-    hashchange: function(callback) { this.bind('hashchange', callback) },
-    openOnClick: function(href) {
-		if (href === undefined || href.length == 0)
-			href = '#';
-		return this.click(function(ev) {
-			if (href && href.charAt(0) == '#') {
-				// execute load in separate call stack
-				window.setTimeout(function() { $.locationHash(href) }, 0);
-			} else {
-				window.location(href);
-			}
-			ev.stopPropagation();
-			return false;
-		});
-    }
-});
-
-// IE 8 introduces the hashchange event natively - so nothing more to do
-if ($.browser.msie && document.documentMode && document.documentMode >= 8) {
-	$.extend({
-		locationHash: function(hash) {
-	        if (!hash) hash = '#';
-	        else if (hash.charAt(0) != '#') hash = '#' + hash;
-	        location.hash = hash;
-	    }
-	});
-	return;
-}
-
-var curHash;
-// hidden iframe for IE (earlier than 8)
-var iframe;
-
-$.extend({
-	locationHash: function(hash) {
-		if (curHash === undefined) return;
-
-		if (!hash) hash = '#';
-		else if (hash.charAt(0) != '#') hash = '#' + hash;
-		
-		location.hash = hash;
-		
-		if (curHash == hash) return;
-		curHash = hash;
-		
-		if ($.browser.msie) updateIEFrame(hash);
-		$.event.trigger('hashchange');
-	}
-});
-
-$(document).ready(function() {
-    curHash = location.hash;
-    if ($.browser.msie) {
-        // stop the callback firing twice during init if no hash present
-        if (curHash == '') curHash = '#';
-        // add hidden iframe for IE
-        iframe = $('<iframe />').hide().get(0);
-        $('body').prepend(iframe);
-        updateIEFrame(location.hash);
-        setInterval(checkHashIE, 100);
-    } else {
-        setInterval(checkHash, 100);
-    }
-});
-$(window).unload(function() { iframe = null });
-
-function checkHash() {
-    var hash = location.hash;
-    if (hash != curHash) {
-        curHash = hash;
-        $.event.trigger('hashchange');
-    }
-}
-
-if ($.browser.msie) {
-    // Attach a live handler for any anchor links
-    $('a[href^=#]').live('click', function() {
-        var hash = $(this).attr('href');
-        // Don't intercept the click if there is an existing anchor on the page
-        // that matches this hash
-        if ($(hash).length == 0 && $('a[name='+hash.slice(1)+']').length == 0) {
-            $.locationHash(hash);
-            return false;
-        }
-    });
-}
-
-function checkHashIE() {
-    // On IE, check for location.hash of iframe
-    var idoc = iframe.contentDocument || iframe.contentWindow.document;
-    var hash = idoc.location.hash;
-    if (hash == '') hash = '#';
-
-    if (hash != curHash) {
-        if (location.hash != hash) location.hash = hash;
-        curHash = hash;
-        $.event.trigger('hashchange');
-    }
-}
-
-function updateIEFrame(hash) {
-    if (hash == '#') hash = '';
-    var idoc = iframe.contentWindow.document;
-    idoc.open();
-    idoc.close();
-    if (idoc.location.hash != hash) idoc.location.hash = hash;
-}
-
-})(jQuery);
-
-//third_party/javascript/jquery_jscrollpane/jquery.jscrollpane.min.js
-/*
- * @license
- * jScrollPane - v2.0.0beta12 - 2012-09-27
- * http://jscrollpane.kelvinluck.com/
- *
- * Copyright (c) 2010 Kelvin Luck
- * Dual licensed under the MIT or GPL licenses.
- */
-(function(b,a,c){b.fn.jScrollPane=function(e){function d(D,O){var ay,Q=this,Y,aj,v,al,T,Z,y,q,az,aE,au,i,I,h,j,aa,U,ap,X,t,A,aq,af,am,G,l,at,ax,x,av,aH,f,L,ai=true,P=true,aG=false,k=false,ao=D.clone(false,false).empty(),ac=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aH=D.css("paddingTop")+" "+D.css("paddingRight")+" "+D.css("paddingBottom")+" "+D.css("paddingLeft");f=(parseInt(D.css("paddingLeft"),10)||0)+(parseInt(D.css("paddingRight"),10)||0);function ar(aQ){var aL,aN,aM,aJ,aI,aP,aO=false,aK=false;ay=aQ;if(Y===c){aI=D.scrollTop();aP=D.scrollLeft();D.css({overflow:"hidden",padding:0});aj=D.innerWidth()+f;v=D.innerHeight();D.width(aj);Y=b('<div class="jspPane" />').css("padding",aH).append(D.children());al=b('<div class="jspContainer" />').css({width:aj+"px",height:v+"px"}).append(Y).appendTo(D)}else{D.css("width","");aO=ay.stickToBottom&&K();aK=ay.stickToRight&&B();aJ=D.innerWidth()+f!=aj||D.outerHeight()!=v;if(aJ){aj=D.innerWidth()+f;v=D.innerHeight();al.css({width:aj+"px",height:v+"px"})}if(!aJ&&L==T&&Y.outerHeight()==Z){D.width(aj);return}L=T;Y.css("width","");D.width(aj);al.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Y.css("overflow","auto");if(aQ.contentWidth){T=aQ.contentWidth}else{T=Y[0].scrollWidth}Z=Y[0].scrollHeight;Y.css("overflow","");y=T/aj;q=Z/v;az=q>1;aE=y>1;if(!(aE||az)){D.removeClass("jspScrollable");Y.css({top:0,width:al.width()-f});n();E();R();w()}else{D.addClass("jspScrollable");aL=ay.maintainPosition&&(I||aa);if(aL){aN=aC();aM=aA()}aF();z();F();if(aL){N(aK?(T-aj):aN,false);M(aO?(Z-v):aM,false)}J();ag();an();if(ay.enableKeyboardNavigation){S()}if(ay.clickOnTrack){p()}C();if(ay.hijackInternalLinks){m()}}if(ay.autoReinitialise&&!av){av=setInterval(function(){ar(ay)},ay.autoReinitialiseDelay)}else{if(!ay.autoReinitialise&&av){clearInterval(av)}}aI&&D.scrollTop(0)&&M(aI,false);aP&&D.scrollLeft(0)&&N(aP,false);D.trigger("jsp-initialised",[aE||az])}function aF(){if(az){al.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=al.find(">.jspVerticalBar");ap=U.find(">.jspTrack");au=ap.find(">.jspDrag");if(ay.showArrows){aq=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aD(0,-1)).bind("click.jsp",aB);af=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aD(0,1)).bind("click.jsp",aB);if(ay.arrowScrollOnHover){aq.bind("mouseover.jsp",aD(0,-1,aq));af.bind("mouseover.jsp",aD(0,1,af))}ak(ap,ay.verticalArrowPositions,aq,af)}t=v;al.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){t-=b(this).outerHeight()});au.hover(function(){au.addClass("jspHover")},function(){au.removeClass("jspHover")}).bind("mousedown.jsp",function(aI){b("html").bind("dragstart.jsp selectstart.jsp",aB);au.addClass("jspActive");var s=aI.pageY-au.position().top;b("html").bind("mousemove.jsp",function(aJ){V(aJ.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",aw);return false});o()}}function o(){ap.height(t+"px");I=0;X=ay.verticalGutter+ap.outerWidth();Y.width(aj-X-f);try{if(U.position().left===0){Y.css("margin-left",X+"px")}}catch(s){}}function z(){if(aE){al.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));am=al.find(">.jspHorizontalBar");G=am.find(">.jspTrack");h=G.find(">.jspDrag");if(ay.showArrows){ax=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aD(-1,0)).bind("click.jsp",aB);x=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aD(1,0)).bind("click.jsp",aB);
-if(ay.arrowScrollOnHover){ax.bind("mouseover.jsp",aD(-1,0,ax));x.bind("mouseover.jsp",aD(1,0,x))}ak(G,ay.horizontalArrowPositions,ax,x)}h.hover(function(){h.addClass("jspHover")},function(){h.removeClass("jspHover")}).bind("mousedown.jsp",function(aI){b("html").bind("dragstart.jsp selectstart.jsp",aB);h.addClass("jspActive");var s=aI.pageX-h.position().left;b("html").bind("mousemove.jsp",function(aJ){W(aJ.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",aw);return false});l=al.innerWidth();ah()}}function ah(){al.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){l-=b(this).outerWidth()});G.width(l+"px");aa=0}function F(){if(aE&&az){var aI=G.outerHeight(),s=ap.outerWidth();t-=aI;b(am).find(">.jspCap:visible,>.jspArrow").each(function(){l+=b(this).outerWidth()});l-=s;v-=s;aj-=aI;G.parent().append(b('<div class="jspCorner" />').css("width",aI+"px"));o();ah()}if(aE){Y.width((al.outerWidth()-f)+"px")}Z=Y.outerHeight();q=Z/v;if(aE){at=Math.ceil(1/y*l);if(at>ay.horizontalDragMaxWidth){at=ay.horizontalDragMaxWidth}else{if(at<ay.horizontalDragMinWidth){at=ay.horizontalDragMinWidth}}h.width(at+"px");j=l-at;ae(aa)}if(az){A=Math.ceil(1/q*t);if(A>ay.verticalDragMaxHeight){A=ay.verticalDragMaxHeight}else{if(A<ay.verticalDragMinHeight){A=ay.verticalDragMinHeight}}au.height(A+"px");i=t-A;ad(I)}}function ak(aJ,aL,aI,s){var aN="before",aK="after",aM;if(aL=="os"){aL=/Mac/.test(navigator.platform)?"after":"split"}if(aL==aN){aK=aL}else{if(aL==aK){aN=aL;aM=aI;aI=s;s=aM}}aJ[aN](aI)[aK](s)}function aD(aI,s,aJ){return function(){H(aI,s,this,aJ);this.blur();return false}}function H(aL,aK,aO,aN){aO=b(aO).addClass("jspActive");var aM,aJ,aI=true,s=function(){if(aL!==0){Q.scrollByX(aL*ay.arrowButtonSpeed)}if(aK!==0){Q.scrollByY(aK*ay.arrowButtonSpeed)}aJ=setTimeout(s,aI?ay.initialDelay:ay.arrowRepeatFreq);aI=false};s();aM=aN?"mouseout.jsp":"mouseup.jsp";aN=aN||b("html");aN.bind(aM,function(){aO.removeClass("jspActive");aJ&&clearTimeout(aJ);aJ=null;aN.unbind(aM)})}function p(){w();if(az){ap.bind("mousedown.jsp",function(aN){if(aN.originalTarget===c||aN.originalTarget==aN.currentTarget){var aL=b(this),aO=aL.offset(),aM=aN.pageY-aO.top-I,aJ,aI=true,s=function(){var aR=aL.offset(),aS=aN.pageY-aR.top-A/2,aP=v*ay.scrollPagePercent,aQ=i*aP/(Z-v);if(aM<0){if(I-aQ>aS){Q.scrollByY(-aP)}else{V(aS)}}else{if(aM>0){if(I+aQ<aS){Q.scrollByY(aP)}else{V(aS)}}else{aK();return}}aJ=setTimeout(s,aI?ay.initialDelay:ay.trackClickRepeatFreq);aI=false},aK=function(){aJ&&clearTimeout(aJ);aJ=null;b(document).unbind("mouseup.jsp",aK)};s();b(document).bind("mouseup.jsp",aK);return false}})}if(aE){G.bind("mousedown.jsp",function(aN){if(aN.originalTarget===c||aN.originalTarget==aN.currentTarget){var aL=b(this),aO=aL.offset(),aM=aN.pageX-aO.left-aa,aJ,aI=true,s=function(){var aR=aL.offset(),aS=aN.pageX-aR.left-at/2,aP=aj*ay.scrollPagePercent,aQ=j*aP/(T-aj);if(aM<0){if(aa-aQ>aS){Q.scrollByX(-aP)}else{W(aS)}}else{if(aM>0){if(aa+aQ<aS){Q.scrollByX(aP)}else{W(aS)}}else{aK();return}}aJ=setTimeout(s,aI?ay.initialDelay:ay.trackClickRepeatFreq);aI=false},aK=function(){aJ&&clearTimeout(aJ);aJ=null;b(document).unbind("mouseup.jsp",aK)};s();b(document).bind("mouseup.jsp",aK);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(ap){ap.unbind("mousedown.jsp")}}function aw(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(au){au.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aI){if(!az){return}if(s<0){s=0}else{if(s>i){s=i}}if(aI===c){aI=ay.animateScroll}if(aI){Q.animate(au,"top",s,ad)}else{au.css("top",s);ad(s)}}function ad(aI){if(aI===c){aI=au.position().top}al.scrollTop(0);I=aI;var aL=I===0,aJ=I==i,aK=aI/i,s=-aK*(Z-v);if(ai!=aL||aG!=aJ){ai=aL;aG=aJ;D.trigger("jsp-arrow-change",[ai,aG,P,k])}u(aL,aJ);Y.css("top",s);D.trigger("jsp-scroll-y",[-s,aL,aJ]).trigger("scroll")}function W(aI,s){if(!aE){return}if(aI<0){aI=0}else{if(aI>j){aI=j}}if(s===c){s=ay.animateScroll}if(s){Q.animate(h,"left",aI,ae)
-}else{h.css("left",aI);ae(aI)}}function ae(aI){if(aI===c){aI=h.position().left}al.scrollTop(0);aa=aI;var aL=aa===0,aK=aa==j,aJ=aI/j,s=-aJ*(T-aj);if(P!=aL||k!=aK){P=aL;k=aK;D.trigger("jsp-arrow-change",[ai,aG,P,k])}r(aL,aK);Y.css("left",s);D.trigger("jsp-scroll-x",[-s,aL,aK]).trigger("scroll")}function u(aI,s){if(ay.showArrows){aq[aI?"addClass":"removeClass"]("jspDisabled");af[s?"addClass":"removeClass"]("jspDisabled")}}function r(aI,s){if(ay.showArrows){ax[aI?"addClass":"removeClass"]("jspDisabled");x[s?"addClass":"removeClass"]("jspDisabled")}}function M(s,aI){var aJ=s/(Z-v);V(aJ*i,aI)}function N(aI,s){var aJ=aI/(T-aj);W(aJ*j,s)}function ab(aV,aQ,aJ){var aN,aK,aL,s=0,aU=0,aI,aP,aO,aS,aR,aT;try{aN=b(aV)}catch(aM){return}aK=aN.outerHeight();aL=aN.outerWidth();al.scrollTop(0);al.scrollLeft(0);while(!aN.is(".jspPane")){s+=aN.position().top;aU+=aN.position().left;aN=aN.offsetParent();if(/^body|html$/i.test(aN[0].nodeName)){return}}aI=aA();aO=aI+v;if(s<aI||aQ){aR=s-ay.verticalGutter}else{if(s+aK>aO){aR=s-v+aK+ay.verticalGutter}}if(aR){M(aR,aJ)}aP=aC();aS=aP+aj;if(aU<aP||aQ){aT=aU-ay.horizontalGutter}else{if(aU+aL>aS){aT=aU-aj+aL+ay.horizontalGutter}}if(aT){N(aT,aJ)}}function aC(){return -Y.position().left}function aA(){return -Y.position().top}function K(){var s=Z-v;return(s>20)&&(s-aA()<10)}function B(){var s=T-aj;return(s>20)&&(s-aC()<10)}function ag(){al.unbind(ac).bind(ac,function(aL,aM,aK,aI){var aJ=aa,s=I;Q.scrollBy(aK*ay.mouseWheelSpeed,-aI*ay.mouseWheelSpeed,false);return aJ==aa&&s==I})}function n(){al.unbind(ac)}function aB(){return false}function J(){Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function E(){Y.find(":input,a").unbind("focus.jsp")}function S(){var s,aI,aK=[];aE&&aK.push(am[0]);az&&aK.push(U[0]);Y.focus(function(){D.focus()});D.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aN){if(aN.target!==this&&!(aK.length&&b(aN.target).closest(aK).length)){return}var aM=aa,aL=I;switch(aN.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aN.keyCode;aJ();break;case 35:M(Z-v);s=null;break;case 36:M(0);s=null;break}aI=aN.keyCode==s&&aM!=aa||aL!=I;return !aI}).bind("keypress.jsp",function(aL){if(aL.keyCode==s){aJ()}return !aI});if(ay.hideFocus){D.css("outline","none");if("hideFocus" in al[0]){D.attr("hideFocus",true)}}else{D.css("outline","");if("hideFocus" in al[0]){D.attr("hideFocus",false)}}function aJ(){var aM=aa,aL=I;switch(s){case 40:Q.scrollByY(ay.keyboardSpeed,false);break;case 38:Q.scrollByY(-ay.keyboardSpeed,false);break;case 34:case 32:Q.scrollByY(v*ay.scrollPagePercent,false);break;case 33:Q.scrollByY(-v*ay.scrollPagePercent,false);break;case 39:Q.scrollByX(ay.keyboardSpeed,false);break;case 37:Q.scrollByX(-ay.keyboardSpeed,false);break}aI=aM!=aa||aL!=I;return aI}}function R(){D.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function C(){if(location.hash&&location.hash.length>1){var aK,aI,aJ=escape(location.hash.substr(1));try{aK=b("#"+aJ+', a[name="'+aJ+'"]')}catch(s){return}if(aK.length&&Y.find(aJ)){if(al.scrollTop()===0){aI=setInterval(function(){if(al.scrollTop()>0){ab(aK,true);b(document).scrollTop(al.position().top);clearInterval(aI)}},50)}else{ab(aK,true);b(document).scrollTop(al.position().top)}}}}function m(){if(b(document.body).data("jspHijack")){return}b(document.body).data("jspHijack",true);b(document.body).delegate("a[href*=#]","click",function(s){var aI=this.href.substr(0,this.href.indexOf("#")),aK=location.href,aO,aP,aJ,aM,aL,aN;if(location.href.indexOf("#")!==-1){aK=location.href.substr(0,location.href.indexOf("#"))}if(aI!==aK){return}aO=escape(this.href.substr(this.href.indexOf("#")+1));aP;try{aP=b("#"+aO+', a[name="'+aO+'"]')}catch(aQ){return}if(!aP.length){return}aJ=aP.closest(".jspScrollable");aM=aJ.data("jsp");aM.scrollToElement(aP,true);if(aJ[0].scrollIntoView){aL=b(a).scrollTop();aN=aP.offset().top;if(aN<aL||aN>aL+b(a).height()){aJ[0].scrollIntoView()}}s.preventDefault()
-})}function an(){var aJ,aI,aL,aK,aM,s=false;al.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aN){var aO=aN.originalEvent.touches[0];aJ=aC();aI=aA();aL=aO.pageX;aK=aO.pageY;aM=false;s=true}).bind("touchmove.jsp",function(aQ){if(!s){return}var aP=aQ.originalEvent.touches[0],aO=aa,aN=I;Q.scrollTo(aJ+aL-aP.pageX,aI+aK-aP.pageY);aM=aM||Math.abs(aL-aP.pageX)>5||Math.abs(aK-aP.pageY)>5;return aO==aa&&aN==I}).bind("touchend.jsp",function(aN){s=false}).bind("click.jsp-touchclick",function(aN){if(aM){aM=false;return false}})}function g(){var s=aA(),aI=aC();D.removeClass("jspScrollable").unbind(".jsp");D.replaceWith(ao.append(Y.children()));ao.scrollTop(s);ao.scrollLeft(aI);if(av){clearInterval(av)}}b.extend(Q,{reinitialise:function(aI){aI=b.extend({},ay,aI);ar(aI)},scrollToElement:function(aJ,aI,s){ab(aJ,aI,s)},scrollTo:function(aJ,s,aI){N(aJ,aI);M(s,aI)},scrollToX:function(aI,s){N(aI,s)},scrollToY:function(s,aI){M(s,aI)},scrollToPercentX:function(aI,s){N(aI*(T-aj),s)},scrollToPercentY:function(aI,s){M(aI*(Z-v),s)},scrollBy:function(aI,s,aJ){Q.scrollByX(aI,aJ);Q.scrollByY(s,aJ)},scrollByX:function(s,aJ){var aI=aC()+Math[s<0?"floor":"ceil"](s),aK=aI/(T-aj);W(aK*j,aJ)},scrollByY:function(s,aJ){var aI=aA()+Math[s<0?"floor":"ceil"](s),aK=aI/(Z-v);V(aK*i,aJ)},positionDragX:function(s,aI){W(s,aI)},positionDragY:function(aI,s){V(aI,s)},animate:function(aI,aL,s,aK){var aJ={};aJ[aL]=s;aI.animate(aJ,{duration:ay.animateDuration,easing:ay.animateEase,queue:false,step:aK})},getContentPositionX:function(){return aC()},getContentPositionY:function(){return aA()},getContentWidth:function(){return T},getContentHeight:function(){return Z},getPercentScrolledX:function(){return aC()/(T-aj)},getPercentScrolledY:function(){return aA()/(Z-v)},getIsScrollableH:function(){return aE},getIsScrollableV:function(){return az},getContentPane:function(){return Y},scrollToBottom:function(s){V(i,s)},hijackInternalLinks:b.noop,destroy:function(){g()}});ar(O)}e=b.extend({},b.fn.jScrollPane.defaults,e);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{b("script",f).filter('[type="text/javascript"],:not([type])').remove();g=new d(f,e);f.data("jsp",g)}})};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);
-
-//third_party/javascript/jquery_mousewheel/jquery.mousewheel.min.js
-/**
- * @license
- * Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
- * Licensed under the MIT License (LICENSE.txt).
- *
- * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
- * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
- * Thanks to: Seamus Leahy for adding deltaX and deltaY
- *
- * Version: 3.0.6
- * 
- * Requires: 1.2.2+
- */
-(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
-
-//third_party/javascript/jquery_ui/v1_8_23/js/jquery-ui-1.8.23.custom.min.js
-/**
- * jQuery UI
- * @version 1.8.23
- * @date 2012-08-15
- * @link https://github.com/jquery/jquery-ui
- * Includes: jquery.ui.core.js
- * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
- * @license MIT (Dual licensed with GPL Version 2 license).
- * http://jquery.org/license
- */
-(function(a,b){function c(b,c){var e=b.nodeName.toLowerCase();if("area"===e){var f=b.parentNode,g=f.name,h;return!b.href||!g||f.nodeName.toLowerCase()!=="map"?!1:(h=a("img[usemap=#"+g+"]")[0],!!h&&d(h))}return(/input|select|textarea|button|object/.test(e)?!b.disabled:"a"==e?b.href||c:c)&&d(b)}function d(b){return!a(b).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.ui=a.ui||{};if(a.ui.version)return;a.extend(a.ui,{version:"1.8.23",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(b,c){return typeof b=="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus(),c&&c.call(d)},b)}):this._focus.apply(this,arguments)},scrollParent:function(){var b;return a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?b=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(a.curCSS(this,"position",1))&&/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0):b=this.parents().filter(function(){return/(auto|scroll)/.test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!b.length?a(document):b},zIndex:function(c){if(c!==b)return this.css("zIndex",c);if(this.length){var d=a(this[0]),e,f;while(d.length&&d[0]!==document){e=d.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){f=parseInt(d.css("zIndex"),10);if(!isNaN(f)&&f!==0)return f}d=d.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a("<a>").outerWidth(1).jquery||a.each(["Width","Height"],function(c,d){function h(b,c,d,f){return a.each(e,function(){c-=parseFloat(a.curCSS(b,"padding"+this,!0))||0,d&&(c-=parseFloat(a.curCSS(b,"border"+this+"Width",!0))||0),f&&(c-=parseFloat(a.curCSS(b,"margin"+this,!0))||0)}),c}var e=d==="Width"?["Left","Right"]:["Top","Bottom"],f=d.toLowerCase(),g={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};a.fn["inner"+d]=function(c){return c===b?g["inner"+d].call(this):this.each(function(){a(this).css(f,h(this,c)+"px")})},a.fn["outer"+d]=function(b,c){return typeof b!="number"?g["outer"+d].call(this,b):this.each(function(){a(this).css(f,h(this,b,!0,c)+"px")})}}),a.extend(a.expr[":"],{data:a.expr.createPseudo?a.expr.createPseudo(function(b){return function(c){return!!a.data(c,b)}}):function(b,c,d){return!!a.data(b,d[3])},focusable:function(b){return c(b,!isNaN(a.attr(b,"tabindex")))},tabbable:function(b){var d=a.attr(b,"tabindex"),e=isNaN(d);return(e||d>=0)&&c(b,!e)}}),a(function(){var b=document.body,c=b.appendChild(c=document.createElement("div"));c.offsetHeight,a.extend(c.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),a.support.minHeight=c.offsetHeight===100,a.support.selectstart="onselectstart"in c,b.removeChild(c).style.display="none"}),a.curCSS||(a.curCSS=a.css),a.extend(a.ui,{plugin:{add:function(b,c,d){var e=a.ui[b].prototype;for(var f in d)e.plugins[f]=e.plugins[f]||[],e.plugins[f].push([c,d[f]])},call:function(a,b,c){var d=a.plugins[b];if(!d||!a.element[0].parentNode)return;for(var e=0;e<d.length;e++)a.options[d[e][0]]&&d[e][1].apply(a.element,c)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(b,c){if(a(b).css("overflow")==="hidden")return!1;var d=c&&c==="left"?"scrollLeft":"scrollTop",e=!1;return b[d]>0?!0:(b[d]=1,e=b[d]>0,b[d]=0,e)},isOverAxis:function(a,b,c){return a>b&&a<b+c},isOver:function(b,c,d,e,f,g){return a.ui.isOverAxis(b,d,f)&&a.ui.isOverAxis(c,e,g)}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.widget.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){if(a.cleanData){var c=a.cleanData;a.cleanData=function(b){for(var d=0,e;(e=b[d])!=null;d++)try{a(e).triggerHandler("remove")}catch(f){}c(b)}}else{var d=a.fn.remove;a.fn.remove=function(b,c){return this.each(function(){return c||(!b||a.filter(b,[this]).length)&&a("*",this).add([this]).each(function(){try{a(this).triggerHandler("remove")}catch(b){}}),d.call(a(this),b,c)})}}a.widget=function(b,c,d){var e=b.split(".")[0],f;b=b.split(".")[1],f=e+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][f]=function(c){return!!a.data(c,b)},a[e]=a[e]||{},a[e][b]=function(a,b){arguments.length&&this._createWidget(a,b)};var g=new c;g.options=a.extend(!0,{},g.options),a[e][b].prototype=a.extend(!0,g,{namespace:e,widgetName:b,widgetEventPrefix:a[e][b].prototype.widgetEventPrefix||b,widgetBaseClass:f},d),a.widget.bridge(b,a[e][b])},a.widget.bridge=function(c,d){a.fn[c]=function(e){var f=typeof e=="string",g=Array.prototype.slice.call(arguments,1),h=this;return e=!f&&g.length?a.extend.apply(null,[!0,e].concat(g)):e,f&&e.charAt(0)==="_"?h:(f?this.each(function(){var d=a.data(this,c),f=d&&a.isFunction(d[e])?d[e].apply(d,g):d;if(f!==d&&f!==b)return h=f,!1}):this.each(function(){var b=a.data(this,c);b?b.option(e||{})._init():a.data(this,c,new d(e,this))}),h)}},a.Widget=function(a,b){arguments.length&&this._createWidget(a,b)},a.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(b,c){a.data(c,this.widgetName,this),this.element=a(c),this.options=a.extend(!0,{},this.options,this._getCreateOptions(),b);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return a.metadata&&a.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+"ui-state-disabled")},widget:function(){return this.element},option:function(c,d){var e=c;if(arguments.length===0)return a.extend({},this.options);if(typeof c=="string"){if(d===b)return this.options[c];e={},e[c]=d}return this._setOptions(e),this},_setOptions:function(b){var c=this;return a.each(b,function(a,b){c._setOption(a,b)}),this},_setOption:function(a,b){return this.options[a]=b,a==="disabled"&&this.widget()[b?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+"ui-state-disabled").attr("aria-disabled",b),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(b,c,d){var e,f,g=this.options[b];d=d||{},c=a.Event(c),c.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase(),c.target=this.element[0],f=c.originalEvent;if(f)for(e in f)e in c||(c[e]=f[e]);return this.element.trigger(c,d),!(a.isFunction(g)&&g.call(this.element[0],c,d)===!1||c.isDefaultPrevented())}}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.mouse.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){var c=!1;a(document).mouseup(function(a){c=!1}),a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(a){return b._mouseDown(a)}).bind("click."+this.widgetName,function(c){if(!0===a.data(c.target,b.widgetName+".preventClickEvent"))return a.removeData(c.target,b.widgetName+".preventClickEvent"),c.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(b){if(c)return;this._mouseStarted&&this._mouseUp(b),this._mouseDownEvent=b;var d=this,e=b.which==1,f=typeof this.options.cancel=="string"&&b.target.nodeName?a(b.target).closest(this.options.cancel).length:!1;if(!e||f||!this._mouseCapture(b))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){d.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=this._mouseStart(b)!==!1;if(!this._mouseStarted)return b.preventDefault(),!0}return!0===a.data(b.target,this.widgetName+".preventClickEvent")&&a.removeData(b.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(a){return d._mouseMove(a)},this._mouseUpDelegate=function(a){return d._mouseUp(a)},a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),b.preventDefault(),c=!0,!0},_mouseMove:function(b){return!a.browser.msie||document.documentMode>=9||!!b.button?this._mouseStarted?(this._mouseDrag(b),b.preventDefault()):(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,b)!==!1,this._mouseStarted?this._mouseDrag(b):this._mouseUp(b)),!this._mouseStarted):this._mouseUp(b)},_mouseUp:function(b){return a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,b.target==this._mouseDownEvent.target&&a.data(b.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(b)),!1},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(a){return this.mouseDelayMet},_mouseStart:function(a){},_mouseDrag:function(a){},_mouseStop:function(a){},_mouseCapture:function(a){return!0}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.position.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f={},g=a.fn.position,h=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return g.apply(this,arguments);b=a.extend({},b);var h=a(b.of),i=h[0],j=(b.collision||"flip").split(" "),k=b.offset?b.offset.split(" "):[0,0],l,m,n;return i.nodeType===9?(l=h.width(),m=h.height(),n={top:0,left:0}):i.setTimeout?(l=h.width(),m=h.height(),n={top:h.scrollTop(),left:h.scrollLeft()}):i.preventDefault?(b.at="left top",l=m=0,n={top:b.of.pageY,left:b.of.pageX}):(l=h.outerWidth(),m=h.outerHeight(),n=h.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),j.length===1&&(j[1]=j[0]),k[0]=parseInt(k[0],10)||0,k.length===1&&(k[1]=k[0]),k[1]=parseInt(k[1],10)||0,b.at[0]==="right"?n.left+=l:b.at[0]===e&&(n.left+=l/2),b.at[1]==="bottom"?n.top+=m:b.at[1]===e&&(n.top+=m/2),n.left+=k[0],n.top+=k[1],this.each(function(){var c=a(this),d=c.outerWidth(),g=c.outerHeight(),h=parseInt(a.curCSS(this,"marginLeft",!0))||0,i=parseInt(a.curCSS(this,"marginTop",!0))||0,o=d+h+(parseInt(a.curCSS(this,"marginRight",!0))||0),p=g+i+(parseInt(a.curCSS(this,"marginBottom",!0))||0),q=a.extend({},n),r;b.my[0]==="right"?q.left-=d:b.my[0]===e&&(q.left-=d/2),b.my[1]==="bottom"?q.top-=g:b.my[1]===e&&(q.top-=g/2),f.fractions||(q.left=Math.round(q.left),q.top=Math.round(q.top)),r={left:q.left-h,top:q.top-i},a.each(["left","top"],function(c,e){a.ui.position[j[c]]&&a.ui.position[j[c]][e](q,{targetWidth:l,targetHeight:m,elemWidth:d,elemHeight:g,collisionPosition:r,collisionWidth:o,collisionHeight:p,offset:k,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(q,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]===e)return;var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0},top:function(b,c){if(c.at[1]===e)return;var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];return!c||!c.ownerDocument?null:b?a.isFunction(b)?this.each(function(c){a(this).offset(b.call(this,c,a(this).offset()))}):this.each(function(){a.offset.setOffset(this,b)}):h.call(this)}),a.curCSS||(a.curCSS=a.css),function(){var b=document.getElementsByTagName("body")[0],c=document.createElement("div"),d,e,g,h,i;d=document.createElement(b?"div":"body"),g={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},b&&a.extend(g,{position:"absolute",left:"-1000px",top:"-1000px"});for(var j in g)d.style[j]=g[j];d.appendChild(c),e=b||document.documentElement,e.insertBefore(d,e.firstChild),c.style.cssText="position: absolute; left: 10.7432222px; top: 10.432325px; height: 30px; width: 201px;",h=a(c).offset(function(a,b){return b}).offset(),d.innerHTML="",e.removeChild(d),i=h.top+h.left+(b?2e3:0),f.fractions=i>21&&i<22}()})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.draggable.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},destroy:function(){if(!this.element.data("draggable"))return;return this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy(),this},_mouseCapture:function(b){var c=this.options;return this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(b),this.handle?(c.iframeFix&&a(c.iframeFix===!0?"iframe":c.iframeFix).each(function(){a('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(a(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(b){var c=this.options;return this.helper=this._createHelper(b),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),a.ui.ddmanager&&(a.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt),c.containment&&this._setContainment(),this._trigger("start",b)===!1?(this._clear(),!1):(this._cacheHelperProportions(),a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this._mouseDrag(b,!0),a.ui.ddmanager&&a.ui.ddmanager.dragStart(this,b),!0)},_mouseDrag:function(b,c){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute");if(!c){var d=this._uiHash();if(this._trigger("drag",b,d)===!1)return this._mouseUp({}),!1;this.position=d.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),!1},_mouseStop:function(b){var c=!1;a.ui.ddmanager&&!this.options.dropBehaviour&&(c=a.ui.ddmanager.drop(this,b)),this.dropped&&(c=this.dropped,this.dropped=!1);var d=this.element[0],e=!1;while(d&&(d=d.parentNode))d==document&&(e=!0);if(!e&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!c||this.options.revert=="valid"&&c||this.options.revert===!0||a.isFunction(this.options.revert)&&this.options.revert.call(this.element,c)){var f=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){f._trigger("stop",b)!==!1&&f._clear()})}else this._trigger("stop",b)!==!1&&this._clear();return!1},_mouseUp:function(b){return this.options.iframeFix===!0&&a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),a.ui.ddmanager&&a.ui.ddmanager.dragStop(this,b),a.ui.mouse.prototype._mouseUp.call(this,b)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(b){var c=!this.options.handle||!a(this.options.handle,this.element).length?!0:!1;return a(this.options.handle,this.element).find("*").andSelf().each(function(){this==b.target&&(c=!0)}),c},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b])):c.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return d.parents("body").length||d.appendTo(c.appendTo=="parent"?this.element[0].parentNode:c.appendTo),d[0]!=this.element[0]&&!/(fixed|absolute)/.test(d.css("position"))&&d.css("position","absolute"),d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[b.containment=="document"?0:a(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,b.containment=="document"?0:a(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(b.containment=="document"?0:a(window).scrollLeft())+a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b.containment=="document"?0:a(window).scrollTop())+(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)&&b.containment.constructor!=Array){var c=a(b.containment),d=c[0];if(!d)return;var e=c.offset(),f=a(d).css("overflow")!="hidden";this.containment=[(parseInt(a(d).css("borderLeftWidth"),10)||0)+(parseInt(a(d).css("paddingLeft"),10)||0),(parseInt(a(d).css("borderTopWidth"),10)||0)+(parseInt(a(d).css("paddingTop"),10)||0),(f?Math.max(d.scrollWidth,d.offsetWidth):d.offsetWidth)-(parseInt(a(d).css("borderLeftWidth"),10)||0)-(parseInt(a(d).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(f?Math.max(d.scrollHeight,d.offsetHeight):d.offsetHeight)-(parseInt(a(d).css("borderTopWidth"),10)||0)-(parseInt(a(d).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=c}else b.containment.constructor==Array&&(this.containment=b.containment)},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName),f=b.pageX,g=b.pageY;if(this.originalPosition){var h;if(this.containment){if(this.relative_container){var i=this.relative_container.offset();h=[this.containment[0]+i.left,this.containment[1]+i.top,this.containment[2]+i.left,this.containment[3]+i.top]}else h=this.containment;b.pageX-this.offset.click.left<h[0]&&(f=h[0]+this.offset.click.left),b.pageY-this.offset.click.top<h[1]&&(g=h[1]+this.offset.click.top),b.pageX-this.offset.click.left>h[2]&&(f=h[2]+this.offset.click.left),b.pageY-this.offset.click.top>h[3]&&(g=h[3]+this.offset.click.top)}if(c.grid){var j=c.grid[1]?this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1]:this.originalPageY;g=h?j-this.offset.click.top<h[1]||j-this.offset.click.top>h[3]?j-this.offset.click.top<h[1]?j+c.grid[1]:j-c.grid[1]:j:j;var k=c.grid[0]?this.originalPageX+Math.round((f-this.originalPageX)/c.grid[0])*c.grid[0]:this.originalPageX;f=h?k-this.offset.click.left<h[0]||k-this.offset.click.left>h[2]?k-this.offset.click.left<h[0]?k+c.grid[0]:k-c.grid[0]:k:k}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:d.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(b,c,d){return d=d||this._uiHash(),a.ui.plugin.call(this,b,[c,d]),b=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),a.Widget.prototype._trigger.call(this,b,c,d)},plugins:{},_uiHash:function(a){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),a.extend(a.ui.draggable,{version:"1.8.23"}),a.ui.plugin.add("draggable","connectToSortable",{start:function(b,c){var d=a(this).data("draggable"),e=d.options,f=a.extend({},c,{item:d.element});d.sortables=[],a(e.connectToSortable).each(function(){var c=a.data(this,"sortable");c&&!c.options.disabled&&(d.sortables.push({instance:c,shouldRevert:c.options.revert}),c.refreshPositions(),c._trigger("activate",b,f))})},stop:function(b,c){var d=a(this).data("draggable"),e=a.extend({},c,{item:d.element});a.each(d.sortables,function(){this.instance.isOver?(this.instance.isOver=0,d.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(b),this.instance.options.helper=this.instance.options._helper,d.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",b,e))})},drag:function(b,c){var d=a(this).data("draggable"),e=this,f=function(b){var c=this.offset.click.top,d=this.offset.click.left,e=this.positionAbs.top,f=this.positionAbs.left,g=b.height,h=b.width,i=b.top,j=b.left;return a.ui.isOver(e+c,f+d,i,j,g,h)};a.each(d.sortables,function(f){this.instance.positionAbs=d.positionAbs,this.instance.helperProportions=d.helperProportions,this.instance.offset.click=d.offset.click,this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=a(e).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return c.helper[0]},b.target=this.instance.currentItem[0],this.instance._mouseCapture(b,!0),this.instance._mouseStart(b,!0,!0),this.instance.offset.click.top=d.offset.click.top,this.instance.offset.click.left=d.offset.click.left,this.instance.offset.parent.left-=d.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=d.offset.parent.top-this.instance.offset.parent.top,d._trigger("toSortable",b),d.dropped=this.instance.element,d.currentItem=d.element,this.instance.fromOutside=d),this.instance.currentItem&&this.instance._mouseDrag(b)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",b,this.instance._uiHash(this.instance)),this.instance._mouseStop(b,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),d._trigger("fromSortable",b),d.dropped=!1)})}}),a.ui.plugin.add("draggable","cursor",{start:function(b,c){var d=a("body"),e=a(this).data("draggable").options;d.css("cursor")&&(e._cursor=d.css("cursor")),d.css("cursor",e.cursor)},stop:function(b,c){var d=a(this).data("draggable").options;d._cursor&&a("body").css("cursor",d._cursor)}}),a.ui.plugin.add("draggable","opacity",{start:function(b,c){var d=a(c.helper),e=a(this).data("draggable").options;d.css("opacity")&&(e._opacity=d.css("opacity")),d.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("draggable").options;d._opacity&&a(c.helper).css("opacity",d._opacity)}}),a.ui.plugin.add("draggable","scroll",{start:function(b,c){var d=a(this).data("draggable");d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"&&(d.overflowOffset=d.scrollParent.offset())},drag:function(b,c){var d=a(this).data("draggable"),e=d.options,f=!1;if(d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"){if(!e.axis||e.axis!="x")d.overflowOffset.top+d.scrollParent[0].offsetHeight-b.pageY<e.scrollSensitivity?d.scrollParent[0].scrollTop=f=d.scrollParent[0].scrollTop+e.scrollSpeed:b.pageY-d.overflowOffset.top<e.scrollSensitivity&&(d.scrollParent[0].scrollTop=f=d.scrollParent[0].scrollTop-e.scrollSpeed);if(!e.axis||e.axis!="y")d.overflowOffset.left+d.scrollParent[0].offsetWidth-b.pageX<e.scrollSensitivity?d.scrollParent[0].scrollLeft=f=d.scrollParent[0].scrollLeft+e.scrollSpeed:b.pageX-d.overflowOffset.left<e.scrollSensitivity&&(d.scrollParent[0].scrollLeft=f=d.scrollParent[0].scrollLeft-e.scrollSpeed)}else{if(!e.axis||e.axis!="x")b.pageY-a(document).scrollTop()<e.scrollSensitivity?f=a(document).scrollTop(a(document).scrollTop()-e.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<e.scrollSensitivity&&(f=a(document).scrollTop(a(document).scrollTop()+e.scrollSpeed));if(!e.axis||e.axis!="y")b.pageX-a(document).scrollLeft()<e.scrollSensitivity?f=a(document).scrollLeft(a(document).scrollLeft()-e.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<e.scrollSensitivity&&(f=a(document).scrollLeft(a(document).scrollLeft()+e.scrollSpeed))}f!==!1&&a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(d,b)}}),a.ui.plugin.add("draggable","snap",{start:function(b,c){var d=a(this).data("draggable"),e=d.options;d.snapElements=[],a(e.snap.constructor!=String?e.snap.items||":data(draggable)":e.snap).each(function(){var b=a(this),c=b.offset();this!=d.element[0]&&d.snapElements.push({item:this,width:b.outerWidth(),height:b.outerHeight(),top:c.top,left:c.left})})},drag:function(b,c){var d=a(this).data("draggable"),e=d.options,f=e.snapTolerance,g=c.offset.left,h=g+d.helperProportions.width,i=c.offset.top,j=i+d.helperProportions.height;for(var k=d.snapElements.length-1;k>=0;k--){var l=d.snapElements[k].left,m=l+d.snapElements[k].width,n=d.snapElements[k].top,o=n+d.snapElements[k].height;if(!(l-f<g&&g<m+f&&n-f<i&&i<o+f||l-f<g&&g<m+f&&n-f<j&&j<o+f||l-f<h&&h<m+f&&n-f<i&&i<o+f||l-f<h&&h<m+f&&n-f<j&&j<o+f)){d.snapElements[k].snapping&&d.options.snap.release&&d.options.snap.release.call(d.element,b,a.extend(d._uiHash(),{snapItem:d.snapElements[k].item})),d.snapElements[k].snapping=!1;continue}if(e.snapMode!="inner"){var p=Math.abs(n-j)<=f,q=Math.abs(o-i)<=f,r=Math.abs(l-h)<=f,s=Math.abs(m-g)<=f;p&&(c.position.top=d._convertPositionTo("relative",{top:n-d.helperProportions.height,left:0}).top-d.margins.top),q&&(c.position.top=d._convertPositionTo("relative",{top:o,left:0}).top-d.margins.top),r&&(c.position.left=d._convertPositionTo("relative",{top:0,left:l-d.helperProportions.width}).left-d.margins.left),s&&(c.position.left=d._convertPositionTo("relative",{top:0,left:m}).left-d.margins.left)}var t=p||q||r||s;if(e.snapMode!="outer"){var p=Math.abs(n-i)<=f,q=Math.abs(o-j)<=f,r=Math.abs(l-g)<=f,s=Math.abs(m-h)<=f;p&&(c.position.top=d._convertPositionTo("relative",{top:n,left:0}).top-d.margins.top),q&&(c.position.top=d._convertPositionTo("relative",{top:o-d.helperProportions.height,left:0}).top-d.margins.top),r&&(c.position.left=d._convertPositionTo("relative",{top:0,left:l}).left-d.margins.left),s&&(c.position.left=d._convertPositionTo("relative",{top:0,left:m-d.helperProportions.width}).left-d.margins.left)}!d.snapElements[k].snapping&&(p||q||r||s||t)&&d.options.snap.snap&&d.options.snap.snap.call(d.element,b,a.extend(d._uiHash(),{snapItem:d.snapElements[k].item})),d.snapElements[k].snapping=p||q||r||s||t}}}),a.ui.plugin.add("draggable","stack",{start:function(b,c){var d=a(this).data("draggable").options,e=a.makeArray(a(d.stack)).sort(function(b,c){return(parseInt(a(b).css("zIndex"),10)||0)-(parseInt(a(c).css("zIndex"),10)||0)});if(!e.length)return;var f=parseInt(e[0].style.zIndex)||0;a(e).each(function(a){this.style.zIndex=f+a}),this[0].style.zIndex=f+e.length}}),a.ui.plugin.add("draggable","zIndex",{start:function(b,c){var d=a(c.helper),e=a(this).data("draggable").options;d.css("zIndex")&&(e._zIndex=d.css("zIndex")),d.css("zIndex",e.zIndex)},stop:function(b,c){var d=a(this).data("draggable").options;d._zIndex&&a(c.helper).css("zIndex",d._zIndex)}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.droppable.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var b=this.options,c=b.accept;this.isover=0,this.isout=1,this.accept=a.isFunction(c)?c:function(a){return a.is(c)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},a.ui.ddmanager.droppables[b.scope]=a.ui.ddmanager.droppables[b.scope]||[],a.ui.ddmanager.droppables[b.scope].push(this),b.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){var b=a.ui.ddmanager.droppables[this.options.scope];for(var c=0;c<b.length;c++)b[c]==this&&b.splice(c,1);return this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable"),this},_setOption:function(b,c){b=="accept"&&(this.accept=a.isFunction(c)?c:function(a){return a.is(c)}),a.Widget.prototype._setOption.apply(this,arguments)},_activate:function(b){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),c&&this._trigger("activate",b,this.ui(c))},_deactivate:function(b){var c=a.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),c&&this._trigger("deactivate",b,this.ui(c))},_over:function(b){var c=a.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return;this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",b,this.ui(c)))},_out:function(b){var c=a.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return;this.accept.call(this.element[0],c.currentItem||c.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",b,this.ui(c)))},_drop:function(b,c){var d=c||a.ui.ddmanager.current;if(!d||(d.currentItem||d.element)[0]==this.element[0])return!1;var e=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var b=a.data(this,"droppable");if(b.options.greedy&&!b.options.disabled&&b.options.scope==d.options.scope&&b.accept.call(b.element[0],d.currentItem||d.element)&&a.ui.intersect(d,a.extend(b,{offset:b.element.offset()}),b.options.tolerance))return e=!0,!1}),e?!1:this.accept.call(this.element[0],d.currentItem||d.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",b,this.ui(d)),this.element):!1},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}}),a.extend(a.ui.droppable,{version:"1.8.23"}),a.ui.intersect=function(b,c,d){if(!c.offset)return!1;var e=(b.positionAbs||b.position.absolute).left,f=e+b.helperProportions.width,g=(b.positionAbs||b.position.absolute).top,h=g+b.helperProportions.height,i=c.offset.left,j=i+c.proportions.width,k=c.offset.top,l=k+c.proportions.height;switch(d){case"fit":return i<=e&&f<=j&&k<=g&&h<=l;case"intersect":return i<e+b.helperProportions.width/2&&f-b.helperProportions.width/2<j&&k<g+b.helperProportions.height/2&&h-b.helperProportions.height/2<l;case"pointer":var m=(b.positionAbs||b.position.absolute).left+(b.clickOffset||b.offset.click).left,n=(b.positionAbs||b.position.absolute).top+(b.clickOffset||b.offset.click).top,o=a.ui.isOver(n,m,k,i,c.proportions.height,c.proportions.width);return o;case"touch":return(g>=k&&g<=l||h>=k&&h<=l||g<k&&h>l)&&(e>=i&&e<=j||f>=i&&f<=j||e<i&&f>j);default:return!1}},a.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(b,c){var d=a.ui.ddmanager.droppables[b.options.scope]||[],e=c?c.type:null,f=(b.currentItem||b.element).find(":data(droppable)").andSelf();g:for(var h=0;h<d.length;h++){if(d[h].options.disabled||b&&!d[h].accept.call(d[h].element[0],b.currentItem||b.element))continue;for(var i=0;i<f.length;i++)if(f[i]==d[h].element[0]){d[h].proportions.height=0;continue g}d[h].visible=d[h].element.css("display")!="none";if(!d[h].visible)continue;e=="mousedown"&&d[h]._activate.call(d[h],c),d[h].offset=d[h].element.offset(),d[h].proportions={width:d[h].element[0].offsetWidth,height:d[h].element[0].offsetHeight}}},drop:function(b,c){var d=!1;return a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&a.ui.intersect(b,this,this.options.tolerance)&&(d=this._drop.call(this,c)||d),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],b.currentItem||b.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,c))}),d},dragStart:function(b,c){b.element.parents(":not(body,html)").bind("scroll.droppable",function(){b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)})},drag:function(b,c){b.options.refreshPositions&&a.ui.ddmanager.prepareOffsets(b,c),a.each(a.ui.ddmanager.droppables[b.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var d=a.ui.intersect(b,this,this.options.tolerance),e=!d&&this.isover==1?"isout":d&&this.isover==0?"isover":null;if(!e)return;var f;if(this.options.greedy){var g=this.element.parents(":data(droppable):eq(0)");g.length&&(f=a.data(g[0],"droppable"),f.greedyChild=e=="isover"?1:0)}f&&e=="isover"&&(f.isover=0,f.isout=1,f._out.call(f,c)),this[e]=1,this[e=="isout"?"isover":"isout"]=0,this[e=="isover"?"_over":"_out"].call(this,c),f&&e=="isout"&&(f.isout=0,f.isover=1,f._over.call(f,c))})},dragStop:function(b,c){b.element.parents(":not(body,html)").unbind("scroll.droppable"),b.options.refreshPositions||a.ui.ddmanager.prepareOffsets(b,c)}}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.resizable.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.resizable",a.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var b=this,c=this.options;this.element.addClass("ui-resizable"),a.extend(this,{_aspectRatio:!!c.aspectRatio,aspectRatio:c.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:c.helper||c.ghost||c.animate?c.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(a('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=c.handles||(a(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var d=this.handles.split(",");this.handles={};for(var e=0;e<d.length;e++){var f=a.trim(d[e]),g="ui-resizable-"+f,h=a('<div class="ui-resizable-handle '+g+'"></div>');h.css({zIndex:c.zIndex}),"se"==f&&h.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[f]=".ui-resizable-"+f,this.element.append(h)}}this._renderAxis=function(b){b=b||this.element;for(var c in this.handles){this.handles[c].constructor==String&&(this.handles[c]=a(this.handles[c],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var d=a(this.handles[c],this.element),e=0;e=/sw|ne|nw|se|n|s/.test(c)?d.outerHeight():d.outerWidth();var f=["padding",/ne|nw|n/.test(c)?"Top":/se|sw|s/.test(c)?"Bottom":/^e$/.test(c)?"Right":"Left"].join("");b.css(f,e),this._proportionallyResize()}if(!a(this.handles[c]).length)continue}},this._renderAxis(this.element),this._handles=a(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!b.resizing){if(this.className)var a=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=a&&a[1]?a[1]:"se"}}),c.autoHide&&(this._handles.hide(),a(this.element).addClass("ui-resizable-autohide").hover(function(){if(c.disabled)return;a(this).removeClass("ui-resizable-autohide"),b._handles.show()},function(){if(c.disabled)return;b.resizing||(a(this).addClass("ui-resizable-autohide"),b._handles.hide())})),this._mouseInit()},destroy:function(){this._mouseDestroy();var b=function(b){a(b).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var c=this.element;c.after(this.originalElement.css({position:c.css("position"),width:c.outerWidth(),height:c.outerHeight(),top:c.css("top"),left:c.css("left")})).remove()}return this.originalElement.css("resize",this.originalResizeStyle),b(this.originalElement),this},_mouseCapture:function(b){var c=!1;for(var d in this.handles)a(this.handles[d])[0]==b.target&&(c=!0);return!this.options.disabled&&c},_mouseStart:function(b){var d=this.options,e=this.element.position(),f=this.element;this.resizing=!0,this.documentScroll={top:a(document).scrollTop(),left:a(document).scrollLeft()},(f.is(".ui-draggable")||/absolute/.test(f.css("position")))&&f.css({position:"absolute",top:e.top,left:e.left}),this._renderProxy();var g=c(this.helper.css("left")),h=c(this.helper.css("top"));d.containment&&(g+=a(d.containment).scrollLeft()||0,h+=a(d.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:g,top:h},this.size=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalSize=this._helper?{width:f.outerWidth(),height:f.outerHeight()}:{width:f.width(),height:f.height()},this.originalPosition={left:g,top:h},this.sizeDiff={width:f.outerWidth()-f.width(),height:f.outerHeight()-f.height()},this.originalMousePosition={left:b.pageX,top:b.pageY},this.aspectRatio=typeof d.aspectRatio=="number"?d.aspectRatio:this.originalSize.width/this.originalSize.height||1;var i=a(".ui-resizable-"+this.axis).css("cursor");return a("body").css("cursor",i=="auto"?this.axis+"-resize":i),f.addClass("ui-resizable-resizing"),this._propagate("start",b),!0},_mouseDrag:function(b){var c=this.helper,d=this.options,e={},f=this,g=this.originalMousePosition,h=this.axis,i=b.pageX-g.left||0,j=b.pageY-g.top||0,k=this._change[h];if(!k)return!1;var l=k.apply(this,[b,i,j]),m=a.browser.msie&&a.browser.version<7,n=this.sizeDiff;this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)l=this._updateRatio(l,b);return l=this._respectSize(l,b),this._propagate("resize",b),c.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",b,this.ui()),!1},_mouseStop:function(b){this.resizing=!1;var c=this.options,d=this;if(this._helper){var e=this._proportionallyResizeElements,f=e.length&&/textarea/i.test(e[0].nodeName),g=f&&a.ui.hasScroll(e[0],"left")?0:d.sizeDiff.height,h=f?0:d.sizeDiff.width,i={width:d.helper.width()-h,height:d.helper.height()-g},j=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,k=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;c.animate||this.element.css(a.extend(i,{top:k,left:j})),d.helper.height(d.size.height),d.helper.width(d.size.width),this._helper&&!c.animate&&this._proportionallyResize()}return a("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",b),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(a){var b=this.options,c,e,f,g,h;h={minWidth:d(b.minWidth)?b.minWidth:0,maxWidth:d(b.maxWidth)?b.maxWidth:Infinity,minHeight:d(b.minHeight)?b.minHeight:0,maxHeight:d(b.maxHeight)?b.maxHeight:Infinity};if(this._aspectRatio||a)c=h.minHeight*this.aspectRatio,f=h.minWidth/this.aspectRatio,e=h.maxHeight*this.aspectRatio,g=h.maxWidth/this.aspectRatio,c>h.minWidth&&(h.minWidth=c),f>h.minHeight&&(h.minHeight=f),e<h.maxWidth&&(h.maxWidth=e),g<h.maxHeight&&(h.maxHeight=g);this._vBoundaries=h},_updateCache:function(a){var b=this.options;this.offset=this.helper.offset(),d(a.left)&&(this.position.left=a.left),d(a.top)&&(this.position.top=a.top),d(a.height)&&(this.size.height=a.height),d(a.width)&&(this.size.width=a.width)},_updateRatio:function(a,b){var c=this.options,e=this.position,f=this.size,g=this.axis;return d(a.height)?a.width=a.height*this.aspectRatio:d(a.width)&&(a.height=a.width/this.aspectRatio),g=="sw"&&(a.left=e.left+(f.width-a.width),a.top=null),g=="nw"&&(a.top=e.top+(f.height-a.height),a.left=e.left+(f.width-a.width)),a},_respectSize:function(a,b){var c=this.helper,e=this._vBoundaries,f=this._aspectRatio||b.shiftKey,g=this.axis,h=d(a.width)&&e.maxWidth&&e.maxWidth<a.width,i=d(a.height)&&e.maxHeight&&e.maxHeight<a.height,j=d(a.width)&&e.minWidth&&e.minWidth>a.width,k=d(a.height)&&e.minHeight&&e.minHeight>a.height;j&&(a.width=e.minWidth),k&&(a.height=e.minHeight),h&&(a.width=e.maxWidth),i&&(a.height=e.maxHeight);var l=this.originalPosition.left+this.originalSize.width,m=this.position.top+this.size.height,n=/sw|nw|w/.test(g),o=/nw|ne|n/.test(g);j&&n&&(a.left=l-e.minWidth),h&&n&&(a.left=l-e.maxWidth),k&&o&&(a.top=m-e.minHeight),i&&o&&(a.top=m-e.maxHeight);var p=!a.width&&!a.height;return p&&!a.left&&a.top?a.top=null:p&&!a.top&&a.left&&(a.left=null),a},_proportionallyResize:function(){var b=this.options;if(!this._proportionallyResizeElements.length)return;var c=this.helper||this.element;for(var d=0;d<this._proportionallyResizeElements.length;d++){var e=this._proportionallyResizeElements[d];if(!this.borderDif){var f=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],g=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];this.borderDif=a.map(f,function(a,b){var c=parseInt(a,10)||0,d=parseInt(g[b],10)||0;return c+d})}if(!a.browser.msie||!a(c).is(":hidden")&&!a(c).parents(":hidden").length)e.css({height:c.height()-this.borderDif[0]-this.borderDif[2]||0,width:c.width()-this.borderDif[1]-this.borderDif[3]||0});else continue}},_renderProxy:function(){var b=this.element,c=this.options;this.elementOffset=b.offset();if(this._helper){this.helper=this.helper||a('<div style="overflow:hidden;"></div>');var d=a.browser.msie&&a.browser.version<7,e=d?1:0,f=d?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+f,height:this.element.outerHeight()+f,position:"absolute",left:this.elementOffset.left-e+"px",top:this.elementOffset.top-e+"px",zIndex:++c.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(a,b,c){return{width:this.originalSize.width+b}},w:function(a,b,c){var d=this.options,e=this.originalSize,f=this.originalPosition;return{left:f.left+b,width:e.width-b}},n:function(a,b,c){var d=this.options,e=this.originalSize,f=this.originalPosition;return{top:f.top+c,height:e.height-c}},s:function(a,b,c){return{height:this.originalSize.height+c}},se:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},sw:function(b,c,d){return a.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,c,d]))},ne:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,c,d]))},nw:function(b,c,d){return a.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,c,d]))}},_propagate:function(b,c){a.ui.plugin.call(this,b,[c,this.ui()]),b!="resize"&&this._trigger(b,c,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),a.extend(a.ui.resizable,{version:"1.8.23"}),a.ui.plugin.add("resizable","alsoResize",{start:function(b,c){var d=a(this).data("resizable"),e=d.options,f=function(b){a(b).each(function(){var b=a(this);b.data("resizable-alsoresize",{width:parseInt(b.width(),10),height:parseInt(b.height(),10),left:parseInt(b.css("left"),10),top:parseInt(b.css("top"),10)})})};typeof e.alsoResize=="object"&&!e.alsoResize.parentNode?e.alsoResize.length?(e.alsoResize=e.alsoResize[0],f(e.alsoResize)):a.each(e.alsoResize,function(a){f(a)}):f(e.alsoResize)},resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.originalSize,g=d.originalPosition,h={height:d.size.height-f.height||0,width:d.size.width-f.width||0,top:d.position.top-g.top||0,left:d.position.left-g.left||0},i=function(b,d){a(b).each(function(){var b=a(this),e=a(this).data("resizable-alsoresize"),f={},g=d&&d.length?d:b.parents(c.originalElement[0]).length?["width","height"]:["width","height","top","left"];a.each(g,function(a,b){var c=(e[b]||0)+(h[b]||0);c&&c>=0&&(f[b]=c||null)}),b.css(f)})};typeof e.alsoResize=="object"&&!e.alsoResize.nodeType?a.each(e.alsoResize,function(a,b){i(a,b)}):i(e.alsoResize)},stop:function(b,c){a(this).removeData("resizable-alsoresize")}}),a.ui.plugin.add("resizable","animate",{stop:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d._proportionallyResizeElements,g=f.length&&/textarea/i.test(f[0].nodeName),h=g&&a.ui.hasScroll(f[0],"left")?0:d.sizeDiff.height,i=g?0:d.sizeDiff.width,j={width:d.size.width-i,height:d.size.height-h},k=parseInt(d.element.css("left"),10)+(d.position.left-d.originalPosition.left)||null,l=parseInt(d.element.css("top"),10)+(d.position.top-d.originalPosition.top)||null;d.element.animate(a.extend(j,l&&k?{top:l,left:k}:{}),{duration:e.animateDuration,easing:e.animateEasing,step:function(){var c={width:parseInt(d.element.css("width"),10),height:parseInt(d.element.css("height"),10),top:parseInt(d.element.css("top"),10),left:parseInt(d.element.css("left"),10)};f&&f.length&&a(f[0]).css({width:c.width,height:c.height}),d._updateCache(c),d._propagate("resize",b)}})}}),a.ui.plugin.add("resizable","containment",{start:function(b,d){var e=a(this).data("resizable"),f=e.options,g=e.element,h=f.containment,i=h instanceof a?h.get(0):/parent/.test(h)?g.parent().get(0):h;if(!i)return;e.containerElement=a(i);if(/document/.test(h)||h==document)e.containerOffset={left:0,top:0},e.containerPosition={left:0,top:0},e.parentData={element:a(document),left:0,top:0,width:a(document).width(),height:a(document).height()||document.body.parentNode.scrollHeight};else{var j=a(i),k=[];a(["Top","Right","Left","Bottom"]).each(function(a,b){k[a]=c(j.css("padding"+b))}),e.containerOffset=j.offset(),e.containerPosition=j.position(),e.containerSize={height:j.innerHeight()-k[3],width:j.innerWidth()-k[1]};var l=e.containerOffset,m=e.containerSize.height,n=e.containerSize.width,o=a.ui.hasScroll(i,"left")?i.scrollWidth:n,p=a.ui.hasScroll(i)?i.scrollHeight:m;e.parentData={element:i,left:l.left,top:l.top,width:o,height:p}}},resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.containerSize,g=d.containerOffset,h=d.size,i=d.position,j=d._aspectRatio||b.shiftKey,k={top:0,left:0},l=d.containerElement;l[0]!=document&&/static/.test(l.css("position"))&&(k=g),i.left<(d._helper?g.left:0)&&(d.size.width=d.size.width+(d._helper?d.position.left-g.left:d.position.left-k.left),j&&(d.size.height=d.size.width/d.aspectRatio),d.position.left=e.helper?g.left:0),i.top<(d._helper?g.top:0)&&(d.size.height=d.size.height+(d._helper?d.position.top-g.top:d.position.top),j&&(d.size.width=d.size.height*d.aspectRatio),d.position.top=d._helper?g.top:0),d.offset.left=d.parentData.left+d.position.left,d.offset.top=d.parentData.top+d.position.top;var m=Math.abs((d._helper?d.offset.left-k.left:d.offset.left-k.left)+d.sizeDiff.width),n=Math.abs((d._helper?d.offset.top-k.top:d.offset.top-g.top)+d.sizeDiff.height),o=d.containerElement.get(0)==d.element.parent().get(0),p=/relative|absolute/.test(d.containerElement.css("position"));o&&p&&(m-=d.parentData.left),m+d.size.width>=d.parentData.width&&(d.size.width=d.parentData.width-m,j&&(d.size.height=d.size.width/d.aspectRatio)),n+d.size.height>=d.parentData.height&&(d.size.height=d.parentData.height-n,j&&(d.size.width=d.size.height*d.aspectRatio))},stop:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.position,g=d.containerOffset,h=d.containerPosition,i=d.containerElement,j=a(d.helper),k=j.offset(),l=j.outerWidth()-d.sizeDiff.width,m=j.outerHeight()-d.sizeDiff.height;d._helper&&!e.animate&&/relative/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m}),d._helper&&!e.animate&&/static/.test(i.css("position"))&&a(this).css({left:k.left-h.left-g.left,width:l,height:m})}}),a.ui.plugin.add("resizable","ghost",{start:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.size;d.ghost=d.originalElement.clone(),d.ghost.css({opacity:.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof e.ghost=="string"?e.ghost:""),d.ghost.appendTo(d.helper)},resize:function(b,c){var d=a(this).data("resizable"),e=d.options;d.ghost&&d.ghost.css({position:"relative",height:d.size.height,width:d.size.width})},stop:function(b,c){var d=a(this).data("resizable"),e=d.options;d.ghost&&d.helper&&d.helper.get(0).removeChild(d.ghost.get(0))}}),a.ui.plugin.add("resizable","grid",{resize:function(b,c){var d=a(this).data("resizable"),e=d.options,f=d.size,g=d.originalSize,h=d.originalPosition,i=d.axis,j=e._aspectRatio||b.shiftKey;e.grid=typeof e.grid=="number"?[e.grid,e.grid]:e.grid;var k=Math.round((f.width-g.width)/(e.grid[0]||1))*(e.grid[0]||1),l=Math.round((f.height-g.height)/(e.grid[1]||1))*(e.grid[1]||1);/^(se|s|e)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l):/^(ne)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l):/^(sw)$/.test(i)?(d.size.width=g.width+k,d.size.height=g.height+l,d.position.left=h.left-k):(d.size.width=g.width+k,d.size.height=g.height+l,d.position.top=h.top-l,d.position.left=h.left-k)}});var c=function(a){return parseInt(a,10)||0},d=function(a){return!isNaN(parseInt(a,10))}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.selectable.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.selectable",a.ui.mouse,{options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var b=this;this.element.addClass("ui-selectable"),this.dragged=!1;var c;this.refresh=function(){c=a(b.options.filter,b.element[0]),c.addClass("ui-selectee"),c.each(function(){var b=a(this),c=b.offset();a.data(this,"selectable-item",{element:this,$element:b,left:c.left,top:c.top,right:c.left+b.outerWidth(),bottom:c.top+b.outerHeight(),startselected:!1,selected:b.hasClass("ui-selected"),selecting:b.hasClass("ui-selecting"),unselecting:b.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=c.addClass("ui-selectee"),this._mouseInit(),this.helper=a("<div class='ui-selectable-helper'></div>")},destroy:function(){return this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable"),this._mouseDestroy(),this},_mouseStart:function(b){var c=this;this.opos=[b.pageX,b.pageY];if(this.options.disabled)return;var d=this.options;this.selectees=a(d.filter,this.element[0]),this._trigger("start",b),a(d.appendTo).append(this.helper),this.helper.css({left:b.clientX,top:b.clientY,width:0,height:0}),d.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var d=a.data(this,"selectable-item");d.startselected=!0,!b.metaKey&&!b.ctrlKey&&(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",b,{unselecting:d.element}))}),a(b.target).parents().andSelf().each(function(){var d=a.data(this,"selectable-item");if(d){var e=!b.metaKey&&!b.ctrlKey||!d.$element.hasClass("ui-selected");return d.$element.removeClass(e?"ui-unselecting":"ui-selected").addClass(e?"ui-selecting":"ui-unselecting"),d.unselecting=!e,d.selecting=e,d.selected=e,e?c._trigger("selecting",b,{selecting:d.element}):c._trigger("unselecting",b,{unselecting:d.element}),!1}})},_mouseDrag:function(b){var c=this;this.dragged=!0;if(this.options.disabled)return;var d=this.options,e=this.opos[0],f=this.opos[1],g=b.pageX,h=b.pageY;if(e>g){var i=g;g=e,e=i}if(f>h){var i=h;h=f,f=i}return this.helper.css({left:e,top:f,width:g-e,height:h-f}),this.selectees.each(function(){var i=a.data(this,"selectable-item");if(!i||i.element==c.element[0])return;var j=!1;d.tolerance=="touch"?j=!(i.left>g||i.right<e||i.top>h||i.bottom<f):d.tolerance=="fit"&&(j=i.left>e&&i.right<g&&i.top>f&&i.bottom<h),j?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,c._trigger("selecting",b,{selecting:i.element}))):(i.selecting&&((b.metaKey||b.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),c._trigger("unselecting",b,{unselecting:i.element}))),i.selected&&!b.metaKey&&!b.ctrlKey&&!i.startselected&&(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,c._trigger("unselecting",b,{unselecting:i.element})))}),!1},_mouseStop:function(b){var c=this;this.dragged=!1;var d=this.options;return a(".ui-unselecting",this.element[0]).each(function(){var d=a.data(this,"selectable-item");d.$element.removeClass("ui-unselecting"),d.unselecting=!1,d.startselected=!1,c._trigger("unselected",b,{unselected:d.element})}),a(".ui-selecting",this.element[0]).each(function(){var d=a.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass("ui-selected"),d.selecting=!1,d.selected=!0,d.startselected=!0,c._trigger("selected",b,{selected:d.element})}),this._trigger("stop",b),this.helper.remove(),!1}}),a.extend(a.ui.selectable,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.sortable.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.sortable",a.ui.mouse,{widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},destroy:function(){a.Widget.prototype.destroy.call(this),this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var b=this.items.length-1;b>=0;b--)this.items[b].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){b==="disabled"?(this.options[b]=c,this.widget()[c?"addClass":"removeClass"]("ui-sortable-disabled")):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(b);var e=null,f=this,g=a(b.target).parents().each(function(){if(a.data(this,d.widgetName+"-item")==f)return e=a(this),!1});a.data(b.target,d.widgetName+"-item")==f&&(e=a(b.target));if(!e)return!1;if(this.options.handle&&!c){var h=!1;a(this.options.handle,e).find("*").andSelf().each(function(){this==b.target&&(h=!0)});if(!h)return!1}return this.currentItem=e,this._removeCurrentsFromItems(),!0},_mouseStart:function(b,c,d){var e=this.options,f=this;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,e.cursorAt&&this._adjustOffsetFromHelper(e.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),e.containment&&this._setContainment(),e.cursor&&(a("body").css("cursor")&&(this._storedCursor=a("body").css("cursor")),a("body").css("cursor",e.cursor)),e.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",e.opacity)),e.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",e.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!d)for(var g=this.containers.length-1;g>=0;g--)this.containers[g]._trigger("activate",b,f._uiHash(this));return a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!e.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b),!0},_mouseDrag:function(b){this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var c=this.options,d=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY<c.scrollSensitivity?this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop+c.scrollSpeed:b.pageY-this.overflowOffset.top<c.scrollSensitivity&&(this.scrollParent[0].scrollTop=d=this.scrollParent[0].scrollTop-c.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-b.pageX<c.scrollSensitivity?this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft+c.scrollSpeed:b.pageX-this.overflowOffset.left<c.scrollSensitivity&&(this.scrollParent[0].scrollLeft=d=this.scrollParent[0].scrollLeft-c.scrollSpeed)):(b.pageY-a(document).scrollTop()<c.scrollSensitivity?d=a(document).scrollTop(a(document).scrollTop()-c.scrollSpeed):a(window).height()-(b.pageY-a(document).scrollTop())<c.scrollSensitivity&&(d=a(document).scrollTop(a(document).scrollTop()+c.scrollSpeed)),b.pageX-a(document).scrollLeft()<c.scrollSensitivity?d=a(document).scrollLeft(a(document).scrollLeft()-c.scrollSpeed):a(window).width()-(b.pageX-a(document).scrollLeft())<c.scrollSensitivity&&(d=a(document).scrollLeft(a(document).scrollLeft()+c.scrollSpeed))),d!==!1&&a.ui.ddmanager&&!c.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(var e=this.items.length-1;e>=0;e--){var f=this.items[e],g=f.item[0],h=this._intersectsWithPointer(f);if(!h)continue;if(g!=this.currentItem[0]&&this.placeholder[h==1?"next":"prev"]()[0]!=g&&!a.ui.contains(this.placeholder[0],g)&&(this.options.type=="semi-dynamic"?!a.ui.contains(this.element[0],g):!0)){this.direction=h==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(f))this._rearrange(b,f);else break;this._trigger("change",b,this._uiHash());break}}return this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(b,c){if(!b)return;a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b);if(this.options.revert){var d=this,e=d.placeholder.offset();d.reverting=!0,a(this.helper).animate({left:e.left-this.offset.parent.left-d.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:e.top-this.offset.parent.top-d.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1},cancel:function(){var b=this;if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("deactivate",null,b._uiHash(this)),this.containers[c].containerCache.over&&(this.containers[c]._trigger("out",null,b._uiHash(this)),this.containers[c].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"="),d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")}),d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l=d+j>h&&d+j<i&&b+k>f&&b+k<g;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?l:f<b+this.helperProportions.width/2&&c-this.helperProportions.width/2<g&&h<d+this.helperProportions.height/2&&e-this.helperProportions.height/2<i},_intersectsWithPointer:function(b){var c=this.options.axis==="x"||a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top,b.height),d=this.options.axis==="y"||a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left,b.width),e=c&&d,f=this._getDragVerticalDirection(),g=this._getDragHorizontalDirection();return e?this.floating?g&&g=="right"||f=="down"?2:1:f&&(f=="down"?2:1):!1},_intersectsWithSides:function(b){var c=a.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,b.top+b.height/2,b.height),d=a.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,b.left+b.width/2,b.width),e=this._getDragVerticalDirection(),f=this._getDragHorizontalDirection();return this.floating&&f?f=="right"&&d||f=="left"&&!d:e&&(e=="down"&&c||e=="up"&&!c)},_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;return a!=0&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){return this._refreshItems(a),this.refreshPositions(),this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c=this,d=[],e=[],f=this._connectWith();if(f&&b)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&e.push([a.isFunction(j.options.items)?j.options.items.call(j.element):a(j.options.items,j.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),j])}}e.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var g=e.length-1;g>=0;g--)e[g][0].each(function(){d.push(this)});return a(d)},_removeCurrentsFromItems:function(){var a=this.currentItem.find(":data("+this.widgetName+"-item)");for(var b=0;b<this.items.length;b++)for(var c=0;c<a.length;c++)a[c]==this.items[b].item[0]&&this.items.splice(b,1)},_refreshItems:function(b){this.items=[],this.containers=[this];var c=this.items,d=this,e=[[a.isFunction(this.options.items)?this.options.items.call(this.element[0],b,{item:this.currentItem}):a(this.options.items,this.element),this]],f=this._connectWith();if(f&&this.ready)for(var g=f.length-1;g>=0;g--){var h=a(f[g]);for(var i=h.length-1;i>=0;i--){var j=a.data(h[i],this.widgetName);j&&j!=this&&!j.options.disabled&&(e.push([a.isFunction(j.options.items)?j.options.items.call(j.element[0],b,{item:this.currentItem}):a(j.options.items,j.element),j]),this.containers.push(j))}}for(var g=e.length-1;g>=0;g--){var k=e[g][1],l=e[g][0];for(var i=0,m=l.length;i<m;i++){var n=a(l[i]);n.data(this.widgetName+"-item",k),c.push({item:n,instance:k,width:0,height:0,left:0,top:0})}}},refreshPositions:function(b){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var c=this.items.length-1;c>=0;c--){var d=this.items[c];if(d.instance!=this.currentContainer&&this.currentContainer&&d.item[0]!=this.currentItem[0])continue;var e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item;b||(d.width=e.outerWidth(),d.height=e.outerHeight());var f=e.offset();d.left=f.left,d.top=f.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var c=this.containers.length-1;c>=0;c--){var f=this.containers[c].element.offset();this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight()}return this},_createPlaceholder:function(b){var c=b||this,d=c.options;if(!d.placeholder||d.placeholder.constructor==String){var e=d.placeholder;d.placeholder={element:function(){var b=a(document.createElement(c.currentItem[0].nodeName)).addClass(e||c.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return e||(b.style.visibility="hidden"),b},update:function(a,b){if(e&&!d.forcePlaceholderSize)return;b.height()||b.height(c.currentItem.innerHeight()-parseInt(c.currentItem.css("paddingTop")||0,10)-parseInt(c.currentItem.css("paddingBottom")||0,10)),b.width()||b.width(c.currentItem.innerWidth()-parseInt(c.currentItem.css("paddingLeft")||0,10)-parseInt(c.currentItem.css("paddingRight")||0,10))}}}c.placeholder=a(d.placeholder.element.call(c.element,c.currentItem)),c.currentItem.after(c.placeholder),d.placeholder.update(c,c.placeholder)},_contactContainers:function(b){var c=null,d=null;for(var e=this.containers.length-1;e>=0;e--){if(a.ui.contains(this.currentItem[0],this.containers[e].element[0]))continue;if(this._intersectsWith(this.containers[e].containerCache)){if(c&&a.ui.contains(this.containers[e].element[0],c.element[0]))continue;c=this.containers[e],d=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",b,this._uiHash(this)),this.containers[e].containerCache.over=0)}if(!c)return;if(this.containers.length===1)this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1;else if(this.currentContainer!=this.containers[d]){var f=1e4,g=null,h=this.positionAbs[this.containers[d].floating?"left":"top"];for(var i=this.items.length-1;i>=0;i--){if(!a.ui.contains(this.containers[d].element[0],this.items[i].item[0]))continue;var j=this.containers[d].floating?this.items[i].item.offset().left:this.items[i].item.offset().top;Math.abs(j-h)<f&&(f=Math.abs(j-h),g=this.items[i],this.direction=j-h>0?"down":"up")}if(!g&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[d],g?this._rearrange(b,g,null,!0):this._rearrange(b,null,this.containers[d].element,!0),this._trigger("change",b,this._uiHash()),this.containers[d]._trigger("change",b,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[d]._trigger("over",b,this._uiHash(this)),this.containers[d].containerCache.over=1}},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b,this.currentItem])):c.helper=="clone"?this.currentItem.clone():this.currentItem;return d.parents("body").length||a(c.appendTo!="parent"?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]),d[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(d[0].style.width==""||c.forceHelperSize)&&d.width(this.currentItem.width()),(d[0].style.height==""||c.forceHelperSize)&&d.height(this.currentItem.height()),d},_adjustOffsetFromHelper:function(b){typeof b=="string"&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)b={top:0,left:0};return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b=this.options;b.containment=="parent"&&(b.containment=this.helper[0].parentNode);if(b.containment=="document"||b.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(b.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(b.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(b.containment)){var c=a(b.containment)[0],d=a(b.containment).offset(),e=a(c).css("overflow")!="hidden";this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(e?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(e?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(b,c){c||(c=this.position);var d=b=="absolute"?1:-1,e=this.options,f=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=/(html|body)/i.test(f[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:f.scrollTop())*d),left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-(a.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:f.scrollLeft())*d)}},_generatePosition:function(b){var c=this.options,d=this.cssPosition=="absolute"&&(this.scrollParent[0]==document||!a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(d[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var f=b.pageX,g=b.pageY;if(this.originalPosition){this.containment&&(b.pageX-this.offset.click.left<this.containment[0]&&(f=this.containment[0]+this.offset.click.left),b.pageY-this.offset.click.top<this.containment[1]&&(g=this.containment[1]+this.offset.click.top),b.pageX-this.offset.click.left>this.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top));if(c.grid){var h=this.originalPageY+Math.round((g-this.originalPageY)/c.grid[1])*c.grid[1];g=this.containment?h-this.offset.click.top<this.containment[1]||h-this.offset.click.top>this.containment[3]?h-this.offset.click.top<this.containment[1]?h+c.grid[1]:h-c.grid[1]:h:h;var i=this.originalPageX+Math.round((f-this.originalPageX)/c.grid[0])*c.grid[0];f=this.containment?i-this.offset.click.left<this.containment[0]||i-this.offset.click.left>this.containment[2]?i-this.offset.click.left<this.containment[0]?i+c.grid[0]:i-c.grid[0]:i:i}}return{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:d.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(a.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:d.scrollLeft())}},_rearrange:function(a,b,c,d){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?b.item[0]:b.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var e=this,f=this.counter;window.setTimeout(function(){f==e.counter&&e.refreshPositions(!d)},0)},_clear:function(b,c){this.reverting=!1;var d=[],e=this;!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var f in this._storedCSS)if(this._storedCSS[f]=="auto"||this._storedCSS[f]=="static")this._storedCSS[f]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!c&&d.push(function(a){this._trigger("receive",a,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!c&&d.push(function(a){this._trigger("update",a,this._uiHash())});if(!a.ui.contains(this.element[0],this.currentItem[0])){c||d.push(function(a){this._trigger("remove",a,this._uiHash())});for(var f=this.containers.length-1;f>=0;f--)a.ui.contains(this.containers[f].element[0],this.currentItem[0])&&!c&&(d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.containers[f])),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.containers[f])))}for(var f=this.containers.length-1;f>=0;f--)c||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this))}}.call(this,this.containers[f])),this.containers[f].containerCache.over=0);this._storedCursor&&a("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!c){this._trigger("beforeStop",b,this._uiHash());for(var f=0;f<d.length;f++)d[f].call(this,b);this._trigger("stop",b,this._uiHash())}return this.fromOutside=!1,!1}c||this._trigger("beforeStop",b,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!c){for(var f=0;f<d.length;f++)d[f].call(this,b);this._trigger("stop",b,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){var c=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}}),a.extend(a.ui.sortable,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.accordion.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.accordion",{options:{active:0,animated:"slide",autoHeight:!0,clearStyle:!1,collapsible:!1,event:"click",fillSpace:!1,header:"> li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var b=this,c=b.options;b.running=0,b.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix"),b.headers=b.element.find(c.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){if(c.disabled)return;a(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){if(c.disabled)return;a(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){if(c.disabled)return;a(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){if(c.disabled)return;a(this).removeClass("ui-state-focus")}),b.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");if(c.navigation){var d=b.element.find("a").filter(c.navigationFilter).eq(0);if(d.length){var e=d.closest(".ui-accordion-header");e.length?b.active=e:b.active=d.closest(".ui-accordion-content").prev()}}b.active=b._findActive(b.active||c.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"),b.active.next().addClass("ui-accordion-content-active"),b._createIcons(),b.resize(),b.element.attr("role","tablist"),b.headers.attr("role","tab").bind("keydown.accordion",function(a){return b._keydown(a)}).next().attr("role","tabpanel"),b.headers.not(b.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide(),b.active.length?b.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):b.headers.eq(0).attr("tabIndex",0),a.browser.safari||b.headers.find("a").attr("tabIndex",-1),c.event&&b.headers.bind(c.event.split(" ").join(".accordion ")+".accordion",function(a){b._clickHandler.call(b,a,this),a.preventDefault()})},_createIcons:function(){var b=this.options;b.icons&&(a("<span></span>").addClass("ui-icon "+b.icons.header).prependTo(this.headers),this.active.children(".ui-icon").toggleClass(b.icons.header).toggleClass(b.icons.headerSelected),this.element.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.children(".ui-icon").remove(),this.element.removeClass("ui-accordion-icons")},destroy:function(){var b=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"),this.headers.find("a").removeAttr("tabIndex"),this._destroyIcons();var c=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");return(b.autoHeight||b.fillHeight)&&c.css("height",""),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b=="active"&&this.activate(c),b=="icons"&&(this._destroyIcons(),c&&this._createIcons()),b=="disabled"&&this.headers.add(this.headers.next())[c?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(b){if(this.options.disabled||b.altKey||b.ctrlKey)return;var c=a.ui.keyCode,d=this.headers.length,e=this.headers.index(b.target),f=!1;switch(b.keyCode){case c.RIGHT:case c.DOWN:f=this.headers[(e+1)%d];break;case c.LEFT:case c.UP:f=this.headers[(e-1+d)%d];break;case c.SPACE:case c.ENTER:this._clickHandler({target:b.target},b.target),b.preventDefault()}return f?(a(b.target).attr("tabIndex",-1),a(f).attr("tabIndex",0),f.focus(),!1):!0},resize:function(){var b=this.options,c;if(b.fillSpace){if(a.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}c=this.element.parent().height(),a.browser.msie&&this.element.parent().css("overflow",d),this.headers.each(function(){c-=a(this).outerHeight(!0)}),this.headers.next().each(function(){a(this).height(Math.max(0,c-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")}else b.autoHeight&&(c=0,this.headers.next().each(function(){c=Math.max(c,a(this).height("").height())}).height(c));return this},activate:function(a){this.options.active=a;var b=this._findActive(a)[0];return this._clickHandler({target:b},b),this},_findActive:function(b){return b?typeof b=="number"?this.headers.filter(":eq("+b+")"):this.headers.not(this.headers.not(b)):b===!1?a([]):this.headers.filter(":eq(0)")},_clickHandler:function(b,c){var d=this.options;if(d.disabled)return;if(!b.target){if(!d.collapsible)return;this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header),this.active.next().addClass("ui-accordion-content-active");var e=this.active.next(),f={options:d,newHeader:a([]),oldHeader:d.active,newContent:a([]),oldContent:e},g=this.active=a([]);this._toggle(g,e,f);return}var h=a(b.currentTarget||c),i=h[0]===this.active[0];d.active=d.collapsible&&i?!1:this.headers.index(h);if(this.running||!d.collapsible&&i)return;var j=this.active,g=h.next(),e=this.active.next(),f={options:d,newHeader:i&&d.collapsible?a([]):h,oldHeader:this.active,newContent:i&&d.collapsible?a([]):g,oldContent:e},k=this.headers.index(this.active[0])>this.headers.index(h[0]);this.active=i?a([]):h,this._toggle(g,e,f,i,k),j.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header),i||(h.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected),h.next().addClass("ui-accordion-content-active"));return},_toggle:function(b,c,d,e,f){var g=this,h=g.options;g.toShow=b,g.toHide=c,g.data=d;var i=function(){if(!g)return;return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data),g.running=c.size()===0?b.size():c.size();if(h.animated){var j={};h.collapsible&&e?j={toShow:a([]),toHide:c,complete:i,down:f,autoHeight:h.autoHeight||h.fillSpace}:j={toShow:b,toHide:c,complete:i,down:f,autoHeight:h.autoHeight||h.fillSpace},h.proxied||(h.proxied=h.animated),h.proxiedDuration||(h.proxiedDuration=h.duration),h.animated=a.isFunction(h.proxied)?h.proxied(j):h.proxied,h.duration=a.isFunction(h.proxiedDuration)?h.proxiedDuration(j):h.proxiedDuration;var k=a.ui.accordion.animations,l=h.duration,m=h.animated;m&&!k[m]&&!a.easing[m]&&(m="slide"),k[m]||(k[m]=function(a){this.slide(a,{easing:m,duration:l||700})}),k[m](j)}else h.collapsible&&e?b.toggle():(c.hide(),b.show()),i(!0);c.prev().attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).blur(),b.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(this.running)return;this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""}),this.toHide.removeClass("ui-accordion-content-active"),this.toHide.length&&(this.toHide.parent()[0].className=this.toHide.parent()[0].className),this._trigger("change",null,this.data)}}),a.extend(a.ui.accordion,{version:"1.8.23",animations:{slide:function(b,c){b=a.extend({easing:"swing",duration:300},b,c);if(!b.toHide.size()){b.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},b);return}if(!b.toShow.size()){b.toHide.animate({height:"hide",paddingTop:"hide",paddingBottom:"hide"},b);return}var d=b.toShow.css("overflow"),e=0,f={},g={},h=["height","paddingTop","paddingBottom"],i,j=b.toShow;i=j[0].style.width,j.width(j.parent().width()-parseFloat(j.css("paddingLeft"))-parseFloat(j.css("paddingRight"))-(parseFloat(j.css("borderLeftWidth"))||0)-(parseFloat(j.css("borderRightWidth"))||0)),a.each(h,function(c,d){g[d]="hide";var e=(""+a.css(b.toShow[0],d)).match(/^([\d+-.]+)(.*)$/);f[d]={value:e[1],unit:e[2]||"px"}}),b.toShow.css({height:0,overflow:"hidden"}).show(),b.toHide.filter(":hidden").each(b.complete).end().filter(":visible").animate(g,{step:function(a,c){c.prop=="height"&&(e=c.end-c.start===0?0:(c.now-c.start)/(c.end-c.start)),b.toShow[0].style[c.prop]=e*f[c.prop].value+f[c.prop].unit},duration:b.duration,easing:b.easing,complete:function(){b.autoHeight||b.toShow.css("height",""),b.toShow.css({width:i,overflow:d}),b.complete()}})},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1e3:200})}}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.autocomplete.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){var c=0;a.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var b=this,c=this.element[0].ownerDocument,d;this.isMultiLine=this.element.is("textarea"),this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(b.options.disabled||b.element.propAttr("readOnly"))return;d=!1;var e=a.ui.keyCode;switch(c.keyCode){case e.PAGE_UP:b._move("previousPage",c);break;case e.PAGE_DOWN:b._move("nextPage",c);break;case e.UP:b._keyEvent("previous",c);break;case e.DOWN:b._keyEvent("next",c);break;case e.ENTER:case e.NUMPAD_ENTER:b.menu.active&&(d=!0,c.preventDefault());case e.TAB:if(!b.menu.active)return;b.menu.select(c);break;case e.ESCAPE:b.element.val(b.term),b.close(c);break;default:clearTimeout(b.searching),b.searching=setTimeout(function(){b.term!=b.element.val()&&(b.selectedItem=null,b.search(null,c))},b.options.delay)}}).bind("keypress.autocomplete",function(a){d&&(d=!1,a.preventDefault())}).bind("focus.autocomplete",function(){if(b.options.disabled)return;b.selectedItem=null,b.previous=b.element.val()}).bind("blur.autocomplete",function(a){if(b.options.disabled)return;clearTimeout(b.searching),b.closing=setTimeout(function(){b.close(a),b._change(a)},150)}),this._initSource(),this.menu=a("<ul></ul>").addClass("ui-autocomplete").appendTo(a(this.options.appendTo||"body",c)[0]).mousedown(function(c){var d=b.menu.element[0];a(c.target).closest(".ui-menu-item").length||setTimeout(function(){a(document).one("mousedown",function(c){c.target!==b.element[0]&&c.target!==d&&!a.ui.contains(d,c.target)&&b.close()})},1),setTimeout(function(){clearTimeout(b.closing)},13)}).menu({focus:function(a,c){var d=c.item.data("item.autocomplete");!1!==b._trigger("focus",a,{item:d})&&/^key/.test(a.originalEvent.type)&&b.element.val(d.value)},selected:function(a,d){var e=d.item.data("item.autocomplete"),f=b.previous;b.element[0]!==c.activeElement&&(b.element.focus(),b.previous=f,setTimeout(function(){b.previous=f,b.selectedItem=e},1)),!1!==b._trigger("select",a,{item:e})&&b.element.val(e.value),b.term=b.element.val(),b.close(a),b.selectedItem=e},blur:function(a,c){b.menu.element.is(":visible")&&b.element.val()!==b.term&&b.element.val(b.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu"),a.fn.bgiframe&&this.menu.element.bgiframe(),b.beforeunloadHandler=function(){b.element.removeAttr("autocomplete")},a(window).bind("beforeunload",b.beforeunloadHandler)},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup"),this.menu.element.remove(),a(window).unbind("beforeunload",this.beforeunloadHandler),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments),b==="source"&&this._initSource(),b==="appendTo"&&this.menu.element.appendTo(a(c||"body",this.element[0].ownerDocument)[0]),b==="disabled"&&c&&this.xhr&&this.xhr.abort()},_initSource:function(){var b=this,c,d;a.isArray(this.options.source)?(c=this.options.source,this.source=function(b,d){d(a.ui.autocomplete.filter(c,b.term))}):typeof this.options.source=="string"?(d=this.options.source,this.source=function(c,e){b.xhr&&b.xhr.abort(),b.xhr=a.ajax({url:d,data:c,dataType:"json",success:function(a,b){e(a)},error:function(){e([])}})}):this.source=this.options.source},search:function(a,b){a=a!=null?a:this.element.val(),this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)===!1)return;return this._search(a)},_search:function(a){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.source({term:a},this._response())},_response:function(){var a=this,b=++c;return function(d){b===c&&a.__response(d),a.pending--,a.pending||a.element.removeClass("ui-autocomplete-loading")}},__response:function(a){!this.options.disabled&&a&&a.length?(a=this._normalize(a),this._suggest(a),this._trigger("open")):this.close()},close:function(a){clearTimeout(this.closing),this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.deactivate(),this._trigger("close",a))},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(b){return b.length&&b[0].label&&b[0].value?b:a.map(b,function(b){return typeof b=="string"?{label:b,value:b}:a.extend({label:b.label||b.value,value:b.value||b.label},b)})},_suggest:function(b){var c=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(c,b),this.menu.deactivate(),this.menu.refresh(),c.show(),this._resizeMenu(),c.position(a.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next(new a.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(b,c){var d=this;a.each(c,function(a,c){d._renderItem(b,c)})},_renderItem:function(b,c){return a("<li></li>").data("item.autocomplete",c).append(a("<a></a>").text(c.label)).appendTo(b)},_move:function(a,b){if(!this.menu.element.is(":visible")){this.search(null,b);return}if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term),this.menu.deactivate();return}this.menu[a](b)},widget:function(){return this.menu.element},_keyEvent:function(a,b){if(!this.isMultiLine||this.menu.element.is(":visible"))this._move(a,b),b.preventDefault()}}),a.extend(a.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},filter:function(b,c){var d=new RegExp(a.ui.autocomplete.escapeRegex(c),"i");return a.grep(b,function(a){return d.test(a.label||a.value||a)})}})})(jQuery),function(a){a.widget("ui.menu",{_create:function(){var b=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(c){if(!a(c.target).closest(".ui-menu-item a").length)return;c.preventDefault(),b.select(c)}),this.refresh()},refresh:function(){var b=this,c=this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem");c.children("a").addClass("ui-corner-all").attr("tabindex",-1).mouseenter(function(c){b.activate(c,a(this).parent())}).mouseleave(function(){b.deactivate()})},activate:function(a,b){this.deactivate();if(this.hasScroll()){var c=b.offset().top-this.element.offset().top,d=this.element.scrollTop(),e=this.element.height();c<0?this.element.scrollTop(d+c):c>=e&&this.element.scrollTop(d+c-e+b.height())}this.active=b.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end(),this._trigger("focus",a,{item:b})},deactivate:function(){if(!this.active)return;this.active.children("a").removeClass("ui-state-hover").removeAttr("id"),this._trigger("blur"),this.active=null},next:function(a){this.move("next",".ui-menu-item:first",a)},previous:function(a){this.move("prev",".ui-menu-item:last",a)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(a,b,c){if(!this.active){this.activate(c,this.element.children(b));return}var d=this.active[a+"All"](".ui-menu-item").eq(0);d.length?this.activate(c,d):this.activate(c,this.element.children(b))},nextPage:function(b){if(this.hasScroll()){if(!this.active||this.last()){this.activate(b,this.element.children(".ui-menu-item:first"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c-d+a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:last")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(b){if(this.hasScroll()){if(!this.active||this.first()){this.activate(b,this.element.children(".ui-menu-item:last"));return}var c=this.active.offset().top,d=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var b=a(this).offset().top-c+d-a(this).height();return b<10&&b>-10});e.length||(e=this.element.children(".ui-menu-item:first")),this.activate(b,e)}else this.activate(b,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[a.fn.prop?"prop":"attr"]("scrollHeight")},select:function(a){this._trigger("selected",a,{item:this.active})}})}(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.button.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){var c,d,e,f,g="ui-button ui-widget ui-state-default ui-corner-all",h="ui-state-hover ui-state-active ",i="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",j=function(){var b=a(this).find(":ui-button");setTimeout(function(){b.button("refresh")},1)},k=function(b){var c=b.name,d=b.form,e=a([]);return c&&(d?e=a(d).find("[name='"+c+"']"):e=a("[name='"+c+"']",b.ownerDocument).filter(function(){return!this.form})),e};a.widget("ui.button",{options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",j),typeof this.options.disabled!="boolean"?this.options.disabled=!!this.element.propAttr("disabled"):this.element.propAttr("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var b=this,h=this.options,i=this.type==="checkbox"||this.type==="radio",l="ui-state-hover"+(i?"":" ui-state-active"),m="ui-state-focus";h.label===null&&(h.label=this.buttonElement.html()),this.buttonElement.addClass(g).attr("role","button").bind("mouseenter.button",function(){if(h.disabled)return;a(this).addClass("ui-state-hover"),this===c&&a(this).addClass("ui-state-active")}).bind("mouseleave.button",function(){if(h.disabled)return;a(this).removeClass(l)}).bind("click.button",function(a){h.disabled&&(a.preventDefault(),a.stopImmediatePropagation())}),this.element.bind("focus.button",function(){b.buttonElement.addClass(m)}).bind("blur.button",function(){b.buttonElement.removeClass(m)}),i&&(this.element.bind("change.button",function(){if(f)return;b.refresh()}),this.buttonElement.bind("mousedown.button",function(a){if(h.disabled)return;f=!1,d=a.pageX,e=a.pageY}).bind("mouseup.button",function(a){if(h.disabled)return;if(d!==a.pageX||e!==a.pageY)f=!0})),this.type==="checkbox"?this.buttonElement.bind("click.button",function(){if(h.disabled||f)return!1;a(this).toggleClass("ui-state-active"),b.buttonElement.attr("aria-pressed",b.element[0].checked)}):this.type==="radio"?this.buttonElement.bind("click.button",function(){if(h.disabled||f)return!1;a(this).addClass("ui-state-active"),b.buttonElement.attr("aria-pressed","true");var c=b.element[0];k(c).not(c).map(function(){return a(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown.button",function(){if(h.disabled)return!1;a(this).addClass("ui-state-active"),c=this,a(document).one("mouseup",function(){c=null})}).bind("mouseup.button",function(){if(h.disabled)return!1;a(this).removeClass("ui-state-active")}).bind("keydown.button",function(b){if(h.disabled)return!1;(b.keyCode==a.ui.keyCode.SPACE||b.keyCode==a.ui.keyCode.ENTER)&&a(this).addClass("ui-state-active")}).bind("keyup.button",function(){a(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(b){b.keyCode===a.ui.keyCode.SPACE&&a(this).click()})),this._setOption("disabled",h.disabled),this._resetButton()},_determineButtonType:function(){this.element.is(":checkbox")?this.type="checkbox":this.element.is(":radio")?this.type="radio":this.element.is("input")?this.type="input":this.type="button";if(this.type==="checkbox"||this.type==="radio"){var a=this.element.parents().filter(":last"),b="label[for='"+this.element.attr("id")+"']";this.buttonElement=a.find(b),this.buttonElement.length||(a=a.length?a.siblings():this.element.siblings(),this.buttonElement=a.filter(b),this.buttonElement.length||(this.buttonElement=a.find(b))),this.element.addClass("ui-helper-hidden-accessible");var c=this.element.is(":checked");c&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.attr("aria-pressed",c)}else this.buttonElement=this.element},widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(g+" "+h+" "+i).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title"),a.Widget.prototype.destroy.call(this)},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments);if(b==="disabled"){c?this.element.propAttr("disabled",!0):this.element.propAttr("disabled",!1);return}this._resetButton()},refresh:function(){var b=this.element.is(":disabled");b!==this.options.disabled&&this._setOption("disabled",b),this.type==="radio"?k(this.element[0]).each(function(){a(this).is(":checked")?a(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):a(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):this.type==="checkbox"&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if(this.type==="input"){this.options.label&&this.element.val(this.options.label);return}var b=this.buttonElement.removeClass(i),c=a("<span></span>",this.element[0].ownerDocument).addClass("ui-button-text").html(this.options.label).appendTo(b.empty()).text(),d=this.options.icons,e=d.primary&&d.secondary,f=[];d.primary||d.secondary?(this.options.text&&f.push("ui-button-text-icon"+(e?"s":d.primary?"-primary":"-secondary")),d.primary&&b.prepend("<span class='ui-button-icon-primary ui-icon "+d.primary+"'></span>"),d.secondary&&b.append("<span class='ui-button-icon-secondary ui-icon "+d.secondary+"'></span>"),this.options.text||(f.push(e?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||b.attr("title",c))):f.push("ui-button-text-only"),b.addClass(f.join(" "))}}),a.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(b,c){b==="disabled"&&this.buttons.button("option",b,c),a.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var b=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(b?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(b?"ui-corner-left":"ui-corner-right").end().end()},destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return a(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"),a.Widget.prototype.destroy.call(this)}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.dialog.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){var c="ui-dialog ui-widget ui-widget-content ui-corner-all ",d={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},e={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};a.widget("ui.dialog",{options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",collision:"fit",using:function(b){var c=a(this).css(b).offset().top;c<0&&a(this).css("top",b.top-c)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.options.title=this.options.title||this.originalTitle;var b=this,d=b.options,e=d.title||"&#160;",f=a.ui.dialog.getTitleId(b.element),g=(b.uiDialog=a("<div></div>")).appendTo(document.body).hide().addClass(c+d.dialogClass).css({zIndex:d.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(c){d.closeOnEscape&&!c.isDefaultPrevented()&&c.keyCode&&c.keyCode===a.ui.keyCode.ESCAPE&&(b.close(c),c.preventDefault())}).attr({role:"dialog","aria-labelledby":f}).mousedown(function(a){b.moveToTop(!1,a)}),h=b.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g),i=(b.uiDialogTitlebar=a("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),j=a('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){j.addClass("ui-state-hover")},function(){j.removeClass("ui-state-hover")}).focus(function(){j.addClass("ui-state-focus")}).blur(function(){j.removeClass("ui-state-focus")}).click(function(a){return b.close(a),!1}).appendTo(i),k=(b.uiDialogTitlebarCloseText=a("<span></span>")).addClass("ui-icon ui-icon-closethick").text(d.closeText).appendTo(j),l=a("<span></span>").addClass("ui-dialog-title").attr("id",f).html(e).prependTo(i);a.isFunction(d.beforeclose)&&!a.isFunction(d.beforeClose)&&(d.beforeClose=d.beforeclose),i.find("*").add(i).disableSelection(),d.draggable&&a.fn.draggable&&b._makeDraggable(),d.resizable&&a.fn.resizable&&b._makeResizable(),b._createButtons(d.buttons),b._isOpen=!1,a.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;return a.overlay&&a.overlay.destroy(),a.uiDialog.hide(),a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),a.uiDialog.remove(),a.originalTitle&&a.element.attr("title",a.originalTitle),a},widget:function(){return this.uiDialog},close:function(b){var c=this,d,e;if(!1===c._trigger("beforeClose",b))return;return c.overlay&&c.overlay.destroy(),c.uiDialog.unbind("keypress.ui-dialog"),c._isOpen=!1,c.options.hide?c.uiDialog.hide(c.options.hide,function(){c._trigger("close",b)}):(c.uiDialog.hide(),c._trigger("close",b)),a.ui.dialog.overlay.resize(),c.options.modal&&(d=0,a(".ui-dialog").each(function(){this!==c.uiDialog[0]&&(e=a(this).css("z-index"),isNaN(e)||(d=Math.max(d,e)))}),a.ui.dialog.maxZ=d),c},isOpen:function(){return this._isOpen},moveToTop:function(b,c){var d=this,e=d.options,f;return e.modal&&!b||!e.stack&&!e.modal?d._trigger("focus",c):(e.zIndex>a.ui.dialog.maxZ&&(a.ui.dialog.maxZ=e.zIndex),d.overlay&&(a.ui.dialog.maxZ+=1,d.overlay.$el.css("z-index",a.ui.dialog.overlay.maxZ=a.ui.dialog.maxZ)),f={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()},a.ui.dialog.maxZ+=1,d.uiDialog.css("z-index",a.ui.dialog.maxZ),d.element.attr(f),d._trigger("focus",c),d)},open:function(){if(this._isOpen)return;var b=this,c=b.options,d=b.uiDialog;return b.overlay=c.modal?new a.ui.dialog.overlay(b):null,b._size(),b._position(c.position),d.show(c.show),b.moveToTop(!0),c.modal&&d.bind("keydown.ui-dialog",function(b){if(b.keyCode!==a.ui.keyCode.TAB)return;var c=a(":tabbable",this),d=c.filter(":first"),e=c.filter(":last");if(b.target===e[0]&&!b.shiftKey)return d.focus(1),!1;if(b.target===d[0]&&b.shiftKey)return e.focus(1),!1}),a(b.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus(),b._isOpen=!0,b._trigger("open"),b},_createButtons:function(b){var c=this,d=!1,e=a("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),f=a("<div></div>").addClass("ui-dialog-buttonset").appendTo(e);c.uiDialog.find(".ui-dialog-buttonpane").remove(),typeof b=="object"&&b!==null&&a.each(b,function(){return!(d=!0)}),d&&(a.each(b,function(b,d){d=a.isFunction(d)?{click:d,text:b}:d;var e=a('<button type="button"></button>').click(function(){d.click.apply(c.element[0],arguments)}).appendTo(f);a.each(d,function(a,b){if(a==="click")return;a in e?e[a](b):e.attr(a,b)}),a.fn.button&&e.button()}),e.appendTo(c.uiDialog))},_makeDraggable:function(){function f(a){return{position:a.position,offset:a.offset}}var b=this,c=b.options,d=a(document),e;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(d,g){e=c.height==="auto"?"auto":a(this).height(),a(this).height(a(this).height()).addClass("ui-dialog-dragging"),b._trigger("dragStart",d,f(g))},drag:function(a,c){b._trigger("drag",a,f(c))},stop:function(g,h){c.position=[h.position.left-d.scrollLeft(),h.position.top-d.scrollTop()],a(this).removeClass("ui-dialog-dragging").height(e),b._trigger("dragStop",g,f(h)),a.ui.dialog.overlay.resize()}})},_makeResizable:function(c){function h(a){return{originalPosition:a.originalPosition,originalSize:a.originalSize,position:a.position,size:a.size}}c=c===b?this.options.resizable:c;var d=this,e=d.options,f=d.uiDialog.css("position"),g=typeof c=="string"?c:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:g,start:function(b,c){a(this).addClass("ui-dialog-resizing"),d._trigger("resizeStart",b,h(c))},resize:function(a,b){d._trigger("resize",a,h(b))},stop:function(b,c){a(this).removeClass("ui-dialog-resizing"),e.height=a(this).height(),e.width=a(this).width(),d._trigger("resizeStop",b,h(c)),a.ui.dialog.overlay.resize()}}).css("position",f).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(b){var c=[],d=[0,0],e;if(b){if(typeof b=="string"||typeof b=="object"&&"0"in b)c=b.split?b.split(" "):[b[0],b[1]],c.length===1&&(c[1]=c[0]),a.each(["left","top"],function(a,b){+c[a]===c[a]&&(d[a]=c[a],c[a]=b)}),b={my:c.join(" "),at:c.join(" "),offset:d.join(" ")};b=a.extend({},a.ui.dialog.prototype.options.position,b)}else b=a.ui.dialog.prototype.options.position;e=this.uiDialog.is(":visible"),e||this.uiDialog.show(),this.uiDialog.css({top:0,left:0}).position(a.extend({of:window},b)),e||this.uiDialog.hide()},_setOptions:function(b){var c=this,f={},g=!1;a.each(b,function(a,b){c._setOption(a,b),a in d&&(g=!0),a in e&&(f[a]=b)}),g&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",f)},_setOption:function(b,d){var e=this,f=e.uiDialog;switch(b){case"beforeclose":b="beforeClose";break;case"buttons":e._createButtons(d);break;case"closeText":e.uiDialogTitlebarCloseText.text(""+d);break;case"dialogClass":f.removeClass(e.options.dialogClass).addClass(c+d);break;case"disabled":d?f.addClass("ui-dialog-disabled"):f.removeClass("ui-dialog-disabled");break;case"draggable":var g=f.is(":data(draggable)");g&&!d&&f.draggable("destroy"),!g&&d&&e._makeDraggable();break;case"position":e._position(d);break;case"resizable":var h=f.is(":data(resizable)");h&&!d&&f.resizable("destroy"),h&&typeof d=="string"&&f.resizable("option","handles",d),!h&&d!==!1&&e._makeResizable(d);break;case"title":a(".ui-dialog-title",e.uiDialogTitlebar).html(""+(d||"&#160;"))}a.Widget.prototype._setOption.apply(e,arguments)},_size:function(){var b=this.options,c,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),b.minWidth>b.width&&(b.width=b.minWidth),c=this.uiDialog.css({height:"auto",width:b.width}).height(),d=Math.max(0,b.minHeight-c);if(b.height==="auto")if(a.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();var f=this.element.css("height","auto").height();e||this.uiDialog.hide(),this.element.height(Math.max(f,d))}else this.element.height(Math.max(b.height-c,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),a.extend(a.ui.dialog,{version:"1.8.23",uuid:0,maxZ:0,getTitleId:function(a){var b=a.attr("id");return b||(this.uuid+=1,b=this.uuid),"ui-dialog-title-"+b},overlay:function(b){this.$el=a.ui.dialog.overlay.create(b)}}),a.extend(a.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:a.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),create:function(b){this.instances.length===0&&(setTimeout(function(){a.ui.dialog.overlay.instances.length&&a(document).bind(a.ui.dialog.overlay.events,function(b){if(a(b.target).zIndex()<a.ui.dialog.overlay.maxZ)return!1})},1),a(document).bind("keydown.dialog-overlay",function(c){b.options.closeOnEscape&&!c.isDefaultPrevented()&&c.keyCode&&c.keyCode===a.ui.keyCode.ESCAPE&&(b.close(c),c.preventDefault())}),a(window).bind("resize.dialog-overlay",a.ui.dialog.overlay.resize));var c=(this.oldInstances.pop()||a("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});return a.fn.bgiframe&&c.bgiframe(),this.instances.push(c),c},destroy:function(b){var c=a.inArray(b,this.instances);c!=-1&&this.oldInstances.push(this.instances.splice(c,1)[0]),this.instances.length===0&&a([document,window]).unbind(".dialog-overlay"),b.remove();var d=0;a.each(this.instances,function(){d=Math.max(d,this.css("z-index"))}),this.maxZ=d},height:function(){var b,c;return a.browser.msie&&a.browser.version<7?(b=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),c=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),b<c?a(window).height()+"px":b+"px"):a(document).height()+"px"},width:function(){var b,c;return a.browser.msie?(b=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),c=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),b<c?a(window).width()+"px":b+"px"):a(document).width()+"px"},resize:function(){var b=a([]);a.each(a.ui.dialog.overlay.instances,function(){b=b.add(this)}),b.css({width:0,height:0}).css({width:a.ui.dialog.overlay.width(),height:a.ui.dialog.overlay.height()})}}),a.extend(a.ui.dialog.overlay.prototype,{destroy:function(){a.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.slider.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){var c=5;a.widget("ui.slider",a.ui.mouse,{widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null},_create:function(){var b=this,d=this.options,e=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f="<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",g=d.values&&d.values.length||1,h=[];this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"+(d.disabled?" ui-slider-disabled ui-disabled":"")),this.range=a([]),d.range&&(d.range===!0&&(d.values||(d.values=[this._valueMin(),this._valueMin()]),d.values.length&&d.values.length!==2&&(d.values=[d.values[0],d.values[0]])),this.range=a("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(d.range==="min"||d.range==="max"?" ui-slider-range-"+d.range:"")));for(var i=e.length;i<g;i+=1)h.push(f);this.handles=e.add(a(h.join("")).appendTo(b.element)),this.handle=this.handles.eq(0),this.handles.add(this.range).filter("a").click(function(a){a.preventDefault()}).hover(function(){d.disabled||a(this).addClass("ui-state-hover")},function(){a(this).removeClass("ui-state-hover")}).focus(function(){d.disabled?a(this).blur():(a(".ui-slider .ui-state-focus").removeClass("ui-state-focus"),a(this).addClass("ui-state-focus"))}).blur(function(){a(this).removeClass("ui-state-focus")}),this.handles.each(function(b){a(this).data("index.ui-slider-handle",b)}),this.handles.keydown(function(d){var e=a(this).data("index.ui-slider-handle"),f,g,h,i;if(b.options.disabled)return;switch(d.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:d.preventDefault();if(!b._keySliding){b._keySliding=!0,a(this).addClass("ui-state-active"),f=b._start(d,e);if(f===!1)return}}i=b.options.step,b.options.values&&b.options.values.length?g=h=b.values(e):g=h=b.value();switch(d.keyCode){case a.ui.keyCode.HOME:h=b._valueMin();break;case a.ui.keyCode.END:h=b._valueMax();break;case a.ui.keyCode.PAGE_UP:h=b._trimAlignValue(g+(b._valueMax()-b._valueMin())/c);break;case a.ui.keyCode.PAGE_DOWN:h=b._trimAlignValue(g-(b._valueMax()-b._valueMin())/c);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(g===b._valueMax())return;h=b._trimAlignValue(g+i);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(g===b._valueMin())return;h=b._trimAlignValue(g-i)}b._slide(d,e,h)}).keyup(function(c){var d=a(this).data("index.ui-slider-handle");b._keySliding&&(b._keySliding=!1,b._stop(c,d),b._change(c,d),a(this).removeClass("ui-state-active"))}),this._refreshValue(),this._animateOff=!1},destroy:function(){return this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider"),this._mouseDestroy(),this},_mouseCapture:function(b){var c=this.options,d,e,f,g,h,i,j,k,l;return c.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),d={x:b.pageX,y:b.pageY},e=this._normValueFromMouse(d),f=this._valueMax()-this._valueMin()+1,h=this,this.handles.each(function(b){var c=Math.abs(e-h.values(b));f>c&&(f=c,g=a(this),i=b)}),c.range===!0&&this.values(1)===c.min&&(i+=1,g=a(this.handles[i])),j=this._start(b,i),j===!1?!1:(this._mouseSliding=!0,h._handleIndex=i,g.addClass("ui-state-active").focus(),k=g.offset(),l=!a(b.target).parents().andSelf().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:b.pageX-k.left-g.width()/2,top:b.pageY-k.top-g.height()/2-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,i,e),this._animateOff=!0,!0))},_mouseStart:function(a){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);return this._slide(a,this._handleIndex,c),!1},_mouseStop:function(a){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;return this.orientation==="horizontal"?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),d<0&&(d=0),this.orientation==="vertical"&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e,this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};return this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),this.options.values.length===2&&this.options.range===!0&&(b===0&&c>d||b===1&&c<d)&&(c=d),c!==this.values(b)&&(e=this.values(),e[b]=c,f=this._trigger("slide",a,{handle:this.handles[b],value:c,values:e}),d=this.values(b?0:1),f!==!1&&this.values(b,c,!0))):c!==this.value()&&(f=this._trigger("slide",a,{handle:this.handles[b],value:c}),f!==!1&&this.value(c))},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("change",a,c)}},value:function(a){if(arguments.length){this.options.value=this._trimAlignValue(a),this._refreshValue(),this._change(null,0);return}return this._value()},values:function(b,c){var d,e,f;if(arguments.length>1){this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b);return}if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();d=this.options.values,e=arguments[0];for(f=0;f<d.length;f+=1)d[f]=this._trimAlignValue(e[f]),this._change(null,f);this._refreshValue()},_setOption:function(b,c){var d,e=0;a.isArray(this.options.values)&&(e=this.options.values.length),a.Widget.prototype._setOption.apply(this,arguments);switch(b){case"disabled":c?(this.handles.filter(".ui-state-focus").blur(),this.handles.removeClass("ui-state-hover"),this.handles.propAttr("disabled",!0),this.element.addClass("ui-disabled")):(this.handles.propAttr("disabled",!1),this.element.removeClass("ui-disabled"));break;case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":this._animateOff=!0,this._refreshValue();for(d=0;d<e;d+=1)this._change(null,d);this._animateOff=!1}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a),a},_values:function(a){var b,c,d;if(arguments.length)return b=this.options.values[a],b=this._trimAlignValue(b),b;c=this.options.values.slice();for(d=0;d<c.length;d+=1)c[d]=this._trimAlignValue(c[d]);return c},_trimAlignValue:function(a){if(a<=this._valueMin())return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b,d=a-c;return Math.abs(c)*2>=b&&(d+=c>0?b:-b),parseFloat(d.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b=this.options.range,c=this.options,d=this,e=this._animateOff?!1:c.animate,f,g={},h,i,j,k;this.options.values&&this.options.values.length?this.handles.each(function(b,i){f=(d.values(b)-d._valueMin())/(d._valueMax()-d._valueMin())*100,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",a(this).stop(1,1)[e?"animate":"css"](g,c.animate),d.options.range===!0&&(d.orientation==="horizontal"?(b===0&&d.range.stop(1,1)[e?"animate":"css"]({left:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({width:f-h+"%"},{queue:!1,duration:c.animate})):(b===0&&d.range.stop(1,1)[e?"animate":"css"]({bottom:f+"%"},c.animate),b===1&&d.range[e?"animate":"css"]({height:f-h+"%"},{queue:!1,duration:c.animate}))),h=f}):(i=this.value(),j=this._valueMin(),k=this._valueMax(),f=k!==j?(i-j)/(k-j)*100:0,g[d.orientation==="horizontal"?"left":"bottom"]=f+"%",this.handle.stop(1,1)[e?"animate":"css"](g,c.animate),b==="min"&&this.orientation==="horizontal"&&this.range.stop(1,1)[e?"animate":"css"]({width:f+"%"},c.animate),b==="max"&&this.orientation==="horizontal"&&this.range[e?"animate":"css"]({width:100-f+"%"},{queue:!1,duration:c.animate}),b==="min"&&this.orientation==="vertical"&&this.range.stop(1,1)[e?"animate":"css"]({height:f+"%"},c.animate),b==="max"&&this.orientation==="vertical"&&this.range[e?"animate":"css"]({height:100-f+"%"},{queue:!1,duration:c.animate}))}}),a.extend(a.ui.slider,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.tabs.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){function e(){return++c}function f(){return++d}var c=0,d=0;a.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:!1,cookie:null,collapsible:!1,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(!0)},_setOption:function(a,b){if(a=="selected"){if(this.options.collapsible&&b==this.options.selected)return;this.select(b)}else this.options[a]=b,this._tabify()},_tabId:function(a){return a.title&&a.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+e()},_sanitizeSelector:function(a){return a.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+f());return a.cookie.apply(null,[b].concat(a.makeArray(arguments)))},_ui:function(a,b){return{tab:a,panel:b,index:this.anchors.index(a)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=a(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function m(b,c){b.css("display",""),!a.support.opacity&&c.opacity&&b[0].style.removeAttribute("filter")}var d=this,e=this.options,f=/^#.+/;this.list=this.element.find("ol,ul").eq(0),this.lis=a(" > li:has(a[href])",this.list),this.anchors=this.lis.map(function(){return a("a",this)[0]}),this.panels=a([]),this.anchors.each(function(b,c){var g=a(c).attr("href"),h=g.split("#")[0],i;h&&(h===location.toString().split("#")[0]||(i=a("base")[0])&&h===i.href)&&(g=c.hash,c.href=g);if(f.test(g))d.panels=d.panels.add(d.element.find(d._sanitizeSelector(g)));else if(g&&g!=="#"){a.data(c,"href.tabs",g),a.data(c,"load.tabs",g.replace(/#.*$/,""));var j=d._tabId(c);c.href="#"+j;var k=d.element.find("#"+j);k.length||(k=a(e.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(d.panels[b-1]||d.list),k.data("destroy.tabs",!0)),d.panels=d.panels.add(k)}else e.disabled.push(b)}),c?(this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"),this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.lis.addClass("ui-state-default ui-corner-top"),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom"),e.selected===b?(location.hash&&this.anchors.each(function(a,b){if(b.hash==location.hash)return e.selected=a,!1}),typeof e.selected!="number"&&e.cookie&&(e.selected=parseInt(d._cookie(),10)),typeof e.selected!="number"&&this.lis.filter(".ui-tabs-selected").length&&(e.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"))),e.selected=e.selected||(this.lis.length?0:-1)):e.selected===null&&(e.selected=-1),e.selected=e.selected>=0&&this.anchors[e.selected]||e.selected<0?e.selected:0,e.disabled=a.unique(e.disabled.concat(a.map(this.lis.filter(".ui-state-disabled"),function(a,b){return d.lis.index(a)}))).sort(),a.inArray(e.selected,e.disabled)!=-1&&e.disabled.splice(a.inArray(e.selected,e.disabled),1),this.panels.addClass("ui-tabs-hide"),this.lis.removeClass("ui-tabs-selected ui-state-active"),e.selected>=0&&this.anchors.length&&(d.element.find(d._sanitizeSelector(d.anchors[e.selected].hash)).removeClass("ui-tabs-hide"),this.lis.eq(e.selected).addClass("ui-tabs-selected ui-state-active"),d.element.queue("tabs",function(){d._trigger("show",null,d._ui(d.anchors[e.selected],d.element.find(d._sanitizeSelector(d.anchors[e.selected].hash))[0]))}),this.load(e.selected)),a(window).bind("unload",function(){d.lis.add(d.anchors).unbind(".tabs"),d.lis=d.anchors=d.panels=null})):e.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")),this.element[e.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible"),e.cookie&&this._cookie(e.selected,e.cookie);for(var g=0,h;h=this.lis[g];g++)a(h)[a.inArray(g,e.disabled)!=-1&&!a(h).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");e.cache===!1&&this.anchors.removeData("cache.tabs"),this.lis.add(this.anchors).unbind(".tabs");if(e.event!=="mouseover"){var i=function(a,b){b.is(":not(.ui-state-disabled)")&&b.addClass("ui-state-"+a)},j=function(a,b){b.removeClass("ui-state-"+a)};this.lis.bind("mouseover.tabs",function(){i("hover",a(this))}),this.lis.bind("mouseout.tabs",function(){j("hover",a(this))}),this.anchors.bind("focus.tabs",function(){i("focus",a(this).closest("li"))}),this.anchors.bind("blur.tabs",function(){j("focus",a(this).closest("li"))})}var k,l;e.fx&&(a.isArray(e.fx)?(k=e.fx[0],l=e.fx[1]):k=l=e.fx);var n=l?function(b,c){a(b).closest("li").addClass("ui-tabs-selected ui-state-active"),c.hide().removeClass("ui-tabs-hide").animate(l,l.duration||"normal",function(){m(c,l),d._trigger("show",null,d._ui(b,c[0]))})}:function(b,c){a(b).closest("li").addClass("ui-tabs-selected ui-state-active"),c.removeClass("ui-tabs-hide"),d._trigger("show",null,d._ui(b,c[0]))},o=k?function(a,b){b.animate(k,k.duration||"normal",function(){d.lis.removeClass("ui-tabs-selected ui-state-active"),b.addClass("ui-tabs-hide"),m(b,k),d.element.dequeue("tabs")})}:function(a,b,c){d.lis.removeClass("ui-tabs-selected ui-state-active"),b.addClass("ui-tabs-hide"),d.element.dequeue("tabs")};this.anchors.bind(e.event+".tabs",function(){var b=this,c=a(b).closest("li"),f=d.panels.filter(":not(.ui-tabs-hide)"),g=d.element.find(d._sanitizeSelector(b.hash));if(c.hasClass("ui-tabs-selected")&&!e.collapsible||c.hasClass("ui-state-disabled")||c.hasClass("ui-state-processing")||d.panels.filter(":animated").length||d._trigger("select",null,d._ui(this,g[0]))===!1)return this.blur(),!1;e.selected=d.anchors.index(this),d.abort();if(e.collapsible){if(c.hasClass("ui-tabs-selected"))return e.selected=-1,e.cookie&&d._cookie(e.selected,e.cookie),d.element.queue("tabs",function(){o(b,f)}).dequeue("tabs"),this.blur(),!1;if(!f.length)return e.cookie&&d._cookie(e.selected,e.cookie),d.element.queue("tabs",function(){n(b,g)}),d.load(d.anchors.index(this)),this.blur(),!1}e.cookie&&d._cookie(e.selected,e.cookie);if(g.length)f.length&&d.element.queue("tabs",function(){o(b,f)}),d.element.queue("tabs",function(){n(b,g)}),d.load(d.anchors.index(this));else throw"jQuery UI Tabs: Mismatching fragment identifier.";a.browser.msie&&this.blur()}),this.anchors.bind("click.tabs",function(){return!1})},_getIndex:function(a){return typeof a=="string"&&(a=this.anchors.index(this.anchors.filter("[href$='"+a+"']"))),a},destroy:function(){var b=this.options;return this.abort(),this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs"),this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"),this.anchors.each(function(){var b=a.data(this,"href.tabs");b&&(this.href=b);var c=a(this).unbind(".tabs");a.each(["href","load","cache"],function(a,b){c.removeData(b+".tabs")})}),this.lis.unbind(".tabs").add(this.panels).each(function(){a.data(this,"destroy.tabs")?a(this).remove():a(this).removeClass(["ui-state-default","ui-corner-top","ui-tabs-selected","ui-state-active","ui-state-hover","ui-state-focus","ui-state-disabled","ui-tabs-panel","ui-widget-content","ui-corner-bottom","ui-tabs-hide"].join(" "))}),b.cookie&&this._cookie(null,b.cookie),this},add:function(c,d,e){e===b&&(e=this.anchors.length);var f=this,g=this.options,h=a(g.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,d)),i=c.indexOf("#")?this._tabId(a("a",h)[0]):c.replace("#","");h.addClass("ui-state-default ui-corner-top").data("destroy.tabs",!0);var j=f.element.find("#"+i);return j.length||(j=a(g.panelTemplate).attr("id",i).data("destroy.tabs",!0)),j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"),e>=this.lis.length?(h.appendTo(this.list),j.appendTo(this.list[0].parentNode)):(h.insertBefore(this.lis[e]),j.insertBefore(this.panels[e])),g.disabled=a.map(g.disabled,function(a,b){return a>=e?++a:a}),this._tabify(),this.anchors.length==1&&(g.selected=0,h.addClass("ui-tabs-selected ui-state-active"),j.removeClass("ui-tabs-hide"),this.element.queue("tabs",function(){f._trigger("show",null,f._ui(f.anchors[0],f.panels[0]))}),this.load(0)),this._trigger("add",null,this._ui(this.anchors[e],this.panels[e])),this},remove:function(b){b=this._getIndex(b);var c=this.options,d=this.lis.eq(b).remove(),e=this.panels.eq(b).remove();return d.hasClass("ui-tabs-selected")&&this.anchors.length>1&&this.select(b+(b+1<this.anchors.length?1:-1)),c.disabled=a.map(a.grep(c.disabled,function(a,c){return a!=b}),function(a,c){return a>=b?--a:a}),this._tabify(),this._trigger("remove",null,this._ui(d.find("a")[0],e[0])),this},enable:function(b){b=this._getIndex(b);var c=this.options;if(a.inArray(b,c.disabled)==-1)return;return this.lis.eq(b).removeClass("ui-state-disabled"),c.disabled=a.grep(c.disabled,function(a,c){return a!=b}),this._trigger("enable",null,this._ui(this.anchors[b],this.panels[b])),this},disable:function(a){a=this._getIndex(a);var b=this,c=this.options;return a!=c.selected&&(this.lis.eq(a).addClass("ui-state-disabled"),c.disabled.push(a),c.disabled.sort(),this._trigger("disable",null,this._ui(this.anchors[a],this.panels[a]))),this},select:function(a){a=this._getIndex(a);if(a==-1)if(this.options.collapsible&&this.options.selected!=-1)a=this.options.selected;else return this;return this.anchors.eq(a).trigger(this.options.event+".tabs"),this},load:function(b){b=this._getIndex(b);var c=this,d=this.options,e=this.anchors.eq(b)[0],f=a.data(e,"load.tabs");this.abort();if(!f||this.element.queue("tabs").length!==0&&a.data(e,"cache.tabs")){this.element.dequeue("tabs");return}this.lis.eq(b).addClass("ui-state-processing");if(d.spinner){var g=a("span",e);g.data("label.tabs",g.html()).html(d.spinner)}return this.xhr=a.ajax(a.extend({},d.ajaxOptions,{url:f,success:function(f,g){c.element.find(c._sanitizeSelector(e.hash)).html(f),c._cleanup(),d.cache&&a.data(e,"cache.tabs",!0),c._trigger("load",null,c._ui(c.anchors[b],c.panels[b]));try{d.ajaxOptions.success(f,g)}catch(h){}},error:function(a,f,g){c._cleanup(),c._trigger("load",null,c._ui(c.anchors[b],c.panels[b]));try{d.ajaxOptions.error(a,f,b,e)}catch(g){}}})),c.element.dequeue("tabs"),this},abort:function(){return this.element.queue([]),this.panels.stop(!1,!0),this.element.queue("tabs",this.element.queue("tabs").splice(-2,2)),this.xhr&&(this.xhr.abort(),delete this.xhr),this._cleanup(),this},url:function(a,b){return this.anchors.eq(a).removeData("cache.tabs").data("load.tabs",b),this},length:function(){return this.anchors.length}}),a.extend(a.ui.tabs,{version:"1.8.23"}),a.extend(a.ui.tabs.prototype,{rotation:null,rotate:function(a,b){var c=this,d=this.options,e=c._rotate||(c._rotate=function(b){clearTimeout(c.rotation),c.rotation=setTimeout(function(){var a=d.selected;c.select(++a<c.anchors.length?a:0)},a),b&&b.stopPropagation()}),f=c._unrotate||(c._unrotate=b?function(a){e()}:function(a){a.clientX&&c.rotate(null)});return a?(this.element.bind("tabsshow",e),this.anchors.bind(d.event+".tabs",f),e()):(clearTimeout(c.rotation),this.element.unbind("tabsshow",e),this.anchors.unbind(d.event+".tabs",f),delete this._rotate,delete this._unrotate),this}})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.datepicker.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function($,undefined){function Datepicker(){this.debug=!1,this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},$.extend(this._defaults,this.regional[""]),this.dpDiv=bindHover($('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}function bindHover(a){var b="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return a.bind("mouseout",function(a){var c=$(a.target).closest(b);if(!c.length)return;c.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(c){var d=$(c.target).closest(b);if($.datepicker._isDisabledDatepicker(instActive.inline?a.parent()[0]:instActive.input[0])||!d.length)return;d.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),d.addClass("ui-state-hover"),d.hasClass("ui-datepicker-prev")&&d.addClass("ui-datepicker-prev-hover"),d.hasClass("ui-datepicker-next")&&d.addClass("ui-datepicker-next-hover")})}function extendRemove(a,b){$.extend(a,b);for(var c in b)if(b[c]==null||b[c]==undefined)a[c]=b[c];return a}function isArray(a){return a&&($.browser.safari&&typeof a=="object"&&a.length||a.constructor&&a.constructor.toString().match(/\Array\(\)/))}$.extend($.ui,{datepicker:{version:"1.8.23"}});var PROP_NAME="datepicker",dpuuid=(new Date).getTime(),instActive;$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){return extendRemove(this._defaults,a||{}),this},_attachDatepicker:function(target,settings){var inlineSettings=null;for(var attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue)}catch(err){inlineSettings[attrName]=attrValue}}}var nodeName=target.nodeName.toLowerCase(),inline=nodeName=="div"||nodeName=="span";target.id||(this.uuid+=1,target.id="dp"+this.uuid);var inst=this._newInst($(target),inline);inst.settings=$.extend({},settings||{},inlineSettings||{}),nodeName=="input"?this._connectDatepicker(target,inst):inline&&this._inlineDatepicker(target,inst)},_newInst:function(a,b){var c=a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1");return{id:c,input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:b?bindHover($('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')):this.dpDiv}},_connectDatepicker:function(a,b){var c=$(a);b.append=$([]),b.trigger=$([]);if(c.hasClass(this.markerClassName))return;this._attachments(c,b),c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),this._autoSize(b),$.data(a,PROP_NAME,b),b.settings.disabled&&this._disableDatepicker(a)},_attachments:function(a,b){var c=this._get(b,"appendText"),d=this._get(b,"isRTL");b.append&&b.append.remove(),c&&(b.append=$('<span class="'+this._appendClass+'">'+c+"</span>"),a[d?"before":"after"](b.append)),a.unbind("focus",this._showDatepicker),b.trigger&&b.trigger.remove();var e=this._get(b,"showOn");(e=="focus"||e=="both")&&a.focus(this._showDatepicker);if(e=="button"||e=="both"){var f=this._get(b,"buttonText"),g=this._get(b,"buttonImage");b.trigger=$(this._get(b,"buttonImageOnly")?$("<img/>").addClass(this._triggerClass).attr({src:g,alt:f,title:f}):$('<button type="button"></button>').addClass(this._triggerClass).html(g==""?f:$("<img/>").attr({src:g,alt:f,title:f}))),a[d?"before":"after"](b.trigger),b.trigger.click(function(){return $.datepicker._datepickerShowing&&$.datepicker._lastInput==a[0]?$.datepicker._hideDatepicker():$.datepicker._datepickerShowing&&$.datepicker._lastInput!=a[0]?($.datepicker._hideDatepicker(),$.datepicker._showDatepicker(a[0])):$.datepicker._showDatepicker(a[0]),!1})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var d=function(a){var b=0,c=0;for(var d=0;d<a.length;d++)a[d].length>b&&(b=a[d].length,c=d);return c};b.setMonth(d(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort"))),b.setDate(d(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=$(a);if(c.hasClass(this.markerClassName))return;c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(a,c,d){b.settings[c]=d}).bind("getData.datepicker",function(a,c){return this._get(b,c)}),$.data(a,PROP_NAME,b),this._setDate(b,this._getDefaultDate(b),!0),this._updateDatepicker(b),this._updateAlternate(b),b.settings.disabled&&this._disableDatepicker(a),b.dpDiv.css("display","block")},_dialogDatepicker:function(a,b,c,d,e){var f=this._dialogInst;if(!f){this.uuid+=1;var g="dp"+this.uuid;this._dialogInput=$('<input type="text" id="'+g+'" style="position: absolute; top: -100px; width: 0px;"/>'),this._dialogInput.keydown(this._doKeyDown),$("body").append(this._dialogInput),f=this._dialogInst=this._newInst(this._dialogInput,!1),f.settings={},$.data(this._dialogInput[0],PROP_NAME,f)}extendRemove(f.settings,d||{}),b=b&&b.constructor==Date?this._formatDate(f,b):b,this._dialogInput.val(b),this._pos=e?e.length?e:[e.pageX,e.pageY]:null;if(!this._pos){var h=document.documentElement.clientWidth,i=document.documentElement.clientHeight,j=document.documentElement.scrollLeft||document.body.scrollLeft,k=document.documentElement.scrollTop||document.body.scrollTop;this._pos=[h/2-100+j,i/2-150+k]}return this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),f.settings.onSelect=c,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),$.blockUI&&$.blockUI(this.dpDiv),$.data(this._dialogInput[0],PROP_NAME,f),this},_destroyDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();$.removeData(a,PROP_NAME),d=="input"?(c.append.remove(),c.trigger.remove(),b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):(d=="div"||d=="span")&&b.removeClass(this.markerClassName).empty()},_enableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!1,c.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().removeClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b})},_disableDatepicker:function(a){var b=$(a),c=$.data(a,PROP_NAME);if(!b.hasClass(this.markerClassName))return;var d=a.nodeName.toLowerCase();if(d=="input")a.disabled=!0,c.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"});else if(d=="div"||d=="span"){var e=b.children("."+this._inlineClass);e.children().addClass("ui-state-disabled"),e.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=$.map(this._disabledInputs,function(b){return b==a?null:b}),this._disabledInputs[this._disabledInputs.length]=a},_isDisabledDatepicker:function(a){if(!a)return!1;for(var b=0;b<this._disabledInputs.length;b++)if(this._disabledInputs[b]==a)return!0;return!1},_getInst:function(a){try{return $.data(a,PROP_NAME)}catch(b){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(a,b,c){var d=this._getInst(a);if(arguments.length==2&&typeof b=="string")return b=="defaults"?$.extend({},$.datepicker._defaults):d?b=="all"?$.extend({},d.settings):this._get(d,b):null;var e=b||{};typeof b=="string"&&(e={},e[b]=c);if(d){this._curInst==d&&this._hideDatepicker();var f=this._getDateDatepicker(a,!0),g=this._getMinMaxDate(d,"min"),h=this._getMinMaxDate(d,"max");extendRemove(d.settings,e),g!==null&&e.dateFormat!==undefined&&e.minDate===undefined&&(d.settings.minDate=this._formatDate(d,g)),h!==null&&e.dateFormat!==undefined&&e.maxDate===undefined&&(d.settings.maxDate=this._formatDate(d,h)),this._attachments($(a),d),this._autoSize(d),this._setDate(d,f),this._updateAlternate(d),this._updateDatepicker(d)}},_changeDatepicker:function(a,b,c){this._optionDatepicker(a,b,c)},_refreshDatepicker:function(a){var b=this._getInst(a);b&&this._updateDatepicker(b)},_setDateDatepicker:function(a,b){var c=this._getInst(a);c&&(this._setDate(c,b),this._updateDatepicker(c),this._updateAlternate(c))},_getDateDatepicker:function(a,b){var c=this._getInst(a);return c&&!c.inline&&this._setDateFromField(c,b),c?this._getDate(c):null},_doKeyDown:function(a){var b=$.datepicker._getInst(a.target),c=!0,d=b.dpDiv.is(".ui-datepicker-rtl");b._keyEvent=!0;if($.datepicker._datepickerShowing)switch(a.keyCode){case 9:$.datepicker._hideDatepicker(),c=!1;break;case 13:var e=$("td."+$.datepicker._dayOverClass+":not(."+$.datepicker._currentClass+")",b.dpDiv);e[0]&&$.datepicker._selectDay(a.target,b.selectedMonth,b.selectedYear,e[0]);var f=$.datepicker._get(b,"onSelect");if(f){var g=$.datepicker._formatDate(b);f.apply(b.input?b.input[0]:null,[g,b])}else $.datepicker._hideDatepicker();return!1;case 27:$.datepicker._hideDatepicker();break;case 33:$.datepicker._adjustDate(a.target,a.ctrlKey?-$.datepicker._get(b,"stepBigMonths"):-$.datepicker._get(b,"stepMonths"),"M");break;case 34:$.datepicker._adjustDate(a.target,a.ctrlKey?+$.datepicker._get(b,"stepBigMonths"):+$.datepicker._get(b,"stepMonths"),"M");break;case 35:(a.ctrlKey||a.metaKey)&&$.datepicker._clearDate(a.target),c=a.ctrlKey||a.metaKey;break;case 36:(a.ctrlKey||a.metaKey)&&$.datepicker._gotoToday(a.target),c=a.ctrlKey||a.metaKey;break;case 37:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,d?1:-1,"D"),c=a.ctrlKey||a.metaKey,a.originalEvent.altKey&&$.datepicker._adjustDate(a.target,a.ctrlKey?-$.datepicker._get(b,"stepBigMonths"):-$.datepicker._get(b,"stepMonths"),"M");break;case 38:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,-7,"D"),c=a.ctrlKey||a.metaKey;break;case 39:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,d?-1:1,"D"),c=a.ctrlKey||a.metaKey,a.originalEvent.altKey&&$.datepicker._adjustDate(a.target,a.ctrlKey?+$.datepicker._get(b,"stepBigMonths"):+$.datepicker._get(b,"stepMonths"),"M");break;case 40:(a.ctrlKey||a.metaKey)&&$.datepicker._adjustDate(a.target,7,"D"),c=a.ctrlKey||a.metaKey;break;default:c=!1}else a.keyCode==36&&a.ctrlKey?$.datepicker._showDatepicker(this):c=!1;c&&(a.preventDefault(),a.stopPropagation())},_doKeyPress:function(a){var b=$.datepicker._getInst(a.target);if($.datepicker._get(b,"constrainInput")){var c=$.datepicker._possibleChars($.datepicker._get(b,"dateFormat")),d=String.fromCharCode(a.charCode==undefined?a.keyCode:a.charCode);return a.ctrlKey||a.metaKey||d<" "||!c||c.indexOf(d)>-1}},_doKeyUp:function(a){var b=$.datepicker._getInst(a.target);if(b.input.val()!=b.lastVal)try{var c=$.datepicker.parseDate($.datepicker._get(b,"dateFormat"),b.input?b.input.val():null,$.datepicker._getFormatConfig(b));c&&($.datepicker._setDateFromField(b),$.datepicker._updateAlternate(b),$.datepicker._updateDatepicker(b))}catch(d){$.datepicker.log(d)}return!0},_showDatepicker:function(a){a=a.target||a,a.nodeName.toLowerCase()!="input"&&(a=$("input",a.parentNode)[0]);if($.datepicker._isDisabledDatepicker(a)||$.datepicker._lastInput==a)return;var b=$.datepicker._getInst(a);$.datepicker._curInst&&$.datepicker._curInst!=b&&($.datepicker._curInst.dpDiv.stop(!0,!0),b&&$.datepicker._datepickerShowing&&$.datepicker._hideDatepicker($.datepicker._curInst.input[0]));var c=$.datepicker._get(b,"beforeShow"),d=c?c.apply(a,[a,b]):{};if(d===!1)return;extendRemove(b.settings,d),b.lastVal=null,$.datepicker._lastInput=a,$.datepicker._setDateFromField(b),$.datepicker._inDialog&&(a.value=""),$.datepicker._pos||($.datepicker._pos=$.datepicker._findPos(a),$.datepicker._pos[1]+=a.offsetHeight);var e=!1;$(a).parents().each(function(){return e|=$(this).css("position")=="fixed",!e}),e&&$.browser.opera&&($.datepicker._pos[0]-=document.documentElement.scrollLeft,$.datepicker._pos[1]-=document.documentElement.scrollTop);var f={left:$.datepicker._pos[0],top:$.datepicker._pos[1]};$.datepicker._pos=null,b.dpDiv.empty(),b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),$.datepicker._updateDatepicker(b),f=$.datepicker._checkOffset(b,f,e),b.dpDiv.css({position:$.datepicker._inDialog&&$.blockUI?"static":e?"fixed":"absolute",display:"none",left:f.left+"px",top:f.top+"px"});if(!b.inline){var g=$.datepicker._get(b,"showAnim"),h=$.datepicker._get(b,"duration"),i=function(){var a=b.dpDiv.find("iframe.ui-datepicker-cover");if(!!a.length){var c=$.datepicker._getBorders(b.dpDiv);a.css({left:-c[0],top:-c[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex($(a).zIndex()+1),$.datepicker._datepickerShowing=!0,$.effects&&$.effects[g]?b.dpDiv.show(g,$.datepicker._get(b,"showOptions"),h,i):b.dpDiv[g||"show"](g?h:null,i),(!g||!h)&&i(),b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus(),$.datepicker._curInst=b}},_updateDatepicker:function(a){var b=this;b.maxRows=4;var c=$.datepicker._getBorders(a.dpDiv);instActive=a,a.dpDiv.empty().append(this._generateHTML(a)),this._attachHandlers(a);var d=a.dpDiv.find("iframe.ui-datepicker-cover");!d.length||d.css({left:-c[0],top:-c[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}),a.dpDiv.find("."+this._dayOverClass+" a").mouseover();var e=this._getNumberOfMonths(a),f=e[1],g=17;a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),f>1&&a.dpDiv.addClass("ui-datepicker-multi-"+f).css("width",g*f+"em"),a.dpDiv[(e[0]!=1||e[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi"),a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),a==$.datepicker._curInst&&$.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var h=a.yearshtml;setTimeout(function(){h===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml),h=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(a){return{thin:1,medium:2,thick:3}[a]||a};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var d=a.dpDiv.outerWidth(),e=a.dpDiv.outerHeight(),f=a.input?a.input.outerWidth():0,g=a.input?a.input.outerHeight():0,h=document.documentElement.clientWidth+(c?0:$(document).scrollLeft()),i=document.documentElement.clientHeight+(c?0:$(document).scrollTop());return b.left-=this._get(a,"isRTL")?d-f:0,b.left-=c&&b.left==a.input.offset().left?$(document).scrollLeft():0,b.top-=c&&b.top==a.input.offset().top+g?$(document).scrollTop():0,b.left-=Math.min(b.left,b.left+d>h&&h>d?Math.abs(b.left+d-h):0),b.top-=Math.min(b.top,b.top+e>i&&i>e?Math.abs(e+g):0),b},_findPos:function(a){var b=this._getInst(a),c=this._get(b,"isRTL");while(a&&(a.type=="hidden"||a.nodeType!=1||$.expr.filters.hidden(a)))a=a[c?"previousSibling":"nextSibling"];var d=$(a).offset();return[d.left,d.top]},_hideDatepicker:function(a){var b=this._curInst;if(!b||a&&b!=$.data(a,PROP_NAME))return;if(this._datepickerShowing){var c=this._get(b,"showAnim"),d=this._get(b,"duration"),e=function(){$.datepicker._tidyDialog(b)};$.effects&&$.effects[c]?b.dpDiv.hide(c,$.datepicker._get(b,"showOptions"),d,e):b.dpDiv[c=="slideDown"?"slideUp":c=="fadeIn"?"fadeOut":"hide"](c?d:null,e),c||e(),this._datepickerShowing=!1;var f=this._get(b,"onClose");f&&f.apply(b.input?b.input[0]:null,[b.input?b.input.val():"",b]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),$.blockUI&&($.unblockUI(),$("body").append(this.dpDiv))),this._inDialog=!1}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(!$.datepicker._curInst)return;var b=$(a.target),c=$.datepicker._getInst(b[0]);(b[0].id!=$.datepicker._mainDivId&&b.parents("#"+$.datepicker._mainDivId).length==0&&!b.hasClass($.datepicker.markerClassName)&&!b.closest("."+$.datepicker._triggerClass).length&&$.datepicker._datepickerShowing&&(!$.datepicker._inDialog||!$.blockUI)||b.hasClass($.datepicker.markerClassName)&&$.datepicker._curInst!=c)&&$.datepicker._hideDatepicker()},_adjustDate:function(a,b,c){var d=$(a),e=this._getInst(d[0]);if(this._isDisabledDatepicker(d[0]))return;this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c),this._updateDatepicker(e)},_gotoToday:function(a){var b=$(a),c=this._getInst(b[0]);if(this._get(c,"gotoCurrent")&&c.currentDay)c.selectedDay=c.currentDay,c.drawMonth=c.selectedMonth=c.currentMonth,c.drawYear=c.selectedYear=c.currentYear;else{var d=new Date;c.selectedDay=d.getDate(),c.drawMonth=c.selectedMonth=d.getMonth(),c.drawYear=c.selectedYear=d.getFullYear()}this._notifyChange(c),this._adjustDate(b)},_selectMonthYear:function(a,b,c){var d=$(a),e=this._getInst(d[0]);e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10),this._notifyChange(e),this._adjustDate(d)},_selectDay:function(a,b,c,d){var e=$(a);if($(d).hasClass(this._unselectableClass)||this._isDisabledDatepicker(e[0]))return;var f=this._getInst(e[0]);f.selectedDay=f.currentDay=$("a",d).html(),f.selectedMonth=f.currentMonth=b,f.selectedYear=f.currentYear=c,this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))},_clearDate:function(a){var b=$(a),c=this._getInst(b[0]);this._selectDate(b,"")},_selectDate:function(a,b){var c=$(a),d=this._getInst(c[0]);b=b!=null?b:this._formatDate(d),d.input&&d.input.val(b),this._updateAlternate(d);var e=this._get(d,"onSelect");e?e.apply(d.input?d.input[0]:null,[b,d]):d.input&&d.input.trigger("change"),d.inline?this._updateDatepicker(d):(this._hideDatepicker(),this._lastInput=d.input[0],typeof d.input[0]!="object"&&d.input.focus(),this._lastInput=null)},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),d=this._getDate(a),e=this.formatDate(c,d,this._getFormatConfig(a));$(b).each(function(){$(this).val(e)})}},noWeekends:function(a){var b=a.getDay();return[b>0&&b<6,""]},iso8601Week:function(a){var b=new Date(a.getTime());b.setDate(b.getDate()+4-(b.getDay()||7));var c=b.getTime();return b.setMonth(0),b.setDate(1),Math.floor(Math.round((c-b)/864e5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?b.toString():b+"";if(b=="")return null;var d=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;d=typeof d!="string"?d:(new Date).getFullYear()%100+parseInt(d,10);var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,g=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,h=(c?c.monthNames:null)||this._defaults.monthNames,i=-1,j=-1,k=-1,l=-1,m=!1,n=function(b){var c=s+1<a.length&&a.charAt(s+1)==b;return c&&s++,c},o=function(a){var c=n(a),d=a=="@"?14:a=="!"?20:a=="y"&&c?4:a=="o"?3:2,e=new RegExp("^\\d{1,"+d+"}"),f=b.substring(r).match(e);if(!f)throw"Missing number at position "+r;return r+=f[0].length,parseInt(f[0],10)},p=function(a,c,d){var e=$.map(n(a)?d:c,function(a,b){return[[b,a]]}).sort(function(a,b){return-(a[1].length-b[1].length)}),f=-1;$.each(e,function(a,c){var d=c[1];if(b.substr(r,d.length).toLowerCase()==d.toLowerCase())return f=c[0],r+=d.length,!1});if(f!=-1)return f+1;throw"Unknown name at position "+r},q=function(){if(b.charAt(r)!=a.charAt(s))throw"Unexpected literal at position "+r;r++},r=0;for(var s=0;s<a.length;s++)if(m)a.charAt(s)=="'"&&!n("'")?m=!1:q();else switch(a.charAt(s)){case"d":k=o("d");break;case"D":p("D",e,f);break;case"o":l=o("o");break;case"m":j=o("m");break;case"M":j=p("M",g,h);break;case"y":i=o("y");break;case"@":var t=new Date(o("@"));i=t.getFullYear(),j=t.getMonth()+1,k=t.getDate();break;case"!":var t=new Date((o("!")-this._ticksTo1970)/1e4);i=t.getFullYear(),j=t.getMonth()+1,k=t.getDate();break;case"'":n("'")?q():m=!0;break;default:q()}if(r<b.length)throw"Extra/unparsed characters found in date: "+b.substring(r);i==-1?i=(new Date).getFullYear():i<100&&(i+=(new Date).getFullYear()-(new Date).getFullYear()%100+(i<=d?0:-100));if(l>-1){j=1,k=l;do{var u=this._getDaysInMonth(i,j-1);if(k<=u)break;j++,k-=u}while(!0)}var t=this._daylightSavingAdjust(new Date(i,j-1,k));if(t.getFullYear()!=i||t.getMonth()+1!=j||t.getDate()!=k)throw"Invalid date";return t},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1e7,formatDate:function(a,b,c){if(!b)return"";var d=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,e=(c?c.dayNames:null)||this._defaults.dayNames,f=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,h=function(b){var c=m+1<a.length&&a.charAt(m+1)==b;return c&&m++,c},i=function(a,b,c){var d=""+b;if(h(a))while(d.length<c)d="0"+d;return d},j=function(a,b,c,d){return h(a)?d[b]:c[b]},k="",l=!1;if(b)for(var m=0;m<a.length;m++)if(l)a.charAt(m)=="'"&&!h("'")?l=!1:k+=a.charAt(m);else switch(a.charAt(m)){case"d":k+=i("d",b.getDate(),2);break;case"D":k+=j("D",b.getDay(),d,e);break;case"o":k+=i("o",Math.round(((new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime()-(new Date(b.getFullYear(),0,0)).getTime())/864e5),3);break;case"m":k+=i("m",b.getMonth()+1,2);break;case"M":k+=j("M",b.getMonth(),f,g);break;case"y":k+=h("y")?b.getFullYear():(b.getYear()%100<10?"0":"")+b.getYear()%100;break;case"@":k+=b.getTime();break;case"!":k+=b.getTime()*1e4+this._ticksTo1970;break;case"'":h("'")?k+="'":l=!0;break;default:k+=a.charAt(m)}return k},_possibleChars:function(a){var b="",c=!1,d=function(b){var c=e+1<a.length&&a.charAt(e+1)==b;return c&&e++,c};for(var e=0;e<a.length;e++)if(c)a.charAt(e)=="'"&&!d("'")?c=!1:b+=a.charAt(e);else switch(a.charAt(e)){case"d":case"m":case"y":case"@":b+="0123456789";break;case"D":case"M":return null;case"'":d("'")?b+="'":c=!0;break;default:b+=a.charAt(e)}return b},_get:function(a,b){return a.settings[b]!==undefined?a.settings[b]:this._defaults[b]},_setDateFromField:function(a,b){if(a.input.val()==a.lastVal)return;var c=this._get(a,"dateFormat"),d=a.lastVal=a.input?a.input.val():null,e,f;e=f=this._getDefaultDate(a);var g=this._getFormatConfig(a);try{e=this.parseDate(c,d,g)||f}catch(h){this.log(h),d=b?"":d}a.selectedDay=e.getDate(),a.drawMonth=a.selectedMonth=e.getMonth(),a.drawYear=a.selectedYear=e.getFullYear(),a.currentDay=d?e.getDate():0,a.currentMonth=d?e.getMonth():0,a.currentYear=d?e.getFullYear():0,this._adjustInstDate(a)},_getDefaultDate:function(a){return this._restrictMinMax(a,this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,b,c){var d=function(a){var b=new Date;return b.setDate(b.getDate()+a),b},e=function(b){try{return $.datepicker.parseDate($.datepicker._get(a,"dateFormat"),b,$.datepicker._getFormatConfig(a))}catch(c){}var d=(b.toLowerCase().match(/^c/)?$.datepicker._getDate(a):null)||new Date,e=d.getFullYear(),f=d.getMonth(),g=d.getDate(),h=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,i=h.exec(b);while(i){switch(i[2]||"d"){case"d":case"D":g+=parseInt(i[1],10);break;case"w":case"W":g+=parseInt(i[1],10)*7;break;case"m":case"M":f+=parseInt(i[1],10),g=Math.min(g,$.datepicker._getDaysInMonth(e,f));break;case"y":case"Y":e+=parseInt(i[1],10),g=Math.min(g,$.datepicker._getDaysInMonth(e,f))}i=h.exec(b)}return new Date(e,f,g)},f=b==null||b===""?c:typeof b=="string"?e(b):typeof b=="number"?isNaN(b)?c:d(b):new Date(b.getTime());return f=f&&f.toString()=="Invalid Date"?c:f,f&&(f.setHours(0),f.setMinutes(0),f.setSeconds(0),f.setMilliseconds(0)),this._daylightSavingAdjust(f)},_daylightSavingAdjust:function(a){return a?(a.setHours(a.getHours()>12?a.getHours()+2:0),a):null},_setDate:function(a,b,c){var d=!b,e=a.selectedMonth,f=a.selectedYear,g=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=g.getDate(),a.drawMonth=a.selectedMonth=a.currentMonth=g.getMonth(),a.drawYear=a.selectedYear=a.currentYear=g.getFullYear(),(e!=a.selectedMonth||f!=a.selectedYear)&&!c&&this._notifyChange(a),this._adjustInstDate(a),a.input&&a.input.val(d?"":this._formatDate(a))},_getDate:function(a){var b=!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return b},_attachHandlers:function(a){var b=this._get(a,"stepMonths"),c="#"+a.id.replace(/\\\\/g,"\\");a.dpDiv.find("[data-handler]").map(function(){var a={prev:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(c,-b,"M")},next:function(){window["DP_jQuery_"+dpuuid].datepicker._adjustDate(c,+b,"M")},hide:function(){window["DP_jQuery_"+dpuuid].datepicker._hideDatepicker()},today:function(){window["DP_jQuery_"+dpuuid].datepicker._gotoToday(c)},selectDay:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectDay(c,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(c,this,"M"),!1},selectYear:function(){return window["DP_jQuery_"+dpuuid].datepicker._selectMonthYear(c,this,"Y"),!1}};$(this).bind(this.getAttribute("data-event"),a[this.getAttribute("data-handler")])})},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),d=this._get(a,"showButtonPanel"),e=this._get(a,"hideIfNoPrevNext"),f=this._get(a,"navigationAsDateFormat"),g=this._getNumberOfMonths(a),h=this._get(a,"showCurrentAtPos"),i=this._get(a,"stepMonths"),j=g[0]!=1||g[1]!=1,k=this._daylightSavingAdjust(a.currentDay?new Date(a.currentYear,a.currentMonth,a.currentDay):new Date(9999,9,9)),l=this._getMinMaxDate(a,"min"),m=this._getMinMaxDate(a,"max"),n=a.drawMonth-h,o=a.drawYear;n<0&&(n+=12,o--);if(m){var p=this._daylightSavingAdjust(new Date(m.getFullYear(),m.getMonth()-g[0]*g[1]+1,m.getDate()));p=l&&p<l?l:p;while(this._daylightSavingAdjust(new Date(o,n,1))>p)n--,n<0&&(n=11,o--)}a.drawMonth=n,a.drawYear=o;var q=this._get(a,"prevText");q=f?this.formatDate(q,this._daylightSavingAdjust(new Date(o,n-i,1)),this._getFormatConfig(a)):q;var r=this._canAdjustMonth(a,-1,o,n)?'<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click" title="'+q+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+q+"</span></a>":e?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+q+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+q+"</span></a>",s=this._get(a,"nextText");s=f?this.formatDate(s,this._daylightSavingAdjust(new Date(o,n+i,1)),this._getFormatConfig(a)):s;var t=this._canAdjustMonth(a,1,o,n)?'<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click" title="'+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>":e?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>",u=this._get(a,"currentText"),v=this._get(a,"gotoCurrent")&&a.currentDay?k:b;u=f?this.formatDate(u,v,this._getFormatConfig(a)):u;var w=a.inline?"":'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">'+this._get(a,"closeText")+"</button>",x=d?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(c?w:"")+(this._isInRange(a,v)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click">'+u+"</button>":"")+(c?"":w)+"</div>":"",y=parseInt(this._get(a,"firstDay"),10);y=isNaN(y)?0:y;var z=this._get(a,"showWeek"),A=this._get(a,"dayNames"),B=this._get(a,"dayNamesShort"),C=this._get(a,"dayNamesMin"),D=this._get(a,"monthNames"),E=this._get(a,"monthNamesShort"),F=this._get(a,"beforeShowDay"),G=this._get(a,"showOtherMonths"),H=this._get(a,"selectOtherMonths"),I=this._get(a,"calculateWeek")||this.iso8601Week,J=this._getDefaultDate(a),K="";for(var L=0;L<g[0];L++){var M="";this.maxRows=4;for(var N=0;N<g[1];N++){var O=this._daylightSavingAdjust(new Date(o,n,a.selectedDay)),P=" ui-corner-all",Q="";if(j){Q+='<div class="ui-datepicker-group';if(g[1]>1)switch(N){case 0:Q+=" ui-datepicker-group-first",P=" ui-corner-"+(c?"right":"left");break;case g[1]-1:Q+=" ui-datepicker-group-last",P=" ui-corner-"+(c?"left":"right");break;default:Q+=" ui-datepicker-group-middle",P=""}Q+='">'}Q+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+P+'">'+(/all|left/.test(P)&&L==0?c?t:r:"")+(/all|right/.test(P)&&L==0?c?r:t:"")+this._generateMonthYearHeader(a,n,o,l,m,L>0||N>0,D,E)+'</div><table class="ui-datepicker-calendar"><thead>'+"<tr>";var R=z?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":"";for(var S=0;S<7;S++){var T=(S+y)%7;R+="<th"+((S+y+6)%7>=5?' class="ui-datepicker-week-end"':"")+">"+'<span title="'+A[T]+'">'+C[T]+"</span></th>"}Q+=R+"</tr></thead><tbody>";var U=this._getDaysInMonth(o,n);o==a.selectedYear&&n==a.selectedMonth&&(a.selectedDay=Math.min(a.selectedDay,U));var V=(this._getFirstDayOfMonth(o,n)-y+7)%7,W=Math.ceil((V+U)/7),X=j?this.maxRows>W?this.maxRows:W:W;this.maxRows=X;var Y=this._daylightSavingAdjust(new Date(o,n,1-V));for(var Z=0;Z<X;Z++){Q+="<tr>";var _=z?'<td class="ui-datepicker-week-col">'+this._get(a,"calculateWeek")(Y)+"</td>":"";for(var S=0;S<7;S++){var ba=F?F.apply(a.input?a.input[0]:null,[Y]):[!0,""],bb=Y.getMonth()!=n,bc=bb&&!H||!ba[0]||l&&Y<l||m&&Y>m;_+='<td class="'+((S+y+6)%7>=5?" ui-datepicker-week-end":"")+(bb?" ui-datepicker-other-month":"")+(Y.getTime()==O.getTime()&&n==a.selectedMonth&&a._keyEvent||J.getTime()==Y.getTime()&&J.getTime()==O.getTime()?" "+this._dayOverClass:"")+(bc?" "+this._unselectableClass+" ui-state-disabled":"")+(bb&&!G?"":" "+ba[1]+(Y.getTime()==k.getTime()?" "+this._currentClass:"")+(Y.getTime()==b.getTime()?" ui-datepicker-today":""))+'"'+((!bb||G)&&ba[2]?' title="'+ba[2]+'"':"")+(bc?"":' data-handler="selectDay" data-event="click" data-month="'+Y.getMonth()+'" data-year="'+Y.getFullYear()+'"')+">"+(bb&&!G?"&#xa0;":bc?'<span class="ui-state-default">'+Y.getDate()+"</span>":'<a class="ui-state-default'+(Y.getTime()==b.getTime()?" ui-state-highlight":"")+(Y.getTime()==k.getTime()?" ui-state-active":"")+(bb?" ui-priority-secondary":"")+'" href="#">'+Y.getDate()+"</a>")+"</td>",Y.setDate(Y.getDate()+1),Y=this._daylightSavingAdjust(Y)}Q+=_+"</tr>"}n++,n>11&&(n=0,o++),Q+="</tbody></table>"+(j?"</div>"+(g[0]>0&&N==g[1]-1?'<div class="ui-datepicker-row-break"></div>':""):""),M+=Q}K+=M}return K+=x+($.browser.msie&&parseInt($.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':""),a._keyEvent=!1,K},_generateMonthYearHeader:function(a,b,c,d,e,f,g,h){var i=this._get(a,"changeMonth"),j=this._get(a,"changeYear"),k=this._get(a,"showMonthAfterYear"),l='<div class="ui-datepicker-title">',m="";if(f||!i)m+='<span class="ui-datepicker-month">'+g[b]+"</span>";else{var n=d&&d.getFullYear()==c,o=e&&e.getFullYear()==c;m+='<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">';for(var p=0;p<12;p++)(!n||p>=d.getMonth())&&(!o||p<=e.getMonth())&&(m+='<option value="'+p+'"'+(p==b?' selected="selected"':"")+">"+h[p]+"</option>");m+="</select>"}k||(l+=m+(f||!i||!j?"&#xa0;":""));if(!a.yearshtml){a.yearshtml="";if(f||!j)l+='<span class="ui-datepicker-year">'+c+"</span>";else{var q=this._get(a,"yearRange").split(":"),r=(new Date).getFullYear(),s=function(a){var b=a.match(/c[+-].*/)?c+parseInt(a.substring(1),10):a.match(/[+-].*/)?r+parseInt(a,10):parseInt(a,10);return isNaN(b)?r:b},t=s(q[0]),u=Math.max(t,s(q[1]||""));t=d?Math.max(t,d.getFullYear()):t,u=e?Math.min(u,e.getFullYear()):u,a.yearshtml+='<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">';for(;t<=u;t++)a.yearshtml+='<option value="'+t+'"'+(t==c?' selected="selected"':"")+">"+t+"</option>";a.yearshtml+="</select>",l+=a.yearshtml,a.yearshtml=null}}return l+=this._get(a,"yearSuffix"),k&&(l+=(f||!i||!j?"&#xa0;":"")+m),l+="</div>",l},_adjustInstDate:function(a,b,c){var d=a.drawYear+(c=="Y"?b:0),e=a.drawMonth+(c=="M"?b:0),f=Math.min(a.selectedDay,this._getDaysInMonth(d,e))+(c=="D"?b:0),g=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(d,e,f)));a.selectedDay=g.getDate(),a.drawMonth=a.selectedMonth=g.getMonth(),a.drawYear=a.selectedYear=g.getFullYear(),(c=="M"||c=="Y")&&this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max"),e=c&&b<c?c:b;return e=d&&e>d?d:e,e},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");b&&b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){var b=this._get(a,"numberOfMonths");return b==null?[1,1]:typeof b=="number"?[1,b]:b},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,d){var e=this._getNumberOfMonths(a),f=this._daylightSavingAdjust(new Date(c,d+(b<0?b:e[0]*e[1]),1));return b<0&&f.setDate(this._getDaysInMonth(f.getFullYear(),f.getMonth())),this._isInRange(a,f)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min"),d=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!d||b.getTime()<=d.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");return b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10),{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,d){b||(a.currentDay=a.selectedDay,a.currentMonth=a.selectedMonth,a.currentYear=a.selectedYear);var e=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(d,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),e,this._getFormatConfig(a))}}),$.fn.datepicker=function(a){if(!this.length)return this;$.datepicker.initialized||($(document).mousedown($.datepicker._checkExternalClick).find("body").append($.datepicker.dpDiv),$.datepicker.initialized=!0);var b=Array.prototype.slice.call(arguments,1);return typeof a!="string"||a!="isDisabled"&&a!="getDate"&&a!="widget"?a=="option"&&arguments.length==2&&typeof arguments[1]=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b)):this.each(function(){typeof a=="string"?$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this].concat(b)):$.datepicker._attachDatepicker(this,a)}):$.datepicker["_"+a+"Datepicker"].apply($.datepicker,[this[0]].concat(b))},$.datepicker=new Datepicker,$.datepicker.initialized=!1,$.datepicker.uuid=(new Date).getTime(),$.datepicker.version="1.8.23",window["DP_jQuery_"+dpuuid]=$})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.ui.progressbar.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()}),this.valueDiv=a("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element),this.oldValue=this._value(),this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove(),a.Widget.prototype.destroy.apply(this,arguments)},value:function(a){return a===b?this._value():(this._setOption("value",a),this)},_setOption:function(b,c){b==="value"&&(this.options.value=c,this._refreshValue(),this._value()===this.options.max&&this._trigger("complete")),a.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;return typeof a!="number"&&(a=0),Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*this._value()/this.options.max},_refreshValue:function(){var a=this.value(),b=this._percentage();this.oldValue!==a&&(this.oldValue=a,this._trigger("change")),this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(b.toFixed(0)+"%"),this.element.attr("aria-valuenow",a)}}),a.extend(a.ui.progressbar,{version:"1.8.23"})})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.core.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-jQuery.effects||function(a,b){function c(b){var c;return b&&b.constructor==Array&&b.length==3?b:(c=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))?[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)]:(c=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(b))?[parseFloat(c[1])*2.55,parseFloat(c[2])*2.55,parseFloat(c[3])*2.55]:(c=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(b))?[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)]:(c=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(b))?[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)]:(c=/rgba\(0, 0, 0, 0\)/.exec(b))?e.transparent:e[a.trim(b).toLowerCase()]}function d(b,d){var e;do{e=(a.curCSS||a.css)(b,d);if(e!=""&&e!="transparent"||a.nodeName(b,"body"))break;d="backgroundColor"}while(b=b.parentNode);return c(e)}function h(){var a=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,b={},c,d;if(a&&a.length&&a[0]&&a[a[0]]){var e=a.length;while(e--)c=a[e],typeof a[c]=="string"&&(d=c.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()}),b[d]=a[c])}else for(c in a)typeof a[c]=="string"&&(b[c]=a[c]);return b}function i(b){var c,d;for(c in b)d=b[c],(d==null||a.isFunction(d)||c in g||/scrollbar/.test(c)||!/color/i.test(c)&&isNaN(parseFloat(d)))&&delete b[c];return b}function j(a,b){var c={_:0},d;for(d in b)a[d]!=b[d]&&(c[d]=b[d]);return c}function k(b,c,d,e){typeof b=="object"&&(e=c,d=null,c=b,b=c.effect),a.isFunction(c)&&(e=c,d=null,c={});if(typeof c=="number"||a.fx.speeds[c])e=d,d=c,c={};return a.isFunction(d)&&(e=d,d=null),c=c||{},d=d||c.duration,d=a.fx.off?0:typeof d=="number"?d:d in a.fx.speeds?a.fx.speeds[d]:a.fx.speeds._default,e=e||c.complete,[b,c,d,e]}function l(b){return!b||typeof b=="number"||a.fx.speeds[b]?!0:typeof b=="string"&&!a.effects[b]?!0:!1}a.effects={},a.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","borderColor","color","outlineColor"],function(b,e){a.fx.step[e]=function(a){a.colorInit||(a.start=d(a.elem,e),a.end=c(a.end),a.colorInit=!0),a.elem.style[e]="rgb("+Math.max(Math.min(parseInt(a.pos*(a.end[0]-a.start[0])+a.start[0],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[1]-a.start[1])+a.start[1],10),255),0)+","+Math.max(Math.min(parseInt(a.pos*(a.end[2]-a.start[2])+a.start[2],10),255),0)+")"}});var e={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},f=["add","remove","toggle"],g={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};a.effects.animateClass=function(b,c,d,e){return a.isFunction(d)&&(e=d,d=null),this.queue(function(){var g=a(this),k=g.attr("style")||" ",l=i(h.call(this)),m,n=g.attr("class")||"";a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),m=i(h.call(this)),g.attr("class",n),g.animate(j(l,m),{queue:!1,duration:c,easing:d,complete:function(){a.each(f,function(a,c){b[c]&&g[c+"Class"](b[c])}),typeof g.attr("style")=="object"?(g.attr("style").cssText="",g.attr("style").cssText=k):g.attr("style",k),e&&e.apply(this,arguments),a.dequeue(this)}})})},a.fn.extend({_addClass:a.fn.addClass,addClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{add:b},c,d,e]):this._addClass(b)},_removeClass:a.fn.removeClass,removeClass:function(b,c,d,e){return c?a.effects.animateClass.apply(this,[{remove:b},c,d,e]):this._removeClass(b)},_toggleClass:a.fn.toggleClass,toggleClass:function(c,d,e,f,g){return typeof d=="boolean"||d===b?e?a.effects.animateClass.apply(this,[d?{add:c}:{remove:c},e,f,g]):this._toggleClass(c,d):a.effects.animateClass.apply(this,[{toggle:c},d,e,f])},switchClass:function(b,c,d,e,f){return a.effects.animateClass.apply(this,[{add:c,remove:b},d,e,f])}}),a.extend(a.effects,{version:"1.8.23",save:function(a,b){for(var c=0;c<b.length;c++)b[c]!==null&&a.data("ec.storage."+b[c],a[0].style[b[c]])},restore:function(a,b){for(var c=0;c<b.length;c++)b[c]!==null&&a.css(b[c],a.data("ec.storage."+b[c]))},setMode:function(a,b){return b=="toggle"&&(b=a.is(":hidden")?"show":"hide"),b},getBaseline:function(a,b){var c,d;switch(a[0]){case"top":c=0;break;case"middle":c=.5;break;case"bottom":c=1;break;default:c=a[0]/b.height}switch(a[1]){case"left":d=0;break;case"center":d=.5;break;case"right":d=1;break;default:d=a[1]/b.width}return{x:d,y:c}},createWrapper:function(b){if(b.parent().is(".ui-effects-wrapper"))return b.parent();var c={width:b.outerWidth(!0),height:b.outerHeight(!0),"float":b.css("float")},d=a("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),e=document.activeElement;try{e.id}catch(f){e=document.body}return b.wrap(d),(b[0]===e||a.contains(b[0],e))&&a(e).focus(),d=b.parent(),b.css("position")=="static"?(d.css({position:"relative"}),b.css({position:"relative"})):(a.extend(c,{position:b.css("position"),zIndex:b.css("z-index")}),a.each(["top","left","bottom","right"],function(a,d){c[d]=b.css(d),isNaN(parseInt(c[d],10))&&(c[d]="auto")}),b.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),d.css(c).show()},removeWrapper:function(b){var c,d=document.activeElement;return b.parent().is(".ui-effects-wrapper")?(c=b.parent().replaceWith(b),(b[0]===d||a.contains(b[0],d))&&a(d).focus(),c):b},setTransition:function(b,c,d,e){return e=e||{},a.each(c,function(a,c){var f=b.cssUnit(c);f[0]>0&&(e[c]=f[0]*d+f[1])}),e}}),a.fn.extend({effect:function(b,c,d,e){var f=k.apply(this,arguments),g={options:f[1],duration:f[2],callback:f[3]},h=g.options.mode,i=a.effects[b];return a.fx.off||!i?h?this[h](g.duration,g.callback):this.each(function(){g.callback&&g.callback.call(this)}):i.call(this,g)},_show:a.fn.show,show:function(a){if(l(a))return this._show.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="show",this.effect.apply(this,b)},_hide:a.fn.hide,hide:function(a){if(l(a))return this._hide.apply(this,arguments);var b=k.apply(this,arguments);return b[1].mode="hide",this.effect.apply(this,b)},__toggle:a.fn.toggle,toggle:function(b){if(l(b)||typeof b=="boolean"||a.isFunction(b))return this.__toggle.apply(this,arguments);var c=k.apply(this,arguments);return c[1].mode="toggle",this.effect.apply(this,c)},cssUnit:function(b){var c=this.css(b),d=[];return a.each(["em","px","%","pt"],function(a,b){c.indexOf(b)>0&&(d=[parseFloat(c),b])}),d}});var m={};a.each(["Quad","Cubic","Quart","Quint","Expo"],function(a,b){m[b]=function(b){return Math.pow(b,a+2)}}),a.extend(m,{Sine:function(a){return 1-Math.cos(a*Math.PI/2)},Circ:function(a){return 1-Math.sqrt(1-a*a)},Elastic:function(a){return a===0||a===1?a:-Math.pow(2,8*(a-1))*Math.sin(((a-1)*80-7.5)*Math.PI/15)},Back:function(a){return a*a*(3*a-2)},Bounce:function(a){var b,c=4;while(a<((b=Math.pow(2,--c))-1)/11);return 1/Math.pow(4,3-c)-7.5625*Math.pow((b*3-2)/22-a,2)}}),a.each(m,function(b,c){a.easing["easeIn"+b]=c,a.easing["easeOut"+b]=function(a){return 1-c(1-a)},a.easing["easeInOut"+b]=function(a){return a<.5?c(a*2)/2:c(a*-2+2)/-2+1}})}(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.blind.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.blind=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"vertical";a.effects.save(c,d),c.show();var g=a.effects.createWrapper(c).css({overflow:"hidden"}),h=f=="vertical"?"height":"width",i=f=="vertical"?g.height():g.width();e=="show"&&g.css(h,0);var j={};j[h]=e=="show"?i:0,g.animate(j,b.duration,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.bounce.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.bounce=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"effect"),f=b.options.direction||"up",g=b.options.distance||20,h=b.options.times||5,i=b.duration||250;/show|hide/.test(e)&&d.push("opacity"),a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var j=f=="up"||f=="down"?"top":"left",k=f=="up"||f=="left"?"pos":"neg",g=b.options.distance||(j=="top"?c.outerHeight(!0)/3:c.outerWidth(!0)/3);e=="show"&&c.css("opacity",0).css(j,k=="pos"?-g:g),e=="hide"&&(g=g/(h*2)),e!="hide"&&h--;if(e=="show"){var l={opacity:1};l[j]=(k=="pos"?"+=":"-=")+g,c.animate(l,i/2,b.options.easing),g=g/2,h--}for(var m=0;m<h;m++){var n={},p={};n[j]=(k=="pos"?"-=":"+=")+g,p[j]=(k=="pos"?"+=":"-=")+g,c.animate(n,i/2,b.options.easing).animate(p,i/2,b.options.easing),g=e=="hide"?g*2:g/2}if(e=="hide"){var l={opacity:0};l[j]=(k=="pos"?"-=":"+=")+g,c.animate(l,i/2,b.options.easing,function(){c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments)})}else{var n={},p={};n[j]=(k=="pos"?"-=":"+=")+g,p[j]=(k=="pos"?"+=":"-=")+g,c.animate(n,i/2,b.options.easing).animate(p,i/2,b.options.easing,function(){a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments)})}c.queue("fx",function(){c.dequeue()}),c.dequeue()})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.clip.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.clip=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right","height","width"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"vertical";a.effects.save(c,d),c.show();var g=a.effects.createWrapper(c).css({overflow:"hidden"}),h=c[0].tagName=="IMG"?g:c,i={size:f=="vertical"?"height":"width",position:f=="vertical"?"top":"left"},j=f=="vertical"?h.height():h.width();e=="show"&&(h.css(i.size,0),h.css(i.position,j/2));var k={};k[i.size]=e=="show"?j:0,k[i.position]=e=="show"?0:j/2,h.animate(k,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.drop.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.drop=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right","opacity"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.direction||"left";a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var g=f=="up"||f=="down"?"top":"left",h=f=="up"||f=="left"?"pos":"neg",i=b.options.distance||(g=="top"?c.outerHeight(!0)/2:c.outerWidth(!0)/2);e=="show"&&c.css("opacity",0).css(g,h=="pos"?-i:i);var j={opacity:e=="show"?1:0};j[g]=(e=="show"?h=="pos"?"+=":"-=":h=="pos"?"-=":"+=")+i,c.animate(j,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.explode.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.explode=function(b){return this.queue(function(){var c=b.options.pieces?Math.round(Math.sqrt(b.options.pieces)):3,d=b.options.pieces?Math.round(Math.sqrt(b.options.pieces)):3;b.options.mode=b.options.mode=="toggle"?a(this).is(":visible")?"hide":"show":b.options.mode;var e=a(this).show().css("visibility","hidden"),f=e.offset();f.top-=parseInt(e.css("marginTop"),10)||0,f.left-=parseInt(e.css("marginLeft"),10)||0;var g=e.outerWidth(!0),h=e.outerHeight(!0);for(var i=0;i<c;i++)for(var j=0;j<d;j++)e.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-j*(g/d),top:-i*(h/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:g/d,height:h/c,left:f.left+j*(g/d)+(b.options.mode=="show"?(j-Math.floor(d/2))*(g/d):0),top:f.top+i*(h/c)+(b.options.mode=="show"?(i-Math.floor(c/2))*(h/c):0),opacity:b.options.mode=="show"?0:1}).animate({left:f.left+j*(g/d)+(b.options.mode=="show"?0:(j-Math.floor(d/2))*(g/d)),top:f.top+i*(h/c)+(b.options.mode=="show"?0:(i-Math.floor(c/2))*(h/c)),opacity:b.options.mode=="show"?1:0},b.duration||500);setTimeout(function(){b.options.mode=="show"?e.css({visibility:"visible"}):e.css({visibility:"visible"}).hide(),b.callback&&b.callback.apply(e[0]),e.dequeue(),a("div.ui-effects-explode").remove()},b.duration||500)})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.fade.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.fade=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"hide");c.animate({opacity:d},{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.fold.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.fold=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"hide"),f=b.options.size||15,g=!!b.options.horizFirst,h=b.duration?b.duration/2:a.fx.speeds._default/2;a.effects.save(c,d),c.show();var i=a.effects.createWrapper(c).css({overflow:"hidden"}),j=e=="show"!=g,k=j?["width","height"]:["height","width"],l=j?[i.width(),i.height()]:[i.height(),i.width()],m=/([0-9]+)%/.exec(f);m&&(f=parseInt(m[1],10)/100*l[e=="hide"?0:1]),e=="show"&&i.css(g?{height:0,width:f}:{height:f,width:0});var n={},p={};n[k[0]]=e=="show"?l[0]:f,p[k[1]]=e=="show"?l[1]:0,i.animate(n,h,b.options.easing).animate(p,h,b.options.easing,function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.highlight.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.highlight=function(b){return this.queue(function(){var c=a(this),d=["backgroundImage","backgroundColor","opacity"],e=a.effects.setMode(c,b.options.mode||"show"),f={backgroundColor:c.css("backgroundColor")};e=="hide"&&(f.opacity=0),a.effects.save(c,d),c.show().css({backgroundImage:"none",backgroundColor:b.options.color||"#ffff99"}).animate(f,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),e=="show"&&!a.support.opacity&&this.style.removeAttribute("filter"),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.pulsate.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.pulsate=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"show"),e=(b.options.times||5)*2-1,f=b.duration?b.duration/2:a.fx.speeds._default/2,g=c.is(":visible"),h=0;g||(c.css("opacity",0).show(),h=1),(d=="hide"&&g||d=="show"&&!g)&&e--;for(var i=0;i<e;i++)c.animate({opacity:h},f,b.options.easing),h=(h+1)%2;c.animate({opacity:h},f,b.options.easing,function(){h==0&&c.hide(),b.callback&&b.callback.apply(this,arguments)}),c.queue("fx",function(){c.dequeue()}).dequeue()})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.scale.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.puff=function(b){return this.queue(function(){var c=a(this),d=a.effects.setMode(c,b.options.mode||"hide"),e=parseInt(b.options.percent,10)||150,f=e/100,g={height:c.height(),width:c.width()};a.extend(b.options,{fade:!0,mode:d,percent:d=="hide"?e:100,from:d=="hide"?g:{height:g.height*f,width:g.width*f}}),c.effect("scale",b.options,b.duration,b.callback),c.dequeue()})},a.effects.scale=function(b){return this.queue(function(){var c=a(this),d=a.extend(!0,{},b.options),e=a.effects.setMode(c,b.options.mode||"effect"),f=parseInt(b.options.percent,10)||(parseInt(b.options.percent,10)==0?0:e=="hide"?0:100),g=b.options.direction||"both",h=b.options.origin;e!="effect"&&(d.origin=h||["middle","center"],d.restore=!0);var i={height:c.height(),width:c.width()};c.from=b.options.from||(e=="show"?{height:0,width:0}:i);var j={y:g!="horizontal"?f/100:1,x:g!="vertical"?f/100:1};c.to={height:i.height*j.y,width:i.width*j.x},b.options.fade&&(e=="show"&&(c.from.opacity=0,c.to.opacity=1),e=="hide"&&(c.from.opacity=1,c.to.opacity=0)),d.from=c.from,d.to=c.to,d.mode=e,c.effect("size",d,b.duration,b.callback),c.dequeue()})},a.effects.size=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right","width","height","overflow","opacity"],e=["position","top","bottom","left","right","overflow","opacity"],f=["width","height","overflow"],g=["fontSize"],h=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],i=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],j=a.effects.setMode(c,b.options.mode||"effect"),k=b.options.restore||!1,l=b.options.scale||"both",m=b.options.origin,n={height:c.height(),width:c.width()};c.from=b.options.from||n,c.to=b.options.to||n;if(m){var p=a.effects.getBaseline(m,n);c.from.top=(n.height-c.from.height)*p.y,c.from.left=(n.width-c.from.width)*p.x,c.to.top=(n.height-c.to.height)*p.y,c.to.left=(n.width-c.to.width)*p.x}var q={from:{y:c.from.height/n.height,x:c.from.width/n.width},to:{y:c.to.height/n.height,x:c.to.width/n.width}};if(l=="box"||l=="both")q.from.y!=q.to.y&&(d=d.concat(h),c.from=a.effects.setTransition(c,h,q.from.y,c.from),c.to=a.effects.setTransition(c,h,q.to.y,c.to)),q.from.x!=q.to.x&&(d=d.concat(i),c.from=a.effects.setTransition(c,i,q.from.x,c.from),c.to=a.effects.setTransition(c,i,q.to.x,c.to));(l=="content"||l=="both")&&q.from.y!=q.to.y&&(d=d.concat(g),c.from=a.effects.setTransition(c,g,q.from.y,c.from),c.to=a.effects.setTransition(c,g,q.to.y,c.to)),a.effects.save(c,k?d:e),c.show(),a.effects.createWrapper(c),c.css("overflow","hidden").css(c.from);if(l=="content"||l=="both")h=h.concat(["marginTop","marginBottom"]).concat(g),i=i.concat(["marginLeft","marginRight"]),f=d.concat(h).concat(i),c.find("*[width]").each(function(){var c=a(this);k&&a.effects.save(c,f);var d={height:c.height(),width:c.width()};c.from={height:d.height*q.from.y,width:d.width*q.from.x},c.to={height:d.height*q.to.y,width:d.width*q.to.x},q.from.y!=q.to.y&&(c.from=a.effects.setTransition(c,h,q.from.y,c.from),c.to=a.effects.setTransition(c,h,q.to.y,c.to)),q.from.x!=q.to.x&&(c.from=a.effects.setTransition(c,i,q.from.x,c.from),c.to=a.effects.setTransition(c,i,q.to.x,c.to)),c.css(c.from),c.animate(c.to,b.duration,b.options.easing,function(){k&&a.effects.restore(c,f)})});c.animate(c.to,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){c.to.opacity===0&&c.css("opacity",c.from.opacity),j=="hide"&&c.hide(),a.effects.restore(c,k?d:e),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.shake.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.shake=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"effect"),f=b.options.direction||"left",g=b.options.distance||20,h=b.options.times||3,i=b.duration||b.options.duration||140;a.effects.save(c,d),c.show(),a.effects.createWrapper(c);var j=f=="up"||f=="down"?"top":"left",k=f=="up"||f=="left"?"pos":"neg",l={},m={},n={};l[j]=(k=="pos"?"-=":"+=")+g,m[j]=(k=="pos"?"+=":"-=")+g*2,n[j]=(k=="pos"?"-=":"+=")+g*2,c.animate(l,i,b.options.easing);for(var p=1;p<h;p++)c.animate(m,i,b.options.easing).animate(n,i,b.options.easing);c.animate(m,i,b.options.easing).animate(l,i/2,b.options.easing,function(){a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments)}),c.queue("fx",function(){c.dequeue()}),c.dequeue()})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.slide.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.slide=function(b){return this.queue(function(){var c=a(this),d=["position","top","bottom","left","right"],e=a.effects.setMode(c,b.options.mode||"show"),f=b.options.direction||"left";a.effects.save(c,d),c.show(),a.effects.createWrapper(c).css({overflow:"hidden"});var g=f=="up"||f=="down"?"top":"left",h=f=="up"||f=="left"?"pos":"neg",i=b.options.distance||(g=="top"?c.outerHeight(!0):c.outerWidth(!0));e=="show"&&c.css(g,h=="pos"?isNaN(i)?"-"+i:-i:i);var j={};j[g]=(e=="show"?h=="pos"?"+=":"-=":h=="pos"?"-=":"+=")+i,c.animate(j,{queue:!1,duration:b.duration,easing:b.options.easing,complete:function(){e=="hide"&&c.hide(),a.effects.restore(c,d),a.effects.removeWrapper(c),b.callback&&b.callback.apply(this,arguments),c.dequeue()}})})}})(jQuery);;/*! jQuery UI - v1.8.23 - 2012-08-15
-* https://github.com/jquery/jquery-ui
-* Includes: jquery.effects.transfer.js
-* Copyright (c) 2012 AUTHORS.txt; Licensed MIT, GPL */
-(function(a,b){a.effects.transfer=function(b){return this.queue(function(){var c=a(this),d=a(b.options.to),e=d.offset(),f={top:e.top,left:e.left,height:d.innerHeight(),width:d.innerWidth()},g=c.offset(),h=a('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(b.options.className).css({top:g.top,left:g.left,height:c.innerHeight(),width:c.innerWidth(),position:"absolute"}).animate(f,b.duration,b.options.easing,function(){h.remove(),b.callback&&b.callback.apply(c[0],arguments),c.dequeue()})})}})(jQuery);;
-/*! (c) 2012 Airbnb, Inc.
-*
-* polyglot.js 0.4.3 may be freely distributed under the terms of the BSD
-* license. For all licensing information, details, and documention:
-* http://airbnb.github.com/polyglot.js */
-(function(e,t){typeof define=="function"&&define.amd?define([],function(){return t(e)}):typeof exports=="object"?module.exports=t(e):e.Polyglot=t(e)})(this,function(e){"use strict";function t(e){e=e||{},this.phrases={},this.extend(e.phrases||{}),this.currentLocale=e.locale||"en",this.allowMissing=!!e.allowMissing,this.warn=e.warn||c}function s(e){var t,n,r,i={};for(t in e)if(e.hasOwnProperty(t)){n=e[t];for(r in n)i[n[r]]=t}return i}function o(e){var t=/^\s+|\s+$/g;return e.replace(t,"")}function u(e,t,r){var i,s,u;return r!=null&&e?(s=e.split(n),u=s[f(t,r)]||s[0],i=o(u)):i=e,i}function a(e){var t=s(i);return t[e]||t.en}function f(e,t){return r[a(e)](t)}function l(e,t){for(var n in t)n!=="_"&&t.hasOwnProperty(n)&&(e=e.replace(new RegExp("%\\{"+n+"\\}","g"),t[n]));return e}function c(t){e.console&&e.console.warn&&e.console.warn("WARNING: "+t)}function h(e){var t={};for(var n in e)t[n]=e[n];return t}t.VERSION="0.4.3",t.prototype.locale=function(e){return e&&(this.currentLocale=e),this.currentLocale},t.prototype.extend=function(e,t){var n;for(var r in e)e.hasOwnProperty(r)&&(n=e[r],t&&(r=t+"."+r),typeof n=="object"?this.extend(n,r):this.phrases[r]=n)},t.prototype.clear=function(){this.phrases={}},t.prototype.replace=function(e){this.clear(),this.extend(e)},t.prototype.t=function(e,t){var n,r;return t=t==null?{}:t,typeof t=="number"&&(t={smart_count:t}),typeof this.phrases[e]=="string"?n=this.phrases[e]:typeof t._=="string"?n=t._:this.allowMissing?n=e:(this.warn('Missing translation for key: "'+e+'"'),r=e),typeof n=="string"&&(t=h(t),r=u(n,this.currentLocale,t.smart_count),r=l(r,t)),r},t.prototype.has=function(e){return e in this.phrases};var n="||||",r={chinese:function(e){return 0},german:function(e){return e!==1?1:0},french:function(e){return e>1?1:0},russian:function(e){return e%10===1&&e%100!==11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},czech:function(e){return e===1?0:e>=2&&e<=4?1:2},polish:function(e){return e===1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},icelandic:function(e){return e%10!==1||e%100===11?1:0}},i={chinese:["fa","id","ja","ko","lo","ms","th","tr","zh"],german:["da","de","en","es","fi","el","he","hu","it","nl","no","pt","sv"],french:["fr","tl","pt-br"],russian:["hr","ru"],czech:["cs"],polish:["pl"],icelandic:["is"]};return t});
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
deleted file mode 100644
index 9709f50..0000000
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ /dev/null
@@ -1,6690 +0,0 @@
-var cookie_namespace = 'android_developer';
-var isMobile = false; // true if mobile, so we can adjust some layout
-var mPagePath; // initialized in ready() function
-
-var basePath = getBaseUri(location.pathname);
-var SITE_ROOT = toRoot + basePath.substring(1, basePath.indexOf("/", 1));
-
-// TODO(akassay) generate this var in the reference doc build.
-var API_LEVELS = ['1', '2', '3', '4', '5', '6', '7', '8', '9',
-      '10', '11', '12', '13', '14', '15', '16',
-      '17', '18', '19', '20', '21', '22', '23', '24'];
-var METADATA = METADATA || {};
-var RESERVED_METADATA_CATEGORY_NAMES = ['extras', 'carousel', 'collections',
-                                        'searchHeroCollections'];
-
-// Ensure that all ajax getScript() requests allow caching
-$.ajaxSetup({
-  cache: true
-});
-
-/******  ON LOAD SET UP STUFF *********/
-
-$(document).ready(function() {
-
-  // prep nav expandos
-  var pagePath = location.href.replace(location.hash, '');
-  // account for intl docs by removing the intl/*/ path
-  if (pagePath.indexOf("/intl/") == 0) {
-    pagePath = pagePath.substr(pagePath.indexOf("/", 6)); // start after intl/ to get last /
-  }
-
-  if (pagePath.indexOf(SITE_ROOT) == 0) {
-    if (pagePath == '' || pagePath.charAt(pagePath.length - 1) == '/') {
-      pagePath += 'index.html';
-    }
-  }
-
-  // Need a copy of the pagePath before it gets changed in the next block;
-  // it's needed to perform proper tab highlighting in offline docs (see rootDir below)
-  var pagePathOriginal = pagePath;
-  if (SITE_ROOT.match(/\.\.\//) || SITE_ROOT == '') {
-    // If running locally, SITE_ROOT will be a relative path, so account for that by
-    // finding the relative URL to this page. This will allow us to find links on the page
-    // leading back to this page.
-    var pathParts = pagePath.split('/');
-    var relativePagePathParts = [];
-    var upDirs = (SITE_ROOT.match(/(\.\.\/)+/) || [''])[0].length / 3;
-    for (var i = 0; i < upDirs; i++) {
-      relativePagePathParts.push('..');
-    }
-    for (var i = 0; i < upDirs; i++) {
-      relativePagePathParts.push(pathParts[pathParts.length - (upDirs - i) - 1]);
-    }
-    relativePagePathParts.push(pathParts[pathParts.length - 1]);
-    pagePath = relativePagePathParts.join('/');
-  } else {
-    // Otherwise the page path is already an absolute URL
-  }
-
-  // set global variable so we can highlight the sidenav a bit later (such as for google reference)
-  // and highlight the sidenav
-  mPagePath = pagePath;
-
-  // Check for params and remove them.
-  mPagePath = mPagePath.split('?')[0];
-  highlightSidenav();
-
-  // set up prev/next links if they exist
-  var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]');
-  var $selListItem;
-  if ($selNavLink.length) {
-    $selListItem = $selNavLink.closest('li');
-
-    // set up prev links
-    var $prevLink = [];
-    var $prevListItem = $selListItem.prev('li');
-
-    var crossBoundaries = ($("body.design").length > 0) || ($("body.guide").length > 0) ? true :
-false; // navigate across topic boundaries only in design docs
-    if ($prevListItem.length) {
-      if ($prevListItem.hasClass('nav-section') || crossBoundaries) {
-        // jump to last topic of previous section
-        $prevLink = $prevListItem.find('a:last');
-      } else if (!$selListItem.hasClass('nav-section')) {
-        // jump to previous topic in this section
-        $prevLink = $prevListItem.find('a:eq(0)');
-      }
-    } else {
-      // jump to this section's index page (if it exists)
-      var $parentListItem = $selListItem.parents('li');
-      $prevLink = $selListItem.parents('li').find('a');
-
-      // except if cross boundaries aren't allowed, and we're at the top of a section already
-      // (and there's another parent)
-      if (!crossBoundaries && $parentListItem.hasClass('nav-section') &&
-                           $selListItem.hasClass('nav-section')) {
-        $prevLink = [];
-      }
-    }
-
-    // set up next links
-    var $nextLink = [];
-    var startClass = false;
-    var isCrossingBoundary = false;
-
-    if ($selListItem.hasClass('nav-section') && $selListItem.children('div.empty').length == 0) {
-      // we're on an index page, jump to the first topic
-      $nextLink = $selListItem.find('ul:eq(0)').find('a:eq(0)');
-
-      // if there aren't any children, go to the next section (required for About pages)
-      if ($nextLink.length == 0) {
-        $nextLink = $selListItem.next('li').find('a');
-      } else if ($('.topic-start-link').length) {
-        // as long as there's a child link and there is a "topic start link" (we're on a landing)
-        // then set the landing page "start link" text to be the first doc title
-        $('.topic-start-link').text($nextLink.text().toUpperCase());
-      }
-
-      // If the selected page has a description, then it's a class or article homepage
-      if ($selListItem.find('a[description]').length) {
-        // this means we're on a class landing page
-        startClass = true;
-      }
-    } else {
-      // jump to the next topic in this section (if it exists)
-      $nextLink = $selListItem.next('li').find('a:eq(0)');
-      if ($nextLink.length == 0) {
-        isCrossingBoundary = true;
-        // no more topics in this section, jump to the first topic in the next section
-        $nextLink = $selListItem.parents('li:eq(0)').next('li').find('a:eq(0)');
-        if (!$nextLink.length) {  // Go up another layer to look for next page (lesson > class > course)
-          $nextLink = $selListItem.parents('li:eq(1)').next('li.nav-section').find('a:eq(0)');
-          if ($nextLink.length == 0) {
-            // if that doesn't work, we're at the end of the list, so disable NEXT link
-            $('.next-page-link').attr('href', '').addClass("disabled")
-                                .click(function() { return false; });
-            // and completely hide the one in the footer
-            $('.content-footer .next-page-link').hide();
-          }
-        }
-      }
-    }
-
-    if (startClass) {
-      $('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide");
-
-      // if there's no training bar (below the start button),
-      // then we need to add a bottom border to button
-      if (!$("#tb").length) {
-        $('.start-class-link').css({'border-bottom':'1px solid #DADADA'});
-      }
-    } else if (isCrossingBoundary && !$('body.design').length) {  // Design always crosses boundaries
-      $('.content-footer.next-class').show();
-      $('.next-page-link').attr('href', '')
-                          .removeClass("hide").addClass("disabled")
-                          .click(function() { return false; });
-      // and completely hide the one in the footer
-      $('.content-footer .next-page-link').hide();
-      $('.content-footer .prev-page-link').hide();
-
-      if ($nextLink.length) {
-        $('.next-class-link').attr('href', $nextLink.attr('href'))
-                             .removeClass("hide");
-
-        $('.content-footer .next-class-link').append($nextLink.html());
-
-        $('.next-class-link').find('.new').empty();
-      }
-    } else {
-      $('.next-page-link').attr('href', $nextLink.attr('href'))
-                          .removeClass("hide");
-      // for the footer link, also add the previous and next page titles
-      if ($prevLink.length) {
-        $('.content-footer .prev-page-link').append($prevLink.html());
-      }
-      if ($nextLink.length) {
-        $('.content-footer .next-page-link').append($nextLink.html());
-      }
-    }
-
-    if (!startClass && $prevLink.length) {
-      var prevHref = $prevLink.attr('href');
-      if (prevHref == SITE_ROOT + 'index.html') {
-        // Don't show Previous when it leads to the homepage
-      } else {
-        $('.prev-page-link').attr('href', $prevLink.attr('href')).removeClass("hide");
-      }
-    }
-  }
-
-  // Set up the course landing pages for Training with class names and descriptions
-  if ($('body.trainingcourse').length) {
-    var $classLinks = $selListItem.find('ul li a').not('#nav .nav-section .nav-section ul a');
-
-    // create an array for all the class descriptions
-    var $classDescriptions = new Array($classLinks.length);
-    var lang = getLangPref();
-    $classLinks.each(function(index) {
-      var langDescr = $(this).attr(lang + "-description");
-      if (typeof langDescr !== 'undefined' && langDescr !== false) {
-        // if there's a class description in the selected language, use that
-        $classDescriptions[index] = langDescr;
-      } else {
-        // otherwise, use the default english description
-        $classDescriptions[index] = $(this).attr("description");
-      }
-    });
-
-    var $olClasses  = $('<ol class="class-list"></ol>');
-    var $liClass;
-    var $h2Title;
-    var $pSummary;
-    var $olLessons;
-    var $liLesson;
-    $classLinks.each(function(index) {
-      $liClass  = $('<li class="clearfix"></li>');
-      $h2Title  = $('<a class="title" href="' + $(this).attr('href') + '"><h2 class="norule">' + $(this).html() + '</h2><span></span></a>');
-      $pSummary = $('<p class="description">' + $classDescriptions[index] + '</p>');
-
-      $olLessons  = $('<ol class="lesson-list"></ol>');
-
-      $lessons = $(this).closest('li').find('ul li a');
-
-      if ($lessons.length) {
-        $lessons.each(function(index) {
-          $olLessons.append('<li><a href="' + $(this).attr('href') + '">' + $(this).html() + '</a></li>');
-        });
-      } else {
-        $pSummary.addClass('article');
-      }
-
-      $liClass.append($h2Title).append($pSummary).append($olLessons);
-      $olClasses.append($liClass);
-    });
-    $('#classes').append($olClasses);
-  }
-
-  // Set up expand/collapse behavior
-  initExpandableNavItems("#nav");
-
-  // Set up play-on-hover <video> tags.
-  $('video.play-on-hover').bind('click', function() {
-    $(this).get(0).load(); // in case the video isn't seekable
-    $(this).get(0).play();
-  });
-
-  // Set up play-on-click for <video> tags with a "video-wrapper".
-  $('.video-wrapper > video').bind('click', function() {
-    this.play();
-    $(this.parentElement).addClass('playing');
-  });
-
-  // Set up tooltips
-  var TOOLTIP_MARGIN = 10;
-  $('acronym,.tooltip-link').each(function() {
-    var $target = $(this);
-    var $tooltip = $('<div>')
-        .addClass('tooltip-box')
-        .append($target.attr('title'))
-        .hide()
-        .appendTo('body');
-    $target.removeAttr('title');
-
-    $target.hover(function() {
-      // in
-      var targetRect = $target.offset();
-      targetRect.width = $target.width();
-      targetRect.height = $target.height();
-
-      $tooltip.css({
-        left: targetRect.left,
-        top: targetRect.top + targetRect.height + TOOLTIP_MARGIN
-      });
-      $tooltip.addClass('below');
-      $tooltip.show();
-    }, function() {
-      // out
-      $tooltip.hide();
-    });
-  });
-
-  // Set up <h2> deeplinks
-  $('h2').click(function() {
-    var id = $(this).attr('id');
-    if (id) {
-      if (history && history.replaceState) {
-        // Change url without scrolling.
-        history.replaceState({}, '', '#' + id);
-      } else {
-        document.location.hash = id;
-      }
-    }
-  });
-
-  //Loads the +1 button
-  //var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
-  //po.src = 'https://apis.google.com/js/plusone.js';
-  //var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
-});
-// END of the onload event
-
-function initExpandableNavItems(rootTag) {
-  var toggleIcon = $(
-      rootTag + ' li.nav-section .nav-section-header .toggle-icon, ' +
-      rootTag + ' li.nav-section .nav-section-header a[href="#"]');
-
-  toggleIcon.on('click keypress', function(e) {
-    if (e.type == 'keypress' && e.which == 13 || e.type == 'click') {
-      doNavToggle(this);
-    }
-  });
-
-  // Stop expand/collapse behavior when clicking on nav section links
-  // (since we're navigating away from the page)
-  // This selector captures the first instance of <a>, but not those with "#" as the href.
-  $('.nav-section-header').find('a:eq(0)').not('a[href="#"]').click(function(evt) {
-    window.location.href = $(this).attr('href');
-    return false;
-  });
-}
-
-function doNavToggle(el) {
-  var section = $(el).closest('li.nav-section');
-  if (section.hasClass('expanded')) {
-    /* hide me and descendants */
-    section.find('ul').slideUp(250, function() {
-      // remove 'expanded' class from my section and any children
-      section.closest('li').removeClass('expanded');
-      $('li.nav-section', section).removeClass('expanded');
-    });
-  } else {
-    /* show me */
-    // first hide all other siblings
-    var $others = $('li.nav-section.expanded', $(el).closest('ul')).not('.sticky');
-    $others.removeClass('expanded').children('ul').slideUp(250);
-
-    // now expand me
-    section.closest('li').addClass('expanded');
-    section.children('ul').slideDown(250);
-  }
-}
-
-/** Highlight the current page in sidenav, expanding children as appropriate */
-function highlightSidenav() {
-  // if something is already highlighted, undo it. This is for dynamic navigation (Samples index)
-  if ($("ul#nav li.selected").length) {
-    unHighlightSidenav();
-  }
-  // look for URL in sidenav, including the hash
-  var $selNavLink = $('#nav').find('a[href="' + mPagePath + location.hash + '"]');
-
-  // If the selNavLink is still empty, look for it without the hash
-  if ($selNavLink.length == 0) {
-    $selNavLink = $('#nav').find('a[href="' + mPagePath + '"]');
-  }
-
-  var $selListItem;
-  var breadcrumb = [];
-
-  if ($selNavLink.length) {
-    // Find this page's <li> in sidenav and set selected
-    $selListItem = $selNavLink.closest('li');
-    $selListItem.addClass('selected');
-
-    // Traverse up the tree and expand all parent nav-sections
-    $selNavLink.parents('li.nav-section').each(function() {
-      $(this).addClass('expanded');
-      $(this).children('ul').show();
-
-      var link = $(this).find('a').first();
-
-      if (!$(this).is($selListItem)) {
-        breadcrumb.unshift(link)
-      }
-    });
-
-    $('#nav').scrollIntoView($selNavLink);
-  }
-
-  breadcrumb.forEach(function(link) {
-    link.dacCrumbs();
-  });
-}
-
-function unHighlightSidenav() {
-  $("ul#nav li.selected").removeClass("selected");
-  $('ul#nav li.nav-section.expanded').removeClass('expanded').children('ul').hide();
-}
-
-var agent = navigator['userAgent'].toLowerCase();
-// If a mobile phone, set flag and do mobile setup
-if ((agent.indexOf("mobile") != -1) ||      // android, iphone, ipod
-    (agent.indexOf("blackberry") != -1) ||
-    (agent.indexOf("webos") != -1) ||
-    (agent.indexOf("mini") != -1)) {        // opera mini browsers
-  isMobile = true;
-}
-
-$(document).ready(function() {
-  $("pre:not(.no-pretty-print)").addClass("prettyprint");
-  prettyPrint();
-});
-
-/* Show popup dialogs */
-function showDialog(id) {
-  $dialog = $("#" + id);
-  $dialog.prepend('<div class="box-border"><div class="top"> <div class="left"></div> <div class="right"></div></div><div class="bottom"> <div class="left"></div> <div class="right"></div> </div> </div>');
-  $dialog.wrapInner('<div/>');
-  $dialog.removeClass("hide");
-}
-
-/* #########    COOKIES!     ########## */
-
-function readCookie(cookie) {
-  var myCookie = cookie_namespace + "_" + cookie + "=";
-  if (document.cookie) {
-    var index = document.cookie.indexOf(myCookie);
-    if (index != -1) {
-      var valStart = index + myCookie.length;
-      var valEnd = document.cookie.indexOf(";", valStart);
-      if (valEnd == -1) {
-        valEnd = document.cookie.length;
-      }
-      var val = document.cookie.substring(valStart, valEnd);
-      return val;
-    }
-  }
-  return 0;
-}
-
-function writeCookie(cookie, val, section) {
-  if (val == undefined) return;
-  section = section == null ? "_" : "_" + section + "_";
-  var age = 2 * 365 * 24 * 60 * 60; // set max-age to 2 years
-  var cookieValue = cookie_namespace + section + cookie + "=" + val +
-                    "; max-age=" + age + "; path=/";
-  document.cookie = cookieValue;
-}
-
-/* #########     END COOKIES!     ########## */
-
-/*
- * Manages secion card states and nav resize to conclude loading
- */
-(function() {
-  $(document).ready(function() {
-
-    // Stack hover states
-    $('.section-card-menu').each(function(index, el) {
-      var height = $(el).height();
-      $(el).css({height:height + 'px', position:'relative'});
-      var $cardInfo = $(el).find('.card-info');
-
-      $cardInfo.css({position: 'absolute', bottom:'0px', left:'0px', right:'0px', overflow:'visible'});
-    });
-
-  });
-
-})();
-
-/*      MISC LIBRARY FUNCTIONS     */
-
-function toggle(obj, slide) {
-  var ul = $("ul:first", obj);
-  var li = ul.parent();
-  if (li.hasClass("closed")) {
-    if (slide) {
-      ul.slideDown("fast");
-    } else {
-      ul.show();
-    }
-    li.removeClass("closed");
-    li.addClass("open");
-    $(".toggle-img", li).attr("title", "hide pages");
-  } else {
-    ul.slideUp("fast");
-    li.removeClass("open");
-    li.addClass("closed");
-    $(".toggle-img", li).attr("title", "show pages");
-  }
-}
-
-function buildToggleLists() {
-  $(".toggle-list").each(
-    function(i) {
-      $("div:first", this).append("<a class='toggle-img' href='#' title='show pages' onClick='toggle(this.parentNode.parentNode, true); return false;'></a>");
-      $(this).addClass("closed");
-    });
-}
-
-function hideNestedItems(list, toggle) {
-  $list = $(list);
-  // hide nested lists
-  if ($list.hasClass('showing')) {
-    $("li ol", $list).hide('fast');
-    $list.removeClass('showing');
-  // show nested lists
-  } else {
-    $("li ol", $list).show('fast');
-    $list.addClass('showing');
-  }
-  $(".more,.less", $(toggle)).toggle();
-}
-
-/* Call this to add listeners to a <select> element for Studio/Eclipse/Other docs */
-function setupIdeDocToggle() {
-  $("select.ide").change(function() {
-    var selected = $(this).find("option:selected").attr("value");
-    $(".select-ide").hide();
-    $(".select-ide." + selected).show();
-
-    $("select.ide").val(selected);
-  });
-}
-
-/* Used to hide and reveal supplemental content, such as long code samples.
-   See the companion CSS in android-developer-docs.css */
-function toggleContent(obj) {
-  var div = $(obj).closest(".toggle-content");
-  var toggleMe = $(".toggle-content-toggleme:eq(0)", div);
-  if (div.hasClass("closed")) { // if it's closed, open it
-    toggleMe.slideDown();
-    $(".toggle-content-text:eq(0)", obj).toggle();
-    div.removeClass("closed").addClass("open");
-    $(".toggle-content-img:eq(0)", div).attr("title", "hide").attr("src", toRoot +
-                  "assets/images/styles/disclosure_up.png");
-  } else { // if it's open, close it
-    toggleMe.slideUp('fast', function() {  // Wait until the animation is done before closing arrow
-      $(".toggle-content-text:eq(0)", obj).toggle();
-      div.removeClass("open").addClass("closed");
-      div.find(".toggle-content").removeClass("open").addClass("closed")
-              .find(".toggle-content-toggleme").hide();
-      $(".toggle-content-img", div).attr("title", "show").attr("src", toRoot +
-                  "assets/images/styles/disclosure_down.png");
-    });
-  }
-  return false;
-}
-
-/* New version of expandable content */
-function toggleExpandable(link, id) {
-  if ($(id).is(':visible')) {
-    $(id).slideUp();
-    $(link).removeClass('expanded');
-  } else {
-    $(id).slideDown();
-    $(link).addClass('expanded');
-  }
-}
-
-function hideExpandable(ids) {
-  $(ids).slideUp();
-  $(ids).prev('h4').find('a.expandable').removeClass('expanded');
-}
-
-/*
- *  Slideshow 1.0
- *  Used on /index.html and /develop/index.html for carousel
- *
- *  Sample usage:
- *  HTML -
- *  <div class="slideshow-container">
- *   <a href="" class="slideshow-prev">Prev</a>
- *   <a href="" class="slideshow-next">Next</a>
- *   <ul>
- *       <li class="item"><img src="images/marquee1.jpg"></li>
- *       <li class="item"><img src="images/marquee2.jpg"></li>
- *       <li class="item"><img src="images/marquee3.jpg"></li>
- *       <li class="item"><img src="images/marquee4.jpg"></li>
- *   </ul>
- *  </div>
- *
- *   <script type="text/javascript">
- *   $('.slideshow-container').dacSlideshow({
- *       auto: true,
- *       btnPrev: '.slideshow-prev',
- *       btnNext: '.slideshow-next'
- *   });
- *   </script>
- *
- *  Options:
- *  btnPrev:    optional identifier for previous button
- *  btnNext:    optional identifier for next button
- *  btnPause:   optional identifier for pause button
- *  auto:       whether or not to auto-proceed
- *  speed:      animation speed
- *  autoTime:   time between auto-rotation
- *  easing:     easing function for transition
- *  start:      item to select by default
- *  scroll:     direction to scroll in
- *  pagination: whether or not to include dotted pagination
- *
- */
-
-(function($) {
-  $.fn.dacSlideshow = function(o) {
-
-    //Options - see above
-    o = $.extend({
-      btnPrev:   null,
-      btnNext:   null,
-      btnPause:  null,
-      auto:      true,
-      speed:     500,
-      autoTime:  12000,
-      easing:    null,
-      start:     0,
-      scroll:    1,
-      pagination: true
-
-    }, o || {});
-
-    //Set up a carousel for each
-    return this.each(function() {
-
-      var running = false;
-      var animCss = o.vertical ? "top" : "left";
-      var sizeCss = o.vertical ? "height" : "width";
-      var div = $(this);
-      var ul = $("ul", div);
-      var tLi = $("li", ul);
-      var tl = tLi.size();
-      var timer = null;
-
-      var li = $("li", ul);
-      var itemLength = li.size();
-      var curr = o.start;
-
-      li.css({float: o.vertical ? "none" : "left"});
-      ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
-      div.css({position: "relative", "z-index": "2", left: "0px"});
-
-      var liSize = o.vertical ? height(li) : width(li);
-      var ulSize = liSize * itemLength;
-      var divSize = liSize;
-
-      li.css({width: li.width(), height: li.height()});
-      ul.css(sizeCss, ulSize + "px").css(animCss, -(curr * liSize));
-
-      div.css(sizeCss, divSize + "px");
-
-      //Pagination
-      if (o.pagination) {
-        var pagination = $("<div class='pagination'></div>");
-        var pag_ul = $("<ul></ul>");
-        if (tl > 1) {
-          for (var i = 0; i < tl; i++) {
-            var li = $("<li>" + i + "</li>");
-            pag_ul.append(li);
-            if (i == o.start) li.addClass('active');
-            li.click(function() {
-              go(parseInt($(this).text()));
-            })
-          }
-          pagination.append(pag_ul);
-          div.append(pagination);
-        }
-      }
-
-      //Previous button
-      if (o.btnPrev)
-             $(o.btnPrev).click(function(e) {
-               e.preventDefault();
-               return go(curr - o.scroll);
-             });
-
-      //Next button
-      if (o.btnNext)
-             $(o.btnNext).click(function(e) {
-               e.preventDefault();
-               return go(curr + o.scroll);
-             });
-
-      //Pause button
-      if (o.btnPause)
-             $(o.btnPause).click(function(e) {
-               e.preventDefault();
-               if ($(this).hasClass('paused')) {
-                 startRotateTimer();
-               } else {
-                 pauseRotateTimer();
-               }
-             });
-
-      //Auto rotation
-      if (o.auto) startRotateTimer();
-
-      function startRotateTimer() {
-        clearInterval(timer);
-        timer = setInterval(function() {
-          if (curr == tl - 1) {
-            go(0);
-          } else {
-            go(curr + o.scroll);
-          }
-        }, o.autoTime);
-        $(o.btnPause).removeClass('paused');
-      }
-
-      function pauseRotateTimer() {
-        clearInterval(timer);
-        $(o.btnPause).addClass('paused');
-      }
-
-      //Go to an item
-      function go(to) {
-        if (!running) {
-
-          if (to < 0) {
-            to = itemLength - 1;
-          } else if (to > itemLength - 1) {
-            to = 0;
-          }
-          curr = to;
-
-          running = true;
-
-          ul.animate(
-              animCss == "left" ? {left: -(curr * liSize)} : {top: -(curr * liSize)} , o.speed, o.easing,
-                     function() {
-                       running = false;
-                     }
-                 );
-
-          $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
-          $((curr - o.scroll < 0 && o.btnPrev)              ||
-             (curr + o.scroll > itemLength && o.btnNext)              ||
-             []
-           ).addClass("disabled");
-
-          var nav_items = $('li', pagination);
-          nav_items.removeClass('active');
-          nav_items.eq(to).addClass('active');
-
-        }
-        if (o.auto) startRotateTimer();
-        return false;
-      };
-    });
-  };
-
-  function css(el, prop) {
-    return parseInt($.css(el[0], prop)) || 0;
-  };
-  function width(el) {
-    return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
-  };
-  function height(el) {
-    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
-  };
-
-})(jQuery);
-
-/*
- *  dacSlideshow 1.0
- *  Used on develop/index.html for side-sliding tabs
- *
- *  Sample usage:
- *  HTML -
- *  <div class="slideshow-container">
- *   <a href="" class="slideshow-prev">Prev</a>
- *   <a href="" class="slideshow-next">Next</a>
- *   <ul>
- *       <li class="item"><img src="images/marquee1.jpg"></li>
- *       <li class="item"><img src="images/marquee2.jpg"></li>
- *       <li class="item"><img src="images/marquee3.jpg"></li>
- *       <li class="item"><img src="images/marquee4.jpg"></li>
- *   </ul>
- *  </div>
- *
- *   <script type="text/javascript">
- *   $('.slideshow-container').dacSlideshow({
- *       auto: true,
- *       btnPrev: '.slideshow-prev',
- *       btnNext: '.slideshow-next'
- *   });
- *   </script>
- *
- *  Options:
- *  btnPrev:    optional identifier for previous button
- *  btnNext:    optional identifier for next button
- *  auto:       whether or not to auto-proceed
- *  speed:      animation speed
- *  autoTime:   time between auto-rotation
- *  easing:     easing function for transition
- *  start:      item to select by default
- *  scroll:     direction to scroll in
- *  pagination: whether or not to include dotted pagination
- *
- */
-(function($) {
-  $.fn.dacTabbedList = function(o) {
-
-    //Options - see above
-    o = $.extend({
-      speed : 250,
-      easing: null,
-      nav_id: null,
-      frame_id: null
-    }, o || {});
-
-    //Set up a carousel for each
-    return this.each(function() {
-
-      var curr = 0;
-      var running = false;
-      var animCss = "margin-left";
-      var sizeCss = "width";
-      var div = $(this);
-
-      var nav = $(o.nav_id, div);
-      var nav_li = $("li", nav);
-      var nav_size = nav_li.size();
-      var frame = div.find(o.frame_id);
-      var content_width = $(frame).find('ul').width();
-      //Buttons
-      $(nav_li).click(function(e) {
-           go($(nav_li).index($(this)));
-         })
-
-      //Go to an item
-      function go(to) {
-        if (!running) {
-          curr = to;
-          running = true;
-
-          frame.animate({'margin-left' : -(curr * content_width)}, o.speed, o.easing,
-                     function() {
-                       running = false;
-                     }
-                 );
-
-          nav_li.removeClass('active');
-          nav_li.eq(to).addClass('active');
-
-        }
-        return false;
-      };
-    });
-  };
-
-  function css(el, prop) {
-    return parseInt($.css(el[0], prop)) || 0;
-  };
-  function width(el) {
-    return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
-  };
-  function height(el) {
-    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
-  };
-
-})(jQuery);
-
-/* ######################################################## */
-/* #################  JAVADOC REFERENCE ################### */
-/* ######################################################## */
-
-
-
-var API_LEVEL_COOKIE = "api_level";
-var minLevel = 1;
-var maxLevel = 1;
-
-function buildApiLevelSelector() {
-  maxLevel = API_LEVELS.length;
-  var userApiLevel = parseInt(readCookie(API_LEVEL_COOKIE));
-  userApiLevel = userApiLevel == 0 ? maxLevel : userApiLevel; // If there's no cookie (zero), use the max by default
-
-  minLevel = parseInt($("#doc-api-level").attr("class"));
-  // Handle provisional api levels; the provisional level will always be the highest possible level
-  // Provisional api levels will also have a length; other stuff that's just missing a level won't,
-  // so leave those kinds of entities at the default level of 1 (for example, the R.styleable class)
-  if (isNaN(minLevel) && minLevel.length) {
-    minLevel = maxLevel;
-  }
-  var select = $("#apiLevelSelector").html("").change(changeApiLevel);
-  for (var i = maxLevel - 1; i >= 0; i--) {
-    var option = $("<option />").attr("value", "" + API_LEVELS[i]).append("" + API_LEVELS[i]);
-    //  if (API_LEVELS[i] < minLevel) option.addClass("absent"); // always false for strings (codenames)
-    select.append(option);
-  }
-
-  // get the DOM element and use setAttribute cuz IE6 fails when using jquery .attr('selected',true)
-  var selectedLevelItem = $("#apiLevelSelector option[value='" + userApiLevel + "']").get(0);
-  selectedLevelItem.setAttribute('selected', true);
-}
-
-function changeApiLevel() {
-  maxLevel = API_LEVELS.length;
-  minLevel = parseInt($('#doc-api-level').attr('class'));
-  var selectedLevel = maxLevel;
-
-  selectedLevel = parseInt($("#apiLevelSelector option:selected").val());
-  toggleVisisbleApis(selectedLevel, "body");
-
-  writeCookie(API_LEVEL_COOKIE, selectedLevel, null);
-
-  if (selectedLevel < minLevel) {
-      // Show the API notice dialog, set number values and button event
-      $('#api-unavailable').trigger('modal-open');
-      $('#api-unavailable .selected-level').text(selectedLevel);
-      $('#api-unavailable .api-level').text(minLevel);
-      $('#api-unavailable button.ok').attr('onclick','$("#apiLevelSelector").val("' + minLevel + '");changeApiLevel();');
-  }
-}
-
-function toggleVisisbleApis(selectedLevel, context) {
-  var apis = $(".api", context);
-  apis.each(function(i) {
-    var obj = $(this);
-    var className = obj.attr("class");
-    var apiLevelIndex = className.lastIndexOf("-") + 1;
-    var apiLevelEndIndex = className.indexOf(" ", apiLevelIndex);
-    apiLevelEndIndex = apiLevelEndIndex != -1 ? apiLevelEndIndex : className.length;
-    var apiLevel = className.substring(apiLevelIndex, apiLevelEndIndex);
-    if (apiLevel.length == 0) { // for odd cases when the since data is actually missing, just bail
-      return;
-    }
-    apiLevel = parseInt(apiLevel);
-
-    // Handle provisional api levels; if this item's level is the provisional one, set it to the max
-    var selectedLevelNum = parseInt(selectedLevel)
-    var apiLevelNum = parseInt(apiLevel);
-    if (isNaN(apiLevelNum)) {
-      apiLevelNum = maxLevel;
-    }
-
-    // Grey things out that aren't available and give a tooltip title
-    if (apiLevelNum > selectedLevelNum) {
-      obj.addClass("absent").attr("title", "Requires API Level \"" +
-            apiLevel + "\" or higher. To reveal, change the target API level " +
-              "above the left navigation.");
-    } else obj.removeClass("absent").removeAttr("title");
-  });
-}
-
-/* #################  SIDENAV TREE VIEW ################### */
-/* TODO: eliminate redundancy with non-google functions */
-function init_google_navtree(navtree_id, toroot, root_nodes) {
-  var me = new Object();
-  me.toroot = toroot;
-  me.node = new Object();
-
-  me.node.li = document.getElementById(navtree_id);
-  if (!me.node.li) {
-    return;
-  }
-
-  me.node.children_data = root_nodes;
-  me.node.children = new Array();
-  me.node.children_ul = document.createElement("ul");
-  me.node.get_children_ul = function() { return me.node.children_ul; };
-  //me.node.children_ul.className = "children_ul";
-  me.node.li.appendChild(me.node.children_ul);
-  me.node.depth = 0;
-
-  get_google_node(me, me.node);
-}
-
-function new_google_node(me, mom, text, link, children_data, api_level) {
-  var node = new Object();
-  var child;
-  node.children = Array();
-  node.children_data = children_data;
-  node.depth = mom.depth + 1;
-  node.get_children_ul = function() {
-      if (!node.children_ul) {
-        node.children_ul = document.createElement("ul");
-        node.children_ul.className = "tree-list-children";
-        node.li.appendChild(node.children_ul);
-      }
-      return node.children_ul;
-    };
-  node.li = document.createElement("li");
-
-  mom.get_children_ul().appendChild(node.li);
-
-  if (link) {
-    child = document.createElement("a");
-
-  } else {
-    child = document.createElement("span");
-    child.className = "tree-list-subtitle";
-
-  }
-  if (children_data != null) {
-    node.li.className = "nav-section";
-    node.label_div = document.createElement("div");
-    node.label_div.className = "nav-section-header-ref";
-    node.li.appendChild(node.label_div);
-    get_google_node(me, node);
-    node.label_div.appendChild(child);
-  } else {
-    node.li.appendChild(child);
-  }
-  if (link) {
-    child.href = me.toroot + link;
-  }
-  node.label = document.createTextNode(text);
-  child.appendChild(node.label);
-
-  node.children_ul = null;
-
-  return node;
-}
-
-function get_google_node(me, mom) {
-  mom.children_visited = true;
-  var linkText;
-  for (var i in mom.children_data) {
-    var node_data = mom.children_data[i];
-    linkText = node_data[0];
-
-    if (linkText.match("^" + "com.google.android") == "com.google.android") {
-      linkText = linkText.substr(19, linkText.length);
-    }
-    mom.children[i] = new_google_node(me, mom, linkText, node_data[1],
-        node_data[2], node_data[3]);
-  }
-}
-
-/****** NEW version of script to build google and sample navs dynamically ******/
-// TODO: update Google reference docs to tolerate this new implementation
-
-var NODE_NAME = 0;
-var NODE_HREF = 1;
-var NODE_GROUP = 2;
-var NODE_TAGS = 3;
-var NODE_CHILDREN = 4;
-
-function init_google_navtree2(navtree_id, data) {
-  var $containerUl = $("#" + navtree_id);
-  for (var i in data) {
-    var node_data = data[i];
-    $containerUl.append(new_google_node2(node_data));
-  }
-
-  // Make all third-generation list items 'sticky' to prevent them from collapsing
-  $containerUl.find('li li li.nav-section').addClass('sticky');
-
-  initExpandableNavItems("#" + navtree_id);
-}
-
-function new_google_node2(node_data) {
-  var linkText = node_data[NODE_NAME];
-  if (linkText.match("^" + "com.google.android") == "com.google.android") {
-    linkText = linkText.substr(19, linkText.length);
-  }
-  var $li = $('<li>');
-  var $a;
-  if (node_data[NODE_HREF] != null) {
-    $a = $('<a href="' + toRoot + node_data[NODE_HREF] + '" title="' + linkText + '" >' +
-        linkText + '</a>');
-  } else {
-    $a = $('<a href="#" onclick="return false;" title="' + linkText + '" >' +
-        linkText + '/</a>');
-  }
-  var $childUl = $('<ul>');
-  if (node_data[NODE_CHILDREN] != null) {
-    $li.addClass("nav-section");
-    $a = $('<div class="nav-section-header">').append($a);
-    if (node_data[NODE_HREF] == null) $a.addClass('empty');
-
-    for (var i in node_data[NODE_CHILDREN]) {
-      var child_node_data = node_data[NODE_CHILDREN][i];
-      $childUl.append(new_google_node2(child_node_data));
-    }
-    $li.append($childUl);
-  }
-  $li.prepend($a);
-
-  return $li;
-}
-
-function showGoogleRefTree() {
-  init_default_google_navtree(toRoot);
-  init_default_gcm_navtree(toRoot);
-}
-
-function init_default_google_navtree(toroot) {
-  // load json file for navtree data
-  $.getScript(toRoot + 'gms_navtree_data.js', function(data, textStatus, jqxhr) {
-    // when the file is loaded, initialize the tree
-    if (jqxhr.status === 200) {
-      init_google_navtree("gms-tree-list", toroot, GMS_NAVTREE_DATA);
-      highlightSidenav();
-    }
-  });
-}
-
-function init_default_gcm_navtree(toroot) {
-  // load json file for navtree data
-  $.getScript(toRoot + 'gcm_navtree_data.js', function(data, textStatus, jqxhr) {
-    // when the file is loaded, initialize the tree
-    if (jqxhr.status === 200) {
-      init_google_navtree("gcm-tree-list", toroot, GCM_NAVTREE_DATA);
-      highlightSidenav();
-    }
-  });
-}
-
-/* TOGGLE INHERITED MEMBERS */
-
-/* Toggle an inherited class (arrow toggle)
- * @param linkObj  The link that was clicked.
- * @param expand  'true' to ensure it's expanded. 'false' to ensure it's closed.
- *                'null' to simply toggle.
- */
-function toggleInherited(linkObj, expand) {
-  var base = linkObj.getAttribute("id");
-  var list = document.getElementById(base + "-list");
-  var summary = document.getElementById(base + "-summary");
-  var trigger = document.getElementById(base + "-trigger");
-  var a = $(linkObj);
-  if ((expand == null && a.hasClass("closed")) || expand) {
-    list.style.display = "none";
-    summary.style.display = "block";
-    trigger.src = toRoot + "assets/images/styles/disclosure_up.png";
-    a.removeClass("closed");
-    a.addClass("opened");
-  } else if ((expand == null && a.hasClass("opened")) || (expand == false)) {
-    list.style.display = "block";
-    summary.style.display = "none";
-    trigger.src = toRoot + "assets/images/styles/disclosure_down.png";
-    a.removeClass("opened");
-    a.addClass("closed");
-  }
-  return false;
-}
-
-/* Toggle all inherited classes in a single table (e.g. all inherited methods)
- * @param linkObj  The link that was clicked.
- * @param expand  'true' to ensure it's expanded. 'false' to ensure it's closed.
- *                'null' to simply toggle.
- */
-function toggleAllInherited(linkObj, expand) {
-  var a = $(linkObj);
-  var table = $(a.parent().parent().parent()); // ugly way to get table/tbody
-  var expandos = $(".jd-expando-trigger", table);
-  if ((expand == null && a.text() == "[Expand]") || expand) {
-    expandos.each(function(i) {
-      toggleInherited(this, true);
-    });
-    a.text("[Collapse]");
-  } else if ((expand == null && a.text() == "[Collapse]") || (expand == false)) {
-    expandos.each(function(i) {
-      toggleInherited(this, false);
-    });
-    a.text("[Expand]");
-  }
-  return false;
-}
-
-/* Toggle all inherited members in the class (link in the class title)
- */
-function toggleAllClassInherited() {
-  var a = $("#toggleAllClassInherited"); // get toggle link from class title
-  var toggles = $(".toggle-all", $("#body-content"));
-  if (a.text() == "[Expand All]") {
-    toggles.each(function(i) {
-      toggleAllInherited(this, true);
-    });
-    a.text("[Collapse All]");
-  } else {
-    toggles.each(function(i) {
-      toggleAllInherited(this, false);
-    });
-    a.text("[Expand All]");
-  }
-  return false;
-}
-
-/* Expand all inherited members in the class. Used when initiating page search */
-function ensureAllInheritedExpanded() {
-  var toggles = $(".toggle-all", $("#body-content"));
-  toggles.each(function(i) {
-    toggleAllInherited(this, true);
-  });
-  $("#toggleAllClassInherited").text("[Collapse All]");
-}
-
-/* HANDLE KEY EVENTS
- * - Listen for Ctrl+F (Cmd on Mac) and expand all inherited members (to aid page search)
- */
-var agent = navigator['userAgent'].toLowerCase();
-var mac = agent.indexOf("macintosh") != -1;
-
-$(document).keydown(function(e) {
-  var control = mac ? e.metaKey && !e.ctrlKey : e.ctrlKey; // get ctrl key
-  if (control && e.which == 70) {  // 70 is "F"
-    ensureAllInheritedExpanded();
-  }
-});
-
-/* On-demand functions */
-
-/** Move sample code line numbers out of PRE block and into non-copyable column */
-function initCodeLineNumbers() {
-  var numbers = $("#codesample-block a.number");
-  if (numbers.length) {
-    $("#codesample-line-numbers").removeClass("hidden").append(numbers);
-  }
-
-  $(document).ready(function() {
-    // select entire line when clicked
-    $("span.code-line").click(function() {
-      if (!shifted) {
-        selectText(this);
-      }
-    });
-    // invoke line link on double click
-    $(".code-line").dblclick(function() {
-      document.location.hash = $(this).attr('id');
-    });
-    // highlight the line when hovering on the number
-    $("#codesample-line-numbers a.number").mouseover(function() {
-      var id = $(this).attr('href');
-      $(id).css('background', '#e7e7e7');
-    });
-    $("#codesample-line-numbers a.number").mouseout(function() {
-      var id = $(this).attr('href');
-      $(id).css('background', 'none');
-    });
-  });
-}
-
-// create SHIFT key binder to avoid the selectText method when selecting multiple lines
-var shifted = false;
-$(document).bind('keyup keydown', function(e) {
-  shifted = e.shiftKey; return true;
-});
-
-// courtesy of jasonedelman.com
-function selectText(element) {
-  var doc = document      ,
-        range, selection
-  ;
-  if (doc.body.createTextRange) { //ms
-    range = doc.body.createTextRange();
-    range.moveToElementText(element);
-    range.select();
-  } else if (window.getSelection) { //all others
-    selection = window.getSelection();
-    range = doc.createRange();
-    range.selectNodeContents(element);
-    selection.removeAllRanges();
-    selection.addRange(range);
-  }
-}
-
-/** Display links and other information about samples that match the
-    group specified by the URL */
-function showSamples() {
-  var group = $("#samples").attr('class');
-  $("#samples").html("<p>Here are some samples for <b>" + group + "</b> apps:</p>");
-
-  var $ul = $("<ul>");
-  $selectedLi = $("#nav li.selected");
-
-  $selectedLi.children("ul").children("li").each(function() {
-    var $li = $("<li>").append($(this).find("a").first().clone());
-    var $samplesLink = $li.find("a");
-    if ($samplesLink.text().endsWith('/')) {
-      $samplesLink.text($samplesLink.text().slice(0,-1));
-    }
-    $ul.append($li);
-  });
-
-  $("#samples").append($ul);
-
-}
-
-/* ########################################################## */
-/* ###################  RESOURCE CARDS  ##################### */
-/* ########################################################## */
-
-/** Handle resource queries, collections, and grids (sections). Requires
-    jd_tag_helpers.js and the *_unified_data.js to be loaded. */
-
-(function() {
-  $(document).ready(function() {
-    // Need to initialize hero carousel before other sections for dedupe
-    // to work correctly.
-    $('[data-carousel-query]').dacCarouselQuery();
-
-    // Iterate over all instances and initialize a resource widget.
-    $('.resource-widget').resourceWidget();
-  });
-
-  $.fn.widgetOptions = function() {
-    return {
-      cardSizes: (this.data('cardsizes') || '').split(','),
-      maxResults: parseInt(this.data('maxresults'), 10) || Infinity,
-      initialResults: this.data('initialResults'),
-      itemsPerPage: this.data('itemsPerPage'),
-      sortOrder: this.data('sortorder'),
-      query: this.data('query'),
-      section: this.data('section'),
-      /* Added by LFL 6/6/14 */
-      resourceStyle: this.data('resourcestyle') || 'card',
-      stackSort: this.data('stacksort') || 'true',
-      // For filter based resources
-      allowDuplicates: this.data('allow-duplicates') || 'false'
-    };
-  };
-
-  $.fn.deprecateOldGridStyles = function() {
-    var m = this.get(0).className.match(/\bcol-(\d+)\b/);
-    if (m && !this.is('.cols > *')) {
-      this.removeClass('col-' + m[1]);
-    }
-    return this;
-  }
-
-  /*
-   * Three types of resource layouts:
-   * Flow - Uses a fixed row-height flow using float left style.
-   * Carousel - Single card slideshow all same dimension absolute.
-   * Stack - Uses fixed columns and flexible element height.
-   */
-  function initResourceWidget(widget, resources, opts) {
-    var $widget = $(widget).deprecateOldGridStyles();
-    var isFlow = $widget.hasClass('resource-flow-layout');
-    var isCarousel = $widget.hasClass('resource-carousel-layout');
-    var isStack = $widget.hasClass('resource-stack-layout');
-
-    opts = opts || $widget.widgetOptions();
-    resources = resources || metadata.query(opts);
-
-    if (opts.maxResults !== undefined) {
-      resources = resources.slice(0, opts.maxResults);
-    }
-
-    if (isFlow) {
-      drawResourcesFlowWidget($widget, opts, resources);
-    } else if (isCarousel) {
-      drawResourcesCarouselWidget($widget, opts, resources);
-    } else if (isStack) {
-      opts.numStacks = $widget.data('numstacks');
-      drawResourcesStackWidget($widget, opts, resources);
-    }
-  }
-
-  $.fn.resourceWidget = function(resources, options) {
-    return this.each(function() {
-      initResourceWidget(this, resources, options);
-    });
-  };
-
-  /* Initializes a Resource Carousel Widget */
-  function drawResourcesCarouselWidget($widget, opts, resources) {
-    $widget.empty();
-    var plusone = false; // stop showing plusone buttons on cards
-
-    $widget.addClass('resource-card slideshow-container')
-      .append($('<a>').addClass('slideshow-prev').text('Prev'))
-      .append($('<a>').addClass('slideshow-next').text('Next'));
-
-    var css = {'width': $widget.width() + 'px',
-                'height': $widget.height() + 'px'};
-
-    var $ul = $('<ul>');
-
-    for (var i = 0; i < resources.length; ++i) {
-      var $card = $('<a>')
-        .attr('href', cleanUrl(resources[i].url))
-        .decorateResourceCard(resources[i], plusone);
-
-      $('<li>').css(css)
-          .append($card)
-          .appendTo($ul);
-    }
-
-    $('<div>').addClass('frame')
-      .append($ul)
-      .appendTo($widget);
-
-    $widget.dacSlideshow({
-      auto: true,
-      btnPrev: '.slideshow-prev',
-      btnNext: '.slideshow-next'
-    });
-  }
-
-  /* Initializes a Resource Card Stack Widget (column-based layout)
-     Modified by LFL 6/6/14
-   */
-  function drawResourcesStackWidget($widget, opts, resources, sections) {
-    // Don't empty widget, grab all items inside since they will be the first
-    // items stacked, followed by the resource query
-    var plusone = false; // stop showing plusone buttons on cards
-    var cards = $widget.find('.resource-card').detach().toArray();
-    var numStacks = opts.numStacks || 1;
-    var $stacks = [];
-
-    for (var i = 0; i < numStacks; ++i) {
-      $stacks[i] = $('<div>').addClass('resource-card-stack')
-          .appendTo($widget);
-    }
-
-    var sectionResources = [];
-
-    // Extract any subsections that are actually resource cards
-    if (sections) {
-      for (i = 0; i < sections.length; ++i) {
-        if (!sections[i].sections || !sections[i].sections.length) {
-          // Render it as a resource card
-          sectionResources.push(
-            $('<a>')
-              .addClass('resource-card section-card')
-              .attr('href', cleanUrl(sections[i].resource.url))
-              .decorateResourceCard(sections[i].resource, plusone)[0]
-          );
-
-        } else {
-          cards.push(
-            $('<div>')
-              .addClass('resource-card section-card-menu')
-              .decorateResourceSection(sections[i], plusone)[0]
-          );
-        }
-      }
-    }
-
-    cards = cards.concat(sectionResources);
-
-    for (i = 0; i < resources.length; ++i) {
-      var $card = createResourceElement(resources[i], opts);
-
-      if (opts.resourceStyle.indexOf('related') > -1) {
-        $card.addClass('related-card');
-      }
-
-      cards.push($card[0]);
-    }
-
-    if (opts.stackSort !== 'false') {
-      for (i = 0; i < cards.length; ++i) {
-        // Find the stack with the shortest height, but give preference to
-        // left to right order.
-        var minHeight = $stacks[0].height();
-        var minIndex = 0;
-
-        for (var j = 1; j < numStacks; ++j) {
-          var height = $stacks[j].height();
-          if (height < minHeight - 45) {
-            minHeight = height;
-            minIndex = j;
-          }
-        }
-
-        $stacks[minIndex].append($(cards[i]));
-      }
-    }
-  }
-
-  /*
-    Create a resource card using the given resource object and a list of html
-     configured options. Returns a jquery object containing the element.
-  */
-  function createResourceElement(resource, opts, plusone) {
-    var $el;
-
-    // The difference here is that generic cards are not entirely clickable
-    // so its a div instead of an a tag, also the generic one is not given
-    // the resource-card class so it appears with a transparent background
-    // and can be styled in whatever way the css setup.
-    if (opts.resourceStyle === 'generic') {
-      $el = $('<div>')
-        .addClass('resource')
-        .attr('href', cleanUrl(resource.url))
-        .decorateResource(resource, opts);
-    } else {
-      var cls = 'resource resource-card';
-
-      $el = $('<a>')
-        .addClass(cls)
-        .attr('href', cleanUrl(resource.url))
-        .decorateResourceCard(resource, plusone);
-    }
-
-    return $el;
-  }
-
-  function createResponsiveFlowColumn(cardSize) {
-    var cardWidth = parseInt(cardSize.match(/(\d+)/)[1], 10);
-    var column = $('<div>').addClass('col-' + (cardWidth / 3) + 'of6');
-    if (cardWidth < 9) {
-      column.addClass('col-tablet-1of2');
-    } else if (cardWidth > 9 && cardWidth < 18) {
-      column.addClass('col-tablet-1of1');
-    }
-    if (cardWidth < 18) {
-      column.addClass('col-mobile-1of1');
-    }
-    return column;
-  }
-
-  /* Initializes a flow widget, see distribute.scss for generating accompanying css */
-  function drawResourcesFlowWidget($widget, opts, resources) {
-    // We'll be doing our own modifications to opts.
-    opts = $.extend({}, opts);
-
-    $widget.empty().addClass('cols');
-    if (opts.itemsPerPage) {
-      $('<div class="col-1of1 dac-section-links dac-text-center">')
-        .append(
-          $('<div class="dac-section-link dac-show-less" data-toggle="show-less">Less<i class="dac-sprite dac-auto-unfold-less"></i></div>'),
-          $('<div class="dac-section-link dac-show-more" data-toggle="show-more">More<i class="dac-sprite dac-auto-unfold-more"></i></div>')
-        )
-        .appendTo($widget);
-    }
-
-    $widget.data('options.resourceflow', opts);
-    $widget.data('resources.resourceflow', resources);
-
-    drawResourceFlowPage($widget, opts, resources);
-  }
-
-  function drawResourceFlowPage($widget, opts, resources) {
-    var cardSizes = opts.cardSizes || ['6x6']; // 2015-08-09: dynamic card sizes are deprecated
-    var i = opts.currentIndex || 0;
-    var j = 0;
-    var plusone = false; // stop showing plusone buttons on cards
-    var firstPage = i === 0;
-    var initialResults = opts.initialResults || opts.itemsPerPage || resources.length;
-    var max = firstPage ? initialResults : i + opts.itemsPerPage;
-    max = Math.min(resources.length, max);
-
-    var page = $('<div class="resource-flow-page">');
-    if (opts.itemsPerPage) {
-      $widget.find('.dac-section-links').before(page);
-    } else {
-      $widget.append(page);
-    }
-
-    while (i < max) {
-      var cardSize = cardSizes[j++ % cardSizes.length];
-      cardSize = cardSize.replace(/^\s+|\s+$/, '');
-
-      var column = createResponsiveFlowColumn(cardSize).appendTo(page);
-
-      // A stack has a third dimension which is the number of stacked items
-      var isStack = cardSize.match(/(\d+)x(\d+)x(\d+)/);
-      var stackCount = 0;
-      var $stackDiv = null;
-
-      if (isStack) {
-        // Create a stack container which should have the dimensions defined
-        // by the product of the items inside.
-        $stackDiv = $('<div>').addClass('resource-card-stack resource-card-' + isStack[1] +
-          'x' + isStack[2] * isStack[3]) .appendTo(column);
-      }
-
-      // Build each stack item or just a single item
-      do {
-        var resource = resources[i];
-
-        var $card = createResourceElement(resources[i], opts, plusone);
-
-        $card.addClass('resource-card-' + cardSize +
-          ' resource-card-' + resource.type.toLowerCase());
-
-        if (isStack) {
-          $card.addClass('resource-card-' + isStack[1] + 'x' + isStack[2]);
-          if (++stackCount === parseInt(isStack[3])) {
-            $card.addClass('resource-card-row-stack-last');
-            stackCount = 0;
-          }
-        } else {
-          stackCount = 0;
-        }
-
-        $card.appendTo($stackDiv || column);
-
-      } while (++i < max && stackCount > 0);
-
-      // Record number of pages viewed in analytics.
-      if (!firstPage) {
-        var clicks = Math.ceil((i - initialResults) / opts.itemsPerPage);
-        devsite.analytics.trackAnalyticsEvent('event',
-            'Cards', 'Click More', clicks);
-      }
-    }
-
-    opts.currentIndex = i;
-    $widget.toggleClass('dac-has-more', i < resources.length);
-    $widget.toggleClass('dac-has-less', !firstPage);
-
-    $widget.trigger('dac:domchange');
-    if (opts.onRenderPage) {
-      opts.onRenderPage(page);
-    }
-  }
-
-  function drawResourceFlowReset($widget, opts, resources) {
-    $widget.find('.resource-flow-page')
-        .slice(1)
-        .remove();
-    $widget.toggleClass('dac-has-more', true);
-    $widget.toggleClass('dac-has-less', false);
-
-    opts.currentIndex = Math.min(opts.initialResults, resources.length);
-    devsite.analytics.trackAnalyticsEvent('event', 'Cards', 'Click Less');
-  }
-
-  /* A decorator for event functions which finds the surrounding widget and it's options */
-  function wrapWithWidget(func) {
-    return function(e) {
-      if (e) e.preventDefault();
-
-      var $widget = $(this).closest('.resource-flow-layout');
-      var opts = $widget.data('options.resourceflow');
-      var resources = $widget.data('resources.resourceflow');
-      func($widget, opts, resources);
-    };
-  }
-
-  /* Build a site map of resources using a section as a root. */
-  function buildSectionList(opts) {
-    if (opts.section && SECTION_BY_ID[opts.section]) {
-      return SECTION_BY_ID[opts.section].sections || [];
-    }
-    return [];
-  }
-
-  function cleanUrl(url) {
-    if (url && url.indexOf('//') === -1) {
-      url = toRoot + url;
-    }
-
-    return url;
-  }
-
-  // Delegated events for resources.
-  $(document).on('click', '.resource-flow-layout [data-toggle="show-more"]', wrapWithWidget(drawResourceFlowPage));
-  $(document).on('click', '.resource-flow-layout [data-toggle="show-less"]', wrapWithWidget(drawResourceFlowReset));
-})();
-
-(function($) {
-  // A mapping from category and type values to new values or human presentable strings.
-  var SECTION_MAP = {
-    googleplay: 'google play'
-  };
-
-  /*
-    Utility method for creating dom for the description area of a card.
-    Used in decorateResourceCard and decorateResource.
-  */
-  function buildResourceCardDescription(resource, plusone) {
-    var $description = $('<div>').addClass('description ellipsis');
-
-    $description.append($('<div>').addClass('text').html(resource.summary));
-
-    if (resource.cta) {
-      $description.append($('<a>').addClass('cta').html(resource.cta));
-    }
-
-    if (plusone) {
-      var plusurl = resource.url.indexOf("//") > -1 ? resource.url :
-        "//developer.android.com/" + resource.url;
-
-      $description.append($('<div>').addClass('util')
-        .append($('<div>').addClass('g-plusone')
-          .attr('data-size', 'small')
-          .attr('data-align', 'right')
-          .attr('data-href', plusurl)));
-    }
-
-    return $description;
-  }
-
-  /* Simple jquery function to create dom for a standard resource card */
-  $.fn.decorateResourceCard = function(resource, plusone) {
-    var section = resource.category || resource.type;
-    section = (SECTION_MAP[section] || section).toLowerCase();
-    var imgUrl = resource.image ||
-      'assets/images/resource-card-default-android.jpg';
-
-    if (imgUrl.indexOf('//') === -1) {
-      imgUrl = toRoot + imgUrl;
-    }
-
-    if (resource.type === 'youtube' || resource.type === 'video') {
-      $('<div>').addClass('play-button')
-        .append($('<i class="dac-sprite dac-play-white">'))
-        .appendTo(this);
-    }
-
-    $('<div>').addClass('card-bg')
-      .css('background-image', 'url(' + (imgUrl || toRoot +
-        'assets/images/resource-card-default-android.jpg') + ')')
-      .appendTo(this);
-
-    $('<div>').addClass('card-info' + (!resource.summary ? ' empty-desc' : ''))
-      .append($('<div>').addClass('section').text(section))
-      .append($('<div>').addClass('title' + (resource.title_highlighted ? ' highlighted' : ''))
-        .html(resource.title_highlighted || resource.title))
-      .append(buildResourceCardDescription(resource, plusone))
-      .appendTo(this);
-
-    return this;
-  };
-
-  /* Simple jquery function to create dom for a resource section card (menu) */
-  $.fn.decorateResourceSection = function(section, plusone) {
-    var resource = section.resource;
-    //keep url clean for matching and offline mode handling
-    var urlPrefix = resource.image.indexOf("//") > -1 ? "" : toRoot;
-    var $base = $('<a>')
-        .addClass('card-bg')
-        .attr('href', resource.url)
-        .append($('<div>').addClass('card-section-icon')
-          .append($('<div>').addClass('icon'))
-          .append($('<div>').addClass('section').html(resource.title)))
-      .appendTo(this);
-
-    var $cardInfo = $('<div>').addClass('card-info').appendTo(this);
-
-    if (section.sections && section.sections.length) {
-      // Recurse the section sub-tree to find a resource image.
-      var stack = [section];
-
-      while (stack.length) {
-        if (stack[0].resource.image) {
-          $base.css('background-image', 'url(' + urlPrefix + stack[0].resource.image + ')');
-          break;
-        }
-
-        if (stack[0].sections) {
-          stack = stack.concat(stack[0].sections);
-        }
-
-        stack.shift();
-      }
-
-      var $ul = $('<ul>')
-        .appendTo($cardInfo);
-
-      var max = section.sections.length > 3 ? 3 : section.sections.length;
-
-      for (var i = 0; i < max; ++i) {
-
-        var subResource = section.sections[i];
-        if (!plusone) {
-          $('<li>')
-            .append($('<a>').attr('href', subResource.url)
-              .append($('<div>').addClass('title').html(subResource.title))
-              .append($('<div>').addClass('description ellipsis')
-                .append($('<div>').addClass('text').html(subResource.summary))
-                .append($('<div>').addClass('util'))))
-          .appendTo($ul);
-        } else {
-          $('<li>')
-            .append($('<a>').attr('href', subResource.url)
-              .append($('<div>').addClass('title').html(subResource.title))
-              .append($('<div>').addClass('description ellipsis')
-                .append($('<div>').addClass('text').html(subResource.summary))
-                .append($('<div>').addClass('util')
-                  .append($('<div>').addClass('g-plusone')
-                    .attr('data-size', 'small')
-                    .attr('data-align', 'right')
-                    .attr('data-href', resource.url)))))
-          .appendTo($ul);
-        }
-      }
-
-      // Add a more row
-      if (max < section.sections.length) {
-        $('<li>')
-          .append($('<a>').attr('href', resource.url)
-            .append($('<div>')
-              .addClass('title')
-              .text('More')))
-        .appendTo($ul);
-      }
-    } else {
-      // No sub-resources, just render description?
-    }
-
-    return this;
-  };
-
-  /* Render other types of resource styles that are not cards. */
-  $.fn.decorateResource = function(resource, opts) {
-    var imgUrl = resource.image ||
-      'assets/images/resource-card-default-android.jpg';
-    var linkUrl = resource.url;
-
-    if (imgUrl.indexOf('//') === -1) {
-      imgUrl = toRoot + imgUrl;
-    }
-
-    if (linkUrl && linkUrl.indexOf('//') === -1) {
-      linkUrl = toRoot + linkUrl;
-    }
-
-    $(this).append(
-      $('<div>').addClass('image')
-        .css('background-image', 'url(' + imgUrl + ')'),
-      $('<div>').addClass('info').append(
-        $('<h4>').addClass('title').html(resource.title_highlighted || resource.title),
-        $('<p>').addClass('summary').html(resource.summary),
-        $('<a>').attr('href', linkUrl).addClass('cta').html('Learn More')
-      )
-    );
-
-    return this;
-  };
-})(jQuery);
-
-/*
-  Fullscreen Carousel
-
-  The following allows for an area at the top of the page that takes over the
-  entire browser height except for its top offset and an optional bottom
-  padding specified as a data attribute.
-
-  HTML:
-
-  <div class="fullscreen-carousel">
-    <div class="fullscreen-carousel-content">
-      <!-- content here -->
-    </div>
-    <div class="fullscreen-carousel-content">
-      <!-- content here -->
-    </div>
-
-    etc ...
-
-  </div>
-
-  Control over how the carousel takes over the screen can mostly be defined in
-  a css file. Setting min-height on the .fullscreen-carousel-content elements
-  will prevent them from shrinking to far vertically when the browser is very
-  short, and setting max-height on the .fullscreen-carousel itself will prevent
-  the area from becoming to long in the case that the browser is stretched very
-  tall.
-
-  There is limited functionality for having multiple sections since that request
-  was removed, but it is possible to add .next-arrow and .prev-arrow elements to
-  scroll between multiple content areas.
-*/
-
-(function() {
-  $(document).ready(function() {
-    $('.fullscreen-carousel').each(function() {
-      initWidget(this);
-    });
-  });
-
-  function initWidget(widget) {
-    var $widget = $(widget);
-
-    var topOffset = $widget.offset().top;
-    var padBottom = parseInt($widget.data('paddingbottom')) || 0;
-    var maxHeight = 0;
-    var minHeight = 0;
-    var $content = $widget.find('.fullscreen-carousel-content');
-    var $nextArrow = $widget.find('.next-arrow');
-    var $prevArrow = $widget.find('.prev-arrow');
-    var $curSection = $($content[0]);
-
-    if ($content.length <= 1) {
-      $nextArrow.hide();
-      $prevArrow.hide();
-    } else {
-      $nextArrow.click(function() {
-        var index = ($content.index($curSection) + 1);
-        $curSection.hide();
-        $curSection = $($content[index >= $content.length ? 0 : index]);
-        $curSection.show();
-      });
-
-      $prevArrow.click(function() {
-        var index = ($content.index($curSection) - 1);
-        $curSection.hide();
-        $curSection = $($content[index < 0 ? $content.length - 1 : 0]);
-        $curSection.show();
-      });
-    }
-
-    // Just hide all content sections except first.
-    $content.each(function(index) {
-      if ($(this).height() > minHeight) minHeight = $(this).height();
-      $(this).css({position: 'absolute',  display: index > 0 ? 'none' : ''});
-    });
-
-    // Register for changes to window size, and trigger.
-    $(window).resize(resizeWidget);
-    resizeWidget();
-
-    function resizeWidget() {
-      var height = $(window).height() - topOffset - padBottom;
-      $widget.width($(window).width());
-      $widget.height(height < minHeight ? minHeight :
-        (maxHeight && height > maxHeight ? maxHeight : height));
-    }
-  }
-})();
-
-/*
-  Tab Carousel
-
-  The following allows tab widgets to be installed via the html below. Each
-  tab content section should have a data-tab attribute matching one of the
-  nav items'. Also each tab content section should have a width matching the
-  tab carousel.
-
-  HTML:
-
-  <div class="tab-carousel">
-    <ul class="tab-nav">
-      <li><a href="#" data-tab="handsets">Handsets</a>
-      <li><a href="#" data-tab="wearable">Wearable</a>
-      <li><a href="#" data-tab="tv">TV</a>
-    </ul>
-
-    <div class="tab-carousel-content">
-      <div data-tab="handsets">
-        <!--Full width content here-->
-      </div>
-
-      <div data-tab="wearable">
-        <!--Full width content here-->
-      </div>
-
-      <div data-tab="tv">
-        <!--Full width content here-->
-      </div>
-    </div>
-  </div>
-
-*/
-(function() {
-  $(document).ready(function() {
-    $('.tab-carousel').each(function() {
-      initWidget(this);
-    });
-  });
-
-  function initWidget(widget) {
-    var $widget = $(widget);
-    var $nav = $widget.find('.tab-nav');
-    var $anchors = $nav.find('[data-tab]');
-    var $li = $nav.find('li');
-    var $contentContainer = $widget.find('.tab-carousel-content');
-    var $tabs = $contentContainer.find('[data-tab]');
-    var $curTab = $($tabs[0]); // Current tab is first tab.
-    var width = $widget.width();
-
-    // Setup nav interactivity.
-    $anchors.click(function(evt) {
-      evt.preventDefault();
-      var query = '[data-tab=' + $(this).data('tab') + ']';
-      transitionWidget($tabs.filter(query));
-    });
-
-    // Add highlight for navigation on first item.
-    var $highlight = $('<div>').addClass('highlight')
-      .css({left:$li.position().left + 'px', width:$li.outerWidth() + 'px'})
-      .appendTo($nav);
-
-    // Store height since we will change contents to absolute.
-    $contentContainer.height($contentContainer.height());
-
-    // Absolutely position tabs so they're ready for transition.
-    $tabs.each(function(index) {
-      $(this).css({position: 'absolute', left: index > 0 ? width + 'px' : '0'});
-    });
-
-    function transitionWidget($toTab) {
-      if (!$curTab.is($toTab)) {
-        var curIndex = $tabs.index($curTab[0]);
-        var toIndex = $tabs.index($toTab[0]);
-        var dir = toIndex > curIndex ? 1 : -1;
-
-        // Animate content sections.
-        $toTab.css({left:(width * dir) + 'px'});
-        $curTab.animate({left:(width * -dir) + 'px'});
-        $toTab.animate({left:'0'});
-
-        // Animate navigation highlight.
-        $highlight.animate({left:$($li[toIndex]).position().left + 'px',
-          width:$($li[toIndex]).outerWidth() + 'px'})
-
-        // Store new current section.
-        $curTab = $toTab;
-      }
-    }
-  }
-})();
-
-/**
- * Auto TOC
- *
- * Upgrades h2s on the page to have a rule and be toggle-able on mobile.
- */
-(function($) {
-  var upgraded = false;
-  var h2Titles;
-
-  function initWidget() {
-    // add HRs below all H2s (except for a few other h2 variants)
-    // Consider doing this with css instead.
-    h2Titles = $('h2').not('#qv h2, #tb h2, .sidebox h2, #devdoc-nav h2, h2.norule');
-    h2Titles.css({paddingBottom:0}).after('<hr/>');
-
-    // Exit early if on older browser.
-    if (!window.matchMedia) {
-      return;
-    }
-
-    // Only run logic in mobile layout.
-    var query = window.matchMedia('(max-width: 719px)');
-    if (query.matches) {
-      makeTogglable();
-    } else {
-      query.addListener(makeTogglable);
-    }
-  }
-
-  function makeTogglable() {
-    // Only run this logic once.
-    if (upgraded) { return; }
-    upgraded = true;
-
-    // Only make content h2s togglable.
-    var contentTitles = h2Titles.filter('#jd-content *');
-
-    // If there are more than 1
-    if (contentTitles.size() < 2) {
-      return;
-    }
-
-    contentTitles.each(function() {
-      // Find all the relevant nodes.
-      var $title = $(this);
-      var $hr = $title.next();
-      var $contents = allNextUntil($hr[0], 'h2, .next-docs');
-      var $section = $($title)
-        .add($hr)
-        .add($title.prev('a[name]'))
-        .add($contents);
-      var $anchor = $section.first().prev();
-      var anchorMethod = 'after';
-      if ($anchor.length === 0) {
-        $anchor = $title.parent();
-        anchorMethod = 'prepend';
-      }
-
-      // Some h2s are in their own container making it pretty hard to find the end, so skip.
-      if ($contents.length === 0) {
-        return;
-      }
-
-      // Remove from DOM before messing with it. DOM is slow!
-      $section.detach();
-
-      // Add mobile-only expand arrows.
-      $title.prepend('<span class="dac-visible-mobile-inline-block">' +
-          '<i class="dac-toggle-expand dac-sprite dac-expand-more-black"></i>' +
-          '<i class="dac-toggle-collapse dac-sprite dac-expand-less-black"></i>' +
-          '</span>')
-        .attr('data-toggle', 'section');
-
-      // Wrap in magic markup.
-      $section = $section.wrapAll('<div class="dac-toggle dac-mobile">').parent();
-
-      // extra div used for max-height calculation.
-      $contents.wrapAll('<div class="dac-toggle-content dac-expand"><div>');
-
-      // Pre-expand section if requested.
-      if ($title.hasClass('is-expanded')) {
-        $section.addClass('is-expanded');
-      }
-
-      // Pre-expand section if targetted by hash.
-      if (location.hash && $section.find(location.hash).length) {
-        $section.addClass('is-expanded');
-      }
-
-      // Add it back to the dom.
-      $anchor[anchorMethod].call($anchor, $section);
-    });
-  }
-
-  // Similar to $.fn.nextUntil() except we need all nodes, jQuery skips text nodes.
-  function allNextUntil(elem, until) {
-    var matched = [];
-
-    while ((elem = elem.nextSibling) && elem.nodeType !== 9) {
-      if (elem.nodeType === 1 && jQuery(elem).is(until)) {
-        break;
-      }
-      matched.push(elem);
-    }
-    return $(matched);
-  }
-
-  $(function() {
-    initWidget();
-  });
-})(jQuery);
-
-(function($, window) {
-  'use strict';
-
-  // Blogger API info
-  var apiUrl = 'https://www.googleapis.com/blogger/v3';
-  var apiKey = 'AIzaSyCFhbGnjW06dYwvRCU8h_zjdpS4PYYbEe8';
-
-  // Blog IDs can be found in the markup of the blog posts
-  var blogs = {
-    'android-developers': {
-      id: '6755709643044947179',
-      title: 'Android Developers Blog'
-    }
-  };
-  var monthNames = ['January', 'February', 'March', 'April', 'May', 'June',
-      'July', 'August', 'September', 'October', 'November', 'December'];
-
-  var BlogReader = (function() {
-    var reader;
-
-    function BlogReader() {
-      this.doneSetup = false;
-    }
-
-    /**
-     * Initialize the blog reader and modal.
-     */
-    BlogReader.prototype.setup = function() {
-      $('#jd-content').append(
-          '<div id="blog-reader" data-modal="blog-reader" class="dac-modal dac-has-small-header">' +
-            '<div class="dac-modal-container">' +
-              '<div class="dac-modal-window">' +
-                '<header class="dac-modal-header">' +
-                  '<div class="dac-modal-header-actions">' +
-                    '<a href="" class="dac-modal-header-open" target="_blank">' +
-                      '<i class="dac-sprite dac-open-in-new"></i>' +
-                    '</a>' +
-                    '<button class="dac-modal-header-close" data-modal-toggle>' +
-                    '</button>' +
-                  '</div>' +
-                  '<h2 class="norule dac-modal-header-title"></h2>' +
-                '</header>' +
-                '<div class="dac-modal-content dac-blog-reader">' +
-                  '<time class="dac-blog-reader-date" pubDate></time>' +
-                  '<h3 class="dac-blog-reader-title"></h3>' +
-                  '<div class="dac-blog-reader-text clearfix"></div>' +
-                '</div>' +
-              '</div>' +
-            '</div>' +
-          '</div>');
-
-      this.blogReader = $('#blog-reader').dacModal();
-
-      this.doneSetup = true;
-    };
-
-    BlogReader.prototype.openModal_ = function(blog, post) {
-      var published = new Date(post.published);
-      var formattedDate = monthNames[published.getMonth()] + ' ' + published.getDate() + ' ' + published.getFullYear();
-      this.blogReader.find('.dac-modal-header-open').attr('href', post.url);
-      this.blogReader.find('.dac-modal-header-title').text(blog.title);
-      this.blogReader.find('.dac-blog-reader-title').html(post.title);
-      this.blogReader.find('.dac-blog-reader-date').html(formattedDate);
-      this.blogReader.find('.dac-blog-reader-text').html(post.content);
-      this.blogReader.trigger('modal-open');
-    };
-
-    /**
-     * Show a blog post in a modal
-     * @param  {string} blogName - The name of the Blogspot blog.
-     * @param  {string} postPath - The path to the blog post.
-     * @param  {bool} secondTry - Has it failed once?
-     */
-    BlogReader.prototype.showPost = function(blogName, postPath, secondTry) {
-      var blog = blogs[blogName];
-      var postUrl = 'https://' + blogName + '.blogspot.com' + postPath;
-
-      var url = apiUrl + '/blogs/' + blog.id + '/posts/bypath?path=' + encodeURIComponent(postPath) + '&key=' + apiKey;
-      $.ajax(url, {timeout: 650}).done(this.openModal_.bind(this, blog)).fail(function(error) {
-        // Retry once if we get an error
-        if (error.status === 500 && !secondTry) {
-          this.showPost(blogName, postPath, true);
-        } else {
-          window.location.href = postUrl;
-        }
-      }.bind(this));
-    };
-
-    return {
-      getReader: function() {
-        if (!reader) {
-          reader = new BlogReader();
-        }
-        return reader;
-      }
-    };
-  })();
-
-  var blogReader = BlogReader.getReader();
-
-  function wrapLinkWithReader(e) {
-    var el = $(e.currentTarget);
-    if (el.hasClass('dac-modal-header-open')) {
-      return;
-    }
-
-    // Only catch links on blogspot.com
-    var matches = el.attr('href').match(/https?:\/\/([^\.]*).blogspot.com([^$]*)/);
-    if (matches && matches.length === 3) {
-      var blogName = matches[1];
-      var postPath = matches[2];
-
-      // Check if we have information about the blog
-      if (!blogs[blogName]) {
-        return;
-      }
-
-      // Setup the first time it's used
-      if (!blogReader.doneSetup) {
-        blogReader.setup();
-      }
-
-      e.preventDefault();
-      blogReader.showPost(blogName, postPath);
-    }
-  }
-
-  $(document).on('click.blog-reader', 'a.resource-card[href*="blogspot.com/"]',
-      wrapLinkWithReader);
-})(jQuery, window);
-
-(function($) {
-  $.fn.debounce = function(func, wait, immediate) {
-    var timeout;
-
-    return function() {
-      var context = this;
-      var args = arguments;
-
-      var later = function() {
-        timeout = null;
-        if (!immediate) {
-          func.apply(context, args);
-        }
-      };
-
-      var callNow = immediate && !timeout;
-      clearTimeout(timeout);
-      timeout = setTimeout(later, wait);
-
-      if (callNow) {
-        func.apply(context, args);
-      }
-    };
-  };
-})(jQuery);
-
-/* Calculate the vertical area remaining */
-(function($) {
-  $.fn.ellipsisfade = function() {
-    // Only fetch line-height of first element to avoid recalculate style.
-    // Will be NaN if no elements match, which is ok.
-    var lineHeight = parseInt(this.css('line-height'), 10);
-
-    this.each(function() {
-      // get element text
-      var $this = $(this);
-      var remainingHeight = $this.parent().parent().height();
-      $this.parent().siblings().each(function() {
-        var elHeight;
-        if ($(this).is(':visible')) {
-          elHeight = $(this).outerHeight(true);
-          remainingHeight = remainingHeight - elHeight;
-        }
-      });
-
-      var adjustedRemainingHeight = ((remainingHeight) / lineHeight >> 0) * lineHeight;
-      $this.parent().css({height: adjustedRemainingHeight});
-      $this.css({height: 'auto'});
-    });
-
-    return this;
-  };
-
-  /* Pass the line height to ellipsisfade() to adjust the height of the
-   text container to show the max number of lines possible, without
-   showing lines that are cut off. This works with the css ellipsis
-   classes to fade last text line and apply an ellipsis char. */
-  function updateEllipsis(context) {
-    if (!(context instanceof jQuery)) {
-      context = $('html');
-    }
-
-    context.find('.card-info .text').ellipsisfade();
-  }
-
-  $(window).on('resize', $.fn.debounce(updateEllipsis, 500));
-  $(updateEllipsis);
-  $('html').on('dac:domchange', function(e) { updateEllipsis($(e.target)); });
-})(jQuery);
-
-/* Filter */
-(function($) {
-  'use strict';
-
-  /**
-   * A single filter item content.
-   * @type {string} - Element template.
-   * @private
-   */
-  var ITEM_STR_ = '<input type="checkbox" value="{{value}}" class="dac-form-checkbox" id="{{id}}">' +
-      '<label for="{{id}}" class="dac-form-checkbox-button"></label>' +
-      '<label for="{{id}}" class="dac-form-label">{{name}}</label>';
-
-  /**
-   * Template for a chip element.
-   * @type {*|HTMLElement}
-   * @private
-   */
-  var CHIP_BASE_ = $('<li class="dac-filter-chip">' +
-    '<button class="dac-filter-chip-close">' +
-      '<i class="dac-sprite dac-close-black dac-filter-chip-close-icon"></i>' +
-    '</button>' +
-  '</li>');
-
-  /**
-   * Component to handle narrowing down resources.
-   * @param {HTMLElement} el - The DOM element.
-   * @param {Object} options
-   * @constructor
-   */
-  function Filter(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, Filter.DEFAULTS_, options);
-    this.init();
-  }
-
-  Filter.DEFAULTS_ = {
-    activeClass: 'dac-active',
-    chipsDataAttr: 'filter-chips',
-    nameDataAttr: 'filter-name',
-    countDataAttr: 'filter-count',
-    tabViewDataAttr: 'tab-view',
-    valueDataAttr: 'filter-value'
-  };
-
-  /**
-   * Draw resource cards.
-   * @param {Array} resources
-   * @private
-   */
-  Filter.prototype.draw_ = function(resources) {
-    var that = this;
-
-    if (resources.length === 0) {
-      this.containerEl_.html('<p class="dac-filter-message">Nothing matches selected filters.</p>');
-      return;
-    }
-
-    // Draw resources.
-    that.containerEl_.resourceWidget(resources, that.data_.options);
-  };
-
-  /**
-   * Initialize a Filter component.
-   */
-  Filter.prototype.init = function() {
-    this.containerEl_ = $(this.options.filter);
-
-    // Setup data settings
-    this.data_ = {};
-    this.data_.chips = {};
-    this.data_.options = this.containerEl_.widgetOptions();
-    this.data_.all = window.metadata.query(this.data_.options);
-
-    // Initialize filter UI
-    this.initUi();
-  };
-
-  /**
-   * Generate a chip for a given filter item.
-   * @param {Object} item - A single filter option (checkbox container).
-   * @returns {HTMLElement} A new Chip element.
-   */
-  Filter.prototype.chipForItem = function(item) {
-    var chip = CHIP_BASE_.clone();
-    chip.prepend(this.data_.chips[item.data('filter-value')]);
-    chip.data('item.dac-filter', item);
-    item.data('chip.dac-filter', chip);
-    this.addToItemValue(item, 1);
-    return chip[0];
-  };
-
-  /**
-   * Update count of checked filter items.
-   * @param {Object} item - A single filter option (checkbox container).
-   * @param {Number} value - Either -1 or 1.
-   */
-  Filter.prototype.addToItemValue = function(item, value) {
-    var tab = item.parent().data(this.options.tabViewDataAttr);
-    var countEl = this.countEl_.filter('[data-' + this.options.countDataAttr + '="' + tab + '"]');
-    var count = value + parseInt(countEl.text(), 10);
-    countEl.text(count);
-    countEl.toggleClass('dac-disabled', count === 0);
-  };
-
-  /**
-   * Set event listeners.
-   * @private
-   */
-  Filter.prototype.setEventListeners_ = function() {
-    this.chipsEl_.on('click.dac-filter', '.dac-filter-chip-close', this.closeChipHandler_.bind(this));
-    this.tabViewEl_.on('change.dac-filter', ':checkbox', this.toggleCheckboxHandler_.bind(this));
-  };
-
-  /**
-   * Check filter items that are active by default.
-   */
-  Filter.prototype.activateInitialFilters_ = function() {
-    var id = (new Date()).getTime();
-    var initiallyCheckedValues = this.data_.options.query.replace(/,\s*/g, '+').split('+');
-    var chips = document.createDocumentFragment();
-    var that = this;
-
-    this.items_.each(function(i) {
-      var item = $(this);
-      var opts = item.data();
-      that.data_.chips[opts.filterValue] = opts.filterName;
-
-      var checkbox = $(ITEM_STR_.replace(/\{\{name\}\}/g, opts.filterName)
-        .replace(/\{\{value\}\}/g, opts.filterValue)
-        .replace(/\{\{id\}\}/g, 'filter-' + id + '-' + (i + 1)));
-
-      if (initiallyCheckedValues.indexOf(opts.filterValue) > -1) {
-        checkbox[0].checked = true;
-        chips.appendChild(that.chipForItem(item));
-      }
-
-      item.append(checkbox);
-    });
-
-    this.chipsEl_.append(chips);
-  };
-
-  /**
-   * Initialize the Filter view
-   */
-  Filter.prototype.initUi = function() {
-    // Cache DOM elements
-    this.chipsEl_ = this.el.find('[data-' + this.options.chipsDataAttr + ']');
-    this.countEl_ = this.el.find('[data-' + this.options.countDataAttr + ']');
-    this.tabViewEl_ = this.el.find('[data-' + this.options.tabViewDataAttr + ']');
-    this.items_ = this.el.find('[data-' + this.options.nameDataAttr + ']');
-
-    // Setup UI
-    this.draw_(this.data_.all);
-    this.activateInitialFilters_();
-    this.setEventListeners_();
-  };
-
-  /**
-   * @returns {[types|Array, tags|Array, category|Array]}
-   */
-  Filter.prototype.getActiveClauses = function() {
-    var tags = [];
-    var types = [];
-    var categories = [];
-
-    this.items_.find(':checked').each(function(i, checkbox) {
-      // Currently, there is implicit business logic here that `tag` is AND'ed together
-      // while `type` is OR'ed. So , and + do the same thing here. It would be great to
-      // reuse the same query engine for filters, but it would need more powerful syntax.
-      // Probably parenthesis, to support "tag:dog + tag:cat + (type:video, type:blog)"
-      var expression = $(checkbox).val();
-      var regex = /(\w+):(\w+)/g;
-      var match;
-
-      while (match = regex.exec(expression)) {
-        switch (match[1]) {
-          case 'category':
-            categories.push(match[2]);
-            break;
-          case 'tag':
-            tags.push(match[2]);
-            break;
-          case 'type':
-            types.push(match[2]);
-            break;
-        }
-      }
-    });
-
-    return [types, tags, categories];
-  };
-
-  /**
-   * Actual filtering logic.
-   * @returns {Array}
-   */
-  Filter.prototype.filteredResources = function() {
-    var data = this.getActiveClauses();
-    var types = data[0];
-    var tags = data[1];
-    var categories = data[2];
-    var resources = [];
-    var resource = {};
-    var tag = '';
-    var shouldAddResource = true;
-
-    for (var resourceIndex = 0; resourceIndex < this.data_.all.length; resourceIndex++) {
-      resource = this.data_.all[resourceIndex];
-      shouldAddResource = types.indexOf(resource.type) > -1;
-
-      if (categories && categories.length > 0) {
-        shouldAddResource = shouldAddResource && categories.indexOf(resource.category) > -1;
-      }
-
-      for (var tagIndex = 0; shouldAddResource && tagIndex < tags.length; tagIndex++) {
-        tag = tags[tagIndex];
-        shouldAddResource = resource.tags.indexOf(tag) > -1;
-      }
-
-      if (shouldAddResource) {
-        resources.push(resource);
-      }
-    }
-
-    return resources;
-  };
-
-  /**
-   * Close Chip Handler
-   * @param {Event} event - Click event
-   * @private
-   */
-  Filter.prototype.closeChipHandler_ = function(event) {
-    var chip = $(event.currentTarget).parent();
-    var checkbox = chip.data('item.dac-filter').find(':first-child')[0];
-    checkbox.checked = false;
-    this.changeStateForCheckbox(checkbox);
-  };
-
-  /**
-   * Handle filter item state change.
-   * @param {Event} event - Change event
-   * @private
-   */
-  Filter.prototype.toggleCheckboxHandler_ = function(event) {
-    this.changeStateForCheckbox(event.currentTarget);
-  };
-
-  /**
-   * Redraw resource view based on new state.
-   * @param checkbox
-   */
-  Filter.prototype.changeStateForCheckbox = function(checkbox) {
-    var item = $(checkbox).parent();
-
-    if (checkbox.checked) {
-      this.chipsEl_.append(this.chipForItem(item));
-      devsite.analytics.trackAnalyticsEvent('event',
-          'Filters', 'Check', $(checkbox).val());
-    } else {
-      item.data('chip.dac-filter').remove();
-      this.addToItemValue(item, -1);
-      devsite.analytics.trackAnalyticsEvent('event',
-          'Filters', 'Uncheck', $(checkbox).val());
-    }
-
-    this.draw_(this.filteredResources());
-  };
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacFilter = function() {
-    return this.each(function() {
-      var el = $(this);
-      new Filter(el, el.data());
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(function() {
-    $('[data-filter]').dacFilter();
-  });
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  /**
-   * Toggle Floating Label state.
-   * @param {HTMLElement} el - The DOM element.
-   * @param options
-   * @constructor
-   */
-  function FloatingLabel(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, FloatingLabel.DEFAULTS_, options);
-    this.group = this.el.closest('.dac-form-input-group');
-    this.input = this.group.find('.dac-form-input');
-
-    this.checkValue_ = this.checkValue_.bind(this);
-    this.checkValue_();
-
-    this.input.on('focus', function() {
-      this.group.addClass('dac-focused');
-    }.bind(this));
-    this.input.on('blur', function() {
-      this.group.removeClass('dac-focused');
-      this.checkValue_();
-    }.bind(this));
-    this.input.on('keyup', this.checkValue_);
-  }
-
-  /**
-   * The label is moved out of the textbox when it has a value.
-   */
-  FloatingLabel.prototype.checkValue_ = function() {
-    if (this.input.val().length) {
-      this.group.addClass('dac-has-value');
-    } else {
-      this.group.removeClass('dac-has-value');
-    }
-  };
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacFloatingLabel = function(options) {
-    return this.each(function() {
-      new FloatingLabel(this, options);
-    });
-  };
-
-  $(document).on('ready.aranja', function() {
-    $('.dac-form-floatlabel').each(function() {
-      $(this).dacFloatingLabel($(this).data());
-    });
-  });
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  /**
-   * @param {HTMLElement} el - The DOM element.
-   * @param {Object} options
-   * @constructor
-   */
-  function Crumbs(selected, options) {
-    this.options = $.extend({}, Crumbs.DEFAULTS_, options);
-    this.el = $(this.options.container);
-
-    // Do not build breadcrumbs for landing site.
-    if (!selected || location.pathname === '/index.html' || location.pathname === '/') {
-      return;
-    }
-
-    // Cache navigation resources
-    this.selected = $(selected);
-    this.selectedParent = this.selected.closest('.dac-nav-secondary').siblings('a');
-
-    // Build the breadcrumb list.
-    this.init();
-  }
-
-  Crumbs.DEFAULTS_ = {
-    container: '.dac-header-crumbs',
-    crumbItem: $('<li class="dac-header-crumbs-item">'),
-    linkClass: 'dac-header-crumbs-link'
-  };
-
-  Crumbs.prototype.init = function() {
-    Crumbs.buildCrumbForLink(this.selected.clone()).appendTo(this.el);
-
-    if (this.selectedParent.length) {
-      Crumbs.buildCrumbForLink(this.selectedParent.clone()).prependTo(this.el);
-    }
-
-    // Reveal the breadcrumbs
-    this.el.addClass('dac-has-content');
-  };
-
-  /**
-   * Build a HTML structure for a breadcrumb.
-   * @param {string} link
-   * @return {jQuery}
-   */
-  Crumbs.buildCrumbForLink = function(link) {
-    link.find('br').replaceWith(' ');
-
-    var crumbLink = $('<a>')
-      .attr('class', Crumbs.DEFAULTS_.linkClass)
-      .attr('href', link.attr('href'))
-      .text(link.text());
-
-    return Crumbs.DEFAULTS_.crumbItem.clone().append(crumbLink);
-  };
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacCrumbs = function(options) {
-    return this.each(function() {
-      new Crumbs(this, options);
-    });
-  };
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  /**
-   * @param {HTMLElement} el - The DOM element.
-   * @param {Object} options
-   * @constructor
-   */
-  function SearchInput(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, SearchInput.DEFAULTS_, options);
-    this.body = $('body');
-    this.input = this.el.find('input');
-    this.close = this.el.find(this.options.closeButton);
-    this.clear = this.el.find(this.options.clearButton);
-    this.icon = this.el.find('.' + this.options.iconClass);
-    this.init();
-  }
-
-  SearchInput.DEFAULTS_ = {
-    activeClass: 'dac-active',
-    activeIconClass: 'dac-search',
-    closeButton: '[data-search-close]',
-    clearButton: '[data-search-clear]',
-    hiddenClass: 'dac-hidden',
-    iconClass: 'dac-header-search-icon',
-    searchModeClass: 'dac-search-mode',
-    transitionDuration: 250
-  };
-
-  SearchInput.prototype.init = function() {
-    this.input.on('focus.dac-search', this.setActiveState.bind(this))
-              .on('input.dac-search', this.checkInputValue.bind(this));
-    this.close.on('click.dac-search', this.unsetActiveStateHandler_.bind(this));
-    this.clear.on('click.dac-search', this.clearInput.bind(this));
-  };
-
-  SearchInput.prototype.setActiveState = function() {
-    var that = this;
-
-    this.clear.addClass(this.options.hiddenClass);
-    this.body.addClass(this.options.searchModeClass);
-    this.checkInputValue();
-
-    // Set icon to black after background has faded to white.
-    setTimeout(function() {
-      that.icon.addClass(that.options.activeIconClass);
-    }, this.options.transitionDuration);
-  };
-
-  SearchInput.prototype.unsetActiveStateHandler_ = function(event) {
-    event.preventDefault();
-    this.unsetActiveState();
-  };
-
-  SearchInput.prototype.unsetActiveState = function() {
-    this.icon.removeClass(this.options.activeIconClass);
-    this.clear.addClass(this.options.hiddenClass);
-    this.body.removeClass(this.options.searchModeClass);
-  };
-
-  SearchInput.prototype.clearInput = function(event) {
-    event.preventDefault();
-    this.input.val('');
-    this.clear.addClass(this.options.hiddenClass);
-  };
-
-  SearchInput.prototype.checkInputValue = function() {
-    if (this.input.val().length) {
-      this.clear.removeClass(this.options.hiddenClass);
-    } else {
-      this.clear.addClass(this.options.hiddenClass);
-    }
-  };
-
-  /**
-   * jQuery plugin
-   * @param {object} options - Override default options.
-   */
-  $.fn.dacSearchInput = function() {
-    return this.each(function() {
-      var el = $(this);
-      el.data('search-input.dac', new SearchInput(el, el.data()));
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(function() {
-    $('[data-search]').dacSearchInput();
-  });
-})(jQuery);
-
-/* global METADATA */
-(function($) {
-  function DacCarouselQuery(el) {
-    el = $(el);
-
-    var opts = el.data();
-    opts.maxResults = parseInt(opts.maxResults || '100', 10);
-    opts.query = opts.carouselQuery;
-    var resources = window.metadata.query(opts);
-
-    el.empty();
-    $(resources).each(function() {
-      var resource = $.extend({}, this, METADATA.carousel[this.url]);
-      el.dacHero(resource);
-    });
-
-    // Pagination element.
-    el.append('<div class="dac-hero-carousel-pagination"><div class="wrap" data-carousel-pagination>');
-
-    el.dacCarousel();
-  }
-
-  // jQuery plugin
-  $.fn.dacCarouselQuery = function() {
-    return this.each(function() {
-      var el = $(this);
-      var data = el.data('dac.carouselQuery');
-
-      if (!data) { el.data('dac.carouselQuery', (data = new DacCarouselQuery(el))); }
-    });
-  };
-
-  // Data API
-  $(function() {
-    $('[data-carousel-query]').dacCarouselQuery();
-  });
-})(jQuery);
-
-(function($) {
-  /**
-   * A CSS based carousel, inspired by SequenceJS.
-   * @param {jQuery} el
-   * @param {object} options
-   * @constructor
-   */
-  function DacCarousel(el, options) {
-    this.el = $(el);
-    this.options = options = $.extend({}, DacCarousel.OPTIONS, this.el.data(), options || {});
-    this.frames = this.el.find(options.frameSelector);
-    this.count = this.frames.size();
-    this.current = options.start;
-
-    this.initPagination();
-    this.initEvents();
-    this.initFrame();
-  }
-
-  DacCarousel.OPTIONS = {
-    auto:      true,
-    autoTime:  10000,
-    autoMinTime: 5000,
-    btnPrev:   '[data-carousel-prev]',
-    btnNext:   '[data-carousel-next]',
-    frameSelector: 'article',
-    loop:      true,
-    start:     0,
-    swipeThreshold: 160,
-    pagination: '[data-carousel-pagination]'
-  };
-
-  DacCarousel.prototype.initPagination = function() {
-    this.pagination = $([]);
-    if (!this.options.pagination) { return; }
-
-    var pagination = $('<ul class="dac-pagination">');
-    var parent = this.el;
-    if (typeof this.options.pagination === 'string') { parent = this.el.find(this.options.pagination); }
-
-    if (this.count > 1) {
-      for (var i = 0; i < this.count; i++) {
-        var li = $('<li class="dac-pagination-item">').text(i);
-        if (i === this.options.start) { li.addClass('active'); }
-        li.click(this.go.bind(this, i));
-
-        pagination.append(li);
-      }
-      this.pagination = pagination.children();
-      parent.append(pagination);
-    }
-  };
-
-  DacCarousel.prototype.initEvents = function() {
-    var that = this;
-
-    this.touch = {
-      start: {x: 0, y: 0},
-      end:   {x: 0, y: 0}
-    };
-
-    this.el.on('touchstart', this.touchstart_.bind(this));
-    this.el.on('touchend', this.touchend_.bind(this));
-    this.el.on('touchmove', this.touchmove_.bind(this));
-
-    this.el.hover(function() {
-      that.pauseRotateTimer();
-    }, function() {
-      that.startRotateTimer();
-    });
-
-    $(this.options.btnPrev).click(function(e) {
-      e.preventDefault();
-      that.prev();
-    });
-
-    $(this.options.btnNext).click(function(e) {
-      e.preventDefault();
-      that.next();
-    });
-  };
-
-  DacCarousel.prototype.touchstart_ = function(event) {
-    var t = event.originalEvent.touches[0];
-    this.touch.start = {x: t.screenX, y: t.screenY};
-  };
-
-  DacCarousel.prototype.touchend_ = function() {
-    var deltaX = this.touch.end.x - this.touch.start.x;
-    var deltaY = Math.abs(this.touch.end.y - this.touch.start.y);
-    var shouldSwipe = (deltaY < Math.abs(deltaX)) && (Math.abs(deltaX) >= this.options.swipeThreshold);
-
-    if (shouldSwipe) {
-      if (deltaX > 0) {
-        this.prev();
-      } else {
-        this.next();
-      }
-    }
-  };
-
-  DacCarousel.prototype.touchmove_ = function(event) {
-    var t = event.originalEvent.touches[0];
-    this.touch.end = {x: t.screenX, y: t.screenY};
-  };
-
-  DacCarousel.prototype.initFrame = function() {
-    this.frames.removeClass('active').eq(this.options.start).addClass('active');
-  };
-
-  DacCarousel.prototype.startRotateTimer = function() {
-    if (!this.options.auto || this.rotateTimer) { return; }
-    this.rotateTimer = setTimeout(this.next.bind(this), this.options.autoTime);
-  };
-
-  DacCarousel.prototype.pauseRotateTimer = function() {
-    clearTimeout(this.rotateTimer);
-    this.rotateTimer = null;
-  };
-
-  DacCarousel.prototype.prev = function() {
-    this.go(this.current - 1);
-  };
-
-  DacCarousel.prototype.next = function() {
-    this.go(this.current + 1);
-  };
-
-  DacCarousel.prototype.go = function(next) {
-    // Figure out what the next slide is.
-    while (this.count > 0 && next >= this.count) { next -= this.count; }
-    while (next < 0) { next += this.count; }
-
-    // Cancel if we're already on that slide.
-    if (next === this.current) { return; }
-
-    // Prepare next slide.
-    this.frames.eq(next).removeClass('out');
-
-    // Recalculate styles before starting slide transition.
-    this.el.resolveStyles();
-    // Update pagination
-    this.pagination.removeClass('active').eq(next).addClass('active');
-
-    // Transition out current frame
-    this.frames.eq(this.current).toggleClass('active out');
-
-    // Transition in a new frame
-    this.frames.eq(next).toggleClass('active');
-
-    this.current = next;
-  };
-
-  // Helper which resolves new styles for an element, so it can start transitioning
-  // from the new values.
-  $.fn.resolveStyles = function() {
-    /*jshint expr:true*/
-    this[0] && this[0].offsetTop;
-    return this;
-  };
-
-  // jQuery plugin
-  $.fn.dacCarousel = function() {
-    this.each(function() {
-      var $el = $(this);
-      $el.data('dac-carousel', new DacCarousel(this));
-    });
-    return this;
-  };
-
-  // Data API
-  $(function() {
-    $('[data-carousel]').dacCarousel();
-  });
-})(jQuery);
-
-/* global toRoot */
-
-(function($) {
-  // Ordering matters
-  var TAG_MAP = [
-    {from: 'developerstory', to: 'Android Developer Story'},
-    {from: 'googleplay', to: 'Google Play'}
-  ];
-
-  function DacHero(el, resource, isSearch) {
-    var slide = $('<article>');
-    slide.addClass(isSearch ? 'dac-search-hero' : 'dac-expand dac-hero');
-    var image = cleanUrl(resource.heroImage || resource.image);
-    var fullBleed = image && !resource.heroColor;
-
-    if (!isSearch) {
-      // Configure background
-      slide.css({
-        backgroundImage: fullBleed ? 'url(' + image + ')' : '',
-        backgroundColor: resource.heroColor || ''
-      });
-
-      // Should copy be inverted
-      slide.toggleClass('dac-invert', resource.heroInvert || fullBleed);
-      slide.toggleClass('dac-darken', fullBleed);
-
-      // Should be clickable
-      slide.append($('<a class="dac-hero-carousel-action">').attr('href', cleanUrl(resource.url)));
-    }
-
-    var cols = $('<div class="cols dac-hero-content">');
-
-    // inline image column
-    var rightCol = $('<div class="col-1of2 col-push-1of2 dac-hero-figure">')
-      .appendTo(cols);
-
-    if ((!fullBleed || isSearch) && image) {
-      rightCol.append($('<img>').attr('src', image));
-    }
-
-    // info column
-    $('<div class="col-1of2 col-pull-1of2">')
-      .append($('<div class="dac-hero-tag">').text(formatTag(resource)))
-      .append($('<h1 class="dac-hero-title">').text(formatTitle(resource)))
-      .append($('<p class="dac-hero-description">').text(resource.summary))
-      .append($('<a class="dac-hero-cta">')
-        .text(formatCTA(resource))
-        .attr('href', cleanUrl(resource.url))
-        .prepend($('<span class="dac-sprite dac-auto-chevron">'))
-      )
-      .appendTo(cols);
-
-    slide.append(cols.wrap('<div class="wrap">').parent());
-    el.append(slide);
-  }
-
-  function cleanUrl(url) {
-    if (url && url.indexOf('//') === -1) {
-      url = toRoot + url;
-    }
-    return url;
-  }
-
-  function formatTag(resource) {
-    // Hmm, need a better more scalable solution for this.
-    for (var i = 0, mapping; mapping = TAG_MAP[i]; i++) {
-      if (resource.tags.indexOf(mapping.from) > -1) {
-        return mapping.to;
-      }
-    }
-    return resource.type;
-  }
-
-  function formatTitle(resource) {
-    return resource.title.replace(/android developer story: /i, '');
-  }
-
-  function formatCTA(resource) {
-    return resource.type === 'youtube' ? 'Watch the video' : 'Learn more';
-  }
-
-  // jQuery plugin
-  $.fn.dacHero = function(resource, isSearch) {
-    return this.each(function() {
-      var el = $(this);
-      return new DacHero(el, resource, isSearch);
-    });
-  };
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  function highlightString(label, query) {
-    query = query || '';
-    //query = query.replace('<wbr>', '').replace('.', '\\.');
-    var queryRE = new RegExp('(' + query + ')', 'ig');
-    return label.replace(queryRE, '<em>$1</em>');
-  }
-
-  $.fn.highlightMatches = function(query) {
-    return this.each(function() {
-      var el = $(this);
-      var label = el.html();
-      var highlighted = highlightString(label, query);
-      el.html(highlighted);
-      el.addClass('highlighted');
-    });
-  };
-})(jQuery);
-
-/**
- * History tracking.
- * Track visited urls in localStorage.
- */
-(function($) {
-  var PAGES_TO_STORE_ = 100;
-  var MIN_NUMBER_OF_PAGES_TO_DISPLAY_ = 6;
-  var CONTAINER_SELECTOR_ = '.dac-search-results-history-wrap';
-
-  /**
-   * Generate resource cards for visited pages.
-   * @param {HTMLElement} el
-   * @constructor
-   */
-  function HistoryQuery(el) {
-    this.el = $(el);
-
-    // Only show history component if enough pages have been visited.
-    if (getVisitedPages().length < MIN_NUMBER_OF_PAGES_TO_DISPLAY_) {
-      this.el.closest(CONTAINER_SELECTOR_).addClass('dac-hidden');
-      return;
-    }
-
-    // Rename query
-    this.el.data('query', this.el.data('history-query'));
-
-    // jQuery method to populate cards.
-    this.el.resourceWidget();
-  }
-
-  /**
-   * Fetch from localStorage an array of visted pages
-   * @returns {Array}
-   */
-  function getVisitedPages() {
-    var visited = localStorage.getItem('visited-pages');
-    return visited ? JSON.parse(visited) : [];
-  }
-
-  /**
-   * Return a page corresponding to cuurent pathname. If none exists, create one.
-   * @param {Array} pages
-   * @param {String} path
-   * @returns {Object} Page
-   */
-  function getPageForPath(pages, path) {
-    var page;
-
-    // Backwards lookup for current page, last pages most likely to be visited again.
-    for (var i = pages.length - 1; i >= 0; i--) {
-      if (pages[i].path === path) {
-        page = pages[i];
-
-        // Remove page object from pages list to ensure correct ordering.
-        pages.splice(i, 1);
-
-        return page;
-      }
-    }
-
-    // If storage limit is exceeded, remove last visited path.
-    if (pages.length >= PAGES_TO_STORE_) {
-      pages.shift();
-    }
-
-    return {path: path};
-  }
-
-  /**
-   * Add current page to back of visited array, increase hit count by 1.
-   */
-  function addCurrectPage() {
-    var path = location.pathname;
-
-    // Do not track frontpage visits.
-    if (path === '/' || path === '/index.html') {return;}
-
-    var pages = getVisitedPages();
-    var page = getPageForPath(pages, path);
-
-    // New page visits have no hit count.
-    page.hit = ~~page.hit + 1;
-
-    // Most recently visted pages are located at the end of the visited array.
-    pages.push(page);
-
-    localStorage.setItem('visited-pages', JSON.stringify(pages));
-  }
-
-  /**
-   * Hit count compare function.
-   * @param {Object} a - page
-   * @param {Object} b - page
-   * @returns {number}
-   */
-  function byHit(a, b) {
-    if (a.hit > b.hit) {
-      return -1;
-    } else if (a.hit < b.hit) {
-      return 1;
-    }
-
-    return 0;
-  }
-
-  /**
-   * Return a list of visited urls in a given order.
-   * @param {String} order - (recent|most-visited)
-   * @returns {Array}
-   */
-  $.dacGetVisitedUrls = function(order) {
-    var pages = getVisitedPages();
-
-    if (order === 'recent') {
-      pages.reverse();
-    } else {
-      pages.sort(byHit);
-    }
-
-    return pages.map(function(page) {
-      return page.path.replace(/^\//, '');
-    });
-  };
-
-  // jQuery plugin
-  $.fn.dacHistoryQuery = function() {
-    return this.each(function() {
-      var el = $(this);
-      var data = el.data('dac.recentlyVisited');
-
-      if (!data) {
-        el.data('dac.recentlyVisited', (data = new HistoryQuery(el)));
-      }
-    });
-  };
-
-  $(function() {
-    $('[data-history-query]').dacHistoryQuery();
-    // Do not block page rendering.
-    setTimeout(addCurrectPage, 0);
-  });
-})(jQuery);
-
-/* ############################################ */
-/* ##########     LOCALIZATION     ############ */
-/* ############################################ */
-/**
- * Global helpers.
- */
-function getBaseUri(uri) {
-  var intlUrl = (uri.substring(0, 6) === '/intl/');
-  if (intlUrl) {
-    var base = uri.substring(uri.indexOf('intl/') + 5, uri.length);
-    base = base.substring(base.indexOf('/') + 1, base.length);
-    return '/' + base;
-  } else {
-    return uri;
-  }
-}
-
-function changeLangPref(targetLang, submit) {
-  window.writeCookie('pref_lang', targetLang, null);
-  $('#language').find('option[value="' + targetLang + '"]').attr('selected', true);
-  if (submit) {
-    $('#setlang').submit();
-  }
-}
-// Redundant usage to appease jshint.
-window.changeLangPref = changeLangPref;
-
-(function() {
-  /**
-   * Whitelisted locales. Should match choices in language dropdown. Repeated here
-   * as a lot of i18n logic happens before page load and dropdown is ready.
-   */
-  var LANGUAGES = [
-    'en',
-    'es',
-    'id',
-    'ja',
-    'ko',
-    'pt-br',
-    'ru',
-    'vi',
-    'zh-cn',
-    'zh-tw'
-  ];
-
-  /**
-   * Master list of translated strings for template files.
-   */
-  var PHRASES = {
-    'newsletter': {
-      'title': 'Get the latest Android developer news and tips that will help you find success on Google Play.',
-      'requiredHint': '* Required Fields',
-      'name': 'Full name',
-      'email': 'Email address',
-      'company': 'Company / developer name',
-      'appUrl': 'One of your Play Store app URLs',
-      'business': {
-        'label': 'Which best describes your business:',
-        'apps': 'Apps',
-        'games': 'Games',
-        'both': 'Apps & Games'
-      },
-      'confirmMailingList': 'Add me to the mailing list for the monthly newsletter and occasional emails about ' +
-                            'development and Google Play opportunities.',
-      'privacyPolicy': 'I acknowledge that the information provided in this form will be subject to Google\'s ' +
-                       '<a href="https://www.google.com/policies/privacy/" target="_blank">privacy policy</a>.',
-      'languageVal': 'English',
-      'successTitle': 'Hooray!',
-      'successDetails': 'You have successfully signed up for the latest Android developer news and tips.',
-      'languageValTarget': {
-        'en': 'English',
-        'ar': 'Arabic (العربيّة)',
-        'id': 'Indonesian (Bahasa)',
-        'fr': 'French (français)',
-        'de': 'German (Deutsch)',
-        'ja': 'Japanese (日本語)',
-        'ko': 'Korean (한국어)',
-        'ru': 'Russian (Русский)',
-        'es': 'Spanish (español)',
-        'th': 'Thai (ภาษาไทย)',
-        'tr': 'Turkish (Türkçe)',
-        'vi': 'Vietnamese (tiếng Việt)',
-        'pt-br': 'Brazilian Portuguese (Português Brasileiro)',
-        'zh-cn': 'Simplified Chinese (简体中文)',
-        'zh-tw': 'Traditional Chinese (繁體中文)',
-      },
-      'resetLangTitle': "Browse this site in %{targetLang}?",
-      'resetLangTextIntro': 'You requested a page in %{targetLang}, but your language preference for this site is %{lang}.',
-      'resetLangTextCta': 'Would you like to change your language preference and browse this site in %{targetLang}? ' +
-                          'If you want to change your language preference later, use the language menu at the bottom of each page.',
-      'resetLangButtonYes': 'Change Language',
-      'resetLangButtonNo': 'Not Now'
-    }
-  };
-
-  /**
-   * Current locale.
-   */
-  var locale = (function() {
-    var lang = window.readCookie('pref_lang');
-    if (lang === 0 || LANGUAGES.indexOf(lang) === -1) {
-      lang = 'en';
-    }
-    return lang;
-  })();
-  var localeTarget = (function() {
-    var lang = getQueryVariable('hl');
-    if (lang === false || LANGUAGES.indexOf(lang) === -1) {
-      lang = locale;
-    }
-    return lang;
-  })();
-
-  /**
-   * Global function shims for backwards compatibility
-   */
-  window.changeNavLang = function() {
-    // Already done.
-  };
-
-  window.loadLangPref = function() {
-    // Languages pref already loaded.
-  };
-
-  window.getLangPref = function() {
-    return locale;
-  };
-
-  window.getLangTarget = function() {
-    return localeTarget;
-  };
-
-  // Expose polyglot instance for advanced localization.
-  var polyglot = window.polyglot = new window.Polyglot({
-    locale: locale,
-    phrases: PHRASES
-  });
-
-  // When DOM is ready.
-  $(function() {
-    // Mark current locale in language picker.
-    $('#language').find('option[value="' + locale + '"]').attr('selected', true);
-
-    $('html').dacTranslate().on('dac:domchange', function(e) {
-      $(e.target).dacTranslate();
-    });
-  });
-
-  $.fn.dacTranslate = function() {
-    // Translate strings in template markup:
-
-    // OLD
-    // Having all translations in HTML does not scale well and bloats every page.
-    // Need to migrate this to data-l JS translations below.
-    if (locale !== 'en') {
-      var $links = this.find('a[' + locale + '-lang]');
-      $links.each(function() { // for each link with a translation
-        var $link = $(this);
-        // put the desired language from the attribute as the text
-        $link.text($link.attr(locale + '-lang'));
-      });
-    }
-
-    // NEW
-    // A simple declarative api for JS translations. Feel free to extend as appropriate.
-
-    // Miscellaneous string compilations
-    // Build full strings from localized substrings:
-    var myLocaleTarget = window.getLangTarget();
-    var myTargetLang = window.polyglot.t("newsletter.languageValTarget." + myLocaleTarget);
-    var myLang = window.polyglot.t("newsletter.languageVal");
-    var myTargetLangTitleString = window.polyglot.t("newsletter.resetLangTitle", {targetLang: myTargetLang});
-    var myResetLangTextIntro = window.polyglot.t("newsletter.resetLangTextIntro", {targetLang: myTargetLang, lang: myLang});
-    var myResetLangTextCta = window.polyglot.t("newsletter.resetLangTextCta", {targetLang: myTargetLang});
-    //var myResetLangButtonYes = window.polyglot.t("newsletter.resetLangButtonYes", {targetLang: myTargetLang});
-
-    // Inject strings as text values in dialog components:
-    $("#langform .dac-modal-header-title").text(myTargetLangTitleString);
-    $("#langform #resetLangText").text(myResetLangTextIntro);
-    $("#langform #resetLangCta").text(myResetLangTextCta);
-    //$("#resetLangButtonYes").attr("data-t", window.polyglot.t(myResetLangButtonYes));
-
-    // Text: <div data-t="nav.home"></div>
-    // HTML: <div data-t="privacy" data-t-html></html>
-    this.find('[data-t]').each(function() {
-      var el = $(this);
-      var data = el.data();
-      if (data.t) {
-        el[data.tHtml === '' ? 'html' : 'text'](polyglot.t(data.t));
-      }
-    });
-
-    return this;
-  };
-})();
-/* ##########     END LOCALIZATION     ############ */
-
-// Translations. These should eventually be moved into language-specific files and loaded on demand.
-// jshint nonbsp:false
-switch (window.getLangPref()) {
-  case 'ar':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Google Play. يمكنك الحصول على آخر الأخبار والنصائح من مطوّري تطبيقات Android، مما يساعدك ' +
-          'على تحقيق النجاح على',
-        'requiredHint': '* حقول مطلوبة',
-        'name': '. الاسم بالكامل ',
-        'email': '. عنوان البريد الإلكتروني ',
-        'company': '. اسم الشركة / اسم مطوّر البرامج',
-        'appUrl': '. أحد عناوين URL لتطبيقاتك في متجر Play',
-        'business': {
-          'label': '. ما العنصر الذي يوضح طبيعة نشاطك التجاري بدقة؟ ',
-          'apps': 'التطبيقات',
-          'games': 'الألعاب',
-          'both': 'التطبيقات والألعاب'
-        },
-        'confirmMailingList': 'إضافتي إلى القائمة البريدية للنشرة الإخبارية الشهرية والرسائل الإلكترونية التي يتم' +
-          ' إرسالها من حين لآخر بشأن التطوير وفرص Google Play.',
-        'privacyPolicy': 'أقر بأن المعلومات المقدَّمة في هذا النموذج تخضع لسياسة خصوصية ' +
-          '<a href="https://www.google.com/intl/ar/policies/privacy/" target="_blank">Google</a>.',
-        'languageVal': 'Arabic (العربيّة)',
-        'successTitle': 'رائع!',
-        'successDetails': 'لقد اشتركت بنجاح للحصول على آخر الأخبار والنصائح من مطوّري برامج Android.'
-      }
-    });
-    break;
-  case 'zh-cn':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': '获取最新的 Android 开发者资讯和提示,助您在 Google Play 上取得成功。',
-        'requiredHint': '* 必填字段',
-        'name': '全名',
-        'email': '电子邮件地址',
-        'company': '公司/开发者名称',
-        'appUrl': '您的某个 Play 商店应用网址',
-        'business': {
-          'label': '哪一项能够最准确地描述您的业务?',
-          'apps': '应用',
-          'games': '游戏',
-          'both': '应用和游戏'
-        },
-        'confirmMailingList': '将我添加到邮寄名单,以便接收每月简报以及不定期发送的关于开发和 Google Play 商机的电子邮件。',
-        'privacyPolicy': '我确认自己了解在此表单中提供的信息受 <a href="https://www.google.com/intl/zh-CN/' +
-        'policies/privacy/" target="_blank">Google</a> 隐私权政策的约束。',
-        'languageVal': 'Simplified Chinese (简体中文)',
-        'successTitle': '太棒了!',
-        'successDetails': '您已成功订阅最新的 Android 开发者资讯和提示。'
-      }
-    });
-    break;
-  case 'zh-tw':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': '獲得 Android 開發人員的最新消息和各項秘訣,讓您在 Google Play 上輕鬆邁向成功之路。',
-        'requiredHint': '* 必要欄位',
-        'name': '全名',
-        'email': '電子郵件地址',
-        'company': '公司/開發人員名稱',
-        'appUrl': '您其中一個 Play 商店應用程式的網址',
-        'business': {
-          'label': '為您的商家選取最合適的產品類別。',
-          'apps': '應用程式',
-          'games': '遊戲',
-          'both': '應用程式和遊戲'
-        },
-        'confirmMailingList': '我想加入 Google Play 的郵寄清單,以便接收每月電子報和 Google Play 不定期寄送的電子郵件,' +
-          '瞭解關於開發和 Google Play 商機的資訊。',
-        'privacyPolicy': '我瞭解,我在這張表單中提供的資訊將受到 <a href="' +
-        'https://www.google.com/intl/zh-TW/policies/privacy/" target="_blank">Google</a> 隱私權政策.',
-        'languageVal': 'Traditional Chinese (繁體中文)',
-        'successTitle': '太棒了!',
-        'successDetails': '您已經成功訂閱 Android 開發人員的最新消息和各項秘訣。'
-      }
-    });
-    break;
-  case 'fr':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Recevez les dernières actualités destinées aux développeurs Android, ainsi que des conseils qui ' +
-          'vous mèneront vers le succès sur Google Play.',
-        'requiredHint': '* Champs obligatoires',
-        'name': 'Nom complet',
-        'email': 'Adresse e-mail',
-        'company': 'Nom de la société ou du développeur',
-        'appUrl': 'Une de vos URL Play Store',
-        'business': {
-          'label': 'Quelle option décrit le mieux votre activité ?',
-          'apps': 'Applications',
-          'games': 'Jeux',
-          'both': 'Applications et jeux'
-        },
-        'confirmMailingList': 'Ajoutez-moi à la liste de diffusion de la newsletter mensuelle et tenez-moi informé ' +
-          'par des e-mails occasionnels de l\'évolution et des opportunités de Google Play.',
-        'privacyPolicy': 'Je comprends que les renseignements fournis dans ce formulaire seront soumis aux <a href="' +
-        'https://www.google.com/intl/fr/policies/privacy/" target="_blank">règles de confidentialité</a> de Google.',
-        'languageVal': 'French (français)',
-        'successTitle': 'Super !',
-        'successDetails': 'Vous êtes bien inscrit pour recevoir les actualités et les conseils destinés aux ' +
-          'développeurs Android.'
-      }
-    });
-    break;
-  case 'de':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Abonniere aktuelle Informationen und Tipps für Android-Entwickler und werde noch erfolgreicher ' +
-          'bei Google Play.',
-        'requiredHint': '* Pflichtfelder',
-        'name': 'Vollständiger Name',
-        'email': 'E-Mail-Adresse',
-        'company': 'Unternehmens-/Entwicklername',
-        'appUrl': 'Eine der URLs deiner Play Store App',
-        'business': {
-          'label': 'Welche der folgenden Kategorien beschreibt dein Unternehmen am besten?',
-          'apps': 'Apps',
-          'games': 'Spiele',
-          'both': 'Apps und Spiele'
-        },
-        'confirmMailingList': 'Meine E-Mail-Adresse soll zur Mailingliste hinzugefügt werden, damit ich den ' +
-          'monatlichen Newsletter sowie gelegentlich E-Mails zu Entwicklungen und Optionen bei Google Play erhalte.',
-        'privacyPolicy': 'Ich bestätige, dass die in diesem Formular bereitgestellten Informationen gemäß der ' +
-          '<a href="https://www.google.com/intl/de/policies/privacy/" target="_blank">Datenschutzerklärung</a> von ' +
-          'Google verwendet werden dürfen.',
-        'languageVal': 'German (Deutsch)',
-        'successTitle': 'Super!',
-        'successDetails': 'Du hast dich erfolgreich angemeldet und erhältst jetzt aktuelle Informationen und Tipps ' +
-          'für Android-Entwickler.'
-      }
-    });
-    break;
-  case 'id':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Receba as dicas e as notícias mais recentes para os desenvolvedores Android e seja bem-sucedido ' +
-        'no Google Play.',
-        'requiredHint': '* Bidang Wajib Diisi',
-        'name': 'Nama lengkap',
-        'email': 'Alamat email',
-        'company': 'Nama pengembang / perusahaan',
-        'appUrl': 'Salah satu URL aplikasi Play Store Anda',
-        'business': {
-          'label': 'Dari berikut ini, mana yang paling cocok dengan bisnis Anda?',
-          'apps': 'Aplikasi',
-          'games': 'Game',
-          'both': 'Aplikasi dan Game'
-        },
-        'confirmMailingList': 'Tambahkan saya ke milis untuk mendapatkan buletin bulanan dan email sesekali mengenai ' +
-          'perkembangan dan kesempatan yang ada di Google Play.',
-        'privacyPolicy': 'Saya memahami bahwa informasi yang diberikan dalam formulir ini tunduk pada <a href="' +
-        'https://www.google.com/intl/in/policies/privacy/" target="_blank">kebijakan privasi</a> Google.',
-        'languageVal': 'Indonesian (Bahasa)',
-        'successTitle': 'Hore!',
-        'successDetails': 'Anda berhasil mendaftar untuk kiat dan berita pengembang Android terbaru.'
-      }
-    });
-    break;
-  case 'it':
-    //window.polyglot.extend({
-    //  'newsletter': {
-    //    'title': 'Receba as dicas e as notícias mais recentes para os desenvolvedores Android e seja bem-sucedido ' +
-    //    'no Google Play.',
-    //    'requiredHint': '* Campos obrigatórios',
-    //    'name': 'Nome completo',
-    //    'email': 'Endereço de Email',
-    //    'company': 'Nome da empresa / do desenvolvedor',
-    //    'appUrl': 'URL de um dos seus apps da Play Store',
-    //    'business': {
-    //      'label': 'Qual das seguintes opções melhor descreve sua empresa?',
-    //      'apps': 'Apps',
-    //      'games': 'Jogos',
-    //      'both': 'Apps e Jogos'
-    //    },
-    //    'confirmMailingList': 'Inscreva-me na lista de e-mails para que eu receba o boletim informativo mensal, ' +
-    //    'bem como e-mails ocasionais sobre o desenvolvimento e as oportunidades do Google Play.',
-    //    'privacyPolicy': 'Reconheço que as informações fornecidas neste formulário estão sujeitas à <a href="' +
-    //    'https://www.google.com.br/policies/privacy/" target="_blank">Política de Privacidade</a> do Google.',
-    //    'languageVal': 'Italian (italiano)',
-    //    'successTitle': 'Uhu!',
-    //    'successDetails': 'Você se inscreveu para receber as notícias e as dicas mais recentes para os ' +
-    //    'desenvolvedores Android.',
-    //  }
-    //});
-    break;
-  case 'ja':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Google Play での成功に役立つ Android デベロッパー向けの最新ニュースやおすすめの情報をお届けします。',
-        'requiredHint': '* 必須',
-        'name': '氏名',
-        'email': 'メールアドレス',
-        'company': '会社名 / デベロッパー名',
-        'appUrl': 'Play ストア アプリの URL(いずれか 1 つ)',
-        'business': {
-          'label': 'お客様のビジネスに最もよく当てはまるものをお選びください。',
-          'apps': 'アプリ',
-          'games': 'ゲーム',
-          'both': 'アプリとゲーム'
-        },
-        'confirmMailingList': '開発や Google Play の最新情報に関する毎月発行のニュースレターや不定期発行のメールを受け取る',
-        'privacyPolicy': 'このフォームに入力した情報に <a href="https://www.google.com/intl/ja/policies/privacy/" ' +
-          'target="_blank">Google</a> のプライバシー ポリシーが適用',
-        'languageVal': 'Japanese (日本語)',
-        'successTitle': '完了です!',
-        'successDetails': 'Android デベロッパー向けの最新ニュースやおすすめの情報の配信登録が完了しました。'
-      }
-    });
-    break;
-  case 'ko':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Google Play에서 성공을 거두는 데 도움이 되는 최신 Android 개발자 소식 및 도움말을 받아 보세요.',
-        'requiredHint': '* 필수 입력란',
-        'name': '이름',
-        'email': '이메일 주소',
-        'company': '회사/개발자 이름',
-        'appUrl': 'Play 스토어 앱 URL 중 1개',
-        'business': {
-          'label': '다음 중 내 비즈니스를 가장 잘 설명하는 단어는 무엇인가요?',
-          'apps': '앱',
-          'games': '게임',
-          'both': '앱 및 게임'
-        },
-        'confirmMailingList': '개발 및 Google Play 관련 소식에 관한 월별 뉴스레터 및 비정기 이메일을 받아보겠습니다.',
-        'privacyPolicy': '이 양식에 제공한 정보는 <a href="https://www.google.com/intl/ko/policies/privacy/" ' +
-          'target="_blank">Google의</a> 개인정보취급방침에 따라 사용됨을',
-        'languageVal':'Korean (한국어)',
-        'successTitle': '축하합니다!',
-        'successDetails': '최신 Android 개발자 뉴스 및 도움말을 받아볼 수 있도록 가입을 완료했습니다.'
-      }
-    });
-    break;
-  case 'pt-br':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Receba as dicas e as notícias mais recentes para os desenvolvedores Android e seja bem-sucedido ' +
-        'no Google Play.',
-        'requiredHint': '* Campos obrigatórios',
-        'name': 'Nome completo',
-        'email': 'Endereço de Email',
-        'company': 'Nome da empresa / do desenvolvedor',
-        'appUrl': 'URL de um dos seus apps da Play Store',
-        'business': {
-          'label': 'Qual das seguintes opções melhor descreve sua empresa?',
-          'apps': 'Apps',
-          'games': 'Jogos',
-          'both': 'Apps e Jogos'
-        },
-        'confirmMailingList': 'Inscreva-me na lista de e-mails para que eu receba o boletim informativo mensal, ' +
-        'bem como e-mails ocasionais sobre o desenvolvimento e as oportunidades do Google Play.',
-        'privacyPolicy': 'Reconheço que as informações fornecidas neste formulário estão sujeitas à <a href="' +
-        'https://www.google.com.br/policies/privacy/" target="_blank">Política de Privacidade</a> do Google.',
-        'languageVal': 'Brazilian Portuguese (Português Brasileiro)',
-        'successTitle': 'Uhu!',
-        'successDetails': 'Você se inscreveu para receber as notícias e as dicas mais recentes para os ' +
-        'desenvolvedores Android.'
-      }
-    });
-    break;
-  case 'ru':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Хотите получать последние новости и советы для разработчиков Google Play? Заполните эту форму.',
-        'requiredHint': '* Обязательные поля',
-        'name': 'Полное имя',
-        'email': 'Адрес электронной почты',
-        'company': 'Название компании или имя разработчика',
-        'appUrl': 'Ссылка на любое ваше приложение в Google Play',
-        'business': {
-          'label': 'Что вы создаете?',
-          'apps': 'Приложения',
-          'games': 'Игры',
-          'both': 'Игры и приложения'
-        },
-        'confirmMailingList': 'Я хочу получать ежемесячную рассылку для разработчиков и другие полезные новости ' +
-          'Google Play.',
-        'privacyPolicy': 'Я предоставляю эти данные в соответствии с <a href="' +
-          'https://www.google.com/intl/ru/policies/privacy/" target="_blank">Политикой конфиденциальности</a> Google.',
-        'languageVal': 'Russian (Русский)',
-        'successTitle': 'Поздравляем!',
-        'successDetails': 'Теперь вы подписаны на последние новости и советы для разработчиков Android.'
-      }
-    });
-    break;
-  case 'es':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Recibe las últimas noticias y sugerencias para programadores de Android y logra tener éxito en ' +
-          'Google Play.',
-        'requiredHint': '* Campos obligatorios',
-        'name': 'Dirección de correo electrónico',
-        'email': 'Endereço de Email',
-        'company': 'Nombre de la empresa o del programador',
-        'appUrl': 'URL de una de tus aplicaciones de Play Store',
-        'business': {
-          'label': '¿Qué describe mejor a tu empresa?',
-          'apps': 'Aplicaciones',
-          'games': 'Juegos',
-          'both': 'Juegos y aplicaciones'
-        },
-        'confirmMailingList': 'Deseo unirme a la lista de distribución para recibir el boletín informativo mensual ' +
-          'y correos electrónicos ocasionales sobre desarrollo y oportunidades de Google Play.',
-        'privacyPolicy': 'Acepto que la información que proporcioné en este formulario cumple con la <a href="' +
-        'https://www.google.com/intl/es/policies/privacy/" target="_blank">política de privacidad</a> de Google.',
-        'languageVal': 'Spanish (español)',
-        'successTitle': '¡Felicitaciones!',
-        'successDetails': 'El registro para recibir las últimas noticias y sugerencias para programadores de Android ' +
-          'se realizó correctamente.'
-      }
-    });
-    break;
-  case 'th':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'รับข่าวสารล่าสุดสำหรับนักพัฒนาซอฟต์แวร์ Android ตลอดจนเคล็ดลับที่จะช่วยให้คุณประสบความสำเร็จบน ' +
-          'Google Play',
-        'requiredHint': '* ช่องที่ต้องกรอก',
-        'name': 'ชื่อและนามสกุล',
-        'email': 'ที่อยู่อีเมล',
-        'company': 'ชื่อบริษัท/นักพัฒนาซอฟต์แวร์',
-        'appUrl': 'URL แอปใดแอปหนึ่งของคุณใน Play สโตร์',
-        'business': {
-          'label': 'ข้อใดตรงกับธุรกิจของคุณมากที่สุด',
-          'apps': 'แอป',
-          'games': 'เกม',
-          'both': 'แอปและเกม'
-        },
-        'confirmMailingList': 'เพิ่มฉันลงในรายชื่ออีเมลเพื่อรับจดหมายข่าวรายเดือนและอีเมลเป็นครั้งคราวเกี่ยวกับก' +
-          'ารพัฒนาซอฟต์แวร์และโอกาสใน Google Play',
-        'privacyPolicy': 'ฉันรับทราบว่าข้อมูลที่ให้ไว้ในแบบฟอร์มนี้จะเป็นไปตามนโยบายส่วนบุคคลของ ' +
-          '<a href="https://www.google.com/intl/th/policies/privacy/" target="_blank">Google</a>',
-        'languageVal': 'Thai (ภาษาไทย)',
-        'successTitle': 'ไชโย!',
-        'successDetails': 'คุณลงชื่อสมัครรับข่าวสารและเคล็ดลับล่าสุดสำหรับนักพัฒนาซอฟต์แวร์ Android เสร็จเรียบร้อยแล้ว'
-      }
-    });
-    break;
-  case 'tr':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Google Play\'de başarılı olmanıza yardımcı olacak en son Android geliştirici haberleri ve ipuçları.',
-        'requiredHint': '* Zorunlu Alanlar',
-        'name': 'Tam ad',
-        'email': 'E-posta adresi',
-        'company': 'Şirket / geliştirici adı',
-        'appUrl': 'Play Store uygulama URL\'lerinizden biri',
-        'business': {
-          'label': 'İşletmenizi en iyi hangisi tanımlar?',
-          'apps': 'Uygulamalar',
-          'games': 'Oyunlar',
-          'both': 'Uygulamalar ve Oyunlar'
-        },
-        'confirmMailingList': 'Beni, geliştirme ve Google Play fırsatlarıyla ilgili ara sıra gönderilen e-posta ' +
-          'iletilerine ilişkin posta listesine ve aylık haber bültenine ekle.',
-        'privacyPolicy': 'Bu formda sağlanan bilgilerin Google\'ın ' +
-          '<a href="https://www.google.com/intl/tr/policies/privacy/" target="_blank">Gizlilik Politikası\'na</a> ' +
-          'tabi olacağını kabul ediyorum.',
-        'languageVal': 'Turkish (Türkçe)',
-        'successTitle': 'Yaşasın!',
-        'successDetails': 'En son Android geliştirici haberleri ve ipuçlarına başarıyla kaydoldunuz.'
-      }
-    });
-    break;
-  case 'vi':
-    window.polyglot.extend({
-      'newsletter': {
-        'title': 'Nhận tin tức và mẹo mới nhất dành cho nhà phát triển Android sẽ giúp bạn tìm thấy thành công trên ' +
-          'Google Play.',
-        'requiredHint': '* Các trường bắt buộc',
-        'name': 'Tên đầy đủ',
-        'email': 'Địa chỉ email',
-        'company': 'Tên công ty/nhà phát triển',
-        'appUrl': 'Một trong số các URL ứng dụng trên cửa hàng Play của bạn',
-        'business': {
-          'label': 'Lựa chọn nào sau đây mô tả chính xác nhất doanh nghiệp của bạn?',
-          'apps': 'Ứng dụng',
-          'games': 'Trò chơi',
-          'both': 'Ứng dụng và trò chơi'
-        },
-        'confirmMailingList': 'Thêm tôi vào danh sách gửi thư cho bản tin hàng tháng và email định kỳ về việc phát ' +
-          'triển và cơ hội của Google Play.',
-        'privacyPolicy': 'Tôi xác nhận rằng thông tin được cung cấp trong biểu mẫu này tuân thủ chính sách bảo mật ' +
-          'của <a href="https://www.google.com/intl/vi/policies/privacy/" target="_blank">Google</a>.',
-        'languageVal': 'Vietnamese (tiếng Việt)',
-        'successTitle': 'Thật tuyệt!',
-        'successDetails': 'Bạn đã đăng ký thành công nhận tin tức và mẹo mới nhất dành cho nhà phát triển của Android.'
-      }
-    });
-    break;
-}
-
-(function($) {
-  'use strict';
-
-  function Modal(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, options);
-    this.isOpen = false;
-
-    this.el.on('click', function(event) {
-      if (!$.contains(this.el.find('.dac-modal-window')[0], event.target)) {
-        return this.el.trigger('modal-close');
-      }
-    }.bind(this));
-
-    this.el.on('modal-open', this.open_.bind(this));
-    this.el.on('modal-close', this.close_.bind(this));
-    this.el.on('modal-toggle', this.toggle_.bind(this));
-  }
-
-  Modal.prototype.toggle_ = function() {
-    this.el.trigger('modal-' + (this.isOpen ? 'close' : 'open'));
-  };
-
-  Modal.prototype.close_ = function() {
-    // When closing the modal for Android Studio downloads, reload the page
-    // because otherwise we might get stuck with post-download dialog state
-    if ($("[data-modal='studio_tos'].dac-active").length) {
-      location.reload();
-    }
-    this.el.removeClass('dac-active');
-    $('body').removeClass('dac-modal-open');
-    this.isOpen = false;
-  };
-
-  Modal.prototype.open_ = function() {
-    this.el.addClass('dac-active');
-    $('body').addClass('dac-modal-open');
-    this.isOpen = true;
-  };
-
-  function onClickToggleModal(event) {
-    event.preventDefault();
-    var toggle = $(event.currentTarget);
-    var options = toggle.data();
-    var modal = options.modalToggle ? $('[data-modal="' + options.modalToggle + '"]') :
-      toggle.closest('[data-modal]');
-    modal.trigger('modal-toggle');
-  }
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacModal = function(options) {
-    return this.each(function() {
-      new Modal(this, options);
-    });
-  };
-
-  $.fn.dacToggleModal = function(options) {
-    return this.each(function() {
-      new ToggleModal(this, options);
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(document).on('ready.aranja', function() {
-    $('[data-modal]').each(function() {
-      $(this).dacModal($(this).data());
-    });
-
-    $('html').on('click.modal', '[data-modal-toggle]', onClickToggleModal);
-
-    // Check if url anchor is targetting a toggle to open the modal.
-    if (location.hash) {
-      var $elem = $(document.getElementById(location.hash.substr(1)));
-      if ($elem.attr('data-modal-toggle')) {
-        $elem.trigger('click');
-      }
-    }
-
-    var isTargetLangValid = false;
-    $(ANDROID_LANGUAGES).each(function(index, langCode) {
-      if (langCode == window.getLangTarget()) {
-        isTargetLangValid = true;
-        return;
-      }
-    });
-    if (window.getLangTarget() !== window.getLangPref() && isTargetLangValid) {
-        $('#langform').trigger('modal-open');
-        $("#langform button.yes").attr("onclick","window.changeLangPref('" + window.getLangTarget() + "', true);  return false;");
-        $("#langform button.no").attr("onclick","window.changeLangPref('" + window.getLangPref() + "', true); return false;");
-    }
-
-    /* Check the current API level, but only if we're in the reference */
-    if (location.pathname.indexOf('/reference') == 0) {
-      // init available apis based on user pref
-      changeApiLevel();
-    }
-  });
-})(jQuery);
-
-/* Fullscreen - Toggle fullscreen mode for reference pages */
-(function($) {
-  'use strict';
-
-  /**
-   * @param {HTMLElement} el - The DOM element.
-   * @constructor
-   */
-  function Fullscreen(el) {
-    this.el = $(el);
-    this.html = $('html');
-    this.icon = this.el.find('.dac-sprite');
-    this.isFullscreen = window.readCookie(Fullscreen.COOKIE_) === 'true';
-    this.activate_();
-    this.el.on('click.dac-fullscreen', this.toggleHandler_.bind(this));
-  }
-
-  /**
-   * Cookie name for storing the state
-   * @type {string}
-   * @private
-   */
-  Fullscreen.COOKIE_ = 'fullscreen';
-
-  /**
-   * Classes to modify the DOM
-   * @type {{mode: string, fullscreen: string, fullscreenExit: string}}
-   * @private
-   */
-  Fullscreen.CLASSES_ = {
-    mode: 'dac-fullscreen-mode',
-    fullscreen: 'dac-fullscreen',
-    fullscreenExit: 'dac-fullscreen-exit'
-  };
-
-  /**
-   * Event listener for toggling fullscreen mode
-   * @param {MouseEvent} event
-   * @private
-   */
-  Fullscreen.prototype.toggleHandler_ = function(event) {
-    event.stopPropagation();
-    this.toggle(!this.isFullscreen, true);
-  };
-
-  /**
-   * Change the DOM based on current state.
-   * @private
-   */
-  Fullscreen.prototype.activate_ = function() {
-    this.icon.toggleClass(Fullscreen.CLASSES_.fullscreen, !this.isFullscreen);
-    this.icon.toggleClass(Fullscreen.CLASSES_.fullscreenExit, this.isFullscreen);
-    this.html.toggleClass(Fullscreen.CLASSES_.mode, this.isFullscreen);
-  };
-
-  /**
-   * Toggle fullscreen mode and store the state in a cookie.
-   */
-  Fullscreen.prototype.toggle = function() {
-    this.isFullscreen = !this.isFullscreen;
-    window.writeCookie(Fullscreen.COOKIE_, this.isFullscreen, null);
-    this.activate_();
-  };
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacFullscreen = function() {
-    return this.each(function() {
-      new Fullscreen($(this));
-    });
-  };
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  /**
-   * @param {HTMLElement} selected - The link that is selected in the nav.
-   * @constructor
-   */
-  function HeaderTabs(selected) {
-
-    // Don't highlight any tabs on the index page
-    if (location.pathname === '/index.html' || location.pathname === '/') {
-      //return;
-    }
-
-    this.selected = $(selected);
-    this.selectedParent = this.selected.closest('.dac-nav-secondary').siblings('a');
-    this.links = $('.dac-header-tabs a');
-
-    this.selectActiveTab();
-  }
-
-  HeaderTabs.prototype.selectActiveTab = function() {
-    var section = null;
-
-    if (this.selectedParent.length) {
-      section = this.selectedParent.text();
-    } else {
-      section = this.selected.text();
-    }
-
-    if (section) {
-      this.links.removeClass('selected');
-
-      this.links.filter(function() {
-        return $(this).text() === $.trim(section);
-      }).addClass('selected');
-    }
-  };
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacHeaderTabs = function() {
-    return this.each(function() {
-      new HeaderTabs(this);
-    });
-  };
-})(jQuery);
-
-(function($) {
-  'use strict';
-  var icon = $('<i/>').addClass('dac-sprite dac-nav-forward');
-  var config = JSON.parse(window.localStorage.getItem('global-navigation') || '{}');
-  var forwardLink = $('<span/>')
-    .addClass('dac-nav-link-forward')
-    .html(icon)
-    .attr('tabindex', 0)
-    .on('click keypress', function(e) {
-      if (e.type == 'keypress' && e.which == 13 || e.type == 'click') {
-        swap_(e);
-      }
-    });
-
-  /**
-   * @constructor
-   */
-  function Nav(navigation) {
-    $('.dac-nav-list').dacCurrentPage().dacHeaderTabs().dacSidebarToggle($('body'));
-
-    navigation.find('[data-reference-tree]').dacReferenceNav();
-
-    setupViews_(navigation.children().eq(0).children());
-
-    initCollapsedNavs(navigation.find('.dac-nav-sub-slider'));
-
-    $('#dac-main-navigation').scrollIntoView('.selected')
-  }
-
-  function updateStore(icon) {
-    var navClass = getCurrentLandingPage_(icon);
-    var isExpanded = icon.hasClass('dac-expand-less-black');
-    var expandedNavs = config.expanded || [];
-    if (isExpanded) {
-      expandedNavs.push(navClass);
-    } else {
-      expandedNavs = expandedNavs.filter(function(item) {
-        return item !== navClass;
-      });
-    }
-    config.expanded = expandedNavs;
-    window.localStorage.setItem('global-navigation', JSON.stringify(config));
-  }
-
-  function toggleSubNav_(icon) {
-    var isExpanded = icon.hasClass('dac-expand-less-black');
-    icon.toggleClass('dac-expand-less-black', !isExpanded);
-    icon.toggleClass('dac-expand-more-black', isExpanded);
-    icon.data('sub-navigation.dac').slideToggle(200);
-
-    updateStore(icon);
-  }
-
-  function handleSubNavToggle_(event) {
-    event.preventDefault();
-    var icon = $(event.target);
-    toggleSubNav_(icon);
-  }
-
-  function getCurrentLandingPage_(icon) {
-    return icon.closest('li')[0].className.replace('dac-nav-item ', '');
-  }
-
-  // Setup sub navigation collapse/expand
-  function initCollapsedNavs(toggleIcons) {
-    toggleIcons.each(setInitiallyActive_($('body')));
-    toggleIcons.on('click keypress', function(e) {
-      if (e.type == 'keypress' && e.which == 13 || e.type == 'click') {
-        handleSubNavToggle_(e);
-      }
-    });
-  }
-
-  function setInitiallyActive_(body) {
-    var expandedNavs = config.expanded || [];
-    return function(i, icon) {
-      icon = $(icon);
-      var subNav = icon.next();
-
-      if (!subNav.length) {
-        return;
-      }
-
-      var landingPageClass = getCurrentLandingPage_(icon);
-      var expanded = expandedNavs.indexOf(landingPageClass) >= 0;
-      landingPageClass = landingPageClass === 'home' ? 'about' : landingPageClass;
-
-      if (landingPageClass == 'about' && location.pathname == '/index.html') {
-        expanded = true;
-      }
-
-      // TODO: Should read from localStorage
-      var visible = body.hasClass(landingPageClass) || expanded;
-
-      icon.data('sub-navigation.dac', subNav);
-      icon.toggleClass('dac-expand-less-black', visible);
-      icon.toggleClass('dac-expand-more-black', !visible);
-      subNav.toggle(visible);
-    };
-  }
-
-  function setupViews_(views) {
-    if (views.length === 1) {
-      // Active tier 1 nav.
-      views.addClass('dac-active');
-    } else {
-      // Activate back button and tier 2 nav.
-      views.slice(0, 2).addClass('dac-active');
-      var selectedNav = views.eq(2).find('.selected').after(forwardLink);
-      var langAttr = selectedNav.attr(window.getLangPref() + '-lang');
-      //form the label from locale attr if possible, else set to selectedNav text value
-      if ((typeof langAttr !== typeof undefined &&  langAttr !== false) && (langAttr !== '')) {
-        $('.dac-nav-back-title').text(langAttr);
-      } else {
-        $('.dac-nav-back-title').text(selectedNav.text());
-      }
-    }
-
-    // Navigation should animate.
-    setTimeout(function() {
-      views.removeClass('dac-no-anim');
-    }, 10);
-  }
-
-  function swap_(event) {
-    event.preventDefault();
-    $(event.currentTarget).trigger('swap-content');
-  }
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacNav = function() {
-    return this.each(function() {
-      new Nav($(this));
-    });
-  };
-})(jQuery);
-
-/* global NAVTREE_DATA */
-(function($) {
-  /**
-   * Build the reference navigation with namespace dropdowns.
-   * @param {jQuery} el - The DOM element.
-   */
-  function buildReferenceNav(el) {
-    var supportLibraryPath = '/reference/android/support/';
-    var currPath = location.pathname;
-
-    if (currPath.indexOf(supportLibraryPath) > -1) {
-      updateSupportLibrariesNav(supportLibraryPath, currPath);
-    }
-    var namespaceList = el.find('[data-reference-namespaces]');
-    var resources = $('[data-reference-resources]').detach();
-    var selected = namespaceList.find('.selected');
-    resources.appendTo(el);
-
-    // Links should be toggleable.
-    namespaceList.find('a').addClass('dac-reference-nav-toggle dac-closed');
-
-    // Set the path for the navtree data to use.
-    var navtree_filepath = getNavtreeFilePath(supportLibraryPath, currPath);
-
-    // Load in all resources
-    $.getScript(navtree_filepath, function(data, textStatus, xhr) {
-      if (xhr.status === 200) {
-        namespaceList.on(
-            'click', 'a.dac-reference-nav-toggle', toggleResourcesHandler);
-      }
-    });
-
-    // No setup required if no resources are present
-    if (!resources.length) {
-      return;
-    }
-
-    // The resources should be a part of selected namespace.
-    var overview = addResourcesToView(resources, selected);
-
-    // Currently viewing Overview
-    if (location.href === overview.attr('href')) {
-      overview.parent().addClass('selected');
-    }
-
-    // Open currently selected resource
-    var listsToOpen = selected.children().eq(1);
-    listsToOpen = listsToOpen.add(
-        listsToOpen.find('.selected').parent()).show();
-
-    // Mark dropdowns as open
-    listsToOpen.prev().removeClass('dac-closed');
-
-    // Scroll into view
-    namespaceList.scrollIntoView(selected);
-  }
-
-  function getNavtreeFilePath(supportLibraryPath, currPath) {
-    var navtree_filepath = '';
-    var navtree_filename = 'navtree_data.js';
-    if (currPath.indexOf(supportLibraryPath + 'test') > -1) {
-      navtree_filepath = supportLibraryPath + 'test/' + navtree_filename;
-    } else if (currPath.indexOf(supportLibraryPath + 'wearable') > -1) {
-      navtree_filepath = supportLibraryPath + 'wearable/' + navtree_filename;
-    } else {
-      navtree_filepath = '/' + navtree_filename;
-    }
-    return navtree_filepath;
-  }
-
-  function updateSupportLibrariesNav(supportLibraryPath, currPath) {
-    var navTitle = '';
-    if (currPath.indexOf(supportLibraryPath + 'test') > -1) {
-      navTitle = 'Test Support APIs';
-    } else if (currPath.indexOf(supportLibraryPath + 'wearable') > -1) {
-      navTitle = 'Wearable Support APIs';
-    }
-    $('#api-nav-title').text(navTitle);
-    $('#api-level-toggle').hide();
-  }
-
-  /**
-   * Handles the toggling of resources.
-   * @param {Event} event
-   */
-  function toggleResourcesHandler(event) {
-    event.preventDefault();
-    if (event.type == 'click' || event.type == 'keypress' && event.which == 13) {
-      var el = $(this);
-      // If resources for given namespace is not present, fetch correct data.
-      if (this.tagName === 'A' && !this.hasResources) {
-        addResourcesToView(buildResourcesViewForData(getDataForNamespace(el.text())), el.parent());
-      }
-
-      el.toggleClass('dac-closed').next().slideToggle(200);
-    }
-  }
-
-  /**
-   * @param {String} namespace
-   * @returns {Array} namespace data
-   */
-  function getDataForNamespace(namespace) {
-    var namespaceData = NAVTREE_DATA.filter(function(data) {
-      return data[0] === namespace;
-    });
-
-    return namespaceData.length ? namespaceData[0][2] : [];
-  }
-
-  /**
-   * Build a list item for a resource
-   * @param {Array} resource
-   * @returns {String}
-   */
-  function buildResourceItem(resource) {
-    return '<li class="api apilevel-' + resource[3] + '"><a href="/' + resource[1] + '">' + resource[0] + '</a></li>';
-  }
-
-  /**
-   * Build resources list items.
-   * @param {Array} resources
-   * @returns {String}
-   */
-  function buildResourceList(resources) {
-    return '<li><h2>' + resources[0] + '</h2><ul>' + resources[2].map(buildResourceItem).join('') + '</ul>';
-  }
-
-  /**
-   * Build a resources view
-   * @param {Array} data
-   * @returns {jQuery} resources in an unordered list.
-   */
-  function buildResourcesViewForData(data) {
-    return $('<ul>' + data.map(buildResourceList).join('') + '</ul>');
-  }
-
-  /**
-   * Add resources to a containing view.
-   * @param {jQuery} resources
-   * @param {jQuery} view
-   * @returns {jQuery} the overview link.
-   */
-  function addResourcesToView(resources, view) {
-    var namespace = view.children().eq(0);
-    var overview = $('<a href="' + namespace.attr('href') + '">Overview</a>');
-
-    // Mark namespace with content;
-    namespace[0].hasResources = true;
-
-    // Add correct classes / event listeners to resources.
-    resources.prepend($('<li>').html(overview))
-      .find('a')
-        .addClass('dac-reference-nav-resource')
-      .end()
-        .find('h2').attr('tabindex', 0)
-        .addClass('dac-reference-nav-toggle dac-closed')
-        .on('click keypress', toggleResourcesHandler)
-      .end()
-        .add(resources.find('ul'))
-        .addClass('dac-reference-nav-resources')
-      .end()
-        .appendTo(view);
-
-    return overview;
-  }
-
-  function setActiveReferencePackage(el) {
-    var packageLinkEls = el.find('[data-reference-namespaces] a');
-    var selected = null;
-    var highestMatchCount = 0;
-    packageLinkEls.each(function(index, linkEl) {
-      var matchCount = 0;
-      $(location.pathname.split('/')).each(function(index, subpath) {
-        if (linkEl.href.indexOf('/' + subpath + '/') > -1) {
-          matchCount++;
-        }
-      });
-      if (matchCount > highestMatchCount) {
-        selected = linkEl;
-        highestMatchCount = matchCount;
-      }
-    });
-    $(selected).parent().addClass('selected');
-  }
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacReferenceNav = function() {
-    return this.each(function() {
-      setActiveReferencePackage($(this));
-      buildReferenceNav($(this));
-    });
-  };
-})(jQuery);
-
-/** Scroll a container to make a target element visible
- This is called when the page finished loading. */
-$.fn.scrollIntoView = function(target) {
-  if ('string' === typeof target) {
-    target = this.find(target);
-  }
-  if (this.is(':visible')) {
-    if (target.length == 0) {
-      // If no selected item found, exit
-      return;
-    }
-
-    // get the target element's offset from its container nav by measuring the element's offset
-    // relative to the document then subtract the container nav's offset relative to the document
-    var targetOffset = target.offset().top - this.offset().top;
-    var containerHeight = this.height();
-    if (targetOffset > containerHeight * .8) { // multiply nav height by .8 so we move up the item
-      // if it's more than 80% down the nav
-      // scroll the item up by an amount equal to 80% the container height
-      this.scrollTop(targetOffset - (containerHeight * .8));
-    }
-  }
-};
-
-(function($) {
-  $.fn.dacCurrentPage = function() {
-    // Highlight the header tabs...
-    // highlight Design tab
-    var baseurl = getBaseUri(window.location.pathname);
-    var urlSegments = baseurl.split('/');
-    var navEl = this;
-    var body = $('body');
-    var subNavEl = navEl.find('.dac-nav-secondary');
-    var parentNavEl;
-    var selected;
-    // In NDK docs, highlight appropriate sub-nav
-    if (body.hasClass('dac-ndk')) {
-      if (body.hasClass('guide')) {
-        selected = navEl.find('> li.guides > a').addClass('selected');
-      } else if (body.hasClass('reference')) {
-        selected = navEl.find('> li.reference > a').addClass('selected');
-      } else if (body.hasClass('samples')) {
-        selected = navEl.find('> li.samples > a').addClass('selected');
-      } else if (body.hasClass('downloads')) {
-        selected = navEl.find('> li.downloads > a').addClass('selected');
-      }
-    } else if (body.hasClass('dac-studio')) {
-      if (body.hasClass('download')) {
-        selected = navEl.find('> li.download > a').addClass('selected');
-      } else if (body.hasClass('features')) {
-        selected = navEl.find('> li.features > a').addClass('selected');
-      } else if (body.hasClass('guide')) {
-        selected = navEl.find('> li.guide > a').addClass('selected');
-      } else if (body.hasClass('preview')) {
-        selected = navEl.find('> li.preview > a').addClass('selected');
-      }
-    } else if (body.hasClass('design')) {
-      selected = navEl.find('> li.design > a').addClass('selected');
-      // highlight Home nav
-    } else if (body.hasClass('about') || location.pathname == '/index.html') {
-      parentNavEl = navEl.find('> li.home > a');
-      parentNavEl.addClass('has-subnav');
-      // In Home docs, also highlight appropriate sub-nav
-      if (urlSegments[1] === 'wear' || urlSegments[1] === 'tv' ||
-        urlSegments[1] === 'auto') {
-        selected = subNavEl.find('li.' + urlSegments[1] + ' > a').addClass('selected');
-      } else if (urlSegments[1] === 'about') {
-        selected = subNavEl.find('li.versions > a').addClass('selected');
-      } else {
-        selected = parentNavEl.removeClass('has-subnav').addClass('selected');
-      }
-      // highlight Develop nav
-    } else if (body.hasClass('develop') || body.hasClass('google')) {
-      parentNavEl = navEl.find('> li.develop > a');
-      parentNavEl.addClass('has-subnav');
-      // In Develop docs, also highlight appropriate sub-nav
-      if (urlSegments[1] === 'training') {
-        selected = subNavEl.find('li.training > a').addClass('selected');
-      } else if (urlSegments[1] === 'guide') {
-        selected = subNavEl.find('li.guide > a').addClass('selected');
-      } else if (urlSegments[1] === 'reference') {
-        // If the root is reference, but page is also part of Google Services, select Google
-        if (body.hasClass('google')) {
-          selected = subNavEl.find('li.google > a').addClass('selected');
-        } else {
-          selected = subNavEl.find('li.reference > a').addClass('selected');
-        }
-      } else if (body.hasClass('google')) {
-        selected = subNavEl.find('li.google > a').addClass('selected');
-      } else if (body.hasClass('samples')) {
-        selected = subNavEl.find('li.samples > a').addClass('selected');
-      } else {
-        selected = parentNavEl.removeClass('has-subnav').addClass('selected');
-      }
-      // highlight Distribute nav
-    } else if (body.hasClass('distribute')) {
-      parentNavEl = navEl.find('> li.distribute > a');
-      parentNavEl.addClass('has-subnav');
-      // In Distribute docs, also highlight appropriate sub-nav
-      if (urlSegments[2] === 'users') {
-        selected = subNavEl.find('li.users > a').addClass('selected');
-      } else if (urlSegments[2] === 'engage') {
-        selected = subNavEl.find('li.engage > a').addClass('selected');
-      } else if (urlSegments[2] === 'monetize') {
-        selected = subNavEl.find('li.monetize > a').addClass('selected');
-      } else if (urlSegments[2] === 'analyze') {
-        selected = subNavEl.find('li.analyze > a').addClass('selected');
-      } else if (urlSegments[2] === 'tools') {
-        selected = subNavEl.find('li.disttools > a').addClass('selected');
-      } else if (urlSegments[2] === 'stories') {
-        selected = subNavEl.find('li.stories > a').addClass('selected');
-      } else if (urlSegments[2] === 'essentials') {
-        selected = subNavEl.find('li.essentials > a').addClass('selected');
-      } else if (urlSegments[2] === 'googleplay') {
-        selected = subNavEl.find('li.googleplay > a').addClass('selected');
-      } else {
-        selected = parentNavEl.removeClass('has-subnav').addClass('selected');
-      }
-    } else if (body.hasClass('preview')) {
-      selected = navEl.find('> li.preview > a').addClass('selected');
-    }
-    return $(selected);
-  };
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  /**
-   * Toggle the visabilty of the mobile navigation.
-   * @param {HTMLElement} el - The DOM element.
-   * @param {Object} options
-   * @constructor
-   */
-  function ToggleNav(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, ToggleNav.DEFAULTS_, options);
-    this.body = $(document.body);
-    this.navigation_ = this.body.find(this.options.navigation);
-    this.el.on('click', this.clickHandler_.bind(this));
-  }
-
-  ToggleNav.BREAKPOINT_ = 980;
-
-  /**
-   * Open on correct sizes
-   */
-  function toggleSidebarVisibility(body) {
-    var wasClosed = ('' + localStorage.getItem('navigation-open')) === 'false';
-    // Override the local storage setting for navigation-open for child sites
-    // with no-subnav class.
-    if (document.body.classList.contains('no-subnav')) {
-      wasClosed = false;
-    }
-
-    if (wasClosed) {
-      body.removeClass(ToggleNav.DEFAULTS_.activeClass);
-    } else if (window.innerWidth >= ToggleNav.BREAKPOINT_) {
-      body.addClass(ToggleNav.DEFAULTS_.activeClass);
-    } else {
-      body.removeClass(ToggleNav.DEFAULTS_.activeClass);
-    }
-  }
-
-  /**
-   * ToggleNav Default Settings
-   * @type {{body: boolean, dimmer: string, navigation: string, activeClass: string}}
-   * @private
-   */
-  ToggleNav.DEFAULTS_ = {
-    body: true,
-    dimmer: '.dac-nav-dimmer',
-    animatingClass: 'dac-nav-animating',
-    navigation: '[data-dac-nav]',
-    activeClass: 'dac-nav-open'
-  };
-
-  /**
-   * The actual toggle logic.
-   * @param {Event} event
-   * @private
-   */
-  ToggleNav.prototype.clickHandler_ = function(event) {
-    event.preventDefault();
-    var animatingClass = this.options.animatingClass;
-    var body = this.body;
-
-    body.addClass(animatingClass);
-    body.toggleClass(this.options.activeClass);
-
-    setTimeout(function() {
-      body.removeClass(animatingClass);
-    }, this.navigation_.transitionDuration());
-
-    if (window.innerWidth >= ToggleNav.BREAKPOINT_) {
-      localStorage.setItem('navigation-open', body.hasClass(this.options.activeClass));
-    }
-  };
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacToggleMobileNav = function() {
-    return this.each(function() {
-      var el = $(this);
-      new ToggleNav(el, el.data());
-    });
-  };
-
-  $.fn.dacSidebarToggle = function(body) {
-    toggleSidebarVisibility(body);
-    $(window).on('resize', toggleSidebarVisibility.bind(null, body));
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(function() {
-    $('[data-dac-toggle-nav]').dacToggleMobileNav();
-  });
-})(jQuery);
-
-(function($) {
-  'use strict';
-
-  /**
-   * Submit the newsletter form to a Google Form.
-   * @param {HTMLElement} el - The Form DOM element.
-   * @constructor
-   */
-  function NewsletterForm(el) {
-    this.el = $(el);
-    this.form = this.el.find('form');
-    $('<iframe/>').hide()
-      .attr('name', 'dac-newsletter-iframe')
-      .attr('src', '')
-      .insertBefore(this.form);
-    this.el.find('[data-newsletter-language]').val(window.polyglot.t('newsletter.languageVal'));
-    this.form.on('submit', this.submitHandler_.bind(this));
-  }
-
-  /**
-   * Milliseconds until modal has vanished after modal-close is triggered.
-   * @type {number}
-   * @private
-   */
-  NewsletterForm.CLOSE_DELAY_ = 300;
-
-  /**
-   * Switch view to display form after close.
-   * @private
-   */
-  NewsletterForm.prototype.closeHandler_ = function() {
-    setTimeout(function() {
-      this.el.trigger('swap-reset');
-    }.bind(this), NewsletterForm.CLOSE_DELAY_);
-  };
-
-  /**
-   * Reset the modal to initial state.
-   * @private
-   */
-  NewsletterForm.prototype.reset_ = function() {
-    this.form.trigger('reset');
-    this.el.one('modal-close', this.closeHandler_.bind(this));
-  };
-
-  /**
-   * Display a success view on submit.
-   * @private
-   */
-  NewsletterForm.prototype.submitHandler_ = function() {
-    this.el.one('swap-complete', this.reset_.bind(this));
-    this.el.trigger('swap-content');
-  };
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacNewsletterForm = function(options) {
-    return this.each(function() {
-      new NewsletterForm(this, options);
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(document).on('ready.aranja', function() {
-    $('[data-newsletter]').each(function() {
-      $(this).dacNewsletterForm();
-    });
-  });
-})(jQuery);
-
-/* globals METADATA, YOUTUBE_RESOURCES, BLOGGER_RESOURCES */
-window.metadata = {};
-
-/**
- * Prepare metadata and indices for querying.
- */
-window.metadata.prepare = (function() {
-  // Helper functions.
-  function mergeArrays() {
-    return Array.prototype.concat.apply([], arguments);
-  }
-
-  /**
-   * Creates lookup maps for a resource index.
-   * I.e. where MAP['some tag'][resource.id] === true when that resource has 'some tag'.
-   * @param resourceDict
-   * @returns {{}}
-   */
-  function buildResourceLookupMap(resourceDict) {
-    var map = {};
-    for (var key in resourceDict) {
-      var dictForKey = {};
-      var srcArr = resourceDict[key];
-      for (var i = 0; i < srcArr.length; i++) {
-        dictForKey[srcArr[i].index] = true;
-      }
-      map[key] = dictForKey;
-    }
-    return map;
-  }
-
-  /**
-   * Merges metadata maps for english and the current language into the global store.
-   */
-  function mergeMetadataMap(name, locale) {
-    if (locale && locale !== 'en' && METADATA[locale]) {
-      METADATA[name] = $.extend(METADATA.en[name], METADATA[locale][name]);
-    } else {
-      METADATA[name] = METADATA.en[name];
-    }
-  }
-
-  /**
-   * Index all resources by type, url, tag and category.
-   * @param resources
-   */
-  function createIndices(resources) {
-    // URL, type, tag and category lookups
-    var byType = METADATA.byType = {};
-    var byUrl = METADATA.byUrl = {};
-    var byTag = METADATA.byTag = {};
-    var byCategory = METADATA.byCategory = {};
-
-    for (var i = 0; i < resources.length; i++) {
-      var res = resources[i];
-
-      // Store index.
-      res.index = i;
-
-      // Index by type.
-      var type = res.type;
-      if (type) {
-        byType[type] = byType[type] || [];
-        byType[type].push(res);
-      }
-
-      // Index by tag.
-      var tags = res.tags || [];
-      for (var j = 0; j < tags.length; j++) {
-        var tag = tags[j];
-        if (tag) {
-          byTag[tag] = byTag[tag] || [];
-          byTag[tag].push(res);
-        }
-      }
-
-      // Index by category.
-      var category = res.category;
-      if (category) {
-        byCategory[category] = byCategory[category] || [];
-        byCategory[category].push(res);
-      }
-
-      // Index by url.
-      var url = res.url;
-      if (url) {
-        res.baseUrl = url.replace(/^intl\/\w+[\/]/, '');
-        byUrl[res.baseUrl] = res;
-      }
-    }
-    METADATA.hasType = buildResourceLookupMap(byType);
-    METADATA.hasTag = buildResourceLookupMap(byTag);
-    METADATA.hasCategory = buildResourceLookupMap(byCategory);
-  }
-
-  return function() {
-    // Only once.
-    if (METADATA.all) { return; }
-
-    // Get current language.
-    var locale = getLangPref();
-    // Merge english resources.
-    if (useDevsiteMetadata) {
-      var all_keys = Object.keys(METADATA['en']);
-      METADATA.all = []
-
-      $(all_keys).each(function(index, category) {
-        if (RESERVED_METADATA_CATEGORY_NAMES.indexOf(category) == -1) {
-          METADATA.all = mergeArrays(
-            METADATA.all,
-            METADATA.en[category]
-          );
-        }
-      });
-
-      METADATA.all = mergeArrays(
-        METADATA.all,
-        YOUTUBE_RESOURCES,
-        BLOGGER_RESOURCES,
-        METADATA.en.extras
-      );
-    } else {
-      METADATA.all = mergeArrays(
-        METADATA.en.about,
-        METADATA.en.design,
-        METADATA.en.distribute,
-        METADATA.en.develop,
-        YOUTUBE_RESOURCES,
-        BLOGGER_RESOURCES,
-        METADATA.en.extras
-      );
-    }
-
-    // Merge local language resources.
-    if (locale !== 'en' && METADATA[locale]) {
-      if (useDevsiteMetadata) {
-        all_keys = Object.keys(METADATA[locale]);
-        $(all_keys).each(function(index, category) {
-          if (RESERVED_METADATA_CATEGORY_NAMES.indexOf(category) == -1) {
-            METADATA.all = mergeArrays(
-              METADATA.all,
-              METADATA.en[category]
-            );
-          }
-        });
-
-        METADATA.all = mergeArrays(
-          METADATA.all,
-          METADATA[locale].extras
-        );
-      } else {
-        METADATA.all = mergeArrays(
-          METADATA.all,
-          METADATA[locale].about,
-          METADATA[locale].design,
-          METADATA[locale].distribute,
-          METADATA[locale].develop,
-          METADATA[locale].extras
-        );
-
-      }
-    }
-
-    mergeMetadataMap('collections', locale);
-    mergeMetadataMap('searchHeroCollections', locale);
-    mergeMetadataMap('carousel', locale);
-
-    // Create query indicies for resources.
-    createIndices(METADATA.all, locale);
-
-    // Reference metadata.
-    METADATA.androidReference = mergeArrays(
-        window.DATA, window.SUPPORT_WEARABLE_DATA, window.SUPPORT_TEST_DATA);
-    METADATA.googleReference = mergeArrays(window.GMS_DATA, window.GCM_DATA);
-  };
-})();
-
-/* global METADATA, util */
-window.metadata.query = (function($) {
-  var pageMap = {};
-
-  function buildResourceList(opts) {
-    window.metadata.prepare();
-    var expressions = parseResourceQuery(opts.query || '');
-    var instanceMap = {};
-    var results = [];
-
-    for (var i = 0; i < expressions.length; i++) {
-      var clauses = expressions[i];
-
-      // Get all resources for first clause
-      var resources = getResourcesForClause(clauses.shift());
-
-      // Concat to final results list
-      results = results.concat(resources.map(filterResources(clauses, i > 0, instanceMap)).filter(filterEmpty));
-    }
-
-    // Set correct order
-    if (opts.sortOrder && results.length) {
-      results = opts.sortOrder === 'random' ? util.shuffle(results) : results.sort(sortResultsByKey(opts.sortOrder));
-    }
-
-    // Slice max results.
-    if (opts.maxResults !== Infinity) {
-      results = results.slice(0, opts.maxResults);
-    }
-
-    // Remove page level duplicates
-    if (opts.allowDuplicates === undefined || opts.allowDuplicates === 'false') {
-      results = results.filter(removePageLevelDuplicates);
-
-      for (var index = 0; index < results.length; ++index) {
-        pageMap[results[index].index] = 1;
-      }
-    }
-
-    return results;
-  }
-
-  function filterResources(clauses, removeDuplicates, map) {
-    return function(resource) {
-      var resourceIsAllowed = true;
-
-      // References must be defined.
-      if (resource === undefined) {
-        return;
-      }
-
-      // Get canonical (localized) version of resource if possible.
-      resource = METADATA.byUrl[resource.baseUrl] || METADATA.byUrl[resource.url] || resource;
-
-      // Filter out resources already used
-      if (removeDuplicates) {
-        resourceIsAllowed = !map[resource.index];
-      }
-
-      // Must fulfill all criteria
-      if (clauses.length > 0) {
-        resourceIsAllowed = resourceIsAllowed && doesResourceMatchClauses(resource, clauses);
-      }
-
-      // Mark resource as used.
-      if (resourceIsAllowed) {
-        map[resource.index] = 1;
-      }
-
-      return resourceIsAllowed && resource;
-    };
-  }
-
-  function filterEmpty(resource) {
-    return resource;
-  }
-
-  function sortResultsByKey(key) {
-    var desc = key.charAt(0) === '-';
-
-    if (desc) {
-      key = key.substring(1);
-    }
-
-    return function(x, y) {
-      return (desc ? -1 : 1) * (parseInt(x[key], 10) - parseInt(y[key], 10));
-    };
-  }
-
-  function getResourcesForClause(clause) {
-    switch (clause.attr) {
-      case 'type':
-        return METADATA.byType[clause.value];
-      case 'tag':
-        return METADATA.byTag[clause.value];
-      case 'collection':
-        var resources = METADATA.collections[clause.value] || {};
-        return getResourcesByUrlCollection(resources.resources);
-      case 'history':
-        return getResourcesByUrlCollection($.dacGetVisitedUrls(clause.value));
-      case 'section':
-        return getResourcesByUrlCollection([clause.value].sections);
-      default:
-        return [];
-    }
-  }
-
-  function getResourcesByUrlCollection(resources) {
-    return (resources || []).map(function(url) {
-      return METADATA.byUrl[url];
-    });
-  }
-
-  function removePageLevelDuplicates(resource) {
-    return resource && !pageMap[resource.index];
-  }
-
-  function doesResourceMatchClauses(resource, clauses) {
-    for (var i = 0; i < clauses.length; i++) {
-      var map;
-      switch (clauses[i].attr) {
-        case 'type':
-          map = METADATA.hasType[clauses[i].value];
-          break;
-        case 'tag':
-          map = METADATA.hasTag[clauses[i].value];
-          break;
-      }
-
-      if (!map || (!!clauses[i].negative ? map[resource.index] : !map[resource.index])) {
-        return clauses[i].negative;
-      }
-    }
-
-    return true;
-  }
-
-  function parseResourceQuery(query) {
-    // Parse query into array of expressions (expression e.g. 'tag:foo + type:video')
-    var expressions = [];
-    var expressionStrs = query.split(',') || [];
-    for (var i = 0; i < expressionStrs.length; i++) {
-      var expr = expressionStrs[i] || '';
-
-      // Break expression into clauses (clause e.g. 'tag:foo')
-      var clauses = [];
-      var clauseStrs = expr.split(/(?=[\+\-])/);
-      for (var j = 0; j < clauseStrs.length; j++) {
-        var clauseStr = clauseStrs[j] || '';
-
-        // Get attribute and value from clause (e.g. attribute='tag', value='foo')
-        var parts = clauseStr.split(':');
-        var clause = {};
-
-        clause.attr = parts[0].replace(/^\s+|\s+$/g, '');
-        if (clause.attr) {
-          if (clause.attr.charAt(0) === '+') {
-            clause.attr = clause.attr.substring(1);
-          } else if (clause.attr.charAt(0) === '-') {
-            clause.negative = true;
-            clause.attr = clause.attr.substring(1);
-          }
-        }
-
-        if (parts.length > 1) {
-          clause.value = parts[1].replace(/^\s+|\s+$/g, '');
-        }
-
-        clauses.push(clause);
-      }
-
-      if (!clauses.length) {
-        continue;
-      }
-
-      expressions.push(clauses);
-    }
-
-    return expressions;
-  }
-
-  return buildResourceList;
-})(jQuery);
-
-/* global METADATA, getLangPref */
-
-window.metadata.search = (function() {
-  'use strict';
-
-  var currentLang = getLangPref();
-
-  function search(query) {
-    window.metadata.prepare();
-    return {
-      android: findDocsMatches(query, METADATA.androidReference),
-      docs: findDocsMatches(query, METADATA.googleReference),
-      resources: findResourceMatches(query)
-    };
-  }
-
-  function findDocsMatches(query, data) {
-    var results = [];
-
-    for (var i = 0; i < data.length; i++) {
-      var s = data[i];
-      if (query.length !== 0 && s.label.toLowerCase().indexOf(query.toLowerCase()) !== -1) {
-        results.push(s);
-      }
-    }
-
-    rankAutocompleteApiResults(query, results);
-
-    return results;
-  }
-
-  function findResourceMatches(query) {
-    var results = [];
-
-    // Search for matching JD docs
-    if (query.length >= 2) {
-      /* In some langs, spaces may be optional between certain non-Ascii word-glyphs. For
-       * those langs, only match query at word boundaries if query includes Ascii chars only.
-       */
-      var NO_BOUNDARY_LANGUAGES = ['ja','ko','vi','zh-cn','zh-tw'];
-      var isAsciiOnly = /^[\u0000-\u007f]*$/.test(query);
-      var noBoundaries = (NO_BOUNDARY_LANGUAGES.indexOf(window.getLangPref()) !== -1);
-      var exprBoundary = (!isAsciiOnly && noBoundaries) ? '' : '(?:^|\\s)';
-      var queryRegex = new RegExp(exprBoundary + query.toLowerCase(), 'g');
-
-      var all = METADATA.all;
-      for (var i = 0; i < all.length; i++) {
-        // current search comparison, with counters for tag and title,
-        // used later to improve ranking
-        var s = all[i];
-        s.matched_tag = 0;
-        s.matched_title = 0;
-        var matched = false;
-
-        // Check if query matches any tags; work backwards toward 1 to assist ranking
-        if (s.keywords) {
-          for (var j = s.keywords.length - 1; j >= 0; j--) {
-            // it matches a tag
-            if (s.keywords[j].toLowerCase().match(queryRegex)) {
-              matched = true;
-              s.matched_tag = j + 1; // add 1 to index position
-            }
-          }
-        }
-
-        // Check if query matches doc title
-        if (s.title.toLowerCase().match(queryRegex)) {
-          matched = true;
-          s.matched_title = 1;
-        }
-
-        // Remember the doc if it matches either
-        if (matched) {
-          results.push(s);
-        }
-      }
-
-      // Improve the current results
-      results = lookupBetterResult(results);
-
-      // Rank/sort all the matched pages
-      rankAutocompleteDocResults(results);
-
-      return results;
-    }
-  }
-
-  // Replaces a match with another resource by url, if it exists.
-  function lookupReplacementByUrl(match, url) {
-    var replacement = METADATA.byUrl[url];
-
-    // Replacement resource does not exists.
-    if (!replacement) { return; }
-
-    replacement.matched_title = Math.max(replacement.matched_title, match.matched_title);
-    replacement.matched_tag = Math.max(replacement.matched_tag, match.matched_tag);
-
-    return replacement;
-  }
-
-  // Find the localized version of a page if it exists.
-  function lookupLocalizedVersion(match) {
-    return METADATA.byUrl[match.baseUrl] || METADATA.byUrl[match.url];
-  }
-
-  // Find the main page for a tutorial when matching a subpage.
-  function lookupTutorialIndex(match) {
-    // Guard for non index tutorial pages.
-    if (match.type !== 'training' || match.url.indexOf('index.html') >= 0) { return; }
-
-    var indexUrl = match.url.replace(/[^\/]+$/, 'index.html');
-    return lookupReplacementByUrl(match, indexUrl);
-  }
-
-  // Find related results which are a better match for the user.
-  function lookupBetterResult(matches) {
-    var newMatches = [];
-
-    matches = matches.filter(function(match) {
-      var newMatch = match;
-      newMatch = lookupTutorialIndex(newMatch) || newMatch;
-      newMatch = lookupLocalizedVersion(newMatch) || newMatch;
-
-      if (newMatch !== match) {
-        newMatches.push(newMatch);
-      }
-
-      return newMatch === match;
-    });
-
-    return toUnique(newMatches.concat(matches));
-  }
-
-  /* Order the jd doc result list based on match quality */
-  function rankAutocompleteDocResults(matches) {
-    if (!matches || !matches.length) {
-      return;
-    }
-
-    var _resultScoreFn = function(match) {
-      var score = 1.0;
-
-      // if the query matched a tag
-      if (match.matched_tag > 0) {
-        // multiply score by factor relative to position in tags list (max of 3)
-        score *= 3 / match.matched_tag;
-
-        // if it also matched the title
-        if (match.matched_title > 0) {
-          score *= 2;
-        }
-      } else if (match.matched_title > 0) {
-        score *= 3;
-      }
-
-      if (match.lang === currentLang) {
-        score *= 5;
-      }
-
-      return score;
-    };
-
-    for (var i = 0; i < matches.length; i++) {
-      matches[i].__resultScore = _resultScoreFn(matches[i]);
-    }
-
-    matches.sort(function(a, b) {
-      var n = b.__resultScore - a.__resultScore;
-
-      if (n === 0) {
-        // lexicographical sort if scores are the same
-        n = (a.title < b.title) ? -1 : 1;
-      }
-
-      return n;
-    });
-  }
-
-  /* Order the result list based on match quality */
-  function rankAutocompleteApiResults(query, matches) {
-    query = query || '';
-    if (!matches || !matches.length) {
-      return;
-    }
-
-    // helper function that gets the last occurence index of the given regex
-    // in the given string, or -1 if not found
-    var _lastSearch = function(s, re) {
-      if (s === '') {
-        return -1;
-      }
-      var l = -1;
-      var tmp;
-      while ((tmp = s.search(re)) >= 0) {
-        if (l < 0) {
-          l = 0;
-        }
-        l += tmp;
-        s = s.substr(tmp + 1);
-      }
-      return l;
-    };
-
-    // helper function that counts the occurrences of a given character in
-    // a given string
-    var _countChar = function(s, c) {
-      var n = 0;
-      for (var i = 0; i < s.length; i++) {
-        if (s.charAt(i) === c) {
-          ++n;
-        }
-      }
-      return n;
-    };
-
-    var queryLower = query.toLowerCase();
-    var queryAlnum = (queryLower.match(/\w+/) || [''])[0];
-    var partPrefixAlnumRE = new RegExp('\\b' + queryAlnum);
-    var partExactAlnumRE = new RegExp('\\b' + queryAlnum + '\\b');
-
-    var _resultScoreFn = function(result) {
-      // scores are calculated based on exact and prefix matches,
-      // and then number of path separators (dots) from the last
-      // match (i.e. favoring classes and deep package names)
-      var score = 1.0;
-      var labelLower = result.label.toLowerCase();
-      var t;
-      var partsAfter;
-      t = _lastSearch(labelLower, partExactAlnumRE);
-      if (t >= 0) {
-        // exact part match
-        partsAfter = _countChar(labelLower.substr(t + 1), '.');
-        score *= 200 / (partsAfter + 1);
-      } else {
-        t = _lastSearch(labelLower, partPrefixAlnumRE);
-        if (t >= 0) {
-          // part prefix match
-          partsAfter = _countChar(labelLower.substr(t + 1), '.');
-          score *= 20 / (partsAfter + 1);
-        }
-      }
-
-      return score;
-    };
-
-    for (var i = 0; i < matches.length; i++) {
-      // if the API is deprecated, default score is 0; otherwise, perform scoring
-      if (matches[i].deprecated === 'true') {
-        matches[i].__resultScore = 0;
-      } else {
-        matches[i].__resultScore = _resultScoreFn(matches[i]);
-      }
-    }
-
-    matches.sort(function(a, b) {
-      var n = b.__resultScore - a.__resultScore;
-
-      if (n === 0) {
-        // lexicographical sort if scores are the same
-        n = (a.label < b.label) ? -1 : 1;
-      }
-
-      return n;
-    });
-  }
-
-  // Destructive but fast toUnique.
-  // http://stackoverflow.com/a/25082874
-  function toUnique(array) {
-    var c;
-    var b = array.length || 1;
-
-    while (c = --b) {
-      while (c--) {
-        if (array[b] === array[c]) {
-          array.splice(c, 1);
-        }
-      }
-    }
-    return array;
-  }
-
-  return search;
-})();
-
-(function($) {
-  'use strict';
-
-  /**
-   * Smoothly scroll to location on current page.
-   * @param el
-   * @param options
-   * @constructor
-   */
-  function ScrollButton(el, options) {
-    this.el = $(el);
-    this.target = $(this.el.attr('href'));
-    this.options = $.extend({}, ScrollButton.DEFAULTS_, options);
-
-    if (typeof this.options.offset === 'string') {
-      this.options.offset = $(this.options.offset).height();
-    }
-
-    this.el.on('click', this.clickHandler_.bind(this));
-  }
-
-  /**
-   * Default options
-   * @type {{duration: number, easing: string, offset: number, scrollContainer: string}}
-   * @private
-   */
-  ScrollButton.DEFAULTS_ = {
-    duration: 300,
-    easing: 'swing',
-    offset: '.dac-header',
-    scrollContainer: 'html, body'
-  };
-
-  /**
-   * Scroll logic
-   * @param event
-   * @private
-   */
-  ScrollButton.prototype.clickHandler_ = function(event) {
-    if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
-      return;
-    }
-
-    event.preventDefault();
-
-    var position = this.getTargetPosition();
-    $(this.options.scrollContainer).animate({
-      scrollTop: position - this.options.offset
-    }, this.options);
-  };
-
-  ScrollButton.prototype.getTargetPosition = function() {
-    if (this.options.scrollContainer === ScrollButton.DEFAULTS_.scrollContainer) {
-      return this.target.offset().top;
-    }
-    var scrollContainer = $(this.options.scrollContainer)[0];
-    var currentEl = this.target[0];
-    var pos = 0;
-    while (currentEl !== scrollContainer && currentEl !== null) {
-      pos += currentEl.offsetTop;
-      currentEl = currentEl.offsetParent;
-    }
-    return pos;
-  };
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacScrollButton = function(options) {
-    return this.each(function() {
-      new ScrollButton(this, options);
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(document).on('ready.aranja', function() {
-    $('[data-scroll-button]').each(function() {
-      $(this).dacScrollButton($(this).data());
-    });
-  });
-})(jQuery);
-
-/* global getLangPref */
-(function($) {
-  var LANG;
-
-  function getSearchLang() {
-    if (!LANG) {
-      LANG = getLangPref();
-
-      // Fix zh-cn to be zh-CN.
-      LANG = LANG.replace(/-\w+/, function(m) { return m.toUpperCase(); });
-    }
-    return LANG;
-  }
-
-  function customSearch(query, start) {
-    var searchParams = {
-      // current cse instance:
-      //cx: '001482626316274216503:zu90b7s047u',
-      // new cse instance:
-      cx: '000521750095050289010:zpcpi1ea4s8',
-      key: 'AIzaSyCFhbGnjW06dYwvRCU8h_zjdpS4PYYbEe8',
-      q: query,
-      start: start || 1,
-      num: 9,
-      hl: getSearchLang(),
-      fields: 'queries,items(pagemap,link,title,htmlSnippet,formattedUrl)'
-    };
-
-    return $.get('https://content.googleapis.com/customsearch/v1?' +  $.param(searchParams));
-  }
-
-  function renderResults(el, results, searchAppliance) {
-    var referenceResults = searchAppliance.getReferenceResults();
-    if (!results.items) {
-      el.append($('<div>').text('No results'));
-      return;
-    }
-
-    for (var i = 0; i < results.items.length; i++) {
-      var item = results.items[i];
-      var isDuplicate = false;
-      $(referenceResults.android).each(function(index, result) {
-        if (item.link.indexOf(result.link) > -1) {
-          isDuplicate = true;
-          return false;
-        }
-      });
-
-      if (!isDuplicate) {
-        var hasImage = item.pagemap && item.pagemap.cse_thumbnail;
-        var sectionMatch = item.link.match(/developer\.android\.com\/(\w*)/);
-        var section = (sectionMatch && sectionMatch[1]) || 'blog';
-
-        var entry = $('<div>').addClass('dac-custom-search-entry cols');
-
-        if (hasImage) {
-          var image = item.pagemap.cse_thumbnail[0];
-          entry.append($('<div>').addClass('dac-custom-search-image-wrapper')
-            .append($('<div>').addClass('dac-custom-search-image').css('background-image', 'url(' + image.src + ')')));
-        }
-
-        entry.append($('<div>').addClass('dac-custom-search-text-wrapper')
-          .append($('<p>').addClass('dac-custom-search-section').text(section))
-          .append(
-            $('<a>').text(item.title).attr('href', item.link).wrap('<h2>').parent().addClass('dac-custom-search-title')
-          )
-          .append($('<p>').addClass('dac-custom-search-snippet').html(item.htmlSnippet.replace(/<br>/g, '')))
-          .append($('<a>').addClass('dac-custom-search-link').text(item.formattedUrl).attr('href', item.link)));
-
-        el.append(entry);
-      }
-    }
-
-    if (results.queries.nextPage) {
-      var loadMoreButton = $('<button id="dac-custom-search-load-more">')
-        .addClass('dac-custom-search-load-more')
-        .text('Load more')
-        .click(function() {
-          loadMoreResults(el, results, searchAppliance);
-        });
-
-      el.append(loadMoreButton);
-    }
-  };
-
-  function loadMoreResults(el, results, searchAppliance) {
-    var query = results.queries.request[0].searchTerms;
-    var start = results.queries.nextPage[0].startIndex;
-    var loadMoreButton = el.find('#dac-custom-search-load-more');
-
-    loadMoreButton.text('Loading more...');
-
-    customSearch(query, start).then(function(results) {
-      loadMoreButton.remove();
-      renderResults(el, results, searchAppliance);
-    });
-  }
-
-  $.fn.customSearch = function(query, searchAppliance) {
-    var el = $(this);
-
-    customSearch(query).then(function(results) {
-      el.empty();
-      renderResults(el, results, searchAppliance);
-    });
-  };
-})(jQuery);
-
-/* global METADATA */
-
-(function($) {
-  $.fn.dacSearchRenderHero = function(resources, query) {
-    var el = $(this);
-    el.empty();
-
-    var resource = METADATA.searchHeroCollections[query];
-
-    if (resource) {
-      el.dacHero(resource, true);
-      el.show();
-
-      return true;
-    } else {
-      el.hide();
-    }
-  };
-})(jQuery);
-
-(function($) {
-  $.fn.dacSearchRenderReferences = function(results, query) {
-    var referenceCard = $('.suggest-card.reference');
-    referenceCard.data('searchreferences.dac', {results: results, query: query});
-    renderResults(referenceCard, results, query, false);
-  };
-
-  var ROW_COUNT_COLLAPSED = 20;
-  var ROW_COUNT_EXPANDED = 40;
-  var ROW_COUNT_GOOGLE_COLLAPSED = 1;
-  var ROW_COUNT_GOOGLE_EXPANDED = 8;
-
-  function onSuggestionClick(e) {
-    devsite.analytics.trackAnalyticsEvent('event',
-        'Suggestion Click', 'clicked: ' + $(e.currentTarget).attr('href'),
-        'query: ' + $('#search_autocomplete').val().toLowerCase());
-  }
-
-  function buildLink(match) {
-    var link = $('<a>').attr('href', window.toRoot + match.link);
-
-    var label = match.label;
-    var classNameStart = label.match(/[A-Z]/) ? label.search(/[A-Z]/) : label.lastIndexOf('.') + 1;
-    var newLink = '<span class="namespace">' +
-      label.substr(0, classNameStart) +
-      '</span>' +
-      label.substr(classNameStart, label.length);
-
-    link.html(newLink);
-    return link;
-  }
-
-  function buildSuggestion(match, query) {
-    var li = $('<li>').addClass('dac-search-results-reference-entry');
-
-    var link = buildLink(match);
-    link.highlightMatches(query);
-    li.append(link);
-    return li[0];
-  }
-
-  function buildResults(results, query) {
-    return results.map(function(match) {
-      return buildSuggestion(match, query);
-    });
-  }
-
-  function renderAndroidResults(list, gMatches, query) {
-    list.empty();
-
-    var header = $('<li class="dac-search-results-reference-header">android APIs</li>');
-    list.append(header);
-
-    if (gMatches.length > 0) {
-      list.removeClass('no-results');
-
-      var resources = buildResults(gMatches, query);
-      list.append(resources);
-      return true;
-    } else {
-      list.append('<li class="dac-search-results-reference-entry-empty">No results</li>');
-    }
-  }
-
-  function renderGoogleDocsResults(list, gGoogleMatches, query) {
-    list = $('.suggest-card.reference ul');
-
-    if (gGoogleMatches.length > 0) {
-      list.append('<li class="dac-search-results-reference-header">in Google Services</li>');
-
-      var resources = buildResults(gGoogleMatches, query);
-      list.append(resources);
-
-      return true;
-    }
-  }
-
-  function renderResults(referenceCard, results, query, expanded) {
-    var list = referenceCard.find('ul');
-    list.toggleClass('is-expanded', !!expanded);
-
-    // Figure out how many results we can show in our fixed size box.
-    var total = expanded ? ROW_COUNT_EXPANDED : ROW_COUNT_COLLAPSED;
-    var googleCount = expanded ? ROW_COUNT_GOOGLE_EXPANDED : ROW_COUNT_GOOGLE_COLLAPSED;
-    googleCount = Math.max(googleCount, total - results.android.length);
-    googleCount = Math.min(googleCount, results.docs.length);
-
-    if (googleCount > 0) {
-      // If there are google results, reserve space for its header.
-      googleCount++;
-    }
-
-    var androidCount = Math.max(0, total - googleCount);
-    if (androidCount === 0) {
-      // Reserve space for "No reference results"
-      googleCount--;
-    }
-
-    renderAndroidResults(list, results.android.slice(0, androidCount), query);
-    renderGoogleDocsResults(list, results.docs.slice(0, googleCount - 1), query);
-
-    var totalResults = results.android.length + results.docs.length;
-    if (totalResults === 0) {
-      list.addClass('no-results');
-    }
-
-    // Tweak see more logic to account for references.
-    var hasMore = totalResults > ROW_COUNT_COLLAPSED && !util.matchesMedia('mobile');
-    if (hasMore) {
-      // We can't actually show all matches, only as many as the expanded list
-      // will fit, so we actually lie if the total results count is more
-      var moreCount = Math.min(totalResults, ROW_COUNT_EXPANDED + ROW_COUNT_GOOGLE_EXPANDED);
-      var $moreLink = $('<li class="dac-search-results-reference-entry-empty " data-toggle="show-more">see more matches</li>');
-      list.append($moreLink.on('click', onToggleMore));
-    }
-    var searchEl = $('#search-resources');
-    searchEl.toggleClass('dac-has-more', searchEl.hasClass('dac-has-more') || (hasMore && !expanded));
-    searchEl.toggleClass('dac-has-less', searchEl.hasClass('dac-has-less') || (hasMore && expanded));
-  }
-
-  function onToggleMore(e) {
-    var link = $(e.currentTarget);
-    var referenceCard = $('.suggest-card.reference');
-    var data = referenceCard.data('searchreferences.dac');
-
-    if (util.matchesMedia('mobile')) { return; }
-
-    renderResults(referenceCard, data.results, data.query, link.data('toggle') === 'show-more');
-  }
-
-  $(document).on('click', '.dac-search-results-resources [data-toggle="show-more"]', onToggleMore);
-  $(document).on('click', '.dac-search-results-resources [data-toggle="show-less"]', onToggleMore);
-  $(document).on('click', '.suggest-card.reference a', onSuggestionClick);
-})(jQuery);
-
-(function($) {
-  function highlightPage(query, page) {
-    page.find('.title').highlightMatches(query);
-  }
-
-  $.fn.dacSearchRenderResources = function(gDocsMatches, query) {
-    this.resourceWidget(gDocsMatches, {
-      itemsPerPage: 18,
-      initialResults: 6,
-      cardSizes: ['6x2'],
-      onRenderPage: highlightPage.bind(null, query)
-    });
-
-    return this;
-  };
-})(jQuery);
-
-/*global metadata */
-
-(function($, metadata) {
-  'use strict';
-
-  function Search() {
-    this.body = $('body');
-    this.lastQuery = null;
-    this.searchResults = $('#search-results');
-    this.searchClose = $('[data-search-close]');
-    this.searchClear = $('[data-search-clear]');
-    this.searchInput = $('#search_autocomplete');
-    this.searchResultsContent = $('#dac-search-results-content');
-    this.searchResultsFor = $('#search-results-for');
-    this.searchResultsHistory = $('#dac-search-results-history');
-    this.searchResultsResources = $('#search-resources');
-    this.searchResultsHero = $('#dac-search-results-hero');
-    this.searchResultsReference = $('#dac-search-results-reference');
-    this.searchHeader = $('[data-search]').data('search-input.dac');
-    this.pageNav = $('a[name=navigation]');
-    this.currQueryReferenceResults = {};
-    this.isOpen = false;
-  }
-
-  Search.prototype.init = function() {
-    this.searchHistory = window.dacStore('search-history');
-
-    this.searchInput.focus(this.onSearchChanged.bind(this));
-    this.searchInput.keypress(this.handleKeyboardShortcut.bind(this));
-    this.pageNav.keyup(this.handleTabbedToNav.bind(this));
-    this.searchResults.keyup(this.handleKeyboardShortcut.bind(this));
-    this.searchInput.on('input', this.onSearchChanged.bind(this));
-    this.searchClear.click(this.clear.bind(this));
-    this.searchClose.click(this.close.bind(this));
-
-    this.customSearch = $.fn.debounce(function(query) {
-      $('#dac-custom-search-results').customSearch(query, this);
-    }.bind(this), 1000);
-    // Start search shortcut (/)
-    $('body').keyup(function(event) {
-      if (event.which === 191 && $(event.target).is(':not(:input)')) {
-        this.searchInput.focus();
-      }
-    }.bind(this));
-
-    $(window).on('popstate', this.onPopState.bind(this));
-    $(window).hashchange(this.onHashChange.bind(this));
-    this.onHashChange();
-  };
-
-  Search.prototype.checkRedirectToIndex = function() {
-    var query = this.getUrlQuery();
-    var target = window.getLangTarget();
-    var prefix = (target !== 'en') ? '/intl/' + target : '';
-    var pathname = location.pathname.slice(prefix.length);
-    if (query != null && pathname !== '/index.html') {
-      location.href = prefix + '/index.html' + location.hash;
-      return true;
-    }
-  };
-
-  Search.prototype.handleKeyboardShortcut = function(event) {
-    // Close (esc)
-    if (event.which === 27) {
-      this.searchClose.trigger('click');
-      event.preventDefault();
-    }
-
-    // Previous result (up arrow)
-    if (event.which === 38) {
-      this.previousResult();
-      event.preventDefault();
-    }
-
-    // Next result (down arrow)
-    if (event.which === 40) {
-      this.nextResult();
-      event.preventDefault();
-    }
-
-    // Navigate to result (enter)
-    if (event.which === 13) {
-      this.navigateToResult();
-      event.preventDefault();
-    }
-  };
-
-  Search.prototype.handleTabbedToNav = function(event) {
-    if (this.isOpen) {
-      this.searchClose.trigger('click');
-    }
-  }
-
-  Search.prototype.goToResult = function(relativeIndex) {
-    var links = this.searchResults.find('a').filter(':visible');
-    var selectedLink = this.searchResults.find('.dac-selected');
-
-    if (selectedLink.length) {
-      var found = $.inArray(selectedLink[0], links);
-
-      selectedLink.removeClass('dac-selected');
-      links.eq(found + relativeIndex).addClass('dac-selected');
-      return true;
-    } else {
-      if (relativeIndex > 0) {
-        links.first().addClass('dac-selected');
-      }
-    }
-  };
-
-  Search.prototype.previousResult = function() {
-    this.goToResult(-1);
-  };
-
-  Search.prototype.nextResult = function() {
-    this.goToResult(1);
-  };
-
-  Search.prototype.navigateToResult = function() {
-    var query = this.getQuery();
-    var selectedLink = this.searchResults.find('.dac-selected');
-
-    if (selectedLink.length) {
-      selectedLink[0].click();
-    } else {
-      this.searchHistory.push(query);
-      this.addQueryToUrl(query);
-
-      var isMobileOrTablet = typeof window.orientation !== 'undefined';
-
-      if (isMobileOrTablet) {
-        this.searchInput.blur();
-      }
-    }
-  };
-
-  Search.prototype.onHashChange = function() {
-    var query = this.getUrlQuery();
-    if (query != null && query !== this.getQuery()) {
-      this.searchInput.val(query);
-      this.onSearchChanged();
-    }
-  };
-
-  Search.prototype.clear = function() {
-    this.searchInput.val('');
-    window.location.hash = '';
-    this.onSearchChanged();
-    this.searchInput.focus();
-  };
-
-  Search.prototype.close = function() {
-    this.removeQueryFromUrl();
-    this.searchInput.blur();
-    this.hideOverlay();
-    this.pageNav.focus();
-    this.isOpen = false;
-  };
-
-  Search.prototype.getUrlQuery = function() {
-    var queryMatch = location.hash.match(/q=(.*)&?/);
-    return queryMatch && queryMatch[1] && decodeURI(queryMatch[1]);
-  };
-
-  Search.prototype.getQuery = function() {
-    return this.searchInput.val().replace(/(^ +)|( +$)/g, '');
-  };
-
-  Search.prototype.getReferenceResults = function() {
-    return this.currQueryReferenceResults;
-  };
-
-  Search.prototype.onSearchChanged = function() {
-    var query = this.getQuery();
-
-    this.showOverlay();
-    this.render(query);
-  };
-
-  Search.prototype.render = function(query) {
-    if (this.lastQuery === query) { return; }
-
-    if (query.length < 2) {
-      query = '';
-    }
-
-    this.lastQuery = query;
-    this.searchResultsFor.text(query);
-
-    // CSE results lag behind the metadata/reference results. We need to empty
-    // the CSE results and add 'Loading' text so user's aren't looking at two
-    // different sets of search results at one time.
-    var $loadingEl =
-        $('<div class="loadingCustomSearchResults">Loading Results...</div>');
-    $('#dac-custom-search-results').empty().prepend($loadingEl);
-
-    this.customSearch(query);
-    var metadataResults = metadata.search(query);
-    this.searchResultsResources.dacSearchRenderResources(metadataResults.resources, query);
-    this.searchResultsReference.dacSearchRenderReferences(metadataResults, query);
-    this.currQueryReferenceResults = metadataResults;
-    var hasHero = this.searchResultsHero.dacSearchRenderHero(metadataResults.resources, query);
-    var hasQuery = !!query;
-
-    this.searchResultsReference.toggle(!hasHero);
-    this.searchResultsContent.toggle(hasQuery);
-    this.searchResultsHistory.toggle(!hasQuery);
-    this.addQueryToUrl(query);
-    this.pushState();
-  };
-
-  Search.prototype.addQueryToUrl = function(query) {
-    var hash = 'q=' + encodeURI(query);
-
-    if (query) {
-      if (window.history.replaceState) {
-        window.history.replaceState(null, '', '#' + hash);
-      } else {
-        window.location.hash = hash;
-      }
-    }
-  };
-
-  Search.prototype.onPopState = function() {
-    if (!this.getUrlQuery()) {
-      this.hideOverlay();
-      this.searchHeader.unsetActiveState();
-    }
-  };
-
-  Search.prototype.removeQueryFromUrl = function() {
-    window.location.hash = '';
-  };
-
-  Search.prototype.pushState = function() {
-    if (window.history.pushState && !this.lastQuery.length) {
-      window.history.pushState(null, '');
-    }
-  };
-
-  Search.prototype.showOverlay = function() {
-    this.isOpen = true;
-    this.body.addClass('dac-modal-open dac-search-open');
-  };
-
-  Search.prototype.hideOverlay = function() {
-    this.body.removeClass('dac-modal-open dac-search-open');
-  };
-
-  $(document).on('ready.aranja', function() {
-    var search = new Search();
-    search.init();
-  });
-})(jQuery, metadata);
-
-window.dacStore = (function(window) {
-  /**
-   * Creates a new persistent store.
-   * If localStorage is unavailable, the items are stored in memory.
-   *
-   * @constructor
-   * @param {string} name    The name of the store
-   * @param {number} maxSize The maximum number of items the store can hold.
-   */
-  var Store = function(name, maxSize) {
-    var content = [];
-
-    var hasLocalStorage = !!window.localStorage;
-
-    if (hasLocalStorage) {
-      try {
-        content = JSON.parse(window.localStorage.getItem(name) || []);
-      } catch (e) {
-        // Store contains invalid data
-        window.localStorage.removeItem(name);
-      }
-    }
-
-    function push(item) {
-      if (content[0] === item) {
-        return;
-      }
-
-      content.unshift(item);
-
-      if (maxSize) {
-        content.splice(maxSize, content.length);
-      }
-
-      if (hasLocalStorage) {
-        window.localStorage.setItem(name, JSON.stringify(content));
-      }
-    }
-
-    function all() {
-      // Return a copy
-      return content.slice();
-    }
-
-    return {
-      push: push,
-      all: all
-    };
-  };
-
-  var stores = {
-    'search-history': new Store('search-history', 3)
-  };
-
-  /**
-   * Get a named persistent store.
-   * @param  {string} name
-   * @return {Store}
-   */
-  return function getStore(name) {
-    return stores[name];
-  };
-})(window);
-
-(function($) {
-  'use strict';
-
-  /**
-   * A component that swaps two dynamic height views with an animation.
-   * Listens for the following events:
-   * * swap-content: triggers SwapContent.swap_()
-   * * swap-reset: triggers SwapContent.reset()
-   * @param el
-   * @param options
-   * @constructor
-   */
-  function SwapContent(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, SwapContent.DEFAULTS_, options);
-    this.options.dynamic = this.options.dynamic === 'true';
-    this.containers = this.el.find(this.options.container);
-    this.initiallyActive = this.containers.children('.' + this.options.activeClass).eq(0);
-    this.el.on('swap-content', this.swap.bind(this));
-    this.el.on('swap-reset', this.reset.bind(this));
-    this.el.find(this.options.swapButton).on('click keypress', function(e) {
-      if (e.type == 'keypress' && e.which == 13 || e.type == 'click') {
-        this.swap();
-      }
-    }.bind(this));
-  }
-
-  /**
-   * SwapContent's default settings.
-   * @type {{activeClass: string, container: string, transitionSpeed: number}}
-   * @private
-   */
-  SwapContent.DEFAULTS_ = {
-    activeClass: 'dac-active',
-    container: '[data-swap-container]',
-    dynamic: 'true',
-    swapButton: '[data-swap-button]',
-    transitionSpeed: 500
-  };
-
-  /**
-   * Returns container's visible height.
-   * @param container
-   * @returns {number}
-   */
-  SwapContent.prototype.currentHeight = function(container) {
-    return container.children('.' + this.options.activeClass).outerHeight();
-  };
-
-  /**
-   * Reset to show initial content
-   */
-  SwapContent.prototype.reset = function() {
-    if (!this.initiallyActive.hasClass(this.initiallyActive)) {
-      this.containers.children().toggleClass(this.options.activeClass);
-    }
-  };
-
-  /**
-   * Complete the swap.
-   */
-  SwapContent.prototype.complete = function() {
-    this.containers.height('auto');
-    this.containers.trigger('swap-complete');
-  };
-
-  /**
-   * Perform the swap of content.
-   */
-  SwapContent.prototype.swap = function() {
-    this.containers.each(function(index, container) {
-      container = $(container);
-
-      if (!this.options.dynamic) {
-        container.children().toggleClass(this.options.activeClass);
-        this.complete.bind(this);
-        $('.' + this.options.activeClass).focus();
-        return;
-      }
-
-      container.height(this.currentHeight(container)).children().toggleClass(this.options.activeClass);
-      container.animate({height: this.currentHeight(container)}, this.options.transitionSpeed,
-        this.complete.bind(this));
-    }.bind(this));
-  };
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacSwapContent = function(options) {
-    return this.each(function() {
-      new SwapContent(this, options);
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(document).on('ready.aranja', function() {
-    $('[data-swap]').each(function() {
-      $(this).dacSwapContent($(this).data());
-    });
-  });
-})(jQuery);
-
-/* Tabs */
-(function($) {
-  'use strict';
-
-  /**
-   * @param {HTMLElement} el - The DOM element.
-   * @param {Object} options
-   * @constructor
-   */
-  function Tabs(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, Tabs.DEFAULTS_, options);
-    this.init();
-  }
-
-  Tabs.DEFAULTS_ = {
-    activeClass: 'dac-active',
-    viewDataAttr: 'tab-view',
-    itemDataAttr: 'tab-item'
-  };
-
-  Tabs.prototype.init = function() {
-    var itemDataAttribute = '[data-' + this.options.itemDataAttr + ']';
-    this.tabEl_ = this.el.find(itemDataAttribute);
-    this.tabViewEl_ = this.el.find('[data-' + this.options.viewDataAttr + ']');
-    this.el.on('click.dac-tabs', itemDataAttribute, this.changeTabs.bind(this));
-  };
-
-  Tabs.prototype.changeTabs = function(event) {
-    var current = $(event.currentTarget);
-    var index = current.index();
-
-    if (current.hasClass(this.options.activeClass)) {
-      current.add(this.tabViewEl_.eq(index)).removeClass(this.options.activeClass);
-    } else {
-      this.tabEl_.add(this.tabViewEl_).removeClass(this.options.activeClass);
-      current.add(this.tabViewEl_.eq(index)).addClass(this.options.activeClass);
-    }
-  };
-
-  /**
-   * jQuery plugin
-   */
-  $.fn.dacTabs = function() {
-    return this.each(function() {
-      var el = $(this);
-      new Tabs(el, el.data());
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(function() {
-    $('[data-tabs]').dacTabs();
-  });
-})(jQuery);
-
-/* Toast Component */
-(function($) {
-  'use strict';
-  /**
-   * @constant
-   * @type {String}
-   */
-  var LOCAL_STORAGE_KEY = 'toast-closed-index';
-
-  /**
-   * Dictionary from local storage.
-   */
-  var toastDictionary = localStorage.getItem(LOCAL_STORAGE_KEY);
-  toastDictionary = toastDictionary ? JSON.parse(toastDictionary) : {};
-
-  /**
-   * Variable used for caching the body.
-   */
-  var bodyCached;
-
-  /**
-   * @param {HTMLElement} el - The DOM element.
-   * @param {Object} options
-   * @constructor
-   */
-  function Toast(el, options) {
-    this.el = $(el);
-    this.options = $.extend({}, Toast.DEFAULTS_, options);
-    this.init();
-  }
-
-  Toast.DEFAULTS_ = {
-    closeBtnClass: 'dac-toast-close-btn',
-    closeDuration: 200,
-    visibleClass: 'dac-visible',
-    wrapClass: 'dac-toast-wrap'
-  };
-
-  /**
-   * Generate a close button.
-   * @returns {*|HTMLElement}
-   */
-  Toast.prototype.closeBtn = function() {
-    this.closeBtnEl = this.closeBtnEl || $('<button class="' + this.options.closeBtnClass + '">' +
-      '<span class="dac-button dac-raised dac-primary">OK</span>' +
-    '</button>');
-    return this.closeBtnEl;
-  };
-
-  /**
-   * Initialize a new toast element
-   */
-  Toast.prototype.init = function() {
-    this.hash = this.el.text().replace(/[\s\n\t]/g, '').split('').slice(0, 128).join('');
-
-    if (toastDictionary[this.hash]) {
-      return;
-    }
-
-    this.closeBtn().on('click', this.onClickHandler.bind(this));
-    this.el.find('.' + this.options.wrapClass).append(this.closeBtn());
-    this.el.addClass(this.options.visibleClass);
-    this.dynamicPadding(this.el.outerHeight());
-  };
-
-  /**
-   * Add padding to make sure all page is visible.
-   */
-  Toast.prototype.dynamicPadding = function(val) {
-    var currentPadding = parseInt(bodyCached.css('padding-bottom') || 0);
-    bodyCached.css('padding-bottom', val + currentPadding);
-  };
-
-  /**
-   * Remove a toast from the DOM
-   */
-  Toast.prototype.remove = function() {
-    this.dynamicPadding(-this.el.outerHeight());
-    this.el.remove();
-  };
-
-  /**
-   * Handle removal of the toast.
-   */
-  Toast.prototype.onClickHandler = function() {
-    // Only fadeout toasts from top of stack. Others are removed immediately.
-    var duration = this.el.index() === 0 ? this.options.closeDuration : 0;
-    this.el.fadeOut(duration, this.remove.bind(this));
-
-    // Save closed state.
-    toastDictionary[this.hash] = 1;
-    localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(toastDictionary));
-  };
-
-  /**
-   * jQuery plugin
-   * @param  {object} options - Override default options.
-   */
-  $.fn.dacToast = function() {
-    return this.each(function() {
-      var el = $(this);
-      new Toast(el, el.data());
-    });
-  };
-
-  /**
-   * Data Attribute API
-   */
-  $(function() {
-    bodyCached = $('#body-content');
-    $('[data-toast]').dacToast();
-  });
-})(jQuery);
-
-(function($) {
-  function Toggle(el) {
-    $(el).on('click.dac.togglesection', this.toggle);
-  }
-
-  Toggle.prototype.toggle = function() {
-    var $this = $(this);
-
-    var $parent = getParent($this);
-    var isExpanded = $parent.hasClass('is-expanded');
-
-    transitionMaxHeight($parent.find('.dac-toggle-content'), !isExpanded);
-    $parent.toggleClass('is-expanded');
-
-    return false;
-  };
-
-  function getParent($this) {
-    var selector = $this.attr('data-target');
-
-    if (!selector) {
-      selector = $this.attr('href');
-      selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '');
-    }
-
-    var $parent = selector && $(selector);
-
-    $parent = $parent && $parent.length ? $parent : $this.closest('.dac-toggle');
-
-    return $parent.length ? $parent : $this.parent();
-  }
-
-  /**
-   * Runs a transition of max-height along with responsive styles which hide or expand the element.
-   * @param $el
-   * @param visible
-   */
-  function transitionMaxHeight($el, visible) {
-    var contentHeight = $el.prop('scrollHeight');
-    var targetHeight = visible ? contentHeight : 0;
-    var duration = $el.transitionDuration();
-
-    // If we're hiding, first set the maxHeight we're transitioning from.
-    if (!visible) {
-      $el.css({
-          transitionDuration: '0s',
-          maxHeight: contentHeight + 'px'
-        })
-        .resolveStyles()
-        .css('transitionDuration', '');
-    }
-
-    // Transition to new state
-    $el.css('maxHeight', targetHeight);
-
-    // Reset maxHeight to css value after transition.
-    setTimeout(function() {
-      $el.css({
-          transitionDuration: '0s',
-          maxHeight: ''
-        })
-        .resolveStyles()
-        .css('transitionDuration', '');
-    }, duration);
-  }
-
-  // Utility to get the transition duration for the element.
-  $.fn.transitionDuration = function() {
-    var d = $(this).css('transitionDuration') || '0s';
-
-    return +(parseFloat(d) * (/ms/.test(d) ? 1 : 1000)).toFixed(0);
-  };
-
-  // jQuery plugin
-  $.fn.toggleSection = function(option) {
-    return this.each(function() {
-      var $this = $(this);
-      var data = $this.data('dac.togglesection');
-      if (!data) {$this.data('dac.togglesection', (data = new Toggle(this)));}
-      if (typeof option === 'string') {data[option].call($this);}
-    });
-  };
-
-  // Data api
-  $(document)
-    .on('click.toggle', '[data-toggle="section"]', Toggle.prototype.toggle);
-})(jQuery);
-
-(function(window) {
-  /**
-   * Media query breakpoints. Should match CSS.
-   */
-  var BREAKPOINTS = {
-    mobile: [0, 719],
-    tablet: [720, 959],
-    desktop: [960, 9999]
-  };
-
-  /**
-   * Fisher-Yates Shuffle (Knuth shuffle).
-   * @param {Array} input
-   * @returns {Array} shuffled array.
-   */
-  function shuffle(input) {
-    for (var i = input.length; i >= 0; i--) {
-      var randomIndex = Math.floor(Math.random() * (i + 1));
-      var randomItem = input[randomIndex];
-      input[randomIndex] = input[i];
-      input[i] = randomItem;
-    }
-
-    return input;
-  }
-
-  /**
-   * Matches media breakpoints like in CSS.
-   * @param {string} form of either mobile, tablet or desktop.
-   */
-  function matchesMedia(form) {
-    var breakpoint = BREAKPOINTS[form];
-    return window.innerWidth >= breakpoint[0] && window.innerWidth <= breakpoint[1];
-  }
-
-  window.util = {
-    shuffle: shuffle,
-    matchesMedia: matchesMedia
-  };
-})(window);
-
-(function($, window) {
-  'use strict';
-
-  var YouTubePlayer = (function() {
-    var player;
-
-    function VideoPlayer() {
-      this.mPlayerPaused = false;
-      this.doneSetup = false;
-    }
-
-    VideoPlayer.prototype.setup = function() {
-      // loads the IFrame Player API code asynchronously.
-      $.getScript('https://www.youtube.com/iframe_api');
-
-      // Add the shadowbox HTML to the body
-      $('body').prepend(
-'<div id="video-player" class="Video">' +
-  '<div id="video-overlay" class="Video-overlay" />' +
-  '<div class="Video-container">' +
-    '<div class="Video-frame">' +
-      '<span class="Video-loading">Loading&hellip;</span>' +
-      '<div id="youTubePlayer"></div>' +
-    '</div>' +
-    '<div class="Video-controls">' +
-      '<button id="picture-in-picture" class="Video-button Video-button--picture-in-picture">' +
-      '<button id="close-video" class="Video-button Video-button--close" />' +
-    '</div>' +
-  '</div>' +
-'</div>');
-
-      this.videoPlayer = $('#video-player');
-
-      var pictureInPictureButton = this.videoPlayer.find('#picture-in-picture');
-      pictureInPictureButton.on('click.aranja', this.toggleMinimizeVideo.bind(this));
-
-      var videoOverlay = this.videoPlayer.find('#video-overlay');
-      var closeButton = this.videoPlayer.find('#close-video');
-      var closeVideo = this.closeVideo.bind(this);
-      videoOverlay.on('click.aranja', closeVideo);
-      closeButton.on('click.aranja', closeVideo);
-
-      this.doneSetup = true;
-    };
-
-    VideoPlayer.prototype.startYouTubePlayer = function(videoId) {
-      this.videoPlayer.show();
-
-      if (!this.isLoaded) {
-        this.queueVideo = videoId;
-        return;
-      }
-
-      this.mPlayerPaused = false;
-      // check if we've already created this player
-      if (!this.youTubePlayer) {
-        // check if there's a start time specified
-        var idAndHash = videoId.split('#');
-        var startTime = 0;
-        if (idAndHash.length > 1) {
-          startTime = idAndHash[1].split('t=')[1] !== undefined ? idAndHash[1].split('t=')[1] : 0;
-        }
-        // enable localized player
-        var lang = getLangPref();
-        var captionsOn = lang === 'en' ? 0 : 1;
-
-        this.youTubePlayer = new YT.Player('youTubePlayer', {
-          height: 720,
-          width: 1280,
-          videoId: idAndHash[0],
-          // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
-          playerVars: {start: startTime, hl: lang, cc_load_policy: captionsOn},
-          // jscs:enable
-          events: {
-            'onReady': this.onPlayerReady.bind(this),
-            'onStateChange': this.onPlayerStateChange.bind(this)
-          }
-        });
-      } else {
-        // if a video different from the one already playing was requested, cue it up
-        if (videoId !== this.getVideoId()) {
-          this.youTubePlayer.cueVideoById(videoId);
-        }
-        this.youTubePlayer.playVideo();
-      }
-    };
-
-    VideoPlayer.prototype.onPlayerReady = function(event) {
-      if (!isMobile) {
-        event.target.playVideo();
-        this.mPlayerPaused = false;
-      }
-    };
-
-    VideoPlayer.prototype.toggleMinimizeVideo = function(event) {
-      event.stopPropagation();
-      this.videoPlayer.toggleClass('Video--picture-in-picture');
-    };
-
-    VideoPlayer.prototype.closeVideo = function() {
-      try {
-        this.youTubePlayer.pauseVideo();
-      } catch (e) {
-      }
-      this.videoPlayer.fadeOut(200, function() {
-        this.videoPlayer.removeClass('Video--picture-in-picture');
-      }.bind(this));
-    };
-
-    VideoPlayer.prototype.getVideoId = function() {
-      // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
-      return this.youTubePlayer && this.youTubePlayer.getVideoData().video_id;
-      // jscs:enable
-    };
-
-    /* Track youtube playback for analytics */
-    VideoPlayer.prototype.onPlayerStateChange = function(event) {
-      var videoId = this.getVideoId();
-      var currentTime = this.youTubePlayer && this.youTubePlayer.getCurrentTime();
-
-      // Video starts, send the video ID
-      if (event.data === YT.PlayerState.PLAYING) {
-        if (this.mPlayerPaused) {
-          devsite.analytics.trackAnalyticsEvent('event',
-              'Videos', 'Resume', videoId);
-        } else {
-          // track the start playing event so we know from which page the video was selected
-          devsite.analytics.trackAnalyticsEvent('event',
-              'Videos', 'Start: ' + videoId, 'on: ' + document.location.href);
-        }
-        this.mPlayerPaused = false;
-      }
-
-      // Video paused, send video ID and video elapsed time
-      if (event.data === YT.PlayerState.PAUSED) {
-        devsite.analytics.trackAnalyticsEvent('event',
-            'Videos', 'Paused: ' + videoId, 'on: ' + currentTime);
-        this.mPlayerPaused = true;
-      }
-
-      // Video finished, send video ID and video elapsed time
-      if (event.data === YT.PlayerState.ENDED) {
-        devsite.analytics.trackAnalyticsEvent('event',
-            'Videos', 'Finished: ' + videoId, 'on: ' + currentTime);
-        this.mPlayerPaused = true;
-      }
-    };
-
-    return {
-      getPlayer: function() {
-        if (!player) {
-          player = new VideoPlayer();
-        }
-
-        return player;
-      }
-    };
-  })();
-
-  var videoPlayer = YouTubePlayer.getPlayer();
-
-  window.onYouTubeIframeAPIReady = function() {
-    videoPlayer.isLoaded = true;
-
-    if (videoPlayer.queueVideo) {
-      videoPlayer.startYouTubePlayer(videoPlayer.queueVideo);
-    }
-  };
-
-  function wrapLinkInPlayer(e) {
-    e.preventDefault();
-
-    if (!videoPlayer.doneSetup) {
-      videoPlayer.setup();
-    }
-
-    var videoIdMatches = $(e.currentTarget).attr('href').match(/(?:youtu.be\/|v=)([^&]*)/);
-    var videoId = videoIdMatches && videoIdMatches[1];
-
-    if (videoId) {
-      videoPlayer.startYouTubePlayer(videoId);
-    }
-  }
-
-  $(document).on('click.video', 'a[href*="youtube.com/watch"], a[href*="youtu.be"]', wrapLinkInPlayer);
-})(jQuery, window);
-
-/**
- * Wide table
- *
- * Wraps tables in a scrollable area so you can read them on mobile.
- */
-(function($) {
-  function initWideTable() {
-    $('table.jd-sumtable').each(function(i, table) {
-      $(table).wrap('<div class="dac-expand wide-table">');
-    });
-  }
-
-  $(function() {
-    initWideTable();
-  });
-})(jQuery);
-
-/** Utilities */
-
-/* returns the given string with all HTML brackets converted to entities
-    TODO: move this to the site's JS library */
-function escapeHTML(string) {
-  return string.replace(/</g,"&lt;")
-                .replace(/>/g,"&gt;");
-};
-
-function getQueryVariable(variable) {
-  var query = window.location.search.substring(1);
-  var vars = query.split("&");
-  for (var i=0;i<vars.length;i++) {
-    var pair = vars[i].split("=");
-    if(pair[0] == variable){return pair[1];}
-  }
-  return(false);
-};
diff --git a/tools/droiddoc/templates-sdk/assets/js/prettify.js b/tools/droiddoc/templates-sdk/assets/js/prettify.js
deleted file mode 100644
index eef5ad7..0000000
--- a/tools/droiddoc/templates-sdk/assets/js/prettify.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
-(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
-[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
-f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
-(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
-{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
-t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
-"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
-l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
-q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
-q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
-"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
-a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
-for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
-m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
-a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
-j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
-"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
-H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
-J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
-I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
-["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
-/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
-["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
-hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
-!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
-250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
-PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
diff --git a/tools/droiddoc/templates-sdk/body_tag.cs b/tools/droiddoc/templates-sdk/body_tag.cs
deleted file mode 100644
index 5761b71..0000000
--- a/tools/droiddoc/templates-sdk/body_tag.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-<body class="gc-documentation <?cs
-  if:(reference.gms || reference.gcm)
-    ?>google<?cs
-  /if ?><?cs
-  if:(guide||develop||training||reference||tools||sdk)
-    ?>develop<?cs
-    if:reference
-      ?> reference api apilevel-<?cs var:class.since ?><?cs var:package.since ?><?cs
-    /if ?><?cs
-  elif:design
-    ?>design<?cs
-  elif:distribute
-    ?>distribute<?cs
-  /if ?>">
-<div id="doc-api-level" class="<?cs var:class.since ?><?cs var:package.since ?>" style="display:none"></div>
diff --git a/tools/droiddoc/templates-sdk/class.cs b/tools/droiddoc/templates-sdk/class.cs
deleted file mode 100644
index dee7a4c..0000000
--- a/tools/droiddoc/templates-sdk/class.cs
+++ /dev/null
@@ -1,646 +0,0 @@
-<?cs # THIS CREATES A CLASS OR INTERFACE PAGE FROM .java FILES ?>
-<?cs include:"macros.cs" ?>
-<?cs include:"macros_override.cs" ?>
-<?cs
-####################
-# MACRO FUNCTION USED ONLY IN THIS TEMPLATE TO GENERATE API REFERENCE
-# FIRST, THE FUNCTIONS FOR THE SUMMARY AT THE TOP OF THE PAGE
-####################
-?>
-
-<?cs
-# Prints the table cells for the summary of methods.
-?><?cs def:write_method_summary(methods, included) ?>
-<?cs set:count = #1 ?>
-<?cs each:method = methods ?>
-  <?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-  <tr class="api apilevel-<?cs var:method.since ?>" >
-  <?cs # leave out this cell if there is no return type = if constructors ?>
-  <?cs if:subcount(method.returnType) ?>
-    <td><code>
-        <?cs var:method.abstract ?>
-        <?cs var:method.default ?>
-        <?cs var:method.static ?>
-        <?cs var:method.final ?>
-        <?cs call:type_link(method.generic) ?>
-        <?cs call:type_link(method.returnType) ?></code>
-    </td>
-  <?cs /if ?>
-    <td width="100%">
-      <code>
-      <?cs call:cond_link(method.name, toroot, method.href, included) ?>(<?cs call:parameter_list(method.params, 0) ?>)
-      </code>
-      <?cs if:subcount(method.shortDescr) || subcount(method.deprecated) ?>
-        <p><?cs call:short_descr(method) ?>
-        <?cs call:show_annotations_list(method) ?></p>
-      <?cs /if ?>
-    </td>
-  </tr>
-  <?cs set:count = count + #1 ?>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs
-# Print the table cells for the summary of fields.
-?><?cs def:write_field_summary(fields, included) ?>
-<?cs set:count = #1 ?>
-<?cs each:field=fields ?>
-  <tr class="api apilevel-<?cs var:field.since ?>" >
-    <td><code>
-    <?cs var:field.scope ?>
-    <?cs var:field.static ?>
-    <?cs var:field.final ?>
-    <?cs call:type_link(field.type) ?></code></td>
-    <td width="100%">
-      <code><?cs call:cond_link(field.name, toroot, field.href, included) ?></code>
-      <p><?cs call:short_descr(field) ?>
-      <?cs call:show_annotations_list(field) ?></p>
-    </td>
-  </tr>
-  <?cs set:count = count + #1 ?>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs
-# Print the table cells for the summary of constants
-?><?cs def:write_constant_summary(fields, included) ?>
-<?cs set:count = #1 ?>
-    <?cs each:field=fields ?>
-    <tr class="api apilevel-<?cs var:field.since ?>" >
-        <td><code><?cs call:type_link(field.type) ?></code></td>
-        <td width="100%">
-          <code><?cs call:cond_link(field.name, toroot, field.href, included) ?></code>
-          <p><?cs call:short_descr(field) ?>
-          <?cs call:show_annotations_list(field) ?></p>
-        </td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs
-# Print the table cells for the summary of attributes
-?><?cs def:write_attr_summary(attrs, included) ?>
-<?cs set:count = #1 ?>
-    <?cs each:attr=attrs ?>
-    <tr class="api apilevel-<?cs var:attr.since ?>" >
-        <td><?cs if:included ?><a href="<?cs var:toroot ?><?cs var:attr.href ?>"><?cs /if
-          ?><code><?cs var:attr.name ?></code><?cs if:included ?></a><?cs /if ?></td>
-        <td width="100%">
-          <?cs call:short_descr(attr) ?>&nbsp;
-          <?cs call:show_annotations_list(attr) ?>
-        </td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs
-# Print the table cells for the inner classes
-?><?cs def:write_inners_summary(classes) ?>
-<?cs set:count = #1 ?>
-  <?cs each:cl=class.inners ?>
-    <tr class="api apilevel-<?cs var:cl.since ?>" >
-      <td class="jd-typecol"><code>
-        <?cs var:cl.scope ?>
-        <?cs var:cl.static ?>
-        <?cs var:cl.final ?>
-        <?cs var:cl.abstract ?>
-        <?cs var:cl.kind ?></code></td>
-      <td class="jd-descrcol" width="100%">
-        <code><?cs call:type_link(cl.type) ?></code>
-        <p><?cs call:short_descr(cl) ?>&nbsp;
-        <?cs call:show_annotations_list(cl) ?></p>
-      </td>
-    </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-<?cs /def ?>
-<?cs
-###################
-# END OF FUNCTIONS FOR API SUMMARY
-# START OF FUNCTIONS FOR THE API DETAILS
-###################
-?>
-<?cs
-# Print the table cells for the summary of constants
-?>
-<?cs def:write_field_details(fields) ?>
-<?cs each:field=fields ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<?cs # the A tag in the next line must remain where it is, so that Eclipse can parse the docs ?>
-<A NAME="<?cs var:field.anchor ?>"></A>
-<?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-<div class="api apilevel-<?cs var:field.since ?>">
-    <h3 class="api-name"><?cs var:field.name ?></h3>
-    <div class="api-level">
-      <?cs call:since_tags(field) ?>
-      <?cs call:federated_refs(field) ?>
-    </div>
-<pre class="api-signature no-pretty-print">
-<?cs if:subcount(field.scope) ?><?cs var:field.scope
-?> <?cs /if ?><?cs if:subcount(field.static) ?><?cs var:field.static
-?> <?cs /if ?><?cs if:subcount(field.final) ?><?cs var:field.final
-?> <?cs /if ?><?cs if:subcount(field.type) ?><?cs call:type_link(field.type)
-?> <?cs /if ?><?cs var:field.name ?></pre>
-    <?cs call:show_annotations_list(field) ?>
-    <?cs call:description(field) ?>
-    <?cs if:subcount(field.constantValue) ?>
-      <p>Constant Value:
-      <?cs if:field.constantValue.isString ?>
-          <?cs var:field.constantValue.str ?>
-      <?cs else ?>
-          <?cs var:field.constantValue.dec ?>
-          (<?cs var:field.constantValue.hex ?>)
-      <?cs /if ?>
-    <?cs /if ?>
-</div>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_method_details(methods) ?>
-<?cs each:method=methods ?>
-<?cs # the A tag in the next line must remain where it is, so that Eclipse can parse the docs ?>
-<A NAME="<?cs var:method.anchor ?>"></A>
-<?cs # The apilevel-N class MUST BE LAST in the sequence of class names ?>
-<div class="api apilevel-<?cs var:method.since ?>">
-    <h3 class="api-name"><?cs var:method.name ?></h3>
-    <div class="api-level">
-      <div><?cs call:since_tags(method) ?></div>
-      <?cs call:federated_refs(method) ?>
-    </div>
-<pre class="api-signature no-pretty-print">
-<?cs if:subcount(method.scope) ?><?cs var:method.scope
-?> <?cs /if ?><?cs if:subcount(method.static) ?><?cs var:method.static
-?> <?cs /if ?><?cs if:subcount(method.final) ?><?cs var:method.final
-?> <?cs /if ?><?cs if:subcount(method.abstract) ?><?cs var:method.abstract
-?> <?cs /if ?><?cs if:subcount(method.returnType) ?><?cs call:type_link(method.returnType)
-?> <?cs /if ?><?cs var:method.name ?> (<?cs call:parameter_list(method.params, 1) ?>)</pre>
-    <?cs call:show_annotations_list(method) ?>
-    <?cs call:description(method) ?>
-</div>
-<?cs /each ?>
-<?cs /def ?>
-
-<?cs def:write_attr_details(attrs) ?>
-<?cs each:attr=attrs ?>
-<?cs # the A tag in the next line must remain where it is, so that Eclipse can parse the docs ?>
-<A NAME="<?cs var:attr.anchor ?>"></A>
-<h3 class="api-name"><?cs var:attr.name ?></h3>
-<?cs call:show_annotations_list(attr) ?>
-<?cs call:description(attr) ?>
-<?cs if:subcount(attr.methods) ?>
-  <p><b>Related methods:</b></p>
-  <ul class="nolist">
-  <?cs each:m=attr.methods ?>
-    <li><a href="<?cs var:toroot ?><?cs var:m.href ?>"><?cs var:m.name ?></a></li>
-  <?cs /each ?>
-  </ul>
-<?cs /if ?>
-<?cs /each ?>
-<?cs /def ?>
-<?cs
-#########################
-# END OF MACROS
-# START OF PAGE PRINTING
-#########################
-?>
-<?cs include:"doctype.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"body_tag.cs" ?>
-<?cs include:"header.cs" ?>
-<?cs include:"page_info.cs" ?>
-<?cs # This DIV spans the entire document to provide scope for some scripts ?>
-<div class="api apilevel-<?cs var:class.since ?>" id="jd-content">
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== START OF CLASS DATA ======== -->
-<?cs
-#
-# Page header with class name and signature
-#
-?>
-<h1 class="api-title"><?cs var:class.name ?></h1>
-<p>
-<code class="api-signature">
-  <?cs var:class.scope ?>
-  <?cs var:class.static ?>
-  <?cs var:class.final ?>
-  <?cs var:class.abstract ?>
-  <?cs var:class.kind ?>
-  <?cs var:class.name ?>
-</code>
-<br>
-<?cs set:colspan = subcount(class.inheritance) ?>
-<?cs each:supr = class.inheritance ?>
-<code class="api-signature">
-  <?cs if:colspan == 2 ?>
-    extends <?cs call:type_link(supr.short_class) ?>
-  <?cs /if ?>
-  <?cs if:last(supr) && subcount(supr.interfaces) ?>
-      implements
-      <?cs each:t=supr.interfaces ?>
-        <?cs call:type_link(t) ?><?cs
-          if: name(t)!=subcount(supr.interfaces)-1
-            ?>, <?cs /if ?>
-      <?cs /each ?>
-  <?cs /if ?>
-  <?cs set:colspan = colspan-1 ?>
-</code>
-<?cs /each ?>
-</p><?cs
-#
-# Class inheritance tree
-#
-?><table class="jd-inheritance-table">
-<?cs set:colspan = subcount(class.inheritance) ?>
-<?cs each:supr = class.inheritance ?>
-  <tr>
-    <?cs loop:i = 1, (subcount(class.inheritance)-colspan), 1 ?>
-      <td class="jd-inheritance-space">&nbsp;<?cs
-        if:(subcount(class.inheritance)-colspan) == i
-          ?>&nbsp;&nbsp;&#x21b3;<?cs
-        /if ?></td>
-    <?cs /loop ?>
-    <td colspan="<?cs var:colspan ?>" class="jd-inheritance-class-cell"><?cs
-      if:colspan == 1
-          ?><?cs call:class_name(class.qualifiedType) ?><?cs
-      else
-          ?><?cs call:type_link(supr.class) ?><?cs
-      /if ?>
-    </td>
-  </tr>
-  <?cs set:colspan = colspan-1 ?>
-<?cs /each ?>
-</table><?cs
-#
-# Collapsible list of subclasses
-#
-?><?cs
-if:subcount(class.subclasses.direct) && !class.subclasses.hidden ?>
-  <table class="jd-sumtable jd-sumtable-subclasses">
-  <tr><td style="border:none;margin:0;padding:0;">
-    <?cs call:expando_trigger("subclasses-direct", "closed") ?>Known Direct Subclasses
-    <?cs call:expandable_class_list("subclasses-direct", class.subclasses.direct, "list") ?>
-  </td></tr>
-  </table>
-  <?cs /if ?>
-  <?cs if:subcount(class.subclasses.indirect) && !class.subclasses.hidden ?>
-  <table class="jd-sumtable jd-sumtable-subclasses"><tr><td colspan="2" style="border:none;margin:0;padding:0;">
-  <?cs call:expando_trigger("subclasses-indirect", "closed") ?>Known Indirect Subclasses
-  <?cs call:expandable_class_list("subclasses-indirect", class.subclasses.indirect, "list") ?>
-  </td></tr></table><?cs
-/if ?>
-<?cs call:show_annotations_list(class) ?>
-<br><hr><?cs
-#
-# The long-form class description.
-#
-?><?cs call:deprecated_warning(class) ?>
-
-<?cs if:subcount(class.descr) ?>
-  <p><?cs call:tag_list(class.descr) ?></p>
-<?cs /if ?>
-
-<?cs call:see_also_tags(class.seeAlso) ?>
-<?cs
-#################
-# CLASS SUMMARY
-#################
-?>
-<?cs # make sure there is a summary view to display ?>
-<?cs if:subcount(class.inners)
-     || subcount(class.attrs)
-     || inhattrs
-     || subcount(class.enumConstants)
-     || subcount(class.constants)
-     || inhconstants
-     || subcount(class.fields)
-     || inhfields
-     || subcount(class.ctors.public)
-     || subcount(class.ctors.protected)
-     || subcount(class.methods.public)
-     || subcount(class.methods.protected)
-     || inhmethods ?>
-<h2 class="api-section">Summary</h2>
-
-<?cs if:subcount(class.inners) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== NESTED CLASS SUMMARY ======== -->
-<table id="nestedclasses" class="responsive">
-<tr><th colspan="2"><h3>Nested classes</h3></th></tr>
-<?cs call:write_inners_summary(class.inners) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<?cs if:subcount(class.attrs) ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="lattrs" class="responsive">
-<tr><th colspan="2"><h3>XML attributes</h3></th></tr>
-<?cs call:write_attr_summary(class.attrs, 1) ?>
-<?cs /if ?>
-
-<?cs # if there are inherited attrs, write the table ?>
-<?cs if:inhattrs ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="inhattrs" class="responsive inhtable">
-<tr><th><h3>Inherited XML attributes</h3></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.attrs) ?>
-<tr class="api apilevel-<?cs var:cl.since ?>" >
-<td colspan="2">
-<?cs call:expando_trigger("inherited-attrs-"+cl.qualified, "closed") ?>From
-<?cs var:cl.kind ?>
-<code>
-  <?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-</code>
-<div id="inherited-attrs-<?cs var:cl.qualified ?>">
-  <div id="inherited-attrs-<?cs var:cl.qualified ?>-list"
-        class="jd-inheritedlinks">
-  </div>
-  <div id="inherited-attrs-<?cs var:cl.qualified ?>-summary" style="display: none;">
-    <table class="jd-sumtable-expando">
-    <?cs call:write_attr_summary(cl.attrs, cl.included) ?></table>
-  </div>
-</div>
-</td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.enumConstants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== ENUM CONSTANT SUMMARY =========== -->
-<table id="enumconstants" class="responsive constants">
-  <tr><th colspan="2"><h3>Enum values</h3></th></tr>
-<?cs set:count = #1 ?>
-  <?cs each:field=class.enumConstants ?>
-  <tr class="api apilevel-<?cs var:field.since ?>" >
-    <td><code><?cs call:type_link(field.type) ?></code>&nbsp;</td>
-    <td width="100%">
-      <code><?cs call:cond_link(field.name, toroot, field.href, cl.included) ?></code>
-      <p><?cs call:short_descr(field) ?>&nbsp;
-      <?cs call:show_annotations_list(field) ?></p>
-    </td>
-  </tr>
-  <?cs set:count = count + #1 ?>
-  <?cs /each ?>
-<?cs /if ?>
-
-<?cs if:subcount(class.constants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== ENUM CONSTANT SUMMARY =========== -->
-<table id="constants" class="responsive constants">
-<tr><th colspan="2"><h3>Constants</h3></th></tr>
-<?cs call:write_constant_summary(class.constants, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs # if there are inherited constants, write the table ?>
-<?cs if:inhconstants ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== ENUM CONSTANT SUMMARY =========== -->
-<table id="inhconstants" class="responsive constants inhtable">
-<tr><th><h3>Inherited constants</h3></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.constants) ?>
-  <tr class="api apilevel-<?cs var:cl.since ?>" >
-  <td>
-  <?cs call:expando_trigger("inherited-constants-"+cl.qualified, "closed") ?>From
-  <?cs var:cl.kind ?>
-  <code>
-    <?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-  </code>
-  <div id="inherited-constants-<?cs var:cl.qualified ?>">
-    <div id="inherited-constants-<?cs var:cl.qualified ?>-list"
-          class="jd-inheritedlinks">
-    </div>
-    <div id="inherited-constants-<?cs var:cl.qualified ?>-summary" style="display: none;">
-      <table class="jd-sumtable-expando responsive">
-      <?cs call:write_constant_summary(cl.constants, cl.included) ?></table>
-    </div>
-  </div>
-  </td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.fields) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="lfields" class="responsive properties">
-<tr><th colspan="2"><h3>Fields</h3></th></tr>
-<?cs call:write_field_summary(class.fields, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs # if there are inherited fields, write the table ?>
-<?cs if:inhfields ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- =========== FIELD SUMMARY =========== -->
-<table id="inhfields" class="properties inhtable">
-<tr><th><h3>Inherited fields</h3></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.fields) ?>
-  <tr class="api apilevel-<?cs var:cl.since ?>" >
-  <td>
-  <?cs call:expando_trigger("inherited-fields-"+cl.qualified, "closed") ?>From
-  <?cs var:cl.kind ?>
-  <code>
-    <?cs call:cond_link(cl.qualified, toroot, cl.link, cl.included) ?>
-  </code>
-  <div id="inherited-fields-<?cs var:cl.qualified ?>">
-    <div id="inherited-fields-<?cs var:cl.qualified ?>-list"
-          class="jd-inheritedlinks">
-    </div>
-    <div id="inherited-fields-<?cs var:cl.qualified ?>-summary" style="display: none;">
-      <table class="jd-sumtable-expando responsive">
-      <?cs call:write_field_summary(cl.fields, cl.included) ?></table>
-    </div>
-  </div>
-  </td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.ctors.public) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== CONSTRUCTOR SUMMARY ======== -->
-<table id="pubctors" class="responsive constructors">
-<tr><th colspan="2"><h3>Public constructors</h3></th></tr>
-<?cs call:write_method_summary(class.ctors.public, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.ctors.protected) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ======== CONSTRUCTOR SUMMARY ======== -->
-<table id="proctors" class="responsive constructors">
-<tr><th colspan="2"><h3>Protected constructors</h3></th></tr>
-<?cs call:write_method_summary(class.ctors.protected, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.methods.public) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========== METHOD SUMMARY =========== -->
-<table id="pubmethods" class="responsive methods">
-<tr><th colspan="2"><h3>Public methods</h3></th></tr>
-<?cs call:write_method_summary(class.methods.public, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs if:subcount(class.methods.protected) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========== METHOD SUMMARY =========== -->
-<table id="promethods" class="reponsive methods">
-<tr><th colspan="2"><h3>Protected methods</h3></th></tr>
-<?cs call:write_method_summary(class.methods.protected, 1) ?>
-</table>
-<?cs /if ?>
-
-<?cs # if there are inherited methods, write the table ?>
-<?cs if:inhmethods ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========== METHOD SUMMARY =========== -->
-<table id="inhmethods" class="methods inhtable">
-<tr><th><h3>Inherited methods</h3></th></tr>
-<?cs each:cl=class.inherited ?>
-<?cs if:subcount(cl.methods) ?>
-<tr class="api apilevel-<?cs var:cl.since ?>" >
-<td colspan="2">
-<?cs call:expando_trigger("inherited-methods-"+cl.qualified, "closed") ?>From
-<?cs var:cl.kind ?>
-<code>
-  <?cs if:cl.included ?>
-    <a href="<?cs var:toroot ?><?cs var:cl.link ?>"><?cs var:cl.qualified ?></a>
-  <?cs elif:cl.federated ?>
-    <a href="<?cs var:cl.link ?>"><?cs var:cl.qualified ?></a>
-  <?cs else ?>
-    <?cs var:cl.qualified ?>
-  <?cs /if ?>
-</code>
-<div id="inherited-methods-<?cs var:cl.qualified ?>">
-  <div id="inherited-methods-<?cs var:cl.qualified ?>-list"
-        class="jd-inheritedlinks">
-  </div>
-  <div id="inherited-methods-<?cs var:cl.qualified ?>-summary" style="display: none;">
-    <table class="jd-sumtable-expando responsive">
-      <?cs call:write_method_summary(cl.methods, cl.included) ?>
-    </table>
-  </div>
-</div>
-</td></tr>
-<?cs /if ?>
-<?cs /each ?>
-</table>
-<?cs /if ?>
-<?cs /if ?>
-<?cs
-################
-# CLASS DETAILS
-################
-?>
-<!-- XML Attributes -->
-<?cs if:subcount(class.attrs) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= FIELD DETAIL ======== -->
-<h2 class="api-section">XML attributes</h2>
-<?cs call:write_attr_details(class.attrs) ?>
-<?cs /if ?>
-
-<!-- Enum Values -->
-<?cs if:subcount(class.enumConstants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= ENUM CONSTANTS DETAIL ======== -->
-<h2 class="api-section">Enum values</h2>
-<?cs call:write_field_details(class.enumConstants) ?>
-<?cs /if ?>
-
-<!-- Constants -->
-<?cs if:subcount(class.constants) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= ENUM CONSTANTS DETAIL ======== -->
-<h2 class="api-section">Constants</h2>
-<?cs call:write_field_details(class.constants) ?>
-<?cs /if ?>
-
-<!-- Fields -->
-<?cs if:subcount(class.fields) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= FIELD DETAIL ======== -->
-<h2 class="api-section">Fields</h2>
-<?cs call:write_field_details(class.fields) ?>
-<?cs /if ?>
-
-<!-- Public ctors -->
-<?cs if:subcount(class.ctors.public) ?>
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= CONSTRUCTOR DETAIL ======== -->
-<h2 class="api-section">Public constructors</h2>
-<?cs call:write_method_details(class.ctors.public) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= CONSTRUCTOR DETAIL ======== -->
-<!-- Protected ctors -->
-<?cs if:subcount(class.ctors.protected) ?>
-<h2 class="api-section">Protected constructors</h2>
-<?cs call:write_method_details(class.ctors.protected) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= METHOD DETAIL ======== -->
-<!-- Public methdos -->
-<?cs if:subcount(class.methods.public) ?>
-<h2 class="api-section">Public methods</h2>
-<?cs call:write_method_details(class.methods.public) ?>
-<?cs /if ?>
-
-<?cs # this next line must be exactly like this to be parsed by eclipse ?>
-<!-- ========= METHOD DETAIL ======== -->
-<?cs if:subcount(class.methods.protected) ?>
-<h2 class="api-section">Protected methods</h2>
-<?cs call:write_method_details(class.methods.protected) ?>
-<?cs /if ?>
-
-<?cs # the next two lines must be exactly like this to be parsed by eclipse ?>
-<!-- ========= END OF CLASS DATA ========= -->
-
-</div><!-- end jd-content -->
-
-<?cs if:devsite ?>
-
-<div class="data-reference-resources-wrapper">
-  <?cs if:subcount(class.package) ?>
-  <ul data-reference-resources>
-    <?cs call:list("Annotations", class.package.annotations) ?>
-    <?cs call:list("Interfaces", class.package.interfaces) ?>
-    <?cs call:list("Classes", class.package.classes) ?>
-    <?cs call:list("Enums", class.package.enums) ?>
-    <?cs call:list("Exceptions", class.package.exceptions) ?>
-    <?cs call:list("Errors", class.package.errors) ?>
-  </ul>
-  <?cs elif:subcount(package) ?>
-  <ul data-reference-resources>
-    <?cs call:class_link_list("Annotations", package.annotations) ?>
-    <?cs call:class_link_list("Interfaces", package.interfaces) ?>
-    <?cs call:class_link_list("Classes", package.classes) ?>
-    <?cs call:class_link_list("Enums", package.enums) ?>
-    <?cs call:class_link_list("Exceptions", package.exceptions) ?>
-    <?cs call:class_link_list("Errors", package.errors) ?>
-  </ul>
-  <?cs /if ?>
-</div>
-<?cs /if ?>
-
-<?cs if:!devsite ?>
-<?cs include:"footer.cs" ?>
-<?cs include:"trailer.cs" ?>
-<?cs /if ?>
-</body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/classes.cs b/tools/droiddoc/templates-sdk/classes.cs
deleted file mode 100644
index 007b57e..0000000
--- a/tools/droiddoc/templates-sdk/classes.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-<?cs # THIS CREATES A LIST OF ALL PACKAGES AND NAMES IT packages.html ?>
-<?cs include:"macros.cs" ?>
-<?cs include:"macros_override.cs" ?>
-<?cs include:"doctype.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"body_tag.cs" ?>
-<?cs include:"header.cs" ?>
-
-<h1><?cs var:page.title ?></h1>
-<p>These are the API classes. See all
-<a href="packages.html">API packages</a>.</p>
-
-<div class="jd-letterlist"><?cs
-  each:letter=docs.classes ?>
-    <a href="#letter_<?cs name:letter ?>"><?cs
-      name:letter ?></a>&nbsp;&nbsp;<?cs
-  /each?>
-</div>
-
-<?cs each:letter=docs.classes ?>
-<?cs set:count = #1 ?>
-<h2 id="letter_<?cs name:letter ?>"><?cs name:letter ?></h2>
-<table>
-    <?cs set:cur_row = #0 ?>
-    <?cs each:cl = letter ?>
-        <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:cl.since ?>" >
-            <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td>
-            <td class="jd-descrcol" width="100%">
-              <?cs call:short_descr(cl) ?>&nbsp;
-              <?cs call:show_annotations_list(cl) ?>
-            </td>
-        </tr>
-    <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-</table>
-<?cs /each ?>
-
-<?cs if:devsite ?>
-<div class="data-reference-resources-wrapper">
-  <?cs if:subcount(class.package) ?>
-  <ul data-reference-resources>
-    <?cs call:list("Annotations", class.package.annotations) ?>
-    <?cs call:list("Interfaces", class.package.interfaces) ?>
-    <?cs call:list("Classes", class.package.classes) ?>
-    <?cs call:list("Enums", class.package.enums) ?>
-    <?cs call:list("Exceptions", class.package.exceptions) ?>
-    <?cs call:list("Errors", class.package.errors) ?>
-  </ul>
-  <?cs elif:subcount(package) ?>
-  <ul data-reference-resources>
-    <?cs call:class_link_list("Annotations", package.annotations) ?>
-    <?cs call:class_link_list("Interfaces", package.interfaces) ?>
-    <?cs call:class_link_list("Classes", package.classes) ?>
-    <?cs call:class_link_list("Enums", package.enums) ?>
-    <?cs call:class_link_list("Exceptions", package.exceptions) ?>
-    <?cs call:class_link_list("Errors", package.errors) ?>
-  </ul>
-  <?cs /if ?>
-</div>
-<?cs /if ?>
-
-
-<?cs if:!devsite ?>
-<?cs include:"footer.cs" ?>
-<?cs include:"trailer.cs" ?>
-<?cs /if ?>
-</body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs
deleted file mode 100644
index 1fef965..0000000
--- a/tools/droiddoc/templates-sdk/components/masthead.cs
+++ /dev/null
@@ -1,322 +0,0 @@
-<?cs def:custom_masthead() ?>
-  <a name="top"></a>
-  <!-- Header -->
-  <div id="header-wrapper">
-    <div class="dac-header <?cs if:ndk ?>dac-ndk<?cs /if ?>" id="header">
-      <div class="dac-header-inner">
-        <a class="dac-nav-toggle" data-dac-toggle-nav href="javascript:;" title="Open navigation">
-          <span class="dac-nav-hamburger">
-            <span class="dac-nav-hamburger-top"></span>
-            <span class="dac-nav-hamburger-mid"></span>
-            <span class="dac-nav-hamburger-bot"></span>
-          </span>
-        </a>
-        <?cs if:ndk ?><a class="dac-header-logo" style="width:144px;" href="<?cs var:toroot
-        ?>ndk/index.html">
-          <img class="dac-header-logo-image" src="<?cs var:toroot ?>assets/images/android_logo.png"
-              srcset="<?cs var:toroot ?>assets/images/[email protected] 2x"
-              width="32" height="36" alt="Android" /> NDK
-          </a><?cs else ?><a class="dac-header-logo" href="<?cs var:toroot ?>index.html">
-          <img class="dac-header-logo-image" src="<?cs var:toroot ?>assets/images/android_logo.png"
-              srcset="<?cs var:toroot ?>assets/images/[email protected] 2x"
-              width="32" height="36" alt="Android" /> Developers
-          </a><?cs /if ?>
-
-        <?cs if:ndk
-        ?><ul class="dac-header-tabs">
-          <li>
-            <a href="<?cs var:toroot ?>ndk/guides/index.html" class="dac-header-tab"
-            zh-tw-lang="API 指南"
-            zh-cn-lang="API 指南"
-            ru-lang="Руководства по API"
-            ko-lang="API 가이드"
-            ja-lang="API ガイド"
-            es-lang="Guías de la API">Guides</a>
-          </li>
-          <li>
-            <a href="<?cs var:toroot ?>ndk/reference/index.html" class="dac-header-tab"
-            zh-tw-lang="參考資源"
-            zh-cn-lang="参考"
-            ru-lang="Справочник"
-            ko-lang="참조문서"
-            ja-lang="リファレンス"
-            es-lang="Referencia">Reference</a>
-          </li>
-          <li>
-            <a href="<?cs var:toroot ?>ndk/samples/index.html" class="dac-header-tab"
-           >Samples</a>
-          </li>
-          <li>
-            <a href="<?cs var:toroot ?>ndk/downloads/index.html" class="dac-header-tab"
-            >Downloads</a>
-          </li>
-        </ul><?cs else
-        ?><?cs
-        #
-        # For the reference only docs, include just one tab
-        #
-        ?><?cs if:referenceonly
-          ?><ul class="dac-header-tabs">
-            <li><a href="<?cs var:toroot ?>reference/packages.html" class="dac-header-tab"><?cs
-              if:sdk.preview
-                ?>Android <?cs var:sdk.codename ?>
-                  Preview <?cs var:sdk.preview.version ?><?cs
-              else
-                ?>Android <?cs var:sdk.version ?>
-                  r<?cs var:sdk.rel.id ?><?cs
-              /if ?></a>
-            </li>
-          </ul>
-        <?cs else ?><?cs
-        #
-        # End reference only docs, now the online DAC tabs...
-        #
-        ?><ul class="dac-header-tabs">
-          <li>
-          <a class="dac-header-tab" href="<?cs var:toroot ?>design/index.html"
-             zh-tw-lang="設計"
-             zh-cn-lang="设计"
-             ru-lang="Проектирование"
-             ko-lang="디자인"
-             ja-lang="設計"
-             es-lang="Diseñar">Design</a>
-          </li>
-          <li>
-          <a class="dac-header-tab" href="<?cs var:toroot ?>develop/index.html"
-             zh-tw-lang="開發"
-             zh-cn-lang="开发"
-             ru-lang="Разработка"
-             ko-lang="개발"
-             ja-lang="開発"
-             es-lang="Desarrollar">Develop</a>
-          </li>
-          <li>
-          <a class="dac-header-tab" href="<?cs var:toroot ?>distribute/index.html"
-             zh-tw-lang="發佈"
-             zh-cn-lang="分发"
-             ru-lang="Распространение"
-             ko-lang="배포"
-             ja-lang="配布"
-             es-lang="Distribuir">Distribute</a>
-          </li>
-        </ul><?cs
-        /if ?><?cs
-        #
-        # End if/else reference only docs
-        #
-        ?><?cs
-        /if ?><?cs # end if/else ndk ?>
-
-        <?cs if:ndk ?><a class="dac-header-console-btn" href="http://developer.android.com">
-          Back to Android Developers
-        </a><?cs else ?><a class="dac-header-console-btn" href="https://play.google.com/apps/publish/">
-          <span class="dac-sprite dac-google-play"></span>
-          <span class="dac-visible-desktop-inline">Developer</span>
-          Console
-        </a><?cs /if ?><?cs
-
-        # ADD SEARCH AND MENU ?><?cs
-        if:!ndk ?><?cs
-          if:!referenceonly ?><?cs
-            call:header_search_widget() ?><?cs
-          /if ?><?cs
-        /if ?>
-      </div><!-- end header-wrap.wrap -->
-    </div><!-- end header -->
-  </div> <!--end header-wrapper -->
-
-  <?cs if:ndk ?>
-  <!-- NDK Navigation-->
-  <nav class="dac-nav">
-    <div class="dac-nav-dimmer" data-dac-toggle-nav></div>
-
-    <div class="dac-nav-sidebar" data-swap data-dynamic="false" data-transition-speed="300" data-dac-nav>
-                   <div data-swap-container>
-        <?cs call:custom_left_nav() ?>
-      <ul id="dac-main-navigation" class="dac-nav-list dac-swap-section dac-left dac-no-anim">
-      <li class="dac-nav-item guides">
-        <a class="dac-nav-link" href="<?cs var:toroot ?>ndk/guides/index.html"
-           zh-tw-lang="API 指南"
-           zh-cn-lang="API 指南"
-           ru-lang="Руководства по API"
-           ko-lang="API 가이드"
-           ja-lang="API ガイド"
-           es-lang="Guías de la API">Guides</a>
-      </li>
-      <li class="dac-nav-item reference">
-        <a class="dac-nav-link" href="<?cs var:toroot ?>ndk/reference/index.html"
-           zh-tw-lang="參考資源"
-           zh-cn-lang="参考"
-           ru-lang="Справочник"
-           ko-lang="참조문서"
-           ja-lang="リファレンス"
-           es-lang="Referencia">Reference</a>
-      </li>
-      <li class="dac-nav-item samples">
-        <a class="dac-nav-link" href="<?cs var:toroot ?>ndk/samples/index.html"
-           >Samples</a>
-      </li>
-      <li class="dac-nav-item downloads">
-        <a class="dac-nav-link" href="<?cs var:toroot ?>ndk/downloads/index.html"
-           >Downloads</a>
-      </li>
-      </ul>
-    </div>
-                       </div>
-  </nav>
-  <!-- end NDK navigation-->
-
-
-
-  <?cs else ?>
-  <!-- Navigation-->
-  <nav class="dac-nav">
-    <div class="dac-nav-dimmer" data-dac-toggle-nav></div>
-
-    <div class="dac-nav-sidebar" data-swap data-dynamic="false" data-transition-speed="300" data-dac-nav>
-      <div <?cs if:!referenceonly ?>data-swap-container<?cs /if ?>>
-        <?cs call:custom_left_nav() ?>
-        <?cs if:!referenceonly ?>
-        <ul id="dac-main-navigation" class="dac-nav-list dac-swap-section dac-left dac-no-anim">
-        <li class="dac-nav-item home">
-          <a class="dac-nav-link" href="<?cs var:toroot ?>index.html">Home</a>
-          <i class="dac-sprite dac-expand-more-black dac-nav-sub-slider"></i>
-          <ul class="dac-nav-secondary about">
-            <li class="dac-nav-item versions">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>about/versions/nougat/index.html">Android</a>
-            </li>
-            <li class="dac-nav-item wear">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>wear/index.html">Wear</a>
-            </li>
-            <li class="dac-nav-item tv">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>tv/index.html">TV</a>
-            </li>
-            <li class="dac-nav-item auto">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>auto/index.html">Auto</a>
-            </li>
-          </ul>
-        </li>
-        <li class="dac-nav-item design">
-          <a class="dac-nav-link" href="<?cs var:toroot ?>design/index.html"
-             zh-tw-lang="設計"
-             zh-cn-lang="设计"
-             ru-lang="Проектирование"
-             ko-lang="디자인"
-             ja-lang="設計"
-             es-lang="Diseñar">Design</a>
-        </li>
-        <li class="dac-nav-item develop">
-          <a class="dac-nav-link" href="<?cs var:toroot ?>develop/index.html"
-             zh-tw-lang="開發"
-             zh-cn-lang="开发"
-             ru-lang="Разработка"
-             ko-lang="개발"
-             ja-lang="開発"
-             es-lang="Desarrollar">Develop</a>
-          <i class="dac-sprite dac-expand-more-black dac-nav-sub-slider"></i>
-          <ul class="dac-nav-secondary develop">
-            <li class="dac-nav-item training">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>training/index.html"
-                 zh-tw-lang="訓練課程"
-                 zh-cn-lang="培训"
-                 ru-lang="Курсы"
-                 ko-lang="교육"
-                 ja-lang="トレーニング"
-                 es-lang="Capacitación">Training</a>
-            </li>
-            <li class="dac-nav-item guide">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>guide/index.html"
-                 zh-tw-lang="API 指南"
-                 zh-cn-lang="API 指南"
-                 ru-lang="Руководства по API"
-                 ko-lang="API 가이드"
-                 ja-lang="API ガイド"
-                 es-lang="Guías de la API">API Guides</a>
-            </li>
-            <li class="dac-nav-item reference">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>reference/packages.html"
-                 zh-tw-lang="參考資源"
-                 zh-cn-lang="参考"
-                 ru-lang="Справочник"
-                 ko-lang="참조문서"
-                 ja-lang="リファレンス"
-                 es-lang="Referencia">Reference</a>
-            </li>
-            <li class="dac-nav-item tools">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>sdk/index.html"
-                 zh-tw-lang="相關工具"
-                 zh-cn-lang="工具"
-                 ru-lang="Инструменты"
-                 ko-lang="도구"
-                 ja-lang="ツール"
-                 es-lang="Herramientas">Tools</a></li>
-            <li class="dac-nav-item google">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>google/index.html">Google Services</a>
-            </li>
-            <?cs if:android.hasSamples ?>
-            <li class="dac-nav-item samples">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>samples/index.html">Samples</a>
-            </li>
-            <?cs /if ?>
-          </ul>
-        </li>
-        <li class="dac-nav-item distribute">
-          <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/<?cs if:android.whichdoc == 'offline' ?>googleplay/<?cs /if ?>index.html"
-             zh-tw-lang="發佈"
-             zh-cn-lang="分发"
-             ru-lang="Распространение"
-             ko-lang="배포"
-             ja-lang="配布"
-             es-lang="Distribuir">Distribute</a>
-          <i class="dac-sprite dac-expand-more-black dac-nav-sub-slider"></i>
-          <ul class="dac-nav-secondary distribute">
-            <li class="dac-nav-item googleplay">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/googleplay/index.html">Google Play</a></li>
-            <li class="dac-nav-item essentials">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/essentials/index.html">Essentials</a></li>
-            <li class="dac-nav-item users">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/users/index.html">Get Users</a></li>
-            <li class="dac-nav-item engage">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/engage/index.html">Engage &amp; Retain</a></li>
-            <li class="dac-nav-item monetize">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/monetize/index.html">Earn</a>
-            </li>
-            <li class="dac-nav-item analyze">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/analyze/index.html">Analyze</a>
-            </li>
-            <li class="dac-nav-item stories">
-              <a class="dac-nav-link" href="<?cs var:toroot ?>distribute/stories/index.html">Stories</a>
-            </li>
-          </ul>
-        </li>
-        <!--<li class="dac-nav-item preview">
-          <a class="dac-nav-link" href="<?cs var:toroot ?>preview/index.html">Preview</a>
-        </li>-->
-        </ul>
-        <?cs /if ?><?cs # end if referenceonly ?>
-      </div>
-    </div>
-  </nav>
-  <!-- end navigation-->
-  <?cs /if ?>
-
-<!-- Nav Setup -->
-<script>$('[data-dac-nav]').dacNav();</script>
-
-<?cs
-/def ?><?cs # end custom_masthead() ?><?cs
-
-def:toast() ?><?cs
-
-# (UN)COMMENT TO TOGGLE VISIBILITY
-
-  <div class="dac-toast-group">
-    <div class="dac-toast" data-toast>
-      <div class="dac-toast-wrap">
-        This is a demo notification <a href="#">Learn more</a>.
-      </div>
-    </div>
-  </div>
-
-?><?cs
-/def ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/customizations.cs b/tools/droiddoc/templates-sdk/customizations.cs
deleted file mode 100644
index 0b938ac..0000000
--- a/tools/droiddoc/templates-sdk/customizations.cs
+++ /dev/null
@@ -1,248 +0,0 @@
-<?cs def:body_content_wrap_start() ?>
-  <div class="wrap clearfix" id="body-content">
-<?cs /def ?><?cs
-
-def:fullpage() ?>
-  <div id="body-content">
-    <div>
-<?cs /def ?><?cs
-
-# The default side navigation for the reference docs ?><?cs
-def:reference_default_nav() ?>
-  <!-- Fullscreen toggler -->
-  <button data-fullscreen class="dac-nav-fullscreen">
-    <i class="dac-sprite dac-fullscreen"></i>
-  </button>
-
-  <script>$('[data-fullscreen]').dacFullscreen();</script>
-  <!-- End: Fullscreen toggler -->
-
-  <?cs if:reference.gcm || reference.gms ?>
-    <?cs include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
-    <script type="text/javascript">
-      showGoogleRefTree();
-    </script>
-  <?cs else ?>
-    <div id="devdoc-nav">
-      <div id="api-nav-header">
-        <div id="api-level-toggle">
-          <label for="apiLevelCheckbox" class="disabled"
-                 title="Select your target API level to dim unavailable APIs">API level: </label>
-          <div class="select-wrapper">
-            <select id="apiLevelSelector">
-              <!-- option elements added by buildApiLevelSelector() -->
-            </select>
-          </div>
-        </div><!-- end toggle -->
-        <div id="api-nav-title">Android APIs</div>
-      </div><!-- end nav header -->
-      <script>
-        var SINCE_DATA = [ <?cs
-          each:since = since ?>'<?cs
-            var:since.name ?>'<?cs
-            if:!last(since) ?>, <?cs /if ?><?cs
-            /each
-          ?> ];
-        buildApiLevelSelector();
-      </script>
-
-      <div class="dac-reference-nav" data-reference-tree>
-        <ul class="dac-reference-nav-list" data-reference-namespaces>
-          <?cs call:package_link_list(docs.packages) ?>
-        </ul>
-
-        <?cs if:subcount(class.package) ?>
-        <ul data-reference-resources>
-          <?cs call:list("Annotations", class.package.annotations) ?>
-          <?cs call:list("Interfaces", class.package.interfaces) ?>
-          <?cs call:list("Classes", class.package.classes) ?>
-          <?cs call:list("Enums", class.package.enums) ?>
-          <?cs call:list("Exceptions", class.package.exceptions) ?>
-          <?cs call:list("Errors", class.package.errors) ?>
-        </ul>
-        <?cs elif:subcount(package) ?>
-        <ul data-reference-resources>
-          <?cs call:class_link_list("Annotations", package.annotations) ?>
-          <?cs call:class_link_list("Interfaces", package.interfaces) ?>
-          <?cs call:class_link_list("Classes", package.classes) ?>
-          <?cs call:class_link_list("Enums", package.enums) ?>
-          <?cs call:class_link_list("Exceptions", package.exceptions) ?>
-          <?cs call:class_link_list("Errors", package.errors) ?>
-        </ul>
-        <?cs /if ?>
-      </div>
-    </div>
-  <?cs /if ?>
-<?cs /def ?><?cs
-
-def:ndk_nav() ?>
-  <div class="wrap clearfix" id="body-content"><div class="cols">
-    <div class="col-3 dac-toggle dac-mobile" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
-      <?cs call:mobile_nav_toggle() ?>
-      <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 ?>
-        </div>
-      </div>
-    </div> <!-- end side-nav -->
-<?cs /def ?><?cs
-
-def:header_search_widget() ?>
-  <form data-search class="dac-header-search">
-    <button class="dac-header-search-close" data-search-close>
-      <i class="dac-sprite dac-back-arrow"></i>
-    </button>
-
-    <div class="dac-header-search-inner">
-      <i class="dac-sprite dac-search-white dac-header-search-icon"></i>
-      <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q" class="dac-header-search-input" placeholder="Search" />
-      <button class="dac-header-search-clear dac-hidden" data-search-clear>
-        <i class="dac-sprite dac-close-black"></i>
-      </button>
-    </div>
-  </form>
-<?cs /def ?><?cs
-
-def:search_results() ?>
-  <div id="search-results" class="dac-search-results">
-    <div id="dac-search-results-history" class="dac-search-results-history">
-      <div class="wrap dac-search-results-history-wrap">
-        <div class="cols">
-          <div class="col-1of2 col-tablet-1of2 col-mobile-1of1">
-            <h2>Most visited</h2>
-            <div class="resource-flow-layout" data-history-query="history:most/visited" data-maxresults="3" data-cardsizes="18x2"></div>
-          </div>
-
-          <div class="col-1of2 col-tablet-1of2 col-mobile-1of1">
-            <h2>Recently visited</h2>
-            <div class="resource-flow-layout cols" data-history-query="history:recent" data-allow-duplicates="true" data-maxresults="3" data-cardsizes="18x2"></div>
-          </div>
-        </div>
-      </div>
-    </div>
-
-    <div id="dac-search-results-content" class="dac-search-results-content">
-      <div class="dac-search-results-metadata wrap">
-        <div class="dac-search-results-for">
-          <h2>Results for <span id="search-results-for"></span></h2>
-        </div>
-
-        <div id="dac-search-results-hero"></div>
-
-        <div class="dac-search-results-hero cols">
-          <div id="dac-search-results-reference" class="col-3of6 col-tablet-1of2 col-mobile-1of1">
-            <div class="suggest-card reference no-display">
-              <ul class="dac-search-results-reference">
-              </ul>
-            </div>
-          </div>
-          <div id="dac-custom-search-results"></div>
-        </div>
-      </div>
-
-    </div>
-  </div>
-<?cs /def ?><?cs
-
-def:custom_left_nav() ?>
-  <?cs if:(!fullpage && !nonavpage) || forcelocalnav ?>
-    <?cs if:!referenceonly ?>
-    <a class="dac-nav-back-button dac-swap-section dac-up dac-no-anim" data-swap-button href="javascript:;">
-      <i class="dac-sprite dac-nav-back"></i> <span class="dac-nav-back-title">Back</span>
-    </a>
-    <?cs /if ?>
-    <div class="dac-nav-sub dac-swap-section dac-right dac-active" itemscope
-      itemtype="http://schema.org/SiteNavigationElement" <?cs
-        if:referenceonly ?>style="top:0 !important;"<?cs /if ?>>
-      <?cs if:ndk ?>
-        <?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 else ?>
-          <?cs call:reference_default_nav() ?>
-        <?cs /if ?>
-      <?cs elif:guide ?>
-        <?cs include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
-      <?cs elif:design ?>
-        <?cs include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
-      <?cs elif:training ?>
-        <?cs include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
-      <?cs elif:tools ?>
-        <?cs include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
-      <?cs elif:google ?>
-        <?cs include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
-      <?cs elif:samples ?>
-        <?cs include:"../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
-      <?cs elif:preview ?>
-        <?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 elif:distribute ?>
-        <?cs if:googleplay ?>
-          <?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 elif:users ?>
-          <?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 elif:monetize ?>
-          <?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 elif:disttools ?>
-          <?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 /if ?>
-      <?cs elif:about ?>
-        <?cs include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
-      <?cs else ?>
-        <?cs call:reference_default_nav() ?>
-      <?cs /if ?>
-    </div>
-  <?cs /if ?>
-<?cs /def ?><?cs
-
-# appears at the bottom of every page ?><?cs
-def:custom_cc_copyright() ?>
-  Except as noted, this content is
-  licensed under <a href="http://creativecommons.org/licenses/by/2.5/">
-  Creative Commons Attribution 2.5</a>. For details and
-  restrictions, see the <a href="<?cs var:toroot ?>license.html">Content
-  License</a>.
-<?cs /def ?><?cs
-
-def:custom_copyright() ?>
-  Except as noted, this content is licensed under <a
-  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>.
-  For details and restrictions, see the <a href="<?cs var:toroot ?>license.html">
-  Content License</a>.
-<?cs /def ?><?cs
-
-def:custom_footerlinks() ?>
-  <a href="<?cs var:toroot ?>about/android.html">About Android</a>
-  <a href="<?cs var:toroot ?>auto/index.html">Auto</a>
-  <a href="<?cs var:toroot ?>tv/index.html">TV</a>
-  <a href="<?cs var:toroot ?>wear/index.html">Wear</a>
-  <a href="<?cs var:toroot ?>legal.html">Legal</a>
-<?cs /def ?><?cs
-
-# appears on the right side of the blue bar at the bottom off every page ?><?cs
-def:custom_buildinfo() ?>
-  <?cs if:!google && !reference.gcm && !reference.gms ?>
-    Android <?cs var:sdk.version ?>&nbsp;r<?cs var:sdk.rel.id ?> &mdash;
-  <?cs /if ?>
-  <script src="<?cs var:toroot ?>timestamp.js" type="text/javascript"></script>
-  <script>document.write(BUILD_TIMESTAMP)</script>
-<?cs /def ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/data.hdf b/tools/droiddoc/templates-sdk/data.hdf
deleted file mode 100644
index 9411b78..0000000
--- a/tools/droiddoc/templates-sdk/data.hdf
+++ /dev/null
@@ -1,4 +0,0 @@
-template {
-    which = normal
-}
-
diff --git a/tools/droiddoc/templates-sdk/designpage.cs b/tools/droiddoc/templates-sdk/designpage.cs
deleted file mode 100644
index d75ce0a..0000000
--- a/tools/droiddoc/templates-sdk/designpage.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-<!DOCTYPE html>
-<?cs include:"macros.cs" ?>
-<html lang="en">
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-    <title>
-      Android Design<?cs if:page.title ?> - <?cs var:page.title ?><?cs /if ?>
-    </title>
-    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
-    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic">
-    <link rel="stylesheet" href="<?cs var:toroot ?>assets/yui-3.3.0-reset-min.css">
-    <link rel="stylesheet" href="<?cs var:toroot ?>assets/design/default.css">
-    <script src="<?cs var:toroot ?>assets/jquery-1.6.2.min.js"></script>
-    <script>var SITE_ROOT = '<?cs var:toroot ?>design';</script>
-    <script src="<?cs var:toroot ?>assets/design/default.js"></script>
-  </head>
-  <body class="gc-documentation 
-    <?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs
-    elif:design ?>design<?cs
-    elif:distribute ?>distribute<?cs
-    /if ?>" itemscope itemtype="http://schema.org/Article">
-    <a name="top"></a>
-
-    <div id="page-container">
-
-      <div id="page-header" itemscope itemtype="http://schema.org/WPHeader"><a href="<?cs var:toroot ?>design/index.html">Android Design</a></div>
-
-      <div id="main-row">
-
-        <div id="nav-container" itemscope itemtype="http://schema.org/SiteNavigationElement">
-
-        <?cs call:design_nav() ?>
-
-        </div>
-
-        <div id="content">
-
-<?cs if:header.hide ?>
-<?cs else ?>
-<div class="content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
-    <?cs if:header.justLinks ?>&nbsp;
-      <?cs elif:header.title ?><h2><?cs var:header.title ?></h2>
-                   <?cs else ?><h2><?cs var:page.title ?></h2>
-    <?cs /if ?>
-</div>
-<?cs /if ?>
-
-<?cs call:tag_list(root.descr) ?>
-
-<?cs if:footer.hide ?>
-<?cs else ?>
-<div class="cols content-footer" itemscope itemtype="http://schema.org/SiteNavigationElement">
-  <div class="paging-links col-9">&nbsp;</div>
-  <div class="paging-links col-4">
-    <a href="#" class="prev-page-link">Previous</a>
-    <a href="#" class="next-page-link">Next</a>
-  </div>
-</div>
-<?cs /if ?>
-
-        </div>
-
-      </div>
-
-      <div id="page-footer" itemscope itemtype="http://schema.org/WPFooter">
-
-        <p id="copyright">
-          Except as noted, this content is licensed under
-          <a href="http://creativecommons.org/licenses/by/2.5/">
-          Creative Commons Attribution 2.5</a>.<br>
-          For details and restrictions, see the
-          <a href="http://developer.android.com/license.html">Content License</a>.
-        </p>
-
-        <p>
-          <a href="http://www.android.com/terms.html">Site Terms of Service</a> &ndash;
-          <a href="http://www.android.com/privacy.html">Privacy Policy</a> &ndash;
-          <a href="http://www.android.com/branding.html">Brand Guidelines</a>
-        </p>
-
-      </div>
-    </div>
-
-    <script type="text/javascript">
-    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
-    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
-    </script>
-    <script type="text/javascript">
-    var pageTracker = _gat._getTracker("UA-5831155-1");
-    pageTracker._trackPageview();
-    </script>
-
-<!-- Start of Tag -->
-<script type="text/javascript">
-var axel = Math.random() + "";
-var a = axel * 10000000000000;
-document.write('<iframe src="https://2507573.fls.doubleclick.net/activityi;src=2507573;type=other026;cat=googl348;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
-</script>
-<noscript>
-<iframe src="https://2507573.fls.doubleclick.net/activityi;src=2507573;type=other026;cat=googl348;ord=1?" width="1" height="1" frameborder="0" style="display:none"></iframe>
-</noscript>
-<!-- End of Tag -->
-  </body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/docpage.cs b/tools/droiddoc/templates-sdk/docpage.cs
deleted file mode 100644
index e8a5ba3..0000000
--- a/tools/droiddoc/templates-sdk/docpage.cs
+++ /dev/null
@@ -1,261 +0,0 @@
-<?cs if:!devsite ?><?cs
-  include:"doctype.cs" ?><?cs /if ?><?cs
-  include:"macros.cs" ?><html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<body<?cs
-if:!devsite ?> class="gc-documentation<?cs
-# add document classes for navigation header selection (and other stuff) ?>
-<?cs
-  if:(google || reference.gms || reference.gcm) ?>google <?cs /if ?><?cs
-  if:ndk ?>ndk<?cs
-    if:guide ?> guide<?cs /if ?><?cs
-    if:samples ?> samples<?cs /if ?><?cs
-    if:reference ?> reference<?cs /if ?><?cs
-    if:downloads ?> downloads<?cs /if ?><?cs
-  else ?><?cs
-    if:(guide||develop||training||reference||tools||sdk||google||samples) ?>develop<?cs
-      if:guide ?> guide<?cs /if ?><?cs
-      if:samples ?> samples<?cs /if ?><?cs
-    elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?>distribute<?cs
-      if:googleplay ?> googleplay<?cs /if ?><?cs
-      if:essentials ?> essentials<?cs /if ?><?cs
-      if:users ?> users<?cs /if ?><?cs
-      if:engage ?> engage<?cs /if ?><?cs
-      if:monetize ?> monetize<?cs /if ?><?cs
-      if:disttools ?> disttools<?cs /if ?><?cs
-      if:stories ?> stories<?cs /if ?><?cs
-      if:analyze ?> analyze<?cs /if ?><?cs
-    elif:(design||vision||material||patterns||devices||designdownloads) ?> design<?cs
-      if:vision ?> vision<?cs /if ?><?cs
-      if:material ?> material<?cs /if ?><?cs
-      if:patterns ?> patterns<?cs /if ?><?cs
-      if:devices ?> devices<?cs /if ?><?cs
-      if:designdownloads ?> designdownloads<?cs /if ?><?cs
-    elif:(about||versions||wear||tv||auto) ?> about<?cs
-      if:versions ?> versions<?cs /if ?><?cs
-      if:wear ?> wear<?cs /if ?><?cs
-      if:tv ?> tv<?cs /if ?><?cs
-      if:auto ?> auto<?cs /if ?><?cs
-    elif:(preview) ?> preview<?cs
-    /if ?><?cs
-    if:page.trainingcourse ?> trainingcourse<?cs /if ?><?cs
-  /if ?>" itemscope itemtype="http://schema.org/Article"><?cs
-/if ?>><?cs
-include:"header.cs" ?><?cs
-
-if:(design||training||walkthru) && !page.trainingcourse && !page.article ?><?cs
-# header logic for docs that provide previous/next buttons ?><?cs
-  if:(header.hide||devsite) ?><?cs
-  else ?>
-    <div class="content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
-      <?cs if:header.justLinks ?>&nbsp;
-      <?cs else ?>
-        <ul class="dac-header-crumbs">
-          <?cs # More <li> elements added here with javascript ?>
-        </ul>
-
-        <!-- Breadcrumb Setup -->
-        <script>$('.dac-nav-list').dacCurrentPage().dacCrumbs();</script>
-
-        <h1 itemprop="name"><?cs var:page.title ?>
-      </h1><?cs
-      /if ?><?cs
-      if:training ?>
-      <div class="training-nav-top" itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <a href="#" class="prev-page-link hide"
-            zh-tw-lang="上一堂課"
-            zh-cn-lang="上一课"
-            ru-lang="Предыдущий"
-            ko-lang="이전"
-            ja-lang="前へ"
-            es-lang="Anterior"
-            >Previous</a>
-        <a href="#" class="next-page-link hide"
-            zh-tw-lang="下一堂課"
-            zh-cn-lang="下一课"
-            ru-lang="Следующий"
-            ko-lang="다음"
-            ja-lang="次へ"
-            es-lang="Siguiente"
-            >Next</a>
-        <a href="#" class="start-class-link hide"
-            zh-tw-lang="開始上課"
-            zh-cn-lang="开始"
-            ru-lang="Начало работы"
-            ko-lang="시작하기"
-            ja-lang="開始する"
-            es-lang="Empezar"
-            >Get started</a>
-      </div><?cs
-      elif:!page.trainingcourse ?>
-      <?cs # <div class="paging-linkss" itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <a href="#" class="prev-page-link hide"
-            zh-tw-lang="上一堂課"
-            zh-cn-lang="上一课"
-            ru-lang="Предыдущий"
-            ko-lang="이전"
-            ja-lang="前へ"
-            es-lang="Anterior"
-            >Previous</a>
-        <a href="#" class="next-page-link hide"
-            zh-tw-lang="下一堂課"
-            zh-cn-lang="下一课"
-            ru-lang="Следующий"
-            ko-lang="다음"
-            ja-lang="次へ"
-            es-lang="Siguiente"
-            >Next</a>
-      </div> ?><?cs
-      /if ?><?cs # end if training ?>
-  </div>
-  <?cs /if ?><?cs # end if header.hide ?><?cs
-
-elif:samplesProjectIndex ?>
-  <div id="api-info-block">
-  <div class="sum-details-links">
-  Overview
-  &#124; <a href="<?cs var:toroot ?>samples/<?cs var:projectDir ?>/project.html">Project</a>
-  &#124; <a href="<?cs var:toroot ?>downloads/samples/<?cs var:projectDir ?>.zip">Download</a>
-  </div><!-- end sum-details-links -->
-  </div><!-- end breadcurmb block -->
-  <h1 itemprop="name"><?cs var:projectDir ?></h1>
-
-<?cs else ?><?cs
-  if:(!fullpage && !header.hide && !devsite) ?><?cs
-    if:page.landing ?><?cs # header logic for docs that are landing pages ?>
-      <div class="landing-banner">
-        <?cs if:page.landing.image ?><?cs # use two-column layout only if there is an image ?>
-        <div class="cols">
-          <div class="col-6">
-            <img src="<?cs var:toroot ?><?cs var:page.landing.image ?>" alt="" />
-          </div>
-          <div class="col-6">
-        <?cs /if ?>
-          <h1 itemprop="name" style="margin-bottom:0;"><?cs var:page.title ?></h1>
-          <p itemprop="description"><?cs var:page.landing.intro ?></p>
-
-          <p><a class="next-page-link topic-start-link"></a></p>
-        <?cs if:page.landing.image ?>
-          </div>
-        </div>
-        <?cs /if ?>
-      </div>
-    <?cs else ?><?cs
-      if:tab1 ?><div id="title-tabs-wrapper"><?cs /if ?>
-        <ul class="dac-header-crumbs">
-          <?cs # More <li> elements added here with javascript ?>
-        </ul>
-
-        <!-- Breadcrumb Setup -->
-        <p><script>$('.dac-nav-list').dacCurrentPage().dacCrumbs();</script></p>
-
-        <h1 itemprop="name" <?cs if:tab1 ?>class="with-title-tabs"<?cs /if ?>><?cs var:page.title ?></h1><?cs
-          if:tab1 ?><ul id="title-tabs">
-              <li class="selected"><a href="<?cs var:tab1.link ?>"><?cs var:tab1 ?></a></li>
-              <?cs if:tab2 ?>
-              <li><a href="<?cs var:tab2.link ?>"><?cs var:tab2 ?></a></li><?cs /if ?>
-              <?cs if:tab3 ?>
-              <li><a href="<?cs var:tab3.link ?>"><?cs var:tab3 ?></a></li><?cs /if ?>
-            </ul>
-          <?cs /if ?>
-      <?cs if:tab1 ?></div><!-- end tab-wrapper --><?cs /if ?><?cs
-    /if ?><?cs
-  /if ?><?cs
-/if ?><?cs # end if design ?><?cs
-
-if devsite ?><?cs
-  if:tab1 ?>
-  <div id="title-tabs-wrapper">
-    <ul id="title-tabs">
-      <li class="selected"><a href="<?cs var:tab1.link ?>"><?cs var:tab1 ?></a></li>
-      <?cs if:tab2 ?>
-      <li><a href="<?cs var:tab2.link ?>"><?cs var:tab2 ?></a></li><?cs /if ?>
-      <?cs if:tab3 ?>
-      <li><a href="<?cs var:tab3.link ?>"><?cs var:tab3 ?></a></li><?cs /if ?>
-    </ul>
-  </div><!-- end tab-wrapper --><?cs
-  /if ?><?cs
-/if ?><?cs
-
-# THIS IS THE MAIN DOC CONTENT ?><?cs
-  if:!devsite ?>
-  <div id="jd-content">
-    <div class="jd-descr" itemprop="articleBody"><?cs
-  /if ?><?cs
-  if:(!fullpage && !header.hide && devsite) ?><?cs
-    if:page.landing ?><?cs # header logic for docs that are landing pages ?>
-        <div class="landing-banner">
-          <?cs if:page.landing.image ?><?cs # use two-column layout only if there is an image ?>
-          <div class="cols">
-            <div class="col-6">
-              <img src="<?cs var:toroot ?><?cs var:page.landing.image ?>" alt="" />
-            </div>
-            <div class="col-6">
-          <?cs /if ?>
-            <h1 itemprop="name" style="margin-bottom:0;"><?cs var:page.title ?></h1>
-            <p itemprop="description"><?cs var:page.landing.intro ?></p>
-
-            <p><a class="next-page-link topic-start-link"></a></p><?cs
-            if:page.landing.image ?>
-            </div>
-          </div><?cs
-          /if ?>
-        </div><?cs
-    /if ?><?cs
-  /if ?>
-
-<?cs call:tag_list(root.descr) ?><?cs
-
-if:!devsite ?>
-    </div><!-- end jd-descr --><?cs
-/if ?><?cs
-
-if:!fullscreen && (design||training||walkthru) && !page.landing && !page.trainingcourse
-      && !footer.hide && !devsite?>
-      <div class="content-footer <?cs
-                    if:fullpage ?>wrap<?cs /if ?>"
-                    itemscope itemtype="http://schema.org/SiteNavigationElement">
-          <div class="paging-links">
-            <a href="#" class="prev-page-link hide"
-              zh-tw-lang="上一堂課"
-              zh-cn-lang="上一课"
-              ru-lang="Предыдущий"
-              ko-lang="이전"
-              ja-lang="前へ"
-              es-lang="Anterior"
-              ><span class="page-link-caption">Previous</span>
-            </a>
-            <a href="#" class="next-page-link hide"
-                zh-tw-lang="下一堂課"
-                zh-cn-lang="下一课"
-                ru-lang="Следующий"
-                ko-lang="다음"
-                ja-lang="次へ"
-                es-lang="Siguiente"
-                ><span class="page-link-caption">Next</span>
-            </a>
-            <a href="#" class="start-class-link hide"
-                zh-tw-lang="開始上課"
-                zh-cn-lang="开始"
-                ru-lang="Начало работы"
-                ko-lang="시작하기"
-                ja-lang="開始する"
-                es-lang="Empezar"
-                >Get started</a>
-            <a href="#" class="next-class-link hide">
-              <span class="page-link-caption">Next class</span>
-            </a>
-          </div>
-      </div><?cs
-    /if ?><?cs
-if:!devsite ?>
-  </div> <!-- end jd-content --><?cs
-/if ?><?cs
-
-if:!devsite ?>
-<?cs include:"footer.cs" ?>
-<?cs include:"trailer.cs" ?>
-<?cs /if ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/footer.cs b/tools/droiddoc/templates-sdk/footer.cs
deleted file mode 100644
index 452a811..0000000
--- a/tools/droiddoc/templates-sdk/footer.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-<?cs # page footer content ?>
-<div class="wrap">
-  <div class="dac-footer<?cs if:fullpage ?> dac-landing<?cs /if ?>">
-    <div class="cols dac-footer-main">
-      <div class="col-1of2">
-        <a class="dac-footer-getnews" id="newsletter" data-modal-toggle="newsletter" href="javascript:;">Get news &amp; tips <span
-          class="dac-fab dac-primary"><i class="dac-sprite dac-mail"></i></span></a>
-      </div>
-      <div class="col-1of2 dac-footer-reachout">
-        <div class="dac-footer-contact">
-          <a class="dac-footer-contact-link" href="http://android-developers.blogspot.com/">Blog</a>
-          <a class="dac-footer-contact-link" href="/support.html">Support</a>
-        </div>
-        <div class="dac-footer-social">
-          <a class="dac-button-social dac-youtube dac-footer-social-link" href="https://www.youtube.com/user/androiddevelopers"><i class="dac-sprite dac-youtube"></i></a>
-          <a class="dac-button-social dac-gplus dac-footer-social-link" href="https://plus.google.com/+AndroidDevelopers"><i class="dac-sprite dac-gplus"></i></a>
-          <a class="dac-button-social dac-twitter dac-footer-social-link" href="https://twitter.com/AndroidDev"><i class="dac-sprite dac-twitter"></i></a>
-        </div>
-      </div>
-    </div>
-
-    <hr class="dac-footer-separator"/>
-
-    <?cs if:reference ?>
-      <p class="dac-footer-copyright">
-        <?cs call:custom_copyright() ?>
-      </p>
-      <p class="dac-footer-build">
-        <?cs call:custom_buildinfo() ?>
-      </p>
-    <?cs elif:!hide_license_footer ?>
-      <p class="dac-footer-copyright">
-        <?cs call:custom_cc_copyright() ?>
-      </p>
-    <?cs /if ?>
-
-    <p class="dac-footer-links">
-      <a href="/about/android.html">About Android</a>
-      <a href="/auto/index.html">Auto</a>
-      <a href="/tv/index.html">TV</a>
-      <a href="/wear/index.html">Wear</a>
-      <a href="/legal.html">Legal</a>
-
-      <span id="language" class="locales">
-        <select name="language" onchange="changeLangPref(this.value, true)">
-          <option value="en" selected="selected">English</option>
-          <option value="es">Español</option>
-          <option value="id">Bahasa Indonesia</option>
-          <option value="ja">日本語</option>
-          <option value="ko">한국어</option>
-          <option value="pt-br">Português Brasileiro</option>
-          <option value="ru">Русский</option>
-          <option value="vi">tiếng Việt</option>
-          <option value="zh-cn">中文(简体)</option>
-          <option value="zh-tw">中文(繁體)</option>
-        </select>
-      </span>
-    </p>
-  </div>
-</div>
-<!-- end footer -->
-
-<?cs call:toast() ?>
-
-<div data-modal="newsletter" data-newsletter data-swap class="dac-modal newsletter">
-  <div class="dac-modal-container">
-    <div class="dac-modal-window">
-      <header class="dac-modal-header">
-        <div class="dac-modal-header-actions">
-          <button class="dac-modal-header-close" data-modal-toggle></button>
-        </div>
-        <div class="dac-swap" data-swap-container>
-          <section class="dac-swap-section dac-active dac-down">
-            <h2 class="norule dac-modal-header-title" data-t="newsletter.title"></h2>
-            <p class="dac-modal-header-subtitle" data-t="newsletter.requiredHint"></p>
-          </section>
-          <section class="dac-swap-section dac-up">
-            <h2 class="norule dac-modal-header-title" data-t="newsletter.successTitle">Hooray!</h2>
-          </section>
-        </div>
-      </header>
-      <div class="dac-swap" data-swap-container>
-        <section class="dac-swap-section dac-active dac-left">
-          <form action="https://docs.google.com/forms/d/1QgnkzbEJIDu9lMEea0mxqWrXUJu0oBCLD7ar23V0Yys/formResponse" class="dac-form" method="post" target="dac-newsletter-iframe">
-            <input type="hidden" name="entry.935454734" data-newsletter-language>
-            <section class="dac-modal-content">
-              <fieldset class="dac-form-fieldset">
-                <div class="cols">
-                  <div class="col-1of2 newsletter-leftCol">
-                    <div class="dac-form-input-group">
-                      <label for="newsletter-full-name" class="dac-form-floatlabel" data-t="newsletter.name">Full name</label>
-                      <input type="text" class="dac-form-input" name="entry.1357890476" id="newsletter-full-name" required>
-                      <span class="dac-form-required">*</span>
-                    </div>
-                    <div class="dac-form-input-group">
-                      <label for="newsletter-email" class="dac-form-floatlabel" data-t="newsletter.email">Email address</label>
-                      <input type="email" class="dac-form-input" name="entry.472100832" id="newsletter-email" required>
-                      <span class="dac-form-required">*</span>
-                    </div>
-                  </div>
-                  <div class="col-1of2 newsletter-rightCol">
-                    <div class="dac-form-input-group">
-                      <label for="newsletter-company" class="dac-form-floatlabel" data-t="newsletter.company">Company / developer name</label>
-                      <input type="text" class="dac-form-input" name="entry.1664780309" id="newsletter-company">
-                    </div>
-                    <div class="dac-form-input-group">
-                      <label for="newsletter-play-store" class="dac-form-floatlabel" data-t="newsletter.appUrl">One of your Play Store app URLs</label>
-                      <input type="url" class="dac-form-input" name="entry.47013838" id="newsletter-play-store" required>
-                      <span class="dac-form-required">*</span>
-                    </div>
-                  </div>
-                </div>
-              </fieldset>
-              <fieldset class="dac-form-fieldset">
-                <div class="cols">
-                  <div class="col-1of2 newsletter-leftCol">
-                    <legend class="dac-form-legend"><span data-t="newsletter.business.label">Which best describes your business:</span><span class="dac-form-required">*</span>
-                    </legend>
-                    <div class="dac-form-radio-group">
-                      <input type="radio" value="Apps" class="dac-form-radio" name="entry.1796324055" id="newsletter-business-type-app" required>
-                      <label for="newsletter-business-type-app" class="dac-form-radio-button"></label>
-                      <label for="newsletter-business-type-app" class="dac-form-label" data-t="newsletter.business.apps">Apps</label>
-                    </div>
-                    <div class="dac-form-radio-group">
-                      <input type="radio" value="Games" class="dac-form-radio" name="entry.1796324055" id="newsletter-business-type-games" required>
-                      <label for="newsletter-business-type-games" class="dac-form-radio-button"></label>
-                      <label for="newsletter-business-type-games" class="dac-form-label" data-t="newsletter.business.games">Games</label>
-                    </div>
-                    <div class="dac-form-radio-group">
-                      <input type="radio" value="Apps and Games" class="dac-form-radio" name="entry.1796324055" id="newsletter-business-type-appsgames" required>
-                      <label for="newsletter-business-type-appsgames" class="dac-form-radio-button"></label>
-                      <label for="newsletter-business-type-appsgames" class="dac-form-label" data-t="newsletter.business.both">Apps &amp; Games</label>
-                    </div>
-                  </div>
-                  <div class="col-1of2 newsletter-rightCol newsletter-checkboxes">
-                    <div class="dac-form-radio-group">
-                      <div class="dac-media">
-                        <div class="dac-media-figure">
-                          <input type="checkbox" class="dac-form-checkbox" name="entry.732309842" id="newsletter-add" required value="Add me to the mailing list for the monthly newsletter and occasional emails about development and Google Play opportunities.">
-                          <label for="newsletter-add" class="dac-form-checkbox-button"></label>
-                        </div>
-                        <div class="dac-media-body">
-                          <label for="newsletter-add" class="dac-form-label dac-form-aside"><span data-t="newsletter.confirmMailingList"></span><span class="dac-form-required">*</span></label>
-                        </div>
-                      </div>
-                    </div>
-                    <div class="dac-form-radio-group">
-                      <div class="dac-media">
-                        <div class="dac-media-figure">
-                          <input type="checkbox" class="dac-form-checkbox" name="entry.2045036090" id="newsletter-terms" required value="I acknowledge that the information provided in this form will be subject to Google's privacy policy (https://www.google.com/policies/privacy/).">
-                          <label for="newsletter-terms" class="dac-form-checkbox-button"></label>
-                        </div>
-                        <div class="dac-media-body">
-                          <label for="newsletter-terms" class="dac-form-label dac-form-aside"><span data-t="newsletter.privacyPolicy" data-t-html></span><span class="dac-form-required">*</span></label>
-                        </div>
-                      </div>
-                    </div>
-                  </div>
-                </div>
-              </fieldset>
-            </section>
-            <footer class="dac-modal-footer">
-              <div class="cols">
-                <div class="col-2of5">
-                </div>
-              </div>
-              <button type="submit" value="Submit" class="dac-fab dac-primary dac-large dac-modal-action"><i class="dac-sprite dac-arrow-right"></i></button>
-            </footer>
-          </form>
-        </section>
-        <section class="dac-swap-section dac-right">
-          <div class="dac-modal-content">
-            <p class="newsletter-success-message" data-t="newsletter.successDetails"></p>
-          </div>
-        </section>
-      </div>
-    </div>
-  </div>
-</div>
-<!-- end newsletter modal -->
-
-<!-- start reset language header modal -->
-<div data-modal="langform" class="dac-modal" id="langform">
-  <div class="dac-modal-container">
-    <div class="dac-modal-window">
-      <header class="dac-modal-header">
-        <div class="dac-modal-header-actions">
-          <button class="dac-modal-header-close" data-modal-toggle></button>
-        </div>
-        <section class="dac-swap-section dac-active dac-down">
-          <h2 class="norule dac-modal-header-title"></h2>
-        </section>
-      </header>
-      <section class="dac-swap-section dac-active dac-left">
-          <section class="dac-modal-content">
-            <fieldset class="dac-form-fieldset">
-              <div class="cols">
-                <div class="col-2of2 langform-leftCol">
-                  <p id="resetLangText"></p>
-                  <p id="resetLangCta"></p>
-                </div>
-              </div>
-            </fieldset>
-          </section>
-          <footer class="dac-modal-footer" id="langfooter">
-            <div class="cols">
-              <div class="col-2of5">
-              </div>
-            </div>
-              <button class="button dac-primary dac-modal-action lang yes" data-t="newsletter.resetLangButtonYes" data-modal-toggle></button>
-              <button class="button dac-primary dac-modal-action lang no" data-t="newsletter.resetLangButtonNo" data-modal-toggle></button>
-            </a>
-          </footer>
-        </form>
-      </section>
-    </div>
-  </div>
-</div>
-<!-- end langreset modal -->
diff --git a/tools/droiddoc/templates-sdk/gcm_navtree_data.cs b/tools/droiddoc/templates-sdk/gcm_navtree_data.cs
deleted file mode 100644
index 6f33d88..0000000
--- a/tools/droiddoc/templates-sdk/gcm_navtree_data.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-var GCM_NAVTREE_DATA =
-<?cs var:reference_tree ?>
-;
diff --git a/tools/droiddoc/templates-sdk/gms_navtree_data.cs b/tools/droiddoc/templates-sdk/gms_navtree_data.cs
deleted file mode 100644
index 66b7d55..0000000
--- a/tools/droiddoc/templates-sdk/gms_navtree_data.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-var GMS_NAVTREE_DATA =
-<?cs var:reference_tree ?>
-;
diff --git a/tools/droiddoc/templates-sdk/head_tag.cs b/tools/droiddoc/templates-sdk/head_tag.cs
deleted file mode 100644
index dd67aa5..0000000
--- a/tools/droiddoc/templates-sdk/head_tag.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-<head>
-  <title><?cs
-if:devsite ?><?cs
-  if:page.title ?><?cs
-    var:html_strip(page.title) ?><?cs
-  else ?>Android Developers<?cs
-  /if ?><?cs
-else ?><?cs
-  if:page.title ?><?cs
-    var:page.title ?> | <?cs
-  /if ?>Android Developers
-<?cs /if ?><?cs
-# END if/else devsite ?></title><?cs
-  ####### If building devsite, add some meta data needed for when generating the top nav ######### ?><?cs
-if:devsite ?>
-  <meta name="top_category" value="<?cs
-      if:ndk ?>ndk<?cs
-      elif:(guide||develop||training||reference||tools||sdk||google||reference.gms||reference.gcm||samples) ?>develop<?cs
-      elif:(topic||libraries||instantapps||perf||arc) ?>develop<?cs
-      elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?>distribute<?cs
-      elif:(design||vision||material||patterns||devices||designdownloads) ?>design<?cs
-      elif:(about||versions||wear||tv||auto) ?>about<?cs
-      elif:wearpreview ?>about<?cs
-      elif:work ?>about<?cs
-      elif:preview ?>preview<?cs
-      else ?>none<?cs
-      /if ?>" /><?cs set:dac_subcategory_set = #1 ?>
-  <meta name="subcategory" value="<?cs
-      if:ndk ?><?cs
-        if:guide ?>guide<?cs
-        elif:samples ?>samples<?cs
-          if:(samplesDocPage&&!samplesProjectIndex) ?> samples-docpage<?cs /if ?><?cs
-        elif:reference ?>reference<?cs
-        elif:downloads ?>downloads<?cs
-        else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
-      else ?><?cs
-        if:(guide||develop||training||reference||tools||sdk||samples) ?><?cs
-          if:guide ?>guide<?cs
-          elif:training ?><?cs
-            if:page.trainingcourse ?>trainingcourse<?cs
-            else ?>training<?cs /if ?><?cs
-          elif:reference ?>reference<?cs
-          elif:samples ?>samples<?cs
-            if:(samplesDocPage&&!samplesProjectIndex) ?> samples-docpage<?cs /if ?><?cs
-          else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
-        elif:(google||reference.gms||reference.gcm) ?>google<?cs
-        elif:(topic||libraries||perf||arc) ?><?cs
-          if:libraries ?>libraries<?cs
-          elif:instantapps ?>instantapps<?cs
-          elif:perf ?>perf<?cs
-          elif:arc ?>arc<?cs
-          else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
-        elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?><?cs
-          if:googleplay ?>googleplay<?cs
-          elif:essentials ?>essentials<?cs
-          elif:users ?>users<?cs
-          elif:engage ?>engage<?cs
-          elif:monetize ?>monetize<?cs
-          elif:disttools ?>disttools<?cs
-          elif:stories ?>stories<?cs
-          elif:analyze ?>analyze<?cs
-          else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
-        elif:(about||versions||wear||tv||auto) ?>about<?cs
-        elif:preview ?>preview<?cs
-        elif:wearpreview ?>wear<?cs
-        elif:work ?>work<?cs
-        elif:design ?>design<?cs
-        elif:walkthru ?>walkthru<?cs
-        else ?>none<?cs set:dac_subcategory_set = #0 ?><?cs /if ?><?cs
-      /if ?>" /><?cs
-      if:nonavpage ?>
-  <meta name="hide_toc" value='True' /><?cs
-      elif: !nonavpage && dac_subcategory_set && !tools && !sdk ?>
-  <meta name="book_path" value="<?cs
-        if:ndk ?>/ndk<?cs
-          if:guide ?>/guides<?cs
-          elif:samples ?>/samples<?cs
-          elif:reference ?>/reference<?cs
-          elif:downloads ?>/downloads<?cs /if ?><?cs
-        else ?><?cs
-          if:(guide||develop||training||reference||tools||sdk||samples) ?><?cs
-            if:guide ?>/guide<?cs
-            elif:training ?>/training<?cs
-            elif:reference ?>/reference<?cs
-            elif:samples ?>/samples<?cs /if ?><?cs
-          elif:(google||reference.gms||reference.gcm) ?>/google<?cs
-          elif:(topic||libraries||perf) ?>/topic<?cs
-            if:libraries ?>/libraries<?cs
-            elif:instantapps ?>/instant-apps<?cs
-            elif:perf ?>/performance<?cs
-            elif:arc ?>/arc<?cs /if ?><?cs
-          elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?>/distribute<?cs
-            if:googleplay ?>/googleplay<?cs
-            elif:essentials ?>/essentials<?cs
-            elif:users ?>/users<?cs
-            elif:engage ?>/engage<?cs
-            elif:monetize ?>/monetize<?cs
-            elif:disttools ?>/tools<?cs
-            elif:stories ?>/stories<?cs
-            elif:analyze ?>/analyze<?cs /if ?><?cs
-          elif:(about||versions||wear||tv||auto) ?>/about<?cs
-          elif:preview ?>/preview<?cs
-          elif:wearpreview ?>/wear/preview<?cs
-          elif:work ?>/work<?cs
-          elif:design ?>/design<?cs
-          elif:reference.testSupport ?>/reference/android/support/test<?cs
-          elif:reference.wearableSupport ?>/reference/android/support/wearable<?cs
-          elif:walkthru ?>/walkthru<?cs /if ?><?cs
-        /if ?>/_book.yaml" /><?cs
-        /if ?>
-  <meta name="project_path" value="<?cs
-      if:(guide||develop||training||reference||tools||sdk||samples) ?><?cs
-        if:guide ?>/guide<?cs
-        elif:training ?>/training<?cs
-        elif:reference ?>/reference<?cs
-        elif:samples ?>/samples<?cs /if ?><?cs
-      elif:(google||reference.gms||reference.gcm) ?>/google<?cs
-      elif:(topic||libraries) ?>/develop<?cs
-      elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories||analyze) ?>/distribute<?cs
-        if:googleplay ?>/googleplay<?cs
-        elif:essentials ?>/essentials<?cs
-        elif:users ?>/users<?cs
-        elif:engage ?>/engage<?cs
-        elif:monetize ?>/monetize<?cs
-        elif:disttools ?>/tools<?cs
-        elif:stories ?>/stories<?cs
-        elif:analyze ?>/analyze<?cs
-        else ?><?cs /if ?><?cs
-      elif:(about||versions||wear||tv||auto) ?><?cs
-        if:versions ?>/about/versions<?cs
-        elif:wear ?>/wear<?cs
-        elif:tv ?>/tv<?cs
-        elif:auto ?>/auto<?cs
-        else ?>/about<?cs /if ?><?cs
-      elif:wearpreview ?>/wear/preview<?cs
-      elif:work ?>/work<?cs
-      elif:preview ?>/preview<?cs
-      elif:design ?>/design<?cs /if ?>/_project.yaml" /><?cs
-
-      if:page.tags && page.tags != "" ?>
-  <meta name="keywords" value='<?cs var:page.tags ?>' /><?cs
-      /if ?><?cs
-      if:meta.tags && meta.tags != "" ?>
-  <meta name="meta_tags" value='<?cs var:meta.tags ?>' /><?cs
-      /if ?><?cs
-      if:fullpage ?>
-  <meta name="full_width" value="True" /><?cs
-      /if ?><?cs
-      if:page.landing ?>
-  <meta name="page_type" value="landing" /><?cs
-      /if ?><?cs
-      if:page.article ?>
-  <meta name="page_type" value="article" /><?cs
-      /if ?><?cs
-      if:page.image ?>
-  <meta name="image_path" value='<?cs var:page.image ?>' /><?cs
-      /if ?><?cs
-      if:excludeFromSuggestions ?>
-  <meta name="hide_from_search_suggest" value="true" /><?cs
-      /if ?><?cs
-/if ?><?cs # END if/else devsite ?><?cs
-
-  if:!devsite ?>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
-<meta content="IE=edge" http-equiv="X-UA-Compatible">
-<link rel="shortcut icon" type="image/x-icon" href="<?cs var:toroot ?>favicon.ico" />
-<link rel="alternate" href="http://developer.android.com/<?cs var:path.canonical ?>" hreflang="en" />
-<link rel="alternate" href="http://developer.android.com/intl/es/<?cs var:path.canonical ?>" hreflang="es" />
-<link rel="alternate" href="http://developer.android.com/intl/id/<?cs var:path.canonical ?>" hreflang="id" />
-<link rel="alternate" href="http://developer.android.com/intl/ja/<?cs var:path.canonical ?>" hreflang="ja" />
-<link rel="alternate" href="http://developer.android.com/intl/ko/<?cs var:path.canonical ?>" hreflang="ko" />
-<link rel="alternate" href="http://developer.android.com/intl/pt-br/<?cs var:path.canonical ?>" hreflang="pt-br" />
-<link rel="alternate" href="http://developer.android.com/intl/ru/<?cs var:path.canonical ?>" hreflang="ru" />
-<link rel="alternate" href="http://developer.android.com/intl/vi/<?cs var:path.canonical ?>" hreflang="vi" />
-<link rel="alternate" href="http://developer.android.com/intl/zh-cn/<?cs var:path.canonical ?>" hreflang="zh-cn" />
-<link rel="alternate" href="http://developer.android.com/intl/zh-tw/<?cs var:path.canonical ?>" hreflang="zh-tw" />
-<?cs /if ?><?cs
-# END if/else !devsite ?><?cs
-
-      if:page.metaDescription ?>
-  <meta name="description" content="<?cs var:page.metaDescription ?>"><?cs
-      /if ?><?cs
-  if:!devsite ?>
-<!-- STYLESHEETS -->
-<link rel="stylesheet"
-href="<?cs
-if:android.whichdoc != 'online' ?>http:<?cs
-/if ?>//fonts.googleapis.com/css?family=Roboto+Condensed">
-<link rel="stylesheet" href="<?cs
-if:android.whichdoc != 'online' ?>http:<?cs
-/if ?>//fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
-  title="roboto">
-<?cs
-  if:ndk ?><link rel="stylesheet" href="<?cs
-  if:android.whichdoc != 'online' ?>http:<?cs
-  /if ?>//fonts.googleapis.com/css?family=Roboto+Mono:400,500,700" title="roboto-mono" type="text/css"><?cs
-/if ?>
-<link href="<?cs var:toroot ?>assets/css/default.css?v=16" rel="stylesheet" type="text/css">
-
-<!-- JAVASCRIPT -->
-<script src="<?cs if:android.whichdoc != 'online' ?>http:<?cs /if ?>//www.google.com/jsapi" type="text/javascript"></script>
-<script src="<?cs var:toroot ?>assets/js/android_3p-bundle.js" type="text/javascript"></script><?cs
-  if:page.customHeadTag ?>
-<?cs var:page.customHeadTag ?><?cs
-  /if ?>
-<script type="text/javascript">
-  var toRoot = "<?cs var:toroot ?>";
-  var metaTags = [<?cs var:meta.tags ?>];
-  var devsite = <?cs if:devsite ?>true<?cs else ?>false<?cs /if ?>;
-  var useUpdatedTemplates = <?cs if:useUpdatedTemplates ?>true<?cs else ?>false<?cs /if ?>;
-</script>
-<script src="<?cs var:toroot ?>assets/js/docs.js?v=17" type="text/javascript"></script>
-
-<script>
-  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
-  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
-  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
-  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
-  ga('create', 'UA-5831155-1', 'android.com');
-  ga('create', 'UA-49880327-2', 'android.com', {'name': 'universal'});  // New tracker);
-  ga('send', 'pageview');
-  ga('universal.send', 'pageview'); // Send page view for new tracker.
-</script><?cs /if ?><?cs
-# END if/else !devsite ?>
-</head>
diff --git a/tools/droiddoc/templates-sdk/header.cs b/tools/droiddoc/templates-sdk/header.cs
deleted file mode 100644
index a927393..0000000
--- a/tools/droiddoc/templates-sdk/header.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-<?cs if:!devsite ?><?cs # leave out the global header for devsite; it is in devsite template ?>
-  <?cs call:custom_masthead() ?>
-
-  <?cs if:(fullpage) ?>
-    <?cs call:fullpage() ?>
-  <?cs else ?>
-    <?cs call:body_content_wrap_start() ?>
-  <?cs /if ?>
-
-  <?cs call:search_results() ?>
-<?cs /if ?><?cs # end if/else !devsite ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/header_tabs.cs b/tools/droiddoc/templates-sdk/header_tabs.cs
deleted file mode 100644
index 38c9da8..0000000
--- a/tools/droiddoc/templates-sdk/header_tabs.cs
+++ /dev/null
@@ -1,2 +0,0 @@
-
-<!-- CURRENTLY NOT USED... ALL TABS ARE IN masthead.cs -->
diff --git a/tools/droiddoc/templates-sdk/jd_lists_unified.cs b/tools/droiddoc/templates-sdk/jd_lists_unified.cs
deleted file mode 100644
index 03141b0..0000000
--- a/tools/droiddoc/templates-sdk/jd_lists_unified.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-<?cs # generate metadata file for samples only ?><?cs
-if:samples_only ?>METADATA['<?cs var:metadata.lang ?>'].develop = METADATA['<?cs var:metadata.lang ?>'].develop.concat([
-<?cs var:reference_tree ?>
-]);
-<?cs # generate standard unified metadata file ?><?cs
-else ?>window.METADATA = window.METADATA || {};
-METADATA['<?cs var:metadata.lang ?>'] = {};
-
-METADATA['<?cs var:metadata.lang ?>'].about = [];
-METADATA['<?cs var:metadata.lang ?>'].design = [];
-METADATA['<?cs var:metadata.lang ?>'].develop = [];
-METADATA['<?cs var:metadata.lang ?>'].distribute = [];
-METADATA['<?cs var:metadata.lang ?>'].extras = [];
-
-<?cs var:reference_tree ?>
-<?cs /if ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/lists.cs b/tools/droiddoc/templates-sdk/lists.cs
deleted file mode 100644
index f08abba..0000000
--- a/tools/droiddoc/templates-sdk/lists.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-var <?cs
-  if:reference.testSupport ?>SUPPORT_TEST_<?cs
-  elif: reference.wearableSupport ?>SUPPORT_WEARABLE_<?cs
-  elif: reference.constraintSupport ?>CONSTRAINT_<?cs
-  /if ?>DATA = [
-<?cs each:page = docs.pages
-?>      { id:<?cs var: page.id ?>, label:"<?cs var:page.label ?>", link:"<?cs var:page.link ?>", type:"<?cs var:page.type ?>", deprecated:"<?cs var:page.deprecated ?>" }<?cs if:!last(page) ?>,<?cs /if ?>
-<?cs /each ?>
-    ];
diff --git a/tools/droiddoc/templates-sdk/macros_override.cs b/tools/droiddoc/templates-sdk/macros_override.cs
deleted file mode 100644
index 5b92fe3..0000000
--- a/tools/droiddoc/templates-sdk/macros_override.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-<?cs # Create a comma separated list of annotations on obj that were in showAnnotations in Doclava ?>
-<?cs # pre is an HTML string to start the list, post is an HTML string to close the list ?>
-<?cs # for example call:show_annotations_list(cl, "<td>Annotations: ", "</td>") ?>
-<?cs # if obj has nothing on obj.showAnnotations, nothing will be output ?>
-<?cs def:show_annotations_list(obj) ?>
-    <?cs each:anno = obj.showAnnotations ?>
-      <?cs if:first(anno) ?>
-        <span class='annotation-message'>
-          Included in documentation by the annotations:
-      <?cs /if ?>
-      @<?cs var:anno.type.label ?>
-      <?cs if:last(anno) == 0 ?>
-        , &nbsp;
-      <?cs /if ?>
-      <?cs if:last(anno)?>
-        </span>
-      <?cs /if ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs # Override default class_link_table to display annotations ?>
-<?cs def:class_link_table(classes) ?>
-  <?cs set:count = #1 ?>
-  <table class="jd-sumtable-expando">
-    <?cs each:cl=classes ?>
-      <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:cl.type.since ?>" >
-        <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td>
-        <td class="jd-descrcol" width="100%">
-          <?cs call:short_descr(cl) ?>&nbsp;
-          <?cs call:show_annotations_list(cl) ?>
-        </td>
-      </tr>
-      <?cs set:count = count + #1 ?>
-    <?cs /each ?>
-  </table>
-<?cs /def ?>
-
-<?cs
-# Prints a comma separated list of parameters with optional line breaks
-?><?cs
-def:parameter_list(params, linebreaks) ?><?cs
-  each:param = params ?><?cs
-      call:simple_type_link(param.type)?> <?cs
-      var:param.name ?><?cs
-      if: name(param)!=subcount(params)-1
-        ?>, <?cs if:linebreaks
-?>
-                <?cs /if ?><?cs
-      /if ?><?cs
-  /each ?><?cs
-/def ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/navtree_data.cs b/tools/droiddoc/templates-sdk/navtree_data.cs
deleted file mode 100644
index 73aa199..0000000
--- a/tools/droiddoc/templates-sdk/navtree_data.cs
+++ /dev/null
@@ -1,3 +0,0 @@
-var NAVTREE_DATA =
-<?cs var:reference_tree ?>
-;
diff --git a/tools/droiddoc/templates-sdk/nosidenavpage.cs b/tools/droiddoc/templates-sdk/nosidenavpage.cs
deleted file mode 100644
index 61754f0..0000000
--- a/tools/droiddoc/templates-sdk/nosidenavpage.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<body class="gc-documentation 
-  <?cs if:(guide||develop||training||reference||tools||sdk) ?>develop<?cs
-  elif:design ?>design<?cs
-  elif:distribute ?>distribute<?cs
-  /if ?>" itemscope itemtype="http://schema.org/Article">
-<a name="top"></a>
-<?cs call:custom_masthead() ?>
-
-<div id="body-content">
-<div>
-<div id="doc-content" style="position:relative;">
-
-<?cs call:tag_list(root.descr) ?>
-
-<?cs include:"footer.cs" ?>
-</div><!-- end doc-content -->
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
-
-
-
diff --git a/tools/droiddoc/templates-sdk/package.cs b/tools/droiddoc/templates-sdk/package.cs
deleted file mode 100644
index d3efdda..0000000
--- a/tools/droiddoc/templates-sdk/package.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-<?cs # THIS CREATES A PACKAGE SUMMARY PAGE FROM EACH package.html FILES
-     # AND NAMES IT package-summary.html ?>
-<?cs include:"macros.cs" ?>
-<?cs include:"macros_override.cs" ?>
-<?cs include:"doctype.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"body_tag.cs" ?>
-<?cs include:"header.cs" ?>
-<?cs include:"page_info.cs" ?>
-<div class="api apilevel-<?cs var:package.since ?>" id="jd-content">
-
-<h1><?cs var:package.name ?></h1>
-
-<?cs if:subcount(package.descr) ?>
-  <?cs call:tag_list(package.descr) ?>
-<?cs /if ?>
-
-<?cs def:class_table(label, classes) ?>
-  <?cs if:subcount(classes) ?>
-    <h2><?cs var:label ?></h2>
-    <?cs call:class_link_table(classes) ?>
-  <?cs /if ?>
-<?cs /def ?>
-
-<?cs call:class_table("Annotations", package.annotations) ?>
-<?cs call:class_table("Interfaces", package.interfaces) ?>
-<?cs call:class_table("Classes", package.classes) ?>
-<?cs call:class_table("Enums", package.enums) ?>
-<?cs call:class_table("Exceptions", package.exceptions) ?>
-<?cs call:class_table("Errors", package.errors) ?>
-
-</div><!-- end apilevel -->
-
-<?cs if:devsite ?>
-<div class="data-reference-resources-wrapper">
-  <?cs if:subcount(class.package) ?>
-  <ul data-reference-resources>
-    <?cs call:list("Annotations", class.package.annotations) ?>
-    <?cs call:list("Interfaces", class.package.interfaces) ?>
-    <?cs call:list("Classes", class.package.classes) ?>
-    <?cs call:list("Enums", class.package.enums) ?>
-    <?cs call:list("Exceptions", class.package.exceptions) ?>
-    <?cs call:list("Errors", class.package.errors) ?>
-  </ul>
-  <?cs elif:subcount(package) ?>
-  <ul data-reference-resources>
-    <?cs call:class_link_list("Annotations", package.annotations) ?>
-    <?cs call:class_link_list("Interfaces", package.interfaces) ?>
-    <?cs call:class_link_list("Classes", package.classes) ?>
-    <?cs call:class_link_list("Enums", package.enums) ?>
-    <?cs call:class_link_list("Exceptions", package.exceptions) ?>
-    <?cs call:class_link_list("Errors", package.errors) ?>
-  </ul>
-  <?cs /if ?>
-</div>
-<?cs /if ?>
-
-<?cs if:!devsite ?>
-<?cs include:"footer.cs" ?>
-<?cs include:"trailer.cs" ?>
-<?cs /if ?>
-</body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/packages.cs b/tools/droiddoc/templates-sdk/packages.cs
deleted file mode 100644
index 3fcfb81..0000000
--- a/tools/droiddoc/templates-sdk/packages.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-<?cs # THIS CREATES A LIST OF ALL PACKAGES AND NAMES IT packages.html ?>
-<?cs include:"macros.cs" ?>
-<?cs include:"doctype.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<?cs include:"body_tag.cs" ?>
-<?cs include:"header.cs" ?>
-
-<h1><?cs var:page.title ?></h1>
-<p>These are the API packages.
-See all <a href="classes.html">API classes</a>.</p>
-
-<?cs set:count = #1 ?>
-<table>
-<?cs each:pkg = docs.packages ?>
-    <tr class="api apilevel-<?cs var:pkg.since ?>" >
-        <td class="jd-linkcol"><?cs call:package_link(pkg) ?></td>
-        <td class="jd-descrcol" width="100%"><?cs call:tag_list(pkg.shortDescr) ?></td>
-    </tr>
-<?cs set:count = count + #1 ?>
-<?cs /each ?>
-</table>
-
-<?cs if:devsite ?>
-<div class="data-reference-resources-wrapper">
-  <?cs if:subcount(class.package) ?>
-  <ul data-reference-resources>
-    <?cs call:list("Annotations", class.package.annotations) ?>
-    <?cs call:list("Interfaces", class.package.interfaces) ?>
-    <?cs call:list("Classes", class.package.classes) ?>
-    <?cs call:list("Enums", class.package.enums) ?>
-    <?cs call:list("Exceptions", class.package.exceptions) ?>
-    <?cs call:list("Errors", class.package.errors) ?>
-  </ul>
-  <?cs elif:subcount(package) ?>
-  <ul data-reference-resources>
-    <?cs call:class_link_list("Annotations", package.annotations) ?>
-    <?cs call:class_link_list("Interfaces", package.interfaces) ?>
-    <?cs call:class_link_list("Classes", package.classes) ?>
-    <?cs call:class_link_list("Enums", package.enums) ?>
-    <?cs call:class_link_list("Exceptions", package.exceptions) ?>
-    <?cs call:class_link_list("Errors", package.errors) ?>
-  </ul>
-  <?cs /if ?>
-</div>
-<?cs /if ?>
-
-<?cs if:!devsite ?>
-<?cs include:"footer.cs" ?>
-<?cs include:"trailer.cs" ?>
-<?cs /if ?>
-</body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/page_info.cs b/tools/droiddoc/templates-sdk/page_info.cs
deleted file mode 100644
index fad1274..0000000
--- a/tools/droiddoc/templates-sdk/page_info.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-<?cs # optional, more info about the page, such as API level and links ?>
-<?cs
-# A modal dialog when API level is set too low for this page
-?><div id="naMessage"></div>
-<?cs
-#
-# If this is a package summary page...
-#
-?><?cs
-if:subcount(package)
-?>
-<div id="api-info-block">
-<div class="api-level">
-  <?cs call:since_tags(package) ?>
-  <?cs call:federated_refs(package) ?>
-</div>
-</div><?cs
-#
-# Or if this is a class page...
-#
-?><?cs
-elif:subcount(class)
-?>
-<div id="api-info-block">
-<div class="api-level">
-  <?cs call:since_tags(class) ?><?cs
-  if:class.deprecatedsince
-    ?><br>Deprecated since <a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html#ApiLevels"
-        >API level <?cs var:class.deprecatedsince ?></a><?cs
-  /if ?>
-  <?cs call:federated_refs(class) ?>
-</div>
-
-<?cs # Set variables about whether there are inherited members; no output ?>
-<?cs each:cl=class.inherited ?>
-  <?cs if:subcount(cl.methods) ?>
-   <?cs set:inhmethods = #1 ?>
-  <?cs /if ?>
-  <?cs if:subcount(cl.constants) ?>
-   <?cs set:inhconstants = #1 ?>
-  <?cs /if ?>
-  <?cs if:subcount(cl.fields) ?>
-   <?cs set:inhfields = #1 ?>
-  <?cs /if ?>
-  <?cs if:subcount(cl.attrs) ?>
-   <?cs set:inhattrs = #1 ?>
-  <?cs /if ?>
-<?cs /each ?>
-
-<div class="sum-details-links">
-<?cs if:inhattrs || inhconstants || inhfields || inhmethods || (!class.subclasses.hidden &&
-     (subcount(class.subclasses.direct) || subcount(class.subclasses.indirect))) ?>
-Summary:
-<?cs if:subcount(class.inners) ?>
-  <a href="#nestedclasses">Nested Classes</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.attrs) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#lattrs">XML Attrs</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhattrs ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhattrs">Inherited XML Attrs</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.enumConstants) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#enumconstants">Enums</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.constants) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#constants">Constants</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhconstants ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhconstants">Inherited Constants</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.fields) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#lfields">Fields</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhfields ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhfields">Inherited Fields</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.ctors.public) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#pubctors">Ctors</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.ctors.protected) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#proctors">Protected Ctors</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.methods.public) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#pubmethods">Methods</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:subcount(class.methods.protected) ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#promethods">Protected Methods</a>
-  <?cs set:linkcount = #1 ?>
-<?cs /if ?>
-<?cs if:inhmethods ?>
-  <?cs if:linkcount ?>&#124; <?cs /if ?><a href="#inhmethods">Inherited Methods</a>
-<?cs /if ?>
-&#124; <a href="#" onclick="return toggleAllClassInherited()" id="toggleAllClassInherited">[Expand All]</a>
-<?cs /if ?>
-</div><!-- end sum-details-links -->
-</div><!-- end api-info-block --><?cs
-/if ?><?cs # end of if package or class ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/sample.cs b/tools/droiddoc/templates-sdk/sample.cs
deleted file mode 100644
index 2c5b9d2..0000000
--- a/tools/droiddoc/templates-sdk/sample.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<body class="gc-documentation develop samples" itemscope itemtype="http://schema.org/Article">
-<?cs include:"header.cs" ?>
-
-<!-- start breadcrumb block -->
-<div id="api-info-block">
-  <div class="sum-details-links">
-
-  <!-- related links -->
-  <a href="<?cs var:toroot ?>samples/<?cs var:projectDir ?>/index.html">Overview</a>
-  &#124; <a href="<?cs var:toroot ?>samples/<?cs var:projectDir ?>/project.html">Project</a>
-  &#124; <a href="<?cs var:toroot ?>downloads/samples/<?cs var:projectDir ?>.zip"
-    onclick="ga('send', 'event', 'Samples', 'Download', <?cs var:projectDir ?>);"
-    >Download</a>
-
-</div><!-- end sum-details-links -->
-
-</div><!-- end breadcurmb block -->
-
-<div id="jd-header" style="border:0;">
-
-<div id="pathCrumb">
-<?cs each:item = parentdirs ?>
-  <?cs if:LinkifyPathCrumb
-    ?><a href="<?cs var:toroot ?><?cs var:item.Link ?>"><?cs var:item.Name ?></a> /
-  <?cs else
-    ?><?cs var:item.Name ?> / <?cs /if ?>
-<?cs /each ?>
-</div>
-
-  <h1 itemprop="name"><?cs var:page.title ?></h1>
-</div>
-<!-- end breadcrumb block -->
-
-
-<?cs # THIS IS THE MAIN DOC CONTENT ?>
-<div id="jd-content">
-
-<?cs if:android.whichdoc == "online" ?>
-
-<?cs # If this is the online docs, build the src code navigation links ?>
-
-
-<?cs var:summary ?>
-
-<!-- begin file contents -->
-
-<?cs # embed image/videos if below maxsize (show message otherwise), else display source code ?>
-<?cs if:resType == "img" ?>
-  <div id="codesample-resource"
-    <?cs if:noDisplay ?>
-      class="noDisplay"><div class="noDisplay-message"></div>
-    <?cs else ?>
-      ><img src="<?cs var:realFile ?>" title="<?cs var:page.title ?>">
-    <?cs /if ?>
-  </div>
-<?cs elif:resType == "video" ?>
-  <div id="codesample-resource"
-    <?cs if:noDisplay ?>
-      class="noDisplay"><div class="noDisplay-message"></div>
-    <?cs else ?>
-      ><video class="play-on-hover" controls style="border:1px solid #ececec;background-color:#f9f9f9;" poster="">
-        <source src="<?cs var:page.title ?>">
-      </video>
-    <?cs /if ?>
-  </div>
-<?cs else ?>
-  <div id="codesample-wrapper">
-    <pre id="codesample-line-numbers" class="no-pretty-print hidden"></pre>
-    <pre id="codesample-block"><?cs var:fileContents ?></pre>
-  </div>
-  <script type="text/javascript">
-  initCodeLineNumbers();
-  </script>
-<?cs /if ?>
-
-<!-- end file contents -->
-
-<?cs else ?><?cs
-  # else, this means it's offline docs,
-          so don't show src links (we dont have the pages!) ?>
-
-<?cs /if ?><?cs # end if/else online docs ?>
-
-      <div class="content-footer <?cs
-                    if:fullpage ?>wrap<?cs
-                    else ?>cols<?cs /if ?>"
-                    itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <div class="<?cs
-                    if:fullpage ?>col-16<?cs
-                    elif:training||guide ?>col-8<?cs
-                    else ?>col-9<?cs /if ?>" style="padding-top:4px">
-          <?cs if:!page.noplus ?><?cs if:fullpage ?><style>#___plusone_0 {float:right !important;}</style><?cs /if ?>
-            <div class="g-plusone" data-size="medium"></div>
-          <?cs /if ?>
-        </div>
-        <?cs if:!fullscreen ?>
-        <div class="paging-links col-4">
-          <?cs if:(design||training||walkthru) && !page.landing && !page.trainingcourse && !footer.hide ?>
-            <a href="#" class="prev-page-link hide"
-                zh-tw-lang="上一堂課"
-                zh-cn-lang="上一课"
-                ru-lang="Предыдущий"
-                ko-lang="이전"
-                ja-lang="前へ"
-                es-lang="Anterior"
-                >Previous</a>
-            <a href="#" class="next-page-link hide"
-                zh-tw-lang="下一堂課"
-                zh-cn-lang="下一课"
-                ru-lang="Следующий"
-                ko-lang="다음"
-                ja-lang="次へ"
-                es-lang="Siguiente"
-                >Next</a>
-          <?cs /if ?>
-        </div>
-        <?cs /if ?>
-      </div>
-
-      <?cs # for training classes, provide a different kind of link when the next page is a different class ?>
-      <?cs if:training && !page.article ?>
-      <div class="content-footer next-class" style="display:none" itemscope itemtype="http://schema.org/SiteNavigationElement">
-          <a href="#" class="next-class-link hide">Next class: </a>
-      </div>
-      <?cs /if ?>
-
-  </div> <!-- end jd-content -->
-
-  <?cs if:!devsite ?>
-  <?cs include:"footer.cs" ?>
-  <?cs include:"trailer.cs" ?>
-  <?cs /if ?>
-
-</body>
-</html>
diff --git a/tools/droiddoc/templates-sdk/sampleindex.cs b/tools/droiddoc/templates-sdk/sampleindex.cs
deleted file mode 100644
index db648ff..0000000
--- a/tools/droiddoc/templates-sdk/sampleindex.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-<?cs include:"doctype.cs" ?>
-<?cs include:"macros.cs" ?>
-<html<?cs if:devsite ?> devsite<?cs /if ?>>
-<?cs include:"head_tag.cs" ?>
-<body class="gc-documentation develop samples" itemscope itemtype="http://schema.org/Article">
-<?cs include:"header.cs" ?>
-
-<!-- start breadcrumb block -->
-<div id="api-info-block">
-<div class="sum-details-links">
-
-<!-- related links -->
-<?cs if:projectStructure ?>
-<a href="<?cs var:toroot ?>samples/<?cs var:projectDir ?>/index.html">Overview</a>
-&#124; Project<?cs else ?>Overview
-&#124; <a href="<?cs var:toroot ?>samples/<?cs var:projectDir ?>/project.html">Project</a>
-<?cs /if ?>
-&#124; <a href="<?cs var:toroot ?>downloads/samples/<?cs var:projectDir ?>.zip"
-    onclick="ga('send', 'event', 'Samples', 'Download', <?cs var:projectDir ?>);"
-    >Download</a>
-
-</div><!-- end sum-details-links -->
-
-</div><!-- end breadcurmb block -->
-
-<h1 itemprop="name"><?cs var:projectDir ?></h1>
-  
-<div id="jd-content">
-<?cs def:display_files(files) ?>
-
-    <?cs each:file = files ?>
-        <?cs if:file.Type != "dir" ?>
-            <div class="structure-<?cs var:file.Type ?>">
-            <a href="<?cs var:toroot ?><?cs var:file.Href ?>"><?cs var:file.Name ?></a>
-            </div>
-        <?cs else ?>
-            <div class="toggle-content opened structure-dir">
-               <a href="#" onclick="return toggleContent(this)">
-               <img src="<?cs var:toroot ?>assets/images/triangle-opened.png"
-                  class="toggle-content-img structure-toggle-img" height="9px" width="9px" />
-               <?cs var:file.Name ?></a><?cs 
-                  if:file.SummaryFlag == "true" ?><span class="dirInfo"
-                    >[&nbsp;<a href="file.SummaryHref">Info</a>&nbsp;]</a></span><?cs 
-                  /if ?>
-               <div class="toggle-content-toggleme structure-toggleme"> 
-            <?cs if:file.Sub.0.Name ?>
-                 <?cs call:display_files(file.Sub) ?>
-            <?cs /if ?>
-               </div> <?cs # /toggleme ?>
-            </div> <?cs # /toggle-content ?>
-         <?cs /if ?>
-    <?cs /each ?>
-<?cs /def ?>
-
-<?cs if:android.whichdoc == "online" ?>
-  <?cs # If this is the online docs, build the src code navigation links ?>
-
-  <?cs if:projectStructure ?>
-
-    <?cs call:display_files(Files) ?>
-
-  <?cs else ?> <?cs # else not project structure doc ?>
-
-    <?cs var:summary ?>
-
-    <?cs # Remove project structure from landing pages for now
-         # <h2>Project Structure</h2>
-         # <p>Decide what to do with this ...</p>
-         # <?cs call:display_files(Files) ?>
-
-  <?cs /if ?> <?cs # end if projectStructure ?>
-
-<?cs else ?><?cs
-  # else, this means it's offline docs,
-          so don't show src links (we dont have the pages!) ?>
-
-<?cs /if ?><?cs # end if/else online docs ?>
-      <div class="content-footer <?cs
-                    if:fullpage ?>wrap<?cs
-                    else ?>cols<?cs /if ?>"
-                    itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <div class="<?cs
-                    if:fullpage ?>col-16<?cs
-                    elif:training||guide ?>col-8<?cs
-                    else ?>col-9<?cs /if ?>" style="padding-top:4px">
-          <?cs if:!page.noplus ?><?cs if:fullpage ?><style>#___plusone_0 {float:right !important;}</style><?cs /if ?>
-            <div class="g-plusone" data-size="medium"></div>
-          <?cs /if ?>
-        </div>
-        <?cs if:!fullscreen ?>
-        <div class="paging-links col-4">
-          <?cs if:(design||training||walkthru) && !page.landing && !page.trainingcourse && !footer.hide ?>
-            <a href="#" class="prev-page-link hide"
-                zh-tw-lang="上一堂課"
-                zh-cn-lang="上一课"
-                ru-lang="Предыдущий"
-                ko-lang="이전"
-                ja-lang="前へ"
-                es-lang="Anterior"
-                >Previous</a>
-            <a href="#" class="next-page-link hide"
-                zh-tw-lang="下一堂課"
-                zh-cn-lang="下一课"
-                ru-lang="Следующий"
-                ko-lang="다음"
-                ja-lang="次へ"
-                es-lang="Siguiente"
-                >Next</a>
-          <?cs /if ?>
-        </div>
-        <?cs /if ?>
-      </div>
-
-      <?cs # for training classes, provide a different kind of link when the next page is a different class ?>
-      <?cs if:training && !page.article ?>
-      <div class="content-footer next-class" style="display:none" itemscope itemtype="http://schema.org/SiteNavigationElement">
-          <a href="#" class="next-class-link hide">Next class: </a>
-      </div>
-      <?cs /if ?>
-
-  </div> <!-- end jd-content -->
-
-<?cs include:"footer.cs" ?>
-
-<?cs include:"trailer.cs" ?>
-
-</body>
-</html>
-
-
diff --git a/tools/droiddoc/templates-sdk/samples_navtree_data.cs b/tools/droiddoc/templates-sdk/samples_navtree_data.cs
deleted file mode 100644
index b9b4214..0000000
--- a/tools/droiddoc/templates-sdk/samples_navtree_data.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-toc:
-- title: About the Samples
-  path: /samples/index.html
-
-- title: What's New
-  path: /samples/new/index.html
-
-<?cs var:samples_toc_tree ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/timestamp.cs b/tools/droiddoc/templates-sdk/timestamp.cs
deleted file mode 100644
index 4bf502a..0000000
--- a/tools/droiddoc/templates-sdk/timestamp.cs
+++ /dev/null
@@ -1 +0,0 @@
-var BUILD_TIMESTAMP = "<?cs var:page.now ?>";
diff --git a/tools/droiddoc/templates-sdk/trailer.cs b/tools/droiddoc/templates-sdk/trailer.cs
deleted file mode 100644
index 2050475..0000000
--- a/tools/droiddoc/templates-sdk/trailer.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-<?cs
-# Other, non-visible things needed at the end of the page,
-# because not every page needs footer content, but does need other stuff
-?>
-</div> <!-- end body-content --> <?cs # normally opened by header.cs ?>
-
-<?cs if:carousel ?>
-<script type="text/javascript">
-$('.slideshow-container').dacSlideshow({
-    btnPrev: '.slideshow-prev',
-    btnNext: '.slideshow-next',
-    btnPause: '#pauseButton'
-});
-</script>
-<?cs /if ?>
-<?cs if:tabbedList ?>
-<script type="text/javascript">
-$(".feed").dacTabbedList({
-    nav_id: '.feed-nav',
-    frame_id: '.feed-frame'
-});
-</script>
-<?cs /if ?>
-
-<script src="https://developer.android.com/ytblogger_lists_unified.js" defer></script>
-<script src="/jd_lists_unified_en.js?v=17" defer></script>
-<script src="/reference/lists.js?v=17" defer></script>
-<script src="/reference/gcm_lists.js?v=17" defer></script>
-<script src="/reference/gms_lists.js?v=17" defer></script>
-<script>
-  // Load localized metadata.
-  (function(lang) {
-    if (lang === 'en') { return; }
-
-    // Write it to the document so it gets evaluated before DOMContentReady.
-    document.write('<script src="/jd_lists_unified_' + lang + '.js?v=14" defer></' + 'script>');
-  })(getLangPref())
-</script>
diff --git a/tools/droiddoc/templates-sdk/yaml_navtree.cs b/tools/droiddoc/templates-sdk/yaml_navtree.cs
deleted file mode 100644
index e5a6404..0000000
--- a/tools/droiddoc/templates-sdk/yaml_navtree.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-<?cs
-
-# print out the yaml nav for the reference docs, only printing the title,
-path, and status_text (API level) for each package.
-
-?>
-reference:<?cs
-each:page = docs.pages?><?cs
-  if:page.type == "package"?>
-- title: <?cs var:page.label ?>
-  path: /<?cs var:page.link ?>
-  status_text: apilevel-<?cs var:page.apilevel ?><?cs
-  /if?><?cs
-/each ?>
diff --git a/tools/fat16copy.py b/tools/fat16copy.py
new file mode 100755
index 0000000..c20930a
--- /dev/null
+++ b/tools/fat16copy.py
@@ -0,0 +1,776 @@
+#!/usr/bin/env python
+#
+# Copyright 2016 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.
+
+import os
+import sys
+import struct
+
+FAT_TABLE_START = 0x200
+DEL_MARKER = 0xe5
+ESCAPE_DEL_MARKER = 0x05
+
+ATTRIBUTE_READ_ONLY = 0x1
+ATTRIBUTE_HIDDEN = 0x2
+ATTRIBUTE_SYSTEM = 0x4
+ATTRIBUTE_VOLUME_LABEL = 0x8
+ATTRIBUTE_SUBDIRECTORY = 0x10
+ATTRIBUTE_ARCHIVE = 0x20
+ATTRIBUTE_DEVICE = 0x40
+
+LFN_ATTRIBUTES = \
+    ATTRIBUTE_VOLUME_LABEL | \
+    ATTRIBUTE_SYSTEM | \
+    ATTRIBUTE_HIDDEN | \
+    ATTRIBUTE_READ_ONLY
+LFN_ATTRIBUTES_BYTE = struct.pack("B", LFN_ATTRIBUTES)
+
+MAX_CLUSTER_ID = 0x7FFF
+
+def read_le_short(f):
+  "Read a little-endian 2-byte integer from the given file-like object"
+  return struct.unpack("<H", f.read(2))[0]
+
+def read_le_long(f):
+  "Read a little-endian 4-byte integer from the given file-like object"
+  return struct.unpack("<L", f.read(4))[0]
+
+def read_byte(f):
+  "Read a 1-byte integer from the given file-like object"
+  return struct.unpack("B", f.read(1))[0]
+
+def skip_bytes(f, n):
+  "Fast-forward the given file-like object by n bytes"
+  f.seek(n, os.SEEK_CUR)
+
+def skip_short(f):
+  "Fast-forward the given file-like object 2 bytes"
+  skip_bytes(f, 2)
+
+def skip_byte(f):
+  "Fast-forward the given file-like object 1 byte"
+  skip_bytes(f, 1)
+
+def rewind_bytes(f, n):
+  "Rewind the given file-like object n bytes"
+  skip_bytes(f, -n)
+
+def rewind_short(f):
+  "Rewind the given file-like object 2 bytes"
+  rewind_bytes(f, 2)
+
+class fake_file(object):
+  """
+  Interface for python file-like objects that we use to manipulate the image.
+  Inheritors must have an idx member which indicates the file pointer, and a
+  size member which indicates the total file size.
+  """
+
+  def seek(self, amount, direction=0):
+    "Implementation of seek from python's file-like object interface."
+    if direction == os.SEEK_CUR:
+      self.idx += amount
+    elif direction == os.SEEK_END:
+      self.idx = self.size - amount
+    else:
+      self.idx = amount
+
+    if self.idx < 0:
+      self.idx = 0
+    if self.idx > self.size:
+      self.idx = self.size
+
+class fat_file(fake_file):
+  """
+  A file inside of our fat image. The file may or may not have a dentry, and
+  if it does this object knows nothing about it. All we see is a valid cluster
+  chain.
+  """
+
+  def __init__(self, fs, cluster, size=None):
+    """
+    fs: The fat() object for the image this file resides in.
+    cluster: The first cluster of data for this file.
+    size: The size of this file. If not given, we use the total length of the
+          cluster chain that starts from the cluster argument.
+    """
+    self.fs = fs
+    self.start_cluster = cluster
+    self.size = size
+
+    if self.size is None:
+      self.size = fs.get_chain_size(cluster)
+
+    self.idx = 0
+
+  def read(self, size):
+    "Read method for pythonic file-like interface."
+    if self.idx + size > self.size:
+      size = self.size - self.idx
+    got = self.fs.read_file(self.start_cluster, self.idx, size)
+    self.idx += len(got)
+    return got
+
+  def write(self, data):
+    "Write method for pythonic file-like interface."
+    self.fs.write_file(self.start_cluster, self.idx, data)
+    self.idx += len(data)
+
+    if self.idx > self.size:
+      self.size = self.idx
+
+def shorten(name, index):
+  """
+  Create a file short name from the given long name (with the extension already
+  removed). The index argument gives a disambiguating integer to work into the
+  name to avoid collisions.
+  """
+  name = "".join(name.split('.')).upper()
+  postfix = "~" + str(index)
+  return name[:8 - len(postfix)] + postfix
+
+class fat_dir(object):
+  "A directory in our fat filesystem."
+
+  def __init__(self, backing):
+    """
+    backing: A file-like object from which we can read dentry info. Should have
+    an fs member allowing us to get to the underlying image.
+    """
+    self.backing = backing
+    self.dentries = []
+    to_read = self.backing.size / 32
+
+    self.backing.seek(0)
+
+    while to_read > 0:
+      (dent, consumed) = self.backing.fs.read_dentry(self.backing)
+      to_read -= consumed
+
+      if dent:
+        self.dentries.append(dent)
+
+  def __str__(self):
+    return "\n".join([str(x) for x in self.dentries]) + "\n"
+
+  def add_dentry(self, attributes, shortname, ext, longname, first_cluster,
+      size):
+    """
+    Add a new dentry to this directory.
+    attributes: Attribute flags for this dentry. See the ATTRIBUTE_ constants
+                above.
+    shortname: Short name of this file. Up to 8 characters, no dots.
+    ext: Extension for this file. Up to 3 characters, no dots.
+    longname: The long name for this file, with extension. Largely unrestricted.
+    first_cluster: The first cluster in the cluster chain holding the contents
+                   of this file.
+    size: The size of this file. Set to 0 for subdirectories.
+    """
+    new_dentry = dentry(self.backing.fs, attributes, shortname, ext,
+        longname, first_cluster, size)
+    new_dentry.commit(self.backing)
+    self.dentries.append(new_dentry)
+    return new_dentry
+
+  def make_short_name(self, name):
+    """
+    Given a long file name, return an 8.3 short name as a tuple. Name will be
+    engineered not to collide with other such names in this folder.
+    """
+    parts = name.rsplit('.', 1)
+
+    if len(parts) == 1:
+      parts.append('')
+
+    name = parts[0]
+    ext = parts[1].upper()
+
+    index = 1
+    shortened = shorten(name, index)
+
+    for dent in self.dentries:
+      assert dent.longname != name, "File must not exist"
+      if dent.shortname == shortened:
+        index += 1
+        shortened = shorten(name, index)
+
+    if len(name) <= 8 and len(ext) <= 3 and not '.' in name:
+      return (name.upper().ljust(8), ext.ljust(3))
+
+    return (shortened.ljust(8), ext[:3].ljust(3))
+
+  def new_file(self, name, data=None):
+    """
+    Add a new regular file to this directory.
+    name: The name of the new file.
+    data: The contents of the new file. Given as a file-like object.
+    """
+    size = 0
+    if data:
+      data.seek(0, os.SEEK_END)
+      size = data.tell()
+
+    # Empty files shouldn't have any clusters assigned.
+    chunk = self.backing.fs.allocate(size) if size > 0 else 0
+    (shortname, ext) = self.make_short_name(name)
+    self.add_dentry(0, shortname, ext, name, chunk, size)
+
+    if data is None:
+      return
+
+    data_file = fat_file(self.backing.fs, chunk, size)
+    data.seek(0)
+    data_file.write(data.read())
+
+  def open_subdirectory(self, name):
+    """
+    Open a subdirectory of this directory with the given name. If the
+    subdirectory doesn't exist, a new one is created instead.
+    Returns a fat_dir().
+    """
+    for dent in self.dentries:
+      if dent.longname == name:
+        return dent.open_directory()
+
+    chunk = self.backing.fs.allocate(1)
+    (shortname, ext) = self.make_short_name(name)
+    new_dentry = self.add_dentry(ATTRIBUTE_SUBDIRECTORY, shortname,
+            ext, name, chunk, 0)
+    result = new_dentry.open_directory()
+
+    parent_cluster = 0
+
+    if hasattr(self.backing, 'start_cluster'):
+      parent_cluster = self.backing.start_cluster
+
+    result.add_dentry(ATTRIBUTE_SUBDIRECTORY, '.', '', '', chunk, 0)
+    result.add_dentry(ATTRIBUTE_SUBDIRECTORY, '..', '', '', parent_cluster, 0)
+
+    return result
+
+def lfn_checksum(name_data):
+  """
+  Given the characters of an 8.3 file name (concatenated *without* the dot),
+  Compute a one-byte checksum which needs to appear in corresponding long file
+  name entries.
+  """
+  assert len(name_data) == 11, "Name data should be exactly 11 characters"
+  name_data = struct.unpack("B" * 11, name_data)
+
+  result = 0
+
+  for char in name_data:
+    last_bit = (result & 1) << 7
+    result = (result >> 1) | last_bit
+    result += char
+    result = result & 0xFF
+
+  return struct.pack("B", result)
+
+class dentry(object):
+  "A directory entry"
+  def __init__(self, fs, attributes, shortname, ext, longname,
+      first_cluster, size):
+    """
+    fs: The fat() object for the image we're stored in.
+    attributes: The attribute flags for this dentry. See the ATTRIBUTE_ flags
+                above.
+    shortname: The short name stored in this dentry. Up to 8 characters, no
+               dots.
+    ext: The file extension stored in this dentry. Up to 3 characters, no
+         dots.
+    longname: The long file name stored in this dentry.
+    first_cluster: The first cluster in the cluster chain backing the file
+                   this dentry points to.
+    size: Size of the file this dentry points to. 0 for subdirectories.
+    """
+    self.fs = fs
+    self.attributes = attributes
+    self.shortname = shortname
+    self.ext = ext
+    self.longname = longname
+    self.first_cluster = first_cluster
+    self.size = size
+
+  def name(self):
+    "A friendly text file name for this dentry."
+    if self.longname:
+      return self.longname
+
+    if not self.ext or len(self.ext) == 0:
+      return self.shortname
+
+    return self.shortname + "." + self.ext
+
+  def __str__(self):
+    return self.name() + " (" + str(self.size) + \
+      " bytes @ " + str(self.first_cluster) + ")"
+
+  def is_directory(self):
+    "Return whether this dentry points to a directory."
+    return (self.attributes & ATTRIBUTE_SUBDIRECTORY) != 0
+
+  def open_file(self):
+    "Open the target of this dentry if it is a regular file."
+    assert not self.is_directory(), "Cannot open directory as file"
+    return fat_file(self.fs, self.first_cluster, self.size)
+
+  def open_directory(self):
+    "Open the target of this dentry if it is a directory."
+    assert self.is_directory(), "Cannot open file as directory"
+    return fat_dir(fat_file(self.fs, self.first_cluster))
+
+  def longname_records(self, checksum):
+    """
+    Get the longname records necessary to store this dentry's long name,
+    packed as a series of 32-byte strings.
+    """
+    if self.longname is None:
+      return []
+    if len(self.longname) == 0:
+      return []
+
+    encoded_long_name = self.longname.encode('utf-16-le')
+    long_name_padding = "\0" * (26 - (len(encoded_long_name) % 26))
+    padded_long_name = encoded_long_name + long_name_padding
+
+    chunks = [padded_long_name[i:i+26] for i in range(0,
+      len(padded_long_name), 26)]
+    records = []
+    sequence_number = 1
+
+    for c in chunks:
+      sequence_byte = struct.pack("B", sequence_number)
+      sequence_number += 1
+      record = sequence_byte + c[:10] + LFN_ATTRIBUTES_BYTE + "\0" + \
+          checksum + c[10:22] + "\0\0" + c[22:]
+      records.append(record)
+
+    last = records.pop()
+    last_seq = struct.unpack("B", last[0])[0]
+    last_seq = last_seq | 0x40
+    last = struct.pack("B", last_seq) + last[1:]
+    records.append(last)
+    records.reverse()
+
+    return records
+
+  def commit(self, f):
+    """
+    Write this dentry into the given file-like object,
+    which is assumed to contain a FAT directory.
+    """
+    f.seek(0)
+    padded_short_name = self.shortname.ljust(8)
+    padded_ext = self.ext.ljust(3)
+    name_data = padded_short_name + padded_ext
+    longname_record_data = self.longname_records(lfn_checksum(name_data))
+    record = struct.pack("<11sBBBHHHHHHHL",
+        name_data,
+        self.attributes,
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        0,
+        self.first_cluster,
+        self.size)
+    entry = "".join(longname_record_data + [record])
+
+    record_count = len(longname_record_data) + 1
+
+    found_count = 0
+    while found_count < record_count:
+      record = f.read(32)
+
+      if record is None or len(record) != 32:
+        # We reached the EOF, so we need to extend the file with a new cluster.
+        f.write("\0" * self.fs.bytes_per_cluster)
+        f.seek(-self.fs.bytes_per_cluster, os.SEEK_CUR)
+        record = f.read(32)
+
+      marker = struct.unpack("B", record[0])[0]
+
+      if marker == DEL_MARKER or marker == 0:
+        found_count += 1
+      else:
+        found_count = 0
+
+    f.seek(-(record_count * 32), os.SEEK_CUR)
+    f.write(entry)
+
+class root_dentry_file(fake_file):
+  """
+  File-like object for the root directory. The root directory isn't stored in a
+  normal file, so we can't use a normal fat_file object to create a view of it.
+  """
+  def __init__(self, fs):
+    self.fs = fs
+    self.idx = 0
+    self.size = fs.root_entries * 32
+
+  def read(self, count):
+    f = self.fs.f
+    f.seek(self.fs.data_start() + self.idx)
+
+    if self.idx + count > self.size:
+      count = self.size - self.idx
+
+    ret = f.read(count)
+    self.idx += len(ret)
+    return ret
+
+  def write(self, data):
+    f = self.fs.f
+    f.seek(self.fs.data_start() + self.idx)
+
+    if self.idx + len(data) > self.size:
+      data = data[:self.size - self.idx]
+
+    f.write(data)
+    self.idx += len(data)
+    if self.idx > self.size:
+      self.size = self.idx
+
+class fat(object):
+  "A FAT image"
+
+  def __init__(self, path):
+    """
+    path: Path to an image file containing a FAT file system.
+    """
+    f = open(path, "r+b")
+
+    self.f = f
+
+    f.seek(0xb)
+    bytes_per_sector = read_le_short(f)
+    sectors_per_cluster = read_byte(f)
+
+    self.bytes_per_cluster = bytes_per_sector * sectors_per_cluster
+
+    reserved_sectors = read_le_short(f)
+    assert reserved_sectors == 1, \
+        "Can only handle FAT with 1 reserved sector"
+
+    fat_count = read_byte(f)
+    assert fat_count == 2, "Can only handle FAT with 2 tables"
+
+    self.root_entries = read_le_short(f)
+
+    skip_short(f) # Image size. Sort of. Useless field.
+    skip_byte(f) # Media type. We don't care.
+
+    self.fat_size = read_le_short(f) * bytes_per_sector
+    self.root = fat_dir(root_dentry_file(self))
+
+  def data_start(self):
+    """
+    Index of the first byte after the FAT tables.
+    """
+    return FAT_TABLE_START + self.fat_size * 2
+
+  def get_chain_size(self, head_cluster):
+    """
+    Return how many total bytes are in the cluster chain rooted at the given
+    cluster.
+    """
+    if head_cluster == 0:
+      return 0
+
+    f = self.f
+    f.seek(FAT_TABLE_START + head_cluster * 2)
+
+    cluster_count = 0
+
+    while head_cluster <= MAX_CLUSTER_ID:
+      cluster_count += 1
+      head_cluster = read_le_short(f)
+      f.seek(FAT_TABLE_START + head_cluster * 2)
+
+    return cluster_count * self.bytes_per_cluster
+
+  def read_dentry(self, f=None):
+    """
+    Read and decode a dentry from the given file-like object at its current
+    seek position.
+    """
+    f = f or self.f
+    attributes = None
+
+    consumed = 1
+
+    lfn_entries = {}
+
+    while True:
+      skip_bytes(f, 11)
+      attributes = read_byte(f)
+      rewind_bytes(f, 12)
+
+      if attributes & LFN_ATTRIBUTES != LFN_ATTRIBUTES:
+        break
+
+      consumed += 1
+
+      seq = read_byte(f)
+      chars = f.read(10)
+      skip_bytes(f, 3) # Various hackish nonsense
+      chars += f.read(12)
+      skip_short(f) # Lots more nonsense
+      chars += f.read(4)
+
+      chars = unicode(chars, "utf-16-le").encode("utf-8")
+
+      lfn_entries[seq] = chars
+
+    ind = read_byte(f)
+
+    if ind == 0 or ind == DEL_MARKER:
+      skip_bytes(f, 31)
+      return (None, consumed)
+
+    if ind == ESCAPE_DEL_MARKER:
+      ind = DEL_MARKER
+
+    ind = str(unichr(ind))
+
+    if ind == '.':
+      skip_bytes(f, 31)
+      return (None, consumed)
+
+    shortname = ind + f.read(7).rstrip()
+    ext = f.read(3).rstrip()
+    skip_bytes(f, 15) # Assorted flags, ctime/atime/mtime, etc.
+    first_cluster = read_le_short(f)
+    size = read_le_long(f)
+
+    lfn = lfn_entries.items()
+    lfn.sort(key=lambda x: x[0])
+    lfn = reduce(lambda x, y: x + y[1], lfn, "")
+
+    if len(lfn) == 0:
+      lfn = None
+    else:
+      lfn = lfn.split('\0', 1)[0]
+
+    return (dentry(self, attributes, shortname, ext, lfn, first_cluster,
+      size), consumed)
+
+  def read_file(self, head_cluster, start_byte, size):
+    """
+    Read from a given FAT file.
+    head_cluster: The first cluster in the file.
+    start_byte: How many bytes in to the file to begin the read.
+    size: How many bytes to read.
+    """
+    f = self.f
+
+    assert size >= 0, "Can't read a negative amount"
+    if size == 0:
+      return ""
+
+    got_data = ""
+
+    while True:
+      size_now = size
+      if start_byte + size > self.bytes_per_cluster:
+        size_now = self.bytes_per_cluster - start_byte
+
+      if start_byte < self.bytes_per_cluster:
+        size -= size_now
+
+        cluster_bytes_from_root = (head_cluster - 2) * \
+            self.bytes_per_cluster
+        bytes_from_root = cluster_bytes_from_root + start_byte
+        bytes_from_data_start = bytes_from_root + self.root_entries * 32
+
+        f.seek(self.data_start() + bytes_from_data_start)
+        line = f.read(size_now)
+        got_data += line
+
+        if size == 0:
+          return got_data
+
+      start_byte -= self.bytes_per_cluster
+
+      if start_byte < 0:
+        start_byte = 0
+
+      f.seek(FAT_TABLE_START + head_cluster * 2)
+      assert head_cluster <= MAX_CLUSTER_ID, "Out-of-bounds read"
+      head_cluster = read_le_short(f)
+      assert head_cluster > 0, "Read free cluster"
+
+    return got_data
+
+  def write_cluster_entry(self, entry):
+    """
+    Write a cluster entry to the FAT table. Assumes our backing file is already
+    seeked to the correct entry in the first FAT table.
+    """
+    f = self.f
+    f.write(struct.pack("<H", entry))
+    skip_bytes(f, self.fat_size - 2)
+    f.write(struct.pack("<H", entry))
+    rewind_bytes(f, self.fat_size)
+
+  def allocate(self, amount):
+    """
+    Allocate a new cluster chain big enough to hold at least the given amount
+    of bytes.
+    """
+    assert amount > 0, "Must allocate a non-zero amount."
+
+    f = self.f
+    f.seek(FAT_TABLE_START + 4)
+
+    current = None
+    current_size = 0
+    free_zones = {}
+
+    pos = 2
+    while pos < self.fat_size / 2:
+      data = read_le_short(f)
+
+      if data == 0 and current is not None:
+        current_size += 1
+      elif data == 0:
+        current = pos
+        current_size = 1
+      elif current is not None:
+        free_zones[current] = current_size
+        current = None
+
+      pos += 1
+
+    if current is not None:
+      free_zones[current] = current_size
+
+    free_zones = free_zones.items()
+    free_zones.sort(key=lambda x: x[1])
+
+    grabbed_zones = []
+    grabbed = 0
+
+    while grabbed < amount and len(free_zones) > 0:
+      zone = free_zones.pop()
+      grabbed += zone[1] * self.bytes_per_cluster
+      grabbed_zones.append(zone)
+
+    if grabbed < amount:
+      return None
+
+    excess = (grabbed - amount) / self.bytes_per_cluster
+
+    grabbed_zones[-1] = (grabbed_zones[-1][0],
+        grabbed_zones[-1][1] - excess)
+
+    out = None
+    grabbed_zones.reverse()
+
+    for cluster, size in grabbed_zones:
+      entries = range(cluster + 1, cluster + size)
+      entries.append(out or 0xFFFF)
+      out = cluster
+      f.seek(FAT_TABLE_START + cluster * 2)
+      for entry in entries:
+        self.write_cluster_entry(entry)
+
+    return out
+
+  def extend_cluster(self, cluster, amount):
+    """
+    Given a cluster which is the *last* cluster in a chain, extend it to hold
+    at least `amount` more bytes.
+    """
+    if amount == 0:
+      return
+    f = self.f
+    entry_offset = FAT_TABLE_START + cluster * 2
+    f.seek(entry_offset)
+    assert read_le_short(f) == 0xFFFF, "Extending from middle of chain"
+
+    return_cluster = self.allocate(amount)
+    f.seek(entry_offset)
+    self.write_cluster_entry(return_cluster)
+    return return_cluster
+
+  def write_file(self, head_cluster, start_byte, data):
+    """
+    Write to a given FAT file.
+
+    head_cluster: The first cluster in the file.
+    start_byte: How many bytes in to the file to begin the write.
+    data: The data to write.
+    """
+    f = self.f
+    last_offset = start_byte + len(data)
+    current_offset = 0
+    current_cluster = head_cluster
+
+    while current_offset < last_offset:
+      # Write everything that falls in the cluster starting at current_offset.
+      data_begin = max(0, current_offset - start_byte)
+      data_end = min(len(data),
+                     current_offset + self.bytes_per_cluster - start_byte)
+      if data_end > data_begin:
+        cluster_file_offset = (self.data_start() + self.root_entries * 32 +
+                               (current_cluster - 2) * self.bytes_per_cluster)
+        f.seek(cluster_file_offset + max(0, start_byte - current_offset))
+        f.write(data[data_begin:data_end])
+
+      # Advance to the next cluster in the chain or get a new cluster if needed.
+      current_offset += self.bytes_per_cluster
+      if last_offset > current_offset:
+        f.seek(FAT_TABLE_START + current_cluster * 2)
+        next_cluster = read_le_short(f)
+        if next_cluster > MAX_CLUSTER_ID:
+          next_cluster = self.extend_cluster(current_cluster, len(data))
+        current_cluster = next_cluster
+        assert current_cluster > 0, "Cannot write free cluster"
+
+
+def add_item(directory, item):
+  """
+  Copy a file into the given FAT directory. If the path given is a directory,
+  copy recursively.
+  directory: fat_dir to copy the file in to
+  item: Path of local file to copy
+  """
+  if os.path.isdir(item):
+    base = os.path.basename(item)
+    if len(base) == 0:
+      base = os.path.basename(item[:-1])
+    sub = directory.open_subdirectory(base)
+    for next_item in sorted(os.listdir(item)):
+      add_item(sub, os.path.join(item, next_item))
+  else:
+    with open(item, 'rb') as f:
+      directory.new_file(os.path.basename(item), f)
+
+if __name__ == "__main__":
+  if len(sys.argv) < 3:
+    print("Usage: fat16copy.py <image> <file> [<file> ...]")
+    print("Files are copied into the root of the image.")
+    print("Directories are copied recursively")
+    sys.exit(1)
+
+  root = fat(sys.argv[1]).root
+
+  for p in sys.argv[2:]:
+    add_item(root, p)
diff --git a/tools/fileslist.py b/tools/fileslist.py
deleted file mode 100755
index b9e7350..0000000
--- a/tools/fileslist.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2009 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.
-#
-
-import json, hashlib, operator, os, sys
-
-def get_file_size(path):
-  st = os.lstat(path)
-  return st.st_size;
-
-def get_file_digest(path):
-  if os.path.isfile(path) == False:
-    return "----------------------------------------------------------------"
-  digest = hashlib.sha256()
-  with open(path, 'rb') as f:
-    while True:
-      buf = f.read(1024*1024)
-      if not buf:
-        break
-      digest.update(buf)
-  return digest.hexdigest();
-
-def main(argv):
-  output = []
-  roots = argv[1:]
-  for root in roots:
-    base = len(root[:root.rfind(os.path.sep)])
-    for dir, dirs, files in os.walk(root):
-      relative = dir[base:]
-      for f in files:
-        try:
-          path = os.path.sep.join((dir, f))
-          row = {
-              "Size": get_file_size(path),
-              "Name": os.path.sep.join((relative, f)),
-              "SHA256": get_file_digest(path),
-            }
-          output.append(row)
-        except os.error:
-          pass
-  output.sort(key=operator.itemgetter("Size", "Name"), reverse=True)
-  print json.dumps(output, indent=2, separators=(',',': '))
-
-if __name__ == '__main__':
-  main(sys.argv)
diff --git a/tools/findleaves.py b/tools/findleaves.py
index 3a9e508..f152a87 100755
--- a/tools/findleaves.py
+++ b/tools/findleaves.py
@@ -23,9 +23,10 @@
 import os
 import sys
 
-def perform_find(mindepth, prune, dirlist, filename):
+def perform_find(mindepth, prune, dirlist, filenames):
   result = []
   pruneleaves = set(map(lambda x: os.path.split(x)[1], prune))
+  seen = set()
   for rootdir in dirlist:
     rootdepth = rootdir.count("/")
     for root, dirs, files in os.walk(rootdir, followlinks=True):
@@ -48,19 +49,36 @@
         if depth < mindepth:
           continue
       # match
-      if filename in files:
-        result.append(os.path.join(root, filename))
-        del dirs[:]
+      for filename in filenames:
+        if filename in files:
+          result.append(os.path.join(root, filename))
+          del dirs[:]
+
+      # filter out inodes that have already been seen due to symlink loops
+      i = 0
+      while i < len(dirs):
+        st = os.stat(os.path.join(root, dirs[i]))
+        key = (st.st_dev, st.st_ino)
+        if key in seen:
+          del dirs[i]
+        else:
+          i += 1
+          seen.add(key)
+
   return result
 
 def usage():
-  sys.stderr.write("""Usage: %(progName)s [<options>] <dirlist> <filename>
+  sys.stderr.write("""Usage: %(progName)s [<options>] [--dir=<dir>] <filenames>
 Options:
    --mindepth=<mindepth>
        Both behave in the same way as their find(1) equivalents.
    --prune=<dirname>
        Avoids returning results from inside any directory called <dirname>
        (e.g., "*/out/*"). May be used multiple times.
+   --dir=<dir>
+       Add a directory to search.  May be repeated multiple times.  For backwards
+       compatibility, if no --dir argument is provided then all but the last entry
+       in <filenames> are treated as directories.
 """ % {
       "progName": os.path.split(sys.argv[0])[1],
     })
@@ -69,6 +87,7 @@
 def main(argv):
   mindepth = -1
   prune = []
+  dirlist = []
   i=1
   while i<len(argv) and len(argv[i])>2 and argv[i][0:2] == "--":
     arg = argv[i]
@@ -82,14 +101,24 @@
       if len(p) == 0:
         usage()
       prune.append(p)
+    elif arg.startswith("--dir="):
+      d = arg[len("--dir="):]
+      if len(p) == 0:
+        usage()
+      dirlist.append(d)
     else:
       usage()
     i += 1
-  if len(argv)-i < 2: # need both <dirlist> and <filename>
-    usage()
-  dirlist = argv[i:-1]
-  filename = argv[-1]
-  results = list(set(perform_find(mindepth, prune, dirlist, filename)))
+  if len(dirlist) == 0: # backwards compatibility
+    if len(argv)-i < 2: # need both <dirlist> and <filename>
+      usage()
+    dirlist = argv[i:-1]
+    filenames = [argv[-1]]
+  else:
+    if len(argv)-i < 1: # need <filename>
+      usage()
+    filenames = argv[i:]
+  results = list(set(perform_find(mindepth, prune, dirlist, filenames)))
   results.sort()
   for r in results:
     print r
diff --git a/tools/fs_config/Android.mk b/tools/fs_config/Android.mk
index 34a3522..65f8a08 100644
--- a/tools/fs_config/Android.mk
+++ b/tools/fs_config/Android.mk
@@ -23,20 +23,38 @@
 
 include $(BUILD_HOST_EXECUTABLE)
 
-# To Build the custom target binary for the host to generate the fs_config
-# override files. The executable is hard coded to include the
-# $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) file if it exists.
-# Expectations:
-#    device/<vendor>/<device>/android_filesystem_config.h
-#        fills in struct fs_path_config android_device_dirs[] and
-#                 struct fs_path_config android_device_files[]
-#    device/<vendor>/<device>/device.mk
-#        PRODUCT_PACKAGES += fs_config_dirs fs_config_files
-
-# If not specified, check if default one to be found
+# One can override the default android_filesystem_config.h file in one of two ways:
+#
+# 1. The old way:
+#   To Build the custom target binary for the host to generate the fs_config
+#   override files. The executable is hard coded to include the
+#   $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) file if it exists.
+#   Expectations:
+#      device/<vendor>/<device>/android_filesystem_config.h
+#          fills in struct fs_path_config android_device_dirs[] and
+#                   struct fs_path_config android_device_files[]
+#      device/<vendor>/<device>/device.mk
+#          PRODUCT_PACKAGES += fs_config_dirs fs_config_files
+#   If not specified, check if default one to be found
+#
+# 2. The new way:
+#   set TARGET_FS_CONFIG_GEN to contain a list of intermediate format files
+#   for generating the android_filesystem_config.h file.
+#
+# More information can be found in the README
 ANDROID_FS_CONFIG_H := android_filesystem_config.h
 
 ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),)
+ifneq ($(TARGET_FS_CONFIG_GEN),)
+$(error Cannot set TARGET_ANDROID_FILESYSTEM_CONFIG_H and TARGET_FS_CONFIG_GEN simultaneously)
+endif
+
+# One and only one file can be specified.
+ifneq ($(words $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),1)
+$(error Multiple fs_config files specified, \
+ see "$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)".)
+endif
+
 ifeq ($(filter %/$(ANDROID_FS_CONFIG_H),$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),)
 $(error TARGET_ANDROID_FILESYSTEM_CONFIG_H file name must be $(ANDROID_FS_CONFIG_H), \
  see "$(notdir $(TARGET_ANDROID_FILESYSTEM_CONFIG_H))".)
@@ -44,20 +62,59 @@
 
 my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)
 else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),)
+
+ifneq ($(TARGET_FS_CONFIG_GEN),)
+$(error Cannot provide $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H) and set TARGET_FS_CONFIG_GEN simultaneously)
+endif
 my_fs_config_h := $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)
+
 else
 my_fs_config_h := $(LOCAL_PATH)/default/$(ANDROID_FS_CONFIG_H)
 endif
 
+##################################
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := fs_config_generate.c
 LOCAL_MODULE := fs_config_generate_$(TARGET_DEVICE)
+LOCAL_MODULE_CLASS := EXECUTABLES
 LOCAL_SHARED_LIBRARIES := libcutils
 LOCAL_CFLAGS := -Werror -Wno-error=\#warnings
-LOCAL_C_INCLUDES := $(dir $(my_fs_config_h))
+
+ifneq ($(TARGET_FS_CONFIG_GEN),)
+system_android_filesystem_config := system/core/include/private/android_filesystem_config.h
+
+# Generate the "generated_oem_aid.h" file
+oem := $(local-generated-sources-dir)/generated_oem_aid.h
+$(oem): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
+$(oem): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
+$(oem): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
+$(oem): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py oemaid --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
+$(oem): $(TARGET_FS_CONFIG_GEN) $(LOCAL_PATH)/fs_config_generator.py
+	$(transform-generated-source)
+
+# Generate the fs_config header
+gen := $(local-generated-sources-dir)/$(ANDROID_FS_CONFIG_H)
+$(gen): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
+$(gen): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
+$(gen): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
+$(gen): PRIVATE_CUSTOM_TOOL = $(PRIVATE_LOCAL_PATH)/fs_config_generator.py fsconfig --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
+$(gen): $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config) $(LOCAL_PATH)/fs_config_generator.py
+	$(transform-generated-source)
+
+LOCAL_GENERATED_SOURCES := $(oem) $(gen)
+
+my_fs_config_h := $(gen)
+my_gen_oem_aid := $(oem)
+gen :=
+oem :=
+endif
+
+LOCAL_C_INCLUDES := $(dir $(my_fs_config_h)) $(dir $(my_gen_oem_aid))
+
 include $(BUILD_HOST_EXECUTABLE)
 fs_config_generate_bin := $(LOCAL_INSTALLED_MODULE)
 
+##################################
 # Generate the system/etc/fs_config_dirs binary file for the target
 # Add fs_config_dirs to PRODUCT_PACKAGES in the device make file to enable
 include $(CLEAR_VARS)
@@ -69,6 +126,7 @@
 	@mkdir -p $(dir $@)
 	$< -D -o $@
 
+##################################
 # Generate the system/etc/fs_config_files binary file for the target
 # Add fs_config_files to PRODUCT_PACKAGES in the device make file to enable
 include $(CLEAR_VARS)
@@ -80,6 +138,60 @@
 	@mkdir -p $(dir $@)
 	$< -F -o $@
 
+# The newer passwd/group targets are only generated if you
+# use the new TARGET_FS_CONFIG_GEN method.
+ifneq ($(TARGET_FS_CONFIG_GEN),)
+
+##################################
+# Build the oemaid library when fs config files are present.
+# Intentionally break build if you require generated AIDS
+# header file, but are not using any fs config files.
+include $(CLEAR_VARS)
+LOCAL_MODULE := liboemaids
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(dir $(my_gen_oem_aid))
+LOCAL_EXPORT_C_INCLUDE_DEPS := $(my_gen_oem_aid)
+include $(BUILD_STATIC_LIBRARY)
+
+##################################
+# Generate the system/etc/passwd text file for the target
+# This file may be empty if no AIDs are defined in
+# TARGET_FS_CONFIG_GEN files.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := passwd
+LOCAL_MODULE_CLASS := ETC
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
+$(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
+$(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
+$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config)
+	@mkdir -p $(dir $@)
+	$(hide) $< passwd --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
+
+##################################
+# Generate the system/etc/group text file for the target
+# This file may be empty if no AIDs are defined in
+# TARGET_FS_CONFIG_GEN files.
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := group
+LOCAL_MODULE_CLASS := ETC
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
+$(LOCAL_BUILT_MODULE): PRIVATE_TARGET_FS_CONFIG_GEN := $(TARGET_FS_CONFIG_GEN)
+$(LOCAL_BUILT_MODULE): PRIVATE_ANDROID_FS_HDR := $(system_android_filesystem_config)
+$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/fs_config_generator.py $(TARGET_FS_CONFIG_GEN) $(system_android_filesystem_config)
+	@mkdir -p $(dir $@)
+	$(hide) $< group --aid-header=$(PRIVATE_ANDROID_FS_HDR) $(PRIVATE_TARGET_FS_CONFIG_GEN) > $@
+
+system_android_filesystem_config :=
+endif
+
 ANDROID_FS_CONFIG_H :=
 my_fs_config_h :=
 fs_config_generate_bin :=
+my_gen_oem_aid :=
diff --git a/tools/fs_config/README b/tools/fs_config/README
new file mode 100644
index 0000000..9919131
--- /dev/null
+++ b/tools/fs_config/README
@@ -0,0 +1,164 @@
+ _____  _____  _____  _____  __  __  _____
+/  _  \/   __\/  _  \|  _  \/  \/  \/   __\
+|  _  <|   __||  _  ||  |  ||  \/  ||   __|
+\__|\_/\_____/\__|__/|_____/\__ \__/\_____/
+
+Generating the android_filesystem_config.h:
+
+To generate the android_filesystem_config.h file, one can choose from
+one of two methods. The first method, is to declare
+TARGET_ANDROID_FILESYSTEM_CONFIG_H in the device BoardConfig.mk file. This
+variable can only have one item in it, and it is used directly as the
+android_filesystem_config.h header when building
+fs_config_generate_$(TARGET_DEVICE) which is used to generate fs_config_files
+and fs_config_dirs target executable.
+
+The limitation with this, is that it can only be set once, thus if the device
+has a make hierarchy, then each device needs its own file, and cannot share
+from a common source or that common source needs to include everything from
+both devices.
+
+The other way is to set TARGET_FS_CONFIG_GEN, which can be a list of
+intermediate fs configuration files. It is a build error on any one
+these conditions:
+ * Specify TARGET_FS_CONFIG_GEN and TARGET_ANDROID_FILESYSTEM_CONFIG_H
+ * Specify TARGET_FS_CONFIG_GEN and provide
+   $(TARGET_DEVICE_DIR)/android_filesystem_config.h
+
+The parsing of the config file follows the Python ConfigParser specification,
+with the sections and fields as defined below. There are two types of sections,
+both sections require all options to be specified. The first section type is
+the "caps" section.
+
+The "caps" section follows the following syntax:
+
+[path]
+mode: Octal file mode
+user: AID_<user>
+group: AID_<group>
+caps: cap*
+
+Where:
+
+[path]
+  The filesystem path to configure. A path ending in / is considered a dir,
+  else its a file.
+
+mode:
+  A valid octal file mode of at least 3 digits. If 3 is specified, it is
+  prefixed with a 0, else mode is used as is.
+
+user:
+  Either the C define for a valid AID or the friendly name. For instance both
+  AID_RADIO and radio are acceptable. Note custom AIDs can be defined in the
+  AID section documented below.
+
+group:
+  Same as user.
+
+caps:
+  The name as declared in
+  system/core/include/private/android_filesystem_capability.h without the
+  leading CAP_. Mixed case is allowed. Caps can also be the raw:
+   * binary (0b0101)
+   * octal (0455)
+   * int (42)
+   * hex (0xFF)
+  For multiple caps, just separate by whitespace.
+
+It is an error to specify multiple sections with the same [path] in different
+files. Note that the same file may contain sections that override the previous
+section in Python versions <= 3.2. In Python 3.2 it's set to strict mode.
+
+
+The next section type is the "AID" section, for specifying OEM specific AIDS.
+
+The AID section follows the following syntax:
+
+[AID_<name>]
+value: <number>
+
+Where:
+
+[AID_<name>]
+  The <name> can contain characters in the set uppercase, numbers
+  and underscores.
+
+value:
+  A valid C style number string. Hex, octal, binary and decimal are supported.
+  See "caps" above for more details on number formatting.
+
+It is an error to specify multiple sections with the same [AID_<name>]. With
+the same constraints as [path] described above. It is also an error to specify
+multiple sections with the same value option. It is also an error to specify a
+value that is outside of the inclusive OEM ranges:
+ * AID_OEM_RESERVED_START(2900) - AID_OEM_RESERVED_END(2999)
+ * AID_OEM_RESERVED_2_START(5000) - AID_OEM_RESERVED_2_END(5999)
+
+as defined by system/core/include/private/android_filesystem_config.h.
+
+Ordering within the TARGET_FS_CONFIG_GEN files is not relevant. The paths for files are sorted
+like so within their respective array definition:
+ * specified path before prefix match
+ ** ie foo before f*
+ * lexicographical less than before other
+ ** ie boo before foo
+
+Given these paths:
+
+paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*']
+
+The sort order would be:
+paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*']
+
+Thus the fs_config tools will match on specified paths before attempting prefix, and match on the
+longest matching prefix.
+
+The declared AIDS are sorted in ascending numerical order based on the option "value". The string
+representation of value is preserved. Both choices were made for maximum readability of the generated
+file and to line up files. Sync lines are placed with the source file as comments in the generated
+header file.
+
+For OEMs wishing to use the define AIDs in their native code, one can access the generated header
+file like so:
+  1. In your C code just #include "generated_oem_aid.h" and start using the declared identifiers.
+  2. In your Makefile add this static library like so: LOCAL_STATIC_LIBRARIES := liboemaids
+
+Unit Tests:
+
+From within the fs_config directory, unit tests can be executed like so:
+$ python -m unittest test_fs_config_generator.Tests
+.............
+----------------------------------------------------------------------
+Ran 13 tests in 0.004s
+
+OK
+
+One could also use nose if they would like:
+$ nose2
+
+To add new tests, simply add a test_<xxx> method to the test class. It will automatically
+get picked up and added to the test suite.
+
+Using the android_filesystem_config.h:
+
+The tool fs_config_generate is built as a dependency to fs_config_dirs and
+fs_config_files host targets, and #includes the above supplied or generated
+android_filesystem_config.h file, and can be instructed to generate the binary
+data that lands in the device target locations /system/etc/fs_config_dirs and
+/system/etc/fs_config_files and in the host's ${OUT} locations
+${OUT}/target/product/<device>/system/etc/fs_config_dirs and
+${OUT}/target/product/<device>/system/etc/fs_config_files. The binary files
+are interpreted by the libcutils fs_conf() function, along with the built-in
+defaults, to serve as overrides to complete the results. The Target files are
+used by filesystem and adb tools to ensure that the file and directory
+properties are preserved during runtime operations. The host files in the
+${OUT} directory are used in the final stages when building the filesystem
+images to set the file and directory properties.
+
+fs_config_generate --help reports:
+
+Generate binary content for fs_config_dirs (-D) and fs_config_files (-F)
+from device-specific android_filesystem_config.h override
+
+Usage: fs_config_generate -D|-F [-o output-file]
diff --git a/tools/fs_config/default/android_filesystem_config.h b/tools/fs_config/default/android_filesystem_config.h
index 820b04a..b7d936a 100644
--- a/tools/fs_config/default/android_filesystem_config.h
+++ b/tools/fs_config/default/android_filesystem_config.h
@@ -19,13 +19,6 @@
 ** by the device side of adb.
 */
 
-/*
-** Resorting to the default file means someone requested fs_config_dirs or
-** fs_config_files in their device configuration without providing an
-** associated header.
-*/
-#warning No device-supplied android_filesystem_config.h, using empty default.
-
 /* Rules for directories.
 ** These rules are applied based on "first match", so they
 ** should start with the most specific path and work their
diff --git a/tools/fs_config/fs_config.c b/tools/fs_config/fs_config.c
index e797957..48f300b 100644
--- a/tools/fs_config/fs_config.c
+++ b/tools/fs_config/fs_config.c
@@ -105,6 +105,9 @@
       switch (buffer[i]) {
         case '\n':
           buffer[i-is_dir] = '\0';
+          if (i == 0) {
+            is_dir = 1; // empty line is considered as root directory
+          }
           i = 1025;
           break;
         case '/':
diff --git a/tools/fs_config/fs_config_generator.py b/tools/fs_config/fs_config_generator.py
new file mode 100755
index 0000000..2cf2fd8
--- /dev/null
+++ b/tools/fs_config/fs_config_generator.py
@@ -0,0 +1,1331 @@
+#!/usr/bin/env python
+"""Generates config files for Android file system properties.
+
+This script is used for generating configuration files for configuring
+Android filesystem properties. Internally, its composed of a plug-able
+interface to support the understanding of new input and output parameters.
+
+Run the help for a list of supported plugins and their capabilities.
+
+Further documentation can be found in the README.
+"""
+
+import argparse
+import ConfigParser
+import re
+import sys
+import textwrap
+
+# Keep the tool in one file to make it easy to run.
+# pylint: disable=too-many-lines
+
+
+# Lowercase generator used to be inline with @staticmethod.
+class generator(object):  # pylint: disable=invalid-name
+    """A decorator class to add commandlet plugins.
+
+    Used as a decorator to classes to add them to
+    the internal plugin interface. Plugins added
+    with @generator() are automatically added to
+    the command line.
+
+    For instance, to add a new generator
+    called foo and have it added just do this:
+
+        @generator("foo")
+        class FooGen(object):
+            ...
+    """
+    _generators = {}
+
+    def __init__(self, gen):
+        """
+        Args:
+            gen (str): The name of the generator to add.
+
+        Raises:
+            ValueError: If there is a similarly named generator already added.
+
+        """
+        self._gen = gen
+
+        if gen in generator._generators:
+            raise ValueError('Duplicate generator name: ' + gen)
+
+        generator._generators[gen] = None
+
+    def __call__(self, cls):
+
+        generator._generators[self._gen] = cls()
+        return cls
+
+    @staticmethod
+    def get():
+        """Gets the list of generators.
+
+        Returns:
+           The list of registered generators.
+        """
+        return generator._generators
+
+
+class Utils(object):
+    """Various assorted static utilities."""
+
+    @staticmethod
+    def in_any_range(value, ranges):
+        """Tests if a value is in a list of given closed range tuples.
+
+        A range tuple is a closed range. That means it's inclusive of its
+        start and ending values.
+
+        Args:
+            value (int): The value to test.
+            range [(int, int)]: The closed range list to test value within.
+
+        Returns:
+            True if value is within the closed range, false otherwise.
+        """
+
+        return any(lower <= value <= upper for (lower, upper) in ranges)
+
+    @staticmethod
+    def get_login_and_uid_cleansed(aid):
+        """Returns a passwd/group file safe logon and uid.
+
+        This checks that the logon and uid of the AID do not
+        contain the delimiter ":" for a passwd/group file.
+
+        Args:
+            aid (AID): The aid to check
+
+        Returns:
+            logon, uid of the AID after checking its safe.
+
+        Raises:
+            ValueError: If there is a delimiter charcter found.
+        """
+        logon = aid.friendly
+        uid = aid.normalized_value
+        if ':' in uid:
+            raise ValueError(
+                'Cannot specify delimiter character ":" in uid: "%s"' % uid)
+        if ':' in logon:
+            raise ValueError(
+                'Cannot specify delimiter character ":" in logon: "%s"' % logon)
+        return logon, uid
+
+
+class AID(object):
+    """This class represents an Android ID or an AID.
+
+    Attributes:
+        identifier (str): The identifier name for a #define.
+        value (str) The User Id (uid) of the associate define.
+        found (str) The file it was found in, can be None.
+        normalized_value (str): Same as value, but base 10.
+        friendly (str): The friendly name of aid.
+    """
+
+    PREFIX = 'AID_'
+
+    # Some of the AIDS like AID_MEDIA_EX had names like mediaex
+    # list a map of things to fixup until we can correct these
+    # at a later date.
+    _FIXUPS = {
+        'media_drm': 'mediadrm',
+        'media_ex': 'mediaex',
+        'media_codec': 'mediacodec'
+    }
+
+    def __init__(self, identifier, value, found):
+        """
+        Args:
+            identifier: The identifier name for a #define <identifier>.
+            value: The value of the AID, aka the uid.
+            found (str): The file found in, not required to be specified.
+
+        Raises:
+            ValueError: if value is not a valid string number as processed by
+                int(x, 0)
+        """
+        self.identifier = identifier
+        self.value = value
+        self.found = found
+        self.normalized_value = str(int(value, 0))
+
+        # Where we calculate the friendly name
+        friendly = identifier[len(AID.PREFIX):].lower()
+        self.friendly = AID._fixup_friendly(friendly)
+
+    def __eq__(self, other):
+
+        return self.identifier == other.identifier \
+            and self.value == other.value and self.found == other.found \
+            and self.normalized_value == other.normalized_value
+
+    @staticmethod
+    def is_friendly(name):
+        """Determines if an AID is a freindly name or C define.
+
+        For example if name is AID_SYSTEM it returns false, if name
+        was system, it would return true.
+
+        Returns:
+            True if name is a friendly name False otherwise.
+        """
+
+        return not name.startswith(AID.PREFIX)
+
+    @staticmethod
+    def _fixup_friendly(friendly):
+        """Fixup friendly names that historically don't follow the convention.
+
+        Args:
+            friendly (str): The friendly name.
+
+        Returns:
+            The fixedup friendly name as a str.
+        """
+
+        if friendly in AID._FIXUPS:
+            return AID._FIXUPS[friendly]
+
+        return friendly
+
+
+class FSConfig(object):
+    """Represents a filesystem config array entry.
+
+    Represents a file system configuration entry for specifying
+    file system capabilities.
+
+    Attributes:
+        mode (str): The mode of the file or directory.
+        user (str): The uid or #define identifier (AID_SYSTEM)
+        group (str): The gid or #define identifier (AID_SYSTEM)
+        caps (str): The capability set.
+        filename (str): The file it was found in.
+    """
+
+    def __init__(self, mode, user, group, caps, path, filename):
+        """
+        Args:
+            mode (str): The mode of the file or directory.
+            user (str): The uid or #define identifier (AID_SYSTEM)
+            group (str): The gid or #define identifier (AID_SYSTEM)
+            caps (str): The capability set as a list.
+            filename (str): The file it was found in.
+        """
+        self.mode = mode
+        self.user = user
+        self.group = group
+        self.caps = caps
+        self.path = path
+        self.filename = filename
+
+    def __eq__(self, other):
+
+        return self.mode == other.mode and self.user == other.user \
+            and self.group == other.group and self.caps == other.caps \
+            and self.path == other.path and self.filename == other.filename
+
+
+class AIDHeaderParser(object):
+    """Parses an android_filesystem_config.h file.
+
+    Parses a C header file and extracts lines starting with #define AID_<name>
+    while capturing the OEM defined ranges and ignoring other ranges. It also
+    skips some hardcoded AIDs it doesn't need to generate a mapping for.
+    It provides some basic sanity checks. The information extracted from this
+    file can later be used to sanity check other things (like oem ranges) as
+    well as generating a mapping of names to uids. It was primarily designed to
+    parse the private/android_filesystem_config.h, but any C header should
+    work.
+    """
+
+
+    _SKIP_AIDS = [
+        re.compile(r'%sUNUSED[0-9].*' % AID.PREFIX),
+        re.compile(r'%sAPP' % AID.PREFIX), re.compile(r'%sUSER' % AID.PREFIX)
+    ]
+    _AID_DEFINE = re.compile(r'\s*#define\s+%s.*' % AID.PREFIX)
+    _OEM_START_KW = 'START'
+    _OEM_END_KW = 'END'
+    _OEM_RANGE = re.compile('%sOEM_RESERVED_[0-9]*_{0,1}(%s|%s)' %
+                            (AID.PREFIX, _OEM_START_KW, _OEM_END_KW))
+    # AID lines cannot end with _START or _END, ie AID_FOO is OK
+    # but AID_FOO_START is skiped. Note that AID_FOOSTART is NOT skipped.
+    _AID_SKIP_RANGE = ['_' + _OEM_START_KW, '_' + _OEM_END_KW]
+    _COLLISION_OK = ['AID_APP', 'AID_APP_START', 'AID_USER', 'AID_USER_OFFSET']
+
+    def __init__(self, aid_header):
+        """
+        Args:
+            aid_header (str): file name for the header
+                file containing AID entries.
+        """
+        self._aid_header = aid_header
+        self._aid_name_to_value = {}
+        self._aid_value_to_name = {}
+        self._oem_ranges = {}
+
+        with open(aid_header) as open_file:
+            self._parse(open_file)
+
+        try:
+            self._process_and_check()
+        except ValueError as exception:
+            sys.exit('Error processing parsed data: "%s"' % (str(exception)))
+
+    def _parse(self, aid_file):
+        """Parses an AID header file. Internal use only.
+
+        Args:
+            aid_file (file): The open AID header file to parse.
+        """
+
+        for lineno, line in enumerate(aid_file):
+
+            def error_message(msg):
+                """Creates an error message with the current parsing state."""
+                # pylint: disable=cell-var-from-loop
+                return 'Error "{}" in file: "{}" on line: {}'.format(
+                    msg, self._aid_header, str(lineno))
+
+            if AIDHeaderParser._AID_DEFINE.match(line):
+                chunks = line.split()
+                identifier = chunks[1]
+                value = chunks[2]
+
+                if any(x.match(identifier) for x in AIDHeaderParser._SKIP_AIDS):
+                    continue
+
+                try:
+                    if AIDHeaderParser._is_oem_range(identifier):
+                        self._handle_oem_range(identifier, value)
+                    elif not any(
+                            identifier.endswith(x)
+                            for x in AIDHeaderParser._AID_SKIP_RANGE):
+                        self._handle_aid(identifier, value)
+                except ValueError as exception:
+                    sys.exit(
+                        error_message('{} for "{}"'.format(exception,
+                                                           identifier)))
+
+    def _handle_aid(self, identifier, value):
+        """Handle an AID C #define.
+
+        Handles an AID, sanity checking, generating the friendly name and
+        adding it to the internal maps. Internal use only.
+
+        Args:
+            identifier (str): The name of the #define identifier. ie AID_FOO.
+            value (str): The value associated with the identifier.
+
+        Raises:
+            ValueError: With message set to indicate the error.
+        """
+
+        aid = AID(identifier, value, self._aid_header)
+
+        # duplicate name
+        if aid.friendly in self._aid_name_to_value:
+            raise ValueError('Duplicate aid "%s"' % identifier)
+
+        if value in self._aid_value_to_name and aid.identifier not in AIDHeaderParser._COLLISION_OK:
+            raise ValueError('Duplicate aid value "%s" for %s' % (value,
+                                                                  identifier))
+
+        self._aid_name_to_value[aid.friendly] = aid
+        self._aid_value_to_name[value] = aid.friendly
+
+    def _handle_oem_range(self, identifier, value):
+        """Handle an OEM range C #define.
+
+        When encountering special AID defines, notably for the OEM ranges
+        this method handles sanity checking and adding them to the internal
+        maps. For internal use only.
+
+        Args:
+            identifier (str): The name of the #define identifier.
+                ie AID_OEM_RESERVED_START/END.
+            value (str): The value associated with the identifier.
+
+        Raises:
+            ValueError: With message set to indicate the error.
+        """
+
+        try:
+            int_value = int(value, 0)
+        except ValueError:
+            raise ValueError(
+                'Could not convert "%s" to integer value, got: "%s"' %
+                (identifier, value))
+
+        # convert AID_OEM_RESERVED_START or AID_OEM_RESERVED_<num>_START
+        # to AID_OEM_RESERVED or AID_OEM_RESERVED_<num>
+        is_start = identifier.endswith(AIDHeaderParser._OEM_START_KW)
+
+        if is_start:
+            tostrip = len(AIDHeaderParser._OEM_START_KW)
+        else:
+            tostrip = len(AIDHeaderParser._OEM_END_KW)
+
+        # ending _
+        tostrip = tostrip + 1
+
+        strip = identifier[:-tostrip]
+        if strip not in self._oem_ranges:
+            self._oem_ranges[strip] = []
+
+        if len(self._oem_ranges[strip]) > 2:
+            raise ValueError('Too many same OEM Ranges "%s"' % identifier)
+
+        if len(self._oem_ranges[strip]) == 1:
+            tmp = self._oem_ranges[strip][0]
+
+            if tmp == int_value:
+                raise ValueError('START and END values equal %u' % int_value)
+            elif is_start and tmp < int_value:
+                raise ValueError('END value %u less than START value %u' %
+                                 (tmp, int_value))
+            elif not is_start and tmp > int_value:
+                raise ValueError('END value %u less than START value %u' %
+                                 (int_value, tmp))
+
+        # Add START values to the head of the list and END values at the end.
+        # Thus, the list is ordered with index 0 as START and index 1 as END.
+        if is_start:
+            self._oem_ranges[strip].insert(0, int_value)
+        else:
+            self._oem_ranges[strip].append(int_value)
+
+    def _process_and_check(self):
+        """Process, check and populate internal data structures.
+
+        After parsing and generating the internal data structures, this method
+        is responsible for sanity checking ALL of the acquired data.
+
+        Raises:
+            ValueError: With the message set to indicate the specific error.
+        """
+
+        # tuplefy the lists since range() does not like them mutable.
+        self._oem_ranges = [
+            AIDHeaderParser._convert_lst_to_tup(k, v)
+            for k, v in self._oem_ranges.iteritems()
+        ]
+
+        # Check for overlapping ranges
+        for i, range1 in enumerate(self._oem_ranges):
+            for range2 in self._oem_ranges[i + 1:]:
+                if AIDHeaderParser._is_overlap(range1, range2):
+                    raise ValueError("Overlapping OEM Ranges found %s and %s" %
+                                     (str(range1), str(range2)))
+
+        # No core AIDs should be within any oem range.
+        for aid in self._aid_value_to_name:
+
+            if Utils.in_any_range(aid, self._oem_ranges):
+                name = self._aid_value_to_name[aid]
+                raise ValueError(
+                    'AID "%s" value: %u within reserved OEM Range: "%s"' %
+                    (name, aid, str(self._oem_ranges)))
+
+    @property
+    def oem_ranges(self):
+        """Retrieves the OEM closed ranges as a list of tuples.
+
+        Returns:
+            A list of closed range tuples: [ (0, 42), (50, 105) ... ]
+        """
+        return self._oem_ranges
+
+    @property
+    def aids(self):
+        """Retrieves the list of found AIDs.
+
+        Returns:
+            A list of AID() objects.
+        """
+        return self._aid_name_to_value.values()
+
+    @staticmethod
+    def _convert_lst_to_tup(name, lst):
+        """Converts a mutable list to a non-mutable tuple.
+
+        Used ONLY for ranges and thus enforces a length of 2.
+
+        Args:
+            lst (List): list that should be "tuplefied".
+
+        Raises:
+            ValueError if lst is not a list or len is not 2.
+
+        Returns:
+            Tuple(lst)
+        """
+        if not lst or len(lst) != 2:
+            raise ValueError('Mismatched range for "%s"' % name)
+
+        return tuple(lst)
+
+    @staticmethod
+    def _is_oem_range(aid):
+        """Detects if a given aid is within the reserved OEM range.
+
+        Args:
+            aid (int): The aid to test
+
+        Returns:
+            True if it is within the range, False otherwise.
+        """
+
+        return AIDHeaderParser._OEM_RANGE.match(aid)
+
+    @staticmethod
+    def _is_overlap(range_a, range_b):
+        """Calculates the overlap of two range tuples.
+
+        A range tuple is a closed range. A closed range includes its endpoints.
+        Note that python tuples use () notation which collides with the
+        mathematical notation for open ranges.
+
+        Args:
+            range_a: The first tuple closed range eg (0, 5).
+            range_b: The second tuple closed range eg (3, 7).
+
+        Returns:
+            True if they overlap, False otherwise.
+        """
+
+        return max(range_a[0], range_b[0]) <= min(range_a[1], range_b[1])
+
+
+class FSConfigFileParser(object):
+    """Parses a config.fs ini format file.
+
+    This class is responsible for parsing the config.fs ini format files.
+    It collects and checks all the data in these files and makes it available
+    for consumption post processed.
+    """
+
+    # These _AID vars work together to ensure that an AID section name
+    # cannot contain invalid characters for a C define or a passwd/group file.
+    # Since _AID_PREFIX is within the set of _AID_MATCH the error logic only
+    # checks end, if you change this, you may have to update the error
+    # detection code.
+    _AID_MATCH = re.compile('%s[A-Z0-9_]+' % AID.PREFIX)
+    _AID_ERR_MSG = 'Expecting upper case, a number or underscore'
+
+    # list of handler to required options, used to identify the
+    # parsing section
+    _SECTIONS = [('_handle_aid', ('value',)),
+                 ('_handle_path', ('mode', 'user', 'group', 'caps'))]
+
+    def __init__(self, config_files, oem_ranges):
+        """
+        Args:
+            config_files ([str]): The list of config.fs files to parse.
+                Note the filename is not important.
+            oem_ranges ([(),()]): range tuples indicating reserved OEM ranges.
+        """
+
+        self._files = []
+        self._dirs = []
+        self._aids = []
+
+        self._seen_paths = {}
+        # (name to file, value to aid)
+        self._seen_aids = ({}, {})
+
+        self._oem_ranges = oem_ranges
+
+        self._config_files = config_files
+
+        for config_file in self._config_files:
+            self._parse(config_file)
+
+    def _parse(self, file_name):
+        """Parses and verifies config.fs files. Internal use only.
+
+        Args:
+            file_name (str): The config.fs (PythonConfigParser file format)
+                file to parse.
+
+        Raises:
+            Anything raised by ConfigParser.read()
+        """
+
+        # Separate config parsers for each file found. If you use
+        # read(filenames...) later files can override earlier files which is
+        # not what we want. Track state across files and enforce with
+        # _handle_dup(). Note, strict ConfigParser is set to true in
+        # Python >= 3.2, so in previous versions same file sections can
+        # override previous
+        # sections.
+
+        config = ConfigParser.ConfigParser()
+        config.read(file_name)
+
+        for section in config.sections():
+
+            found = False
+
+            for test in FSConfigFileParser._SECTIONS:
+                handler = test[0]
+                options = test[1]
+
+                if all([config.has_option(section, item) for item in options]):
+                    handler = getattr(self, handler)
+                    handler(file_name, section, config)
+                    found = True
+                    break
+
+            if not found:
+                sys.exit('Invalid section "%s" in file: "%s"' %
+                         (section, file_name))
+
+            # sort entries:
+            # * specified path before prefix match
+            # ** ie foo before f*
+            # * lexicographical less than before other
+            # ** ie boo before foo
+            # Given these paths:
+            # paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*']
+            # The sort order would be:
+            # paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*']
+            # Thus the fs_config tools will match on specified paths before
+            # attempting prefix, and match on the longest matching prefix.
+            self._files.sort(key=FSConfigFileParser._file_key)
+
+            # sort on value of (file_name, name, value, strvalue)
+            # This is only cosmetic so AIDS are arranged in ascending order
+            # within the generated file.
+            self._aids.sort(key=lambda item: item.normalized_value)
+
+    def _handle_aid(self, file_name, section_name, config):
+        """Verifies an AID entry and adds it to the aid list.
+
+        Calls sys.exit() with a descriptive message of the failure.
+
+        Args:
+            file_name (str): The filename of the config file being parsed.
+            section_name (str): The section name currently being parsed.
+            config (ConfigParser): The ConfigParser section being parsed that
+                the option values will come from.
+        """
+
+        def error_message(msg):
+            """Creates an error message with current parsing state."""
+            return '{} for: "{}" file: "{}"'.format(msg, section_name,
+                                                    file_name)
+
+        FSConfigFileParser._handle_dup_and_add('AID', file_name, section_name,
+                                               self._seen_aids[0])
+
+        match = FSConfigFileParser._AID_MATCH.match(section_name)
+        invalid = match.end() if match else len(AID.PREFIX)
+        if invalid != len(section_name):
+            tmp_errmsg = ('Invalid characters in AID section at "%d" for: "%s"'
+                          % (invalid, FSConfigFileParser._AID_ERR_MSG))
+            sys.exit(error_message(tmp_errmsg))
+
+        value = config.get(section_name, 'value')
+
+        if not value:
+            sys.exit(error_message('Found specified but unset "value"'))
+
+        try:
+            aid = AID(section_name, value, file_name)
+        except ValueError:
+            sys.exit(
+                error_message('Invalid "value", not aid number, got: \"%s\"' %
+                              value))
+
+        # Values must be within OEM range
+        if not Utils.in_any_range(int(aid.value, 0), self._oem_ranges):
+            emsg = '"value" not in valid range %s, got: %s'
+            emsg = emsg % (str(self._oem_ranges), value)
+            sys.exit(error_message(emsg))
+
+        # use the normalized int value in the dict and detect
+        # duplicate definitions of the same value
+        FSConfigFileParser._handle_dup_and_add(
+            'AID', file_name, aid.normalized_value, self._seen_aids[1])
+
+        # Append aid tuple of (AID_*, base10(value), _path(value))
+        # We keep the _path version of value so we can print that out in the
+        # generated header so investigating parties can identify parts.
+        # We store the base10 value for sorting, so everything is ascending
+        # later.
+        self._aids.append(aid)
+
+    def _handle_path(self, file_name, section_name, config):
+        """Add a file capability entry to the internal list.
+
+        Handles a file capability entry, verifies it, and adds it to
+        to the internal dirs or files list based on path. If it ends
+        with a / its a dir. Internal use only.
+
+        Calls sys.exit() on any validation error with message set.
+
+        Args:
+            file_name (str): The current name of the file being parsed.
+            section_name (str): The name of the section to parse.
+            config (str): The config parser.
+        """
+
+        FSConfigFileParser._handle_dup_and_add('path', file_name, section_name,
+                                               self._seen_paths)
+
+        mode = config.get(section_name, 'mode')
+        user = config.get(section_name, 'user')
+        group = config.get(section_name, 'group')
+        caps = config.get(section_name, 'caps')
+
+        errmsg = ('Found specified but unset option: \"%s" in file: \"' +
+                  file_name + '\"')
+
+        if not mode:
+            sys.exit(errmsg % 'mode')
+
+        if not user:
+            sys.exit(errmsg % 'user')
+
+        if not group:
+            sys.exit(errmsg % 'group')
+
+        if not caps:
+            sys.exit(errmsg % 'caps')
+
+        caps = caps.split()
+
+        tmp = []
+        for cap in caps:
+            try:
+                # test if string is int, if it is, use as is.
+                int(cap, 0)
+                tmp.append('(' + cap + ')')
+            except ValueError:
+                tmp.append('(1ULL << CAP_' + cap.upper() + ')')
+
+        caps = tmp
+
+        if len(mode) == 3:
+            mode = '0' + mode
+
+        try:
+            int(mode, 8)
+        except ValueError:
+            sys.exit('Mode must be octal characters, got: "%s"' % mode)
+
+        if len(mode) != 4:
+            sys.exit('Mode must be 3 or 4 characters, got: "%s"' % mode)
+
+        caps_str = '|'.join(caps)
+
+        entry = FSConfig(mode, user, group, caps_str, section_name, file_name)
+        if section_name[-1] == '/':
+            self._dirs.append(entry)
+        else:
+            self._files.append(entry)
+
+    @property
+    def files(self):
+        """Get the list of FSConfig file entries.
+
+        Returns:
+             a list of FSConfig() objects for file paths.
+        """
+        return self._files
+
+    @property
+    def dirs(self):
+        """Get the list of FSConfig dir entries.
+
+        Returns:
+            a list of FSConfig() objects for directory paths.
+        """
+        return self._dirs
+
+    @property
+    def aids(self):
+        """Get the list of AID entries.
+
+        Returns:
+            a list of AID() objects.
+        """
+        return self._aids
+
+    @staticmethod
+    def _file_key(fs_config):
+        """Used as the key paramter to sort.
+
+        This is used as a the function to the key parameter of a sort.
+        it wraps the string supplied in a class that implements the
+        appropriate __lt__ operator for the sort on path strings. See
+        StringWrapper class for more details.
+
+        Args:
+            fs_config (FSConfig): A FSConfig entry.
+
+        Returns:
+            A StringWrapper object
+        """
+
+        # Wrapper class for custom prefix matching strings
+        class StringWrapper(object):
+            """Wrapper class used for sorting prefix strings.
+
+            The algorithm is as follows:
+              - specified path before prefix match
+                - ie foo before f*
+              - lexicographical less than before other
+                - ie boo before foo
+
+            Given these paths:
+            paths=['ac', 'a', 'acd', 'an', 'a*', 'aa', 'ac*']
+            The sort order would be:
+            paths=['a', 'aa', 'ac', 'acd', 'an', 'ac*', 'a*']
+            Thus the fs_config tools will match on specified paths before
+            attempting prefix, and match on the longest matching prefix.
+            """
+
+            def __init__(self, path):
+                """
+                Args:
+                    path (str): the path string to wrap.
+                """
+                self.is_prefix = path[-1] == '*'
+                if self.is_prefix:
+                    self.path = path[:-1]
+                else:
+                    self.path = path
+
+            def __lt__(self, other):
+
+                # if were both suffixed the smallest string
+                # is 'bigger'
+                if self.is_prefix and other.is_prefix:
+                    result = len(self.path) > len(other.path)
+                # If I am an the suffix match, im bigger
+                elif self.is_prefix:
+                    result = False
+                # If other is the suffix match, he's bigger
+                elif other.is_prefix:
+                    result = True
+                # Alphabetical
+                else:
+                    result = self.path < other.path
+                return result
+
+        return StringWrapper(fs_config.path)
+
+    @staticmethod
+    def _handle_dup_and_add(name, file_name, section_name, seen):
+        """Tracks and detects duplicates. Internal use only.
+
+        Calls sys.exit() on a duplicate.
+
+        Args:
+            name (str): The name to use in the error reporting. The pretty
+                name for the section.
+            file_name (str): The file currently being parsed.
+            section_name (str): The name of the section. This would be path
+                or identifier depending on what's being parsed.
+            seen (dict): The dictionary of seen things to check against.
+        """
+        if section_name in seen:
+            dups = '"' + seen[section_name] + '" and '
+            dups += file_name
+            sys.exit('Duplicate %s "%s" found in files: %s' %
+                     (name, section_name, dups))
+
+        seen[section_name] = file_name
+
+
+class BaseGenerator(object):
+    """Interface for Generators.
+
+    Base class for generators, generators should implement
+    these method stubs.
+    """
+
+    def add_opts(self, opt_group):
+        """Used to add per-generator options to the command line.
+
+        Args:
+            opt_group (argument group object): The argument group to append to.
+                See the ArgParse docs for more details.
+        """
+
+        raise NotImplementedError("Not Implemented")
+
+    def __call__(self, args):
+        """This is called to do whatever magic the generator does.
+
+        Args:
+            args (dict): The arguments from ArgParse as a dictionary.
+                ie if you specified an argument of foo in add_opts, access
+                it via args['foo']
+        """
+
+        raise NotImplementedError("Not Implemented")
+
+
+@generator('fsconfig')
+class FSConfigGen(BaseGenerator):
+    """Generates the android_filesystem_config.h file.
+
+    Output is  used in generating fs_config_files and fs_config_dirs.
+    """
+
+    _GENERATED = textwrap.dedent("""\
+        /*
+         * THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY
+         */
+        """)
+
+    _INCLUDES = [
+        '<private/android_filesystem_config.h>', '"generated_oem_aid.h"'
+    ]
+
+    _DEFINE_NO_DIRS = '#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS'
+    _DEFINE_NO_FILES = '#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES'
+
+    _DEFAULT_WARNING = (
+        '#warning No device-supplied android_filesystem_config.h,'
+        ' using empty default.')
+
+    # Long names.
+    # pylint: disable=invalid-name
+    _NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS_ENTRY = (
+        '{ 00000, AID_ROOT, AID_ROOT, 0,'
+        '"system/etc/fs_config_dirs" },')
+
+    _NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES_ENTRY = (
+        '{ 00000, AID_ROOT, AID_ROOT, 0,'
+        '"system/etc/fs_config_files" },')
+
+    _IFDEF_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS = (
+        '#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS')
+    # pylint: enable=invalid-name
+
+    _ENDIF = '#endif'
+
+    _OPEN_FILE_STRUCT = (
+        'static const struct fs_path_config android_device_files[] = {')
+
+    _OPEN_DIR_STRUCT = (
+        'static const struct fs_path_config android_device_dirs[] = {')
+
+    _CLOSE_FILE_STRUCT = '};'
+
+    _GENERIC_DEFINE = "#define %s\t%s"
+
+    _FILE_COMMENT = '// Defined in file: \"%s\"'
+
+    def __init__(self, *args, **kwargs):
+        BaseGenerator.__init__(args, kwargs)
+
+        self._oem_parser = None
+        self._base_parser = None
+        self._friendly_to_aid = None
+
+    def add_opts(self, opt_group):
+
+        opt_group.add_argument(
+            'fsconfig', nargs='+', help='The list of fsconfig files to parse')
+
+        opt_group.add_argument(
+            '--aid-header',
+            required=True,
+            help='An android_filesystem_config.h file'
+            ' to parse AIDs and OEM Ranges from')
+
+    def __call__(self, args):
+
+        self._base_parser = AIDHeaderParser(args['aid_header'])
+        self._oem_parser = FSConfigFileParser(args['fsconfig'],
+                                              self._base_parser.oem_ranges)
+        base_aids = self._base_parser.aids
+        oem_aids = self._oem_parser.aids
+
+        # Detect name collisions on AIDs. Since friendly works as the
+        # identifier for collision testing and we need friendly later on for
+        # name resolution, just calculate and use friendly.
+        # {aid.friendly: aid for aid in base_aids}
+        base_friendly = {aid.friendly: aid for aid in base_aids}
+        oem_friendly = {aid.friendly: aid for aid in oem_aids}
+
+        base_set = set(base_friendly.keys())
+        oem_set = set(oem_friendly.keys())
+
+        common = base_set & oem_set
+
+        if len(common) > 0:
+            emsg = 'Following AID Collisions detected for: \n'
+            for friendly in common:
+                base = base_friendly[friendly]
+                oem = oem_friendly[friendly]
+                emsg += (
+                    'Identifier: "%s" Friendly Name: "%s" '
+                    'found in file "%s" and "%s"' %
+                    (base.identifier, base.friendly, base.found, oem.found))
+                sys.exit(emsg)
+
+        self._friendly_to_aid = oem_friendly
+        self._friendly_to_aid.update(base_friendly)
+
+        self._generate()
+
+    def _to_fs_entry(self, fs_config):
+        """Converts an FSConfig entry to an fs entry.
+
+        Prints '{ mode, user, group, caps, "path" },'.
+
+        Calls sys.exit() on error.
+
+        Args:
+            fs_config (FSConfig): The entry to convert to
+                a valid C array entry.
+        """
+
+        # Get some short names
+        mode = fs_config.mode
+        user = fs_config.user
+        group = fs_config.group
+        fname = fs_config.filename
+        caps = fs_config.caps
+        path = fs_config.path
+
+        emsg = 'Cannot convert friendly name "%s" to identifier!'
+
+        # remap friendly names to identifier names
+        if AID.is_friendly(user):
+            if user not in self._friendly_to_aid:
+                sys.exit(emsg % user)
+            user = self._friendly_to_aid[user].identifier
+
+        if AID.is_friendly(group):
+            if group not in self._friendly_to_aid:
+                sys.exit(emsg % group)
+            group = self._friendly_to_aid[group].identifier
+
+        fmt = '{ %s, %s, %s, %s, "%s" },'
+
+        expanded = fmt % (mode, user, group, caps, path)
+
+        print FSConfigGen._FILE_COMMENT % fname
+        print '    ' + expanded
+
+    @staticmethod
+    def _gen_inc():
+        """Generate the include header lines and print to stdout."""
+        for include in FSConfigGen._INCLUDES:
+            print '#include %s' % include
+
+    def _generate(self):
+        """Generates an OEM android_filesystem_config.h header file to stdout.
+
+        Args:
+            files ([FSConfig]): A list of FSConfig objects for file entries.
+            dirs ([FSConfig]): A list of FSConfig objects for directory
+                entries.
+            aids ([AIDS]): A list of AID objects for Android Id entries.
+        """
+        print FSConfigGen._GENERATED
+        print
+
+        FSConfigGen._gen_inc()
+        print
+
+        dirs = self._oem_parser.dirs
+        files = self._oem_parser.files
+        aids = self._oem_parser.aids
+
+        are_dirs = len(dirs) > 0
+        are_files = len(files) > 0
+        are_aids = len(aids) > 0
+
+        if are_aids:
+            for aid in aids:
+                # use the preserved _path value
+                print FSConfigGen._FILE_COMMENT % aid.found
+                print FSConfigGen._GENERIC_DEFINE % (aid.identifier, aid.value)
+
+            print
+
+        if not are_dirs:
+            print FSConfigGen._DEFINE_NO_DIRS + '\n'
+
+        if not are_files:
+            print FSConfigGen._DEFINE_NO_FILES + '\n'
+
+        if not are_files and not are_dirs and not are_aids:
+            return
+
+        if are_files:
+            print FSConfigGen._OPEN_FILE_STRUCT
+            for fs_config in files:
+                self._to_fs_entry(fs_config)
+
+            if not are_dirs:
+                print FSConfigGen._IFDEF_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS
+                print(
+                    '    ' +
+                    FSConfigGen._NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS_ENTRY)
+                print FSConfigGen._ENDIF
+            print FSConfigGen._CLOSE_FILE_STRUCT
+
+        if are_dirs:
+            print FSConfigGen._OPEN_DIR_STRUCT
+            for dir_entry in dirs:
+                self._to_fs_entry(dir_entry)
+
+            print FSConfigGen._CLOSE_FILE_STRUCT
+
+
+@generator('aidarray')
+class AIDArrayGen(BaseGenerator):
+    """Generates the android_id static array."""
+
+    _GENERATED = ('/*\n'
+                  ' * THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n'
+                  ' */')
+
+    _INCLUDE = '#include <private/android_filesystem_config.h>'
+
+    _STRUCT_FS_CONFIG = textwrap.dedent("""
+                         struct android_id_info {
+                             const char *name;
+                             unsigned aid;
+                         };""")
+
+    _OPEN_ID_ARRAY = 'static const struct android_id_info android_ids[] = {'
+
+    _ID_ENTRY = '    { "%s", %s },'
+
+    _CLOSE_FILE_STRUCT = '};'
+
+    _COUNT = ('#define android_id_count \\\n'
+              '    (sizeof(android_ids) / sizeof(android_ids[0]))')
+
+    def add_opts(self, opt_group):
+
+        opt_group.add_argument(
+            'hdrfile', help='The android_filesystem_config.h'
+            'file to parse')
+
+    def __call__(self, args):
+
+        hdr = AIDHeaderParser(args['hdrfile'])
+
+        print AIDArrayGen._GENERATED
+        print
+        print AIDArrayGen._INCLUDE
+        print
+        print AIDArrayGen._STRUCT_FS_CONFIG
+        print
+        print AIDArrayGen._OPEN_ID_ARRAY
+
+        for aid in hdr.aids:
+            print AIDArrayGen._ID_ENTRY % (aid.friendly, aid.identifier)
+
+        print AIDArrayGen._CLOSE_FILE_STRUCT
+        print
+        print AIDArrayGen._COUNT
+        print
+
+
+@generator('oemaid')
+class OEMAidGen(BaseGenerator):
+    """Generates the OEM AID_<name> value header file."""
+
+    _GENERATED = ('/*\n'
+                  ' * THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n'
+                  ' */')
+
+    _GENERIC_DEFINE = "#define %s\t%s"
+
+    _FILE_COMMENT = '// Defined in file: \"%s\"'
+
+    # Intentional trailing newline for readability.
+    _FILE_IFNDEF_DEFINE = ('#ifndef GENERATED_OEM_AIDS_H_\n'
+                           '#define GENERATED_OEM_AIDS_H_\n')
+
+    _FILE_ENDIF = '#endif'
+
+    def __init__(self):
+
+        self._old_file = None
+
+    def add_opts(self, opt_group):
+
+        opt_group.add_argument(
+            'fsconfig', nargs='+', help='The list of fsconfig files to parse.')
+
+        opt_group.add_argument(
+            '--aid-header',
+            required=True,
+            help='An android_filesystem_config.h file'
+            'to parse AIDs and OEM Ranges from')
+
+    def __call__(self, args):
+
+        hdr_parser = AIDHeaderParser(args['aid_header'])
+
+        parser = FSConfigFileParser(args['fsconfig'], hdr_parser.oem_ranges)
+
+        print OEMAidGen._GENERATED
+
+        print OEMAidGen._FILE_IFNDEF_DEFINE
+
+        for aid in parser.aids:
+            self._print_aid(aid)
+            print
+
+        print OEMAidGen._FILE_ENDIF
+
+    def _print_aid(self, aid):
+        """Prints a valid #define AID identifier to stdout.
+
+        Args:
+            aid to print
+        """
+
+        # print the source file location of the AID
+        found_file = aid.found
+        if found_file != self._old_file:
+            print OEMAidGen._FILE_COMMENT % found_file
+            self._old_file = found_file
+
+        print OEMAidGen._GENERIC_DEFINE % (aid.identifier, aid.value)
+
+
+@generator('passwd')
+class PasswdGen(BaseGenerator):
+    """Generates the /etc/passwd file per man (5) passwd."""
+
+    _GENERATED = ('#\n# THIS IS AN AUTOGENERATED FILE! DO NOT MODIFY!\n#')
+
+    _FILE_COMMENT = '# Defined in file: \"%s\"'
+
+    def __init__(self):
+
+        self._old_file = None
+
+    def add_opts(self, opt_group):
+
+        opt_group.add_argument(
+            'fsconfig', nargs='+', help='The list of fsconfig files to parse.')
+
+        opt_group.add_argument(
+            '--aid-header',
+            required=True,
+            help='An android_filesystem_config.h file'
+            'to parse AIDs and OEM Ranges from')
+
+    def __call__(self, args):
+
+        hdr_parser = AIDHeaderParser(args['aid_header'])
+
+        parser = FSConfigFileParser(args['fsconfig'], hdr_parser.oem_ranges)
+
+        aids = parser.aids
+
+        # nothing to do if no aids defined
+        if len(aids) == 0:
+            return
+
+        print PasswdGen._GENERATED
+
+        for aid in aids:
+            self._print_formatted_line(aid)
+
+    def _print_formatted_line(self, aid):
+        """Prints the aid to stdout in the passwd format. Internal use only.
+
+        Colon delimited:
+            login name, friendly name
+            encrypted password (optional)
+            uid (int)
+            gid (int)
+            User name or comment field
+            home directory
+            interpreter (optional)
+
+        Args:
+            aid (AID): The aid to print.
+        """
+        if self._old_file != aid.found:
+            self._old_file = aid.found
+            print PasswdGen._FILE_COMMENT % aid.found
+
+        try:
+            logon, uid = Utils.get_login_and_uid_cleansed(aid)
+        except ValueError as exception:
+            sys.exit(exception)
+
+        print "%s::%s:%s::/:/system/bin/sh" % (logon, uid, uid)
+
+
+@generator('group')
+class GroupGen(PasswdGen):
+    """Generates the /etc/group file per man (5) group."""
+
+    # Overrides parent
+    def _print_formatted_line(self, aid):
+        """Prints the aid to stdout in the group format. Internal use only.
+
+        Formatted (per man 5 group) like:
+            group_name:password:GID:user_list
+
+        Args:
+            aid (AID): The aid to print.
+        """
+        if self._old_file != aid.found:
+            self._old_file = aid.found
+            print PasswdGen._FILE_COMMENT % aid.found
+
+        try:
+            logon, uid = Utils.get_login_and_uid_cleansed(aid)
+        except ValueError as exception:
+            sys.exit(exception)
+
+        print "%s::%s:" % (logon, uid)
+
+
+def main():
+    """Main entry point for execution."""
+
+    opt_parser = argparse.ArgumentParser(
+        description='A tool for parsing fsconfig config files and producing' +
+        'digestable outputs.')
+    subparser = opt_parser.add_subparsers(help='generators')
+
+    gens = generator.get()
+
+    # for each gen, instantiate and add them as an option
+    for name, gen in gens.iteritems():
+
+        generator_option_parser = subparser.add_parser(name, help=gen.__doc__)
+        generator_option_parser.set_defaults(which=name)
+
+        opt_group = generator_option_parser.add_argument_group(name +
+                                                               ' options')
+        gen.add_opts(opt_group)
+
+    args = opt_parser.parse_args()
+
+    args_as_dict = vars(args)
+    which = args_as_dict['which']
+    del args_as_dict['which']
+
+    gens[which](args_as_dict)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/tools/fs_config/pylintrc b/tools/fs_config/pylintrc
new file mode 100644
index 0000000..3e44870
--- /dev/null
+++ b/tools/fs_config/pylintrc
@@ -0,0 +1,5 @@
+[MESSAGES CONTROL]
+disable=fixme,design,locally-disabled,too-many-lines
+
+[VARIABLES]
+dummy-variables-rgx=_|dummy
diff --git a/tools/fs_config/test_fs_config_generator.py b/tools/fs_config/test_fs_config_generator.py
new file mode 100755
index 0000000..a49058a
--- /dev/null
+++ b/tools/fs_config/test_fs_config_generator.py
@@ -0,0 +1,313 @@
+#!/usr/bin/env python
+"""Unit test suite for the fs_config_genertor.py tool."""
+
+import tempfile
+import textwrap
+import unittest
+
+from fs_config_generator import AID
+from fs_config_generator import AIDHeaderParser
+from fs_config_generator import FSConfigFileParser
+from fs_config_generator import FSConfig
+from fs_config_generator import Utils
+
+
+# Disable protected access so we can test class internal
+# methods. Also, disable invalid-name as some of the
+# class method names are over length.
+# pylint: disable=protected-access,invalid-name
+class Tests(unittest.TestCase):
+    """Test class for unit tests"""
+
+    def test_is_overlap(self):
+        """Test overlap detection helper"""
+
+        self.assertTrue(AIDHeaderParser._is_overlap((0, 1), (1, 2)))
+
+        self.assertTrue(AIDHeaderParser._is_overlap((0, 100), (90, 200)))
+
+        self.assertTrue(AIDHeaderParser._is_overlap((20, 50), (1, 101)))
+
+        self.assertFalse(AIDHeaderParser._is_overlap((0, 100), (101, 200)))
+
+        self.assertFalse(AIDHeaderParser._is_overlap((-10, 0), (10, 20)))
+
+    def test_in_any_range(self):
+        """Test if value in range"""
+
+        self.assertFalse(Utils.in_any_range(50, [(100, 200), (1, 2), (1, 1)]))
+        self.assertFalse(Utils.in_any_range(250, [(100, 200), (1, 2), (1, 1)]))
+
+        self.assertTrue(Utils.in_any_range(100, [(100, 200), (1, 2), (1, 1)]))
+        self.assertTrue(Utils.in_any_range(200, [(100, 200), (1, 2), (1, 1)]))
+        self.assertTrue(Utils.in_any_range(150, [(100, 200)]))
+
+    def test_aid(self):
+        """Test AID class constructor"""
+
+        aid = AID('AID_FOO_BAR', '0xFF', 'myfakefile')
+        self.assertEquals(aid.identifier, 'AID_FOO_BAR')
+        self.assertEquals(aid.value, '0xFF')
+        self.assertEquals(aid.found, 'myfakefile')
+        self.assertEquals(aid.normalized_value, '255')
+        self.assertEquals(aid.friendly, 'foo_bar')
+
+        aid = AID('AID_MEDIA_EX', '1234', 'myfakefile')
+        self.assertEquals(aid.identifier, 'AID_MEDIA_EX')
+        self.assertEquals(aid.value, '1234')
+        self.assertEquals(aid.found, 'myfakefile')
+        self.assertEquals(aid.normalized_value, '1234')
+        self.assertEquals(aid.friendly, 'mediaex')
+
+    def test_aid_header_parser_good(self):
+        """Test AID Header Parser good input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_FOO 1000
+                #define AID_BAR 1001
+                #define SOMETHING "something"
+                #define AID_OEM_RESERVED_START 2900
+                #define AID_OEM_RESERVED_END   2999
+                #define AID_OEM_RESERVED_1_START  7000
+                #define AID_OEM_RESERVED_1_END    8000
+            """))
+            temp_file.flush()
+
+            parser = AIDHeaderParser(temp_file.name)
+            oem_ranges = parser.oem_ranges
+            aids = parser.aids
+
+            self.assertTrue((2900, 2999) in oem_ranges)
+            self.assertFalse((5000, 6000) in oem_ranges)
+
+            for aid in aids:
+                self.assertTrue(aid.normalized_value in ['1000', '1001'])
+                self.assertFalse(aid.normalized_value in ['1', '2', '3'])
+
+    def test_aid_header_parser_good_unordered(self):
+        """Test AID Header Parser good unordered input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_FOO 1000
+                #define AID_OEM_RESERVED_1_END    8000
+                #define AID_BAR 1001
+                #define SOMETHING "something"
+                #define AID_OEM_RESERVED_END   2999
+                #define AID_OEM_RESERVED_1_START  7000
+                #define AID_OEM_RESERVED_START 2900
+            """))
+            temp_file.flush()
+
+            parser = AIDHeaderParser(temp_file.name)
+            oem_ranges = parser.oem_ranges
+            aids = parser.aids
+
+            self.assertTrue((2900, 2999) in oem_ranges)
+            self.assertFalse((5000, 6000) in oem_ranges)
+
+            for aid in aids:
+                self.assertTrue(aid.normalized_value in ['1000', '1001'])
+                self.assertFalse(aid.normalized_value in ['1', '2', '3'])
+
+    def test_aid_header_parser_bad_aid(self):
+        """Test AID Header Parser bad aid input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_FOO "bad"
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                AIDHeaderParser(temp_file.name)
+
+    def test_aid_header_parser_bad_oem_range(self):
+        """Test AID Header Parser bad oem range input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_OEM_RESERVED_START 2900
+                #define AID_OEM_RESERVED_END   1800
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                AIDHeaderParser(temp_file.name)
+
+    def test_aid_header_parser_bad_oem_range_no_end(self):
+        """Test AID Header Parser bad oem range (no end) input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_OEM_RESERVED_START 2900
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                AIDHeaderParser(temp_file.name)
+
+    def test_aid_header_parser_bad_oem_range_no_start(self):
+        """Test AID Header Parser bad oem range (no start) input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_OEM_RESERVED_END 2900
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                AIDHeaderParser(temp_file.name)
+
+    def test_aid_header_parser_bad_oem_range_mismatch_start_end(self):
+        """Test AID Header Parser bad oem range mismatched input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_OEM_RESERVED_START 2900
+                #define AID_OEM_RESERVED_2_END 2900
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                AIDHeaderParser(temp_file.name)
+
+    def test_aid_header_parser_bad_duplicate_ranges(self):
+        """Test AID Header Parser exits cleanly on duplicate AIDs"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_FOO 100
+                #define AID_BAR 100
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                AIDHeaderParser(temp_file.name)
+
+    def test_aid_header_parser_no_bad_aids(self):
+        """Test AID Header Parser that it doesn't contain:
+        Ranges, ie things the end with "_START" or "_END"
+        AID_APP
+        AID_USER
+        For more details see:
+          - https://android-review.googlesource.com/#/c/313024
+          - https://android-review.googlesource.com/#/c/313169
+        """
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                #define AID_APP              10000 /* TODO: switch users over to AID_APP_START */
+                #define AID_APP_START        10000 /* first app user */
+                #define AID_APP_END          19999 /* last app user */
+
+                #define AID_CACHE_GID_START  20000 /* start of gids for apps to mark cached data */
+                #define AID_CACHE_GID_END    29999 /* end of gids for apps to mark cached data */
+
+                #define AID_SHARED_GID_START 50000 /* start of gids for apps in each user to share */
+                #define AID_SHARED_GID_END   59999 /* end of gids for apps in each user to share */
+
+                #define AID_ISOLATED_START   99000 /* start of uids for fully isolated sandboxed processes */
+                #define AID_ISOLATED_END     99999 /* end of uids for fully isolated sandboxed processes */
+
+                #define AID_USER            100000 /* TODO: switch users over to AID_USER_OFFSET */
+                #define AID_USER_OFFSET     100000 /* offset for uid ranges for each user */
+            """))
+            temp_file.flush()
+
+            parser = AIDHeaderParser(temp_file.name)
+            aids = parser.aids
+
+            bad_aids = ['_START', '_END', 'AID_APP', 'AID_USER']
+
+            for aid in aids:
+                self.assertFalse(
+                    any(bad in aid.identifier for bad in bad_aids),
+                    'Not expecting keywords "%s" in aids "%s"' %
+                    (str(bad_aids), str([tmp.identifier for tmp in aids])))
+
+    def test_fs_config_file_parser_good(self):
+        """Test FSConfig Parser good input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                [/system/bin/file]
+                user: AID_FOO
+                group: AID_SYSTEM
+                mode: 0777
+                caps: BLOCK_SUSPEND
+
+                [/vendor/path/dir/]
+                user: AID_FOO
+                group: AID_SYSTEM
+                mode: 0777
+                caps: 0
+
+                [AID_OEM1]
+                # 5001 in base16
+                value: 0x1389
+            """))
+            temp_file.flush()
+
+            parser = FSConfigFileParser([temp_file.name], [(5000, 5999)])
+            files = parser.files
+            dirs = parser.dirs
+            aids = parser.aids
+
+            self.assertEquals(len(files), 1)
+            self.assertEquals(len(dirs), 1)
+            self.assertEquals(len(aids), 1)
+
+            aid = aids[0]
+            fcap = files[0]
+            dcap = dirs[0]
+
+            self.assertEqual(fcap,
+                             FSConfig('0777', 'AID_FOO', 'AID_SYSTEM',
+                                      '(1ULL << CAP_BLOCK_SUSPEND)',
+                                      '/system/bin/file', temp_file.name))
+
+            self.assertEqual(dcap,
+                             FSConfig('0777', 'AID_FOO', 'AID_SYSTEM', '(0)',
+                                      '/vendor/path/dir/', temp_file.name))
+
+            self.assertEqual(aid, AID('AID_OEM1', '0x1389', temp_file.name))
+
+    def test_fs_config_file_parser_bad(self):
+        """Test FSConfig Parser bad input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                [/system/bin/file]
+                caps: BLOCK_SUSPEND
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                FSConfigFileParser([temp_file.name], [(5000, 5999)])
+
+    def test_fs_config_file_parser_bad_aid_range(self):
+        """Test FSConfig Parser bad aid range value input file"""
+
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(
+                textwrap.dedent("""
+                [AID_OEM1]
+                value: 25
+            """))
+            temp_file.flush()
+
+            with self.assertRaises(SystemExit):
+                FSConfigFileParser([temp_file.name], [(5000, 5999)])
diff --git a/tools/generate-enforce-rro-android-manifest.py b/tools/generate-enforce-rro-android-manifest.py
new file mode 100755
index 0000000..68331cf
--- /dev/null
+++ b/tools/generate-enforce-rro-android-manifest.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2017 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.
+"""
+Utility to generate the Android manifest file of runtime resource overlay
+package for source module.
+"""
+from xml.dom.minidom import parseString
+import argparse
+import os
+import sys
+
+ANDROID_MANIFEST_TEMPLATE="""<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="%s.auto_generated_rro__"
+    android:versionCode="1"
+    android:versionName="1.0">
+    <overlay android:targetPackage="%s" android:priority="0" android:isStatic="true"/>
+</manifest>
+"""
+
+
+def get_args():
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        '-u', '--use-package-name', action='store_true',
+        help='Indicate that --package-info is a package name.')
+    parser.add_argument(
+        '-p', '--package-info', required=True,
+        help='Manifest package name or manifest file path of source module.')
+    parser.add_argument(
+        '-o', '--output', required=True,
+        help='Output manifest file path.')
+    return parser.parse_args()
+
+
+def main(argv):
+  args = get_args()
+
+  package_name = args.package_info
+  if not args.use_package_name:
+    with open(args.package_info) as f:
+      data = f.read()
+      f.close()
+      dom = parseString(data)
+      package_name = dom.documentElement.getAttribute('package')
+
+  with open(args.output, 'w+') as f:
+    f.write(ANDROID_MANIFEST_TEMPLATE % (package_name, package_name))
+    f.close()
+
+
+if __name__ == "__main__":
+  main(sys.argv)
diff --git a/tools/generate-notice-files.py b/tools/generate-notice-files.py
index 5b13bf5..adbf7c2 100755
--- a/tools/generate-notice-files.py
+++ b/tools/generate-notice-files.py
@@ -14,14 +14,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 """
-Usage: generate-notice-files [plain text output file] [html output file] [file title] [directory of notices]
+Usage: generate-notice-files --text-output [plain text output file] \
+               --html-output [html output file] \
+               --xml-output [xml output file] \
+               -t [file title] -s [directory of notices]
 
 Generate the Android notice files, including both text and html files.
 
 -h to display this usage message and exit.
 """
 from collections import defaultdict
-import getopt
+import argparse
 import hashlib
 import itertools
 import os
@@ -38,26 +41,6 @@
     "<": "&lt;",
     }
 
-try:
-  opts, args = getopt.getopt(sys.argv[1:], "h")
-except getopt.GetoptError, err:
-    print str(err)
-    print __doc__
-    sys.exit(2)
-
-for o, a in opts:
-  if o == "-h":
-    print __doc__
-    sys.exit(2)
-  else:
-    print >> sys.stderr, "unhandled option %s" % (o,)
-
-if len(args) != 4:
-    print """need exactly four arguments, the two output files, the file title
-             and the directory containing notices, not %d""" % (len(args),)
-    print __doc__
-    sys.exit(1)
-
 def hexify(s):
     return ("%02x"*len(s)) % tuple(map(ord, s))
 
@@ -163,27 +146,123 @@
       print >> output_file, open(value[0]).read()
     output_file.close()
 
-def main(args):
-    txt_output_file = args[0]
-    html_output_file = args[1]
-    file_title = args[2]
+def combine_notice_files_xml(files_with_same_hash, input_dir, output_filename):
+    """Combine notice files in FILE_HASH and output a XML version to OUTPUT_FILENAME."""
+
+    SRC_DIR_STRIP_RE = re.compile(input_dir + "(/.*).txt")
+
+    # Set up a filename to row id table (anchors inside tables don't work in
+    # most browsers, but href's to table row ids do)
+    id_table = {}
+    for file_key in files_with_same_hash.keys():
+        for filename in files_with_same_hash[file_key]:
+             id_table[filename] = file_key
+
+    # Open the output file, and output the header pieces
+    output_file = open(output_filename, "wb")
+
+    print >> output_file, '<?xml version="1.0" encoding="utf-8"?>'
+    print >> output_file, "<licenses>"
+
+    # Flatten the list of lists into a single list of filenames
+    sorted_filenames = sorted(id_table.keys())
+
+    # Print out a nice table of contents
+    for filename in sorted_filenames:
+        stripped_filename = SRC_DIR_STRIP_RE.sub(r"\1", filename)
+        print >> output_file, '<file-name contentId="%s">%s</file-name>' % (id_table.get(filename), stripped_filename)
+
+    print >> output_file
+    print >> output_file
+
+    processed_file_keys = []
+    # Output the individual notice file lists
+    for filename in sorted_filenames:
+        file_key = id_table.get(filename)
+        if file_key in processed_file_keys:
+            continue
+        processed_file_keys.append(file_key)
+
+        print >> output_file, '<file-content contentId="%s"><![CDATA[%s]]></file-content>' % (file_key, html_escape(open(filename).read()))
+        print >> output_file
+
+    # Finish off the file output
+    print >> output_file, "</licenses>"
+    output_file.close()
+
+def get_args():
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        '--text-output', required=True,
+        help='The text output file path.')
+    parser.add_argument(
+        '--html-output',
+        help='The html output file path.')
+    parser.add_argument(
+        '--xml-output',
+        help='The xml output file path.')
+    parser.add_argument(
+        '-t', '--title', required=True,
+        help='The file title.')
+    parser.add_argument(
+        '-s', '--source-dir', required=True,
+        help='The directory containing notices.')
+    parser.add_argument(
+        '-i', '--included-subdirs', action='append',
+        help='The sub directories which should be included.')
+    parser.add_argument(
+        '-e', '--excluded-subdirs', action='append',
+        help='The sub directories which should be excluded.')
+    return parser.parse_args()
+
+def main(argv):
+    args = get_args()
+
+    txt_output_file = args.text_output
+    html_output_file = args.html_output
+    xml_output_file = args.xml_output
+    file_title = args.title
+    included_subdirs = []
+    excluded_subdirs = []
+    if args.included_subdirs is not None:
+        included_subdirs = args.included_subdirs
+    if args.excluded_subdirs is not None:
+        excluded_subdirs = args.excluded_subdirs
 
     # Find all the notice files and md5 them
-    input_dir = os.path.normpath(args[3])
+    input_dir = os.path.normpath(args.source_dir)
     files_with_same_hash = defaultdict(list)
     for root, dir, files in os.walk(input_dir):
         for file in files:
-            if file.endswith(".txt"):
+            matched = True
+            if len(included_subdirs) > 0:
+                matched = False
+                for subdir in included_subdirs:
+                    if root.startswith(input_dir + '/' + subdir):
+                        matched = True
+                        break
+            elif len(excluded_subdirs) > 0:
+                for subdir in excluded_subdirs:
+                    if root.startswith(input_dir + '/' + subdir):
+                        matched = False
+                        break
+            if matched and file.endswith(".txt"):
                 filename = os.path.join(root, file)
                 file_md5sum = md5sum(filename)
                 files_with_same_hash[file_md5sum].append(filename)
 
     filesets = [sorted(files_with_same_hash[md5]) for md5 in sorted(files_with_same_hash.keys())]
 
-    print "Combining NOTICE files into HTML"
-    combine_notice_files_html(filesets, input_dir, html_output_file)
     print "Combining NOTICE files into text"
     combine_notice_files_text(filesets, input_dir, txt_output_file, file_title)
 
+    if html_output_file is not None:
+        print "Combining NOTICE files into HTML"
+        combine_notice_files_html(filesets, input_dir, html_output_file)
+
+    if xml_output_file is not None:
+        print "Combining NOTICE files into XML"
+        combine_notice_files_xml(files_with_same_hash, input_dir, xml_output_file)
+
 if __name__ == "__main__":
-    main(args)
+    main(sys.argv)
diff --git a/tools/ijar/Android.bp b/tools/ijar/Android.bp
new file mode 100644
index 0000000..a244a2d
--- /dev/null
+++ b/tools/ijar/Android.bp
@@ -0,0 +1,18 @@
+// Copyright 2015 The Android Open Source Project
+//
+// The rest of files in this directory comes from
+// https://github.com/bazelbuild/bazel/tree/master/third_party/ijar
+
+cc_binary_host {
+    srcs: [
+        "classfile.cc",
+        "ijar.cc",
+        "zip.cc",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    host_ldlibs: ["-lz"],
+    name: "ijar",
+}
diff --git a/tools/ijar/Android.mk b/tools/ijar/Android.mk
deleted file mode 100644
index 8b2a02c..0000000
--- a/tools/ijar/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2015 The Android Open Source Project
-#
-# The rest of files in this directory comes from
-# https://github.com/bazelbuild/bazel/tree/master/third_party/ijar
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := classfile.cc ijar.cc zip.cc
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libz-host
-LOCAL_MODULE := ijar
-# libc++ is not supported for TARGET_BUILD_APPS builds
-LOCAL_CXX_STL := libstdc++
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/ijar/classfile.cc b/tools/ijar/classfile.cc
index e0cf42e..d33e0db 100644
--- a/tools/ijar/classfile.cc
+++ b/tools/ijar/classfile.cc
@@ -123,7 +123,7 @@
 // See sec.4.4 of JVM spec.
 struct Constant {
 
-  Constant(u1 tag) :
+  explicit Constant(u1 tag) :
       slot_(0),
       tag_(tag) {}
 
@@ -180,7 +180,7 @@
 // See sec.4.4.1 of JVM spec.
 struct Constant_Class : Constant
 {
-  Constant_Class(u2 name_index) :
+  explicit Constant_Class(u2 name_index) :
       Constant(CONSTANT_Class),
       name_index_(name_index) {}
 
@@ -231,7 +231,7 @@
 // See sec.4.4.3 of JVM spec.
 struct Constant_String : Constant
 {
-  Constant_String(u2 string_index) :
+  explicit Constant_String(u2 string_index) :
       Constant(CONSTANT_String),
       string_index_(string_index) {}
 
@@ -360,7 +360,7 @@
 // See sec.4.4.9 of JVM spec.
 struct Constant_MethodType : Constant
 {
-  Constant_MethodType(u2 descriptor_index) :
+  explicit Constant_MethodType(u2 descriptor_index) :
       Constant(CONSTANT_MethodType),
       descriptor_index_(descriptor_index) {}
 
diff --git a/tools/ijar/zip.cc b/tools/ijar/zip.cc
index ca5f396..3aa06db 100644
--- a/tools/ijar/zip.cc
+++ b/tools/ijar/zip.cc
@@ -846,6 +846,7 @@
   memcpy(entry->file_name, filename, file_name_length_);
   entry->extra_field_length = 0;
   entry->extra_field = (const u1 *)"";
+  entry->crc32 = 0;
 
   // Output the ZIP local_file_header:
   put_u4le(q, LOCAL_FILE_HEADER_SIGNATURE);
diff --git a/tools/libhost/Android.bp b/tools/libhost/Android.bp
new file mode 100644
index 0000000..e5a5ecf
--- /dev/null
+++ b/tools/libhost/Android.bp
@@ -0,0 +1,20 @@
+cc_library_host_static {
+
+    srcs: ["CopyFile.c"],
+
+    cflags: [
+        "-Werror",
+        "-Wall",
+    ],
+
+    name: "libhost",
+    target: {
+        windows: {
+            enabled: true,
+        },
+    },
+    local_include_dirs: ["include"],
+    export_include_dirs: ["include"],
+    stl: "none",
+
+}
diff --git a/libs/host/CopyFile.c b/tools/libhost/CopyFile.c
similarity index 98%
rename from libs/host/CopyFile.c
rename to tools/libhost/CopyFile.c
index 5be012c..bd65f1e 100644
--- a/libs/host/CopyFile.c
+++ b/tools/libhost/CopyFile.c
@@ -323,8 +323,11 @@
                 (void) close(dstFd);
             }
 
-            if (copyResult != 0)
+            if (copyResult != 0) {
+                free(srcRsrcName);
+                free(dstRsrcName);
                 return -1;
+            }
         }
 
         free(srcRsrcName);
diff --git a/libs/host/include/host/CopyFile.h b/tools/libhost/include/host/CopyFile.h
similarity index 100%
rename from libs/host/include/host/CopyFile.h
rename to tools/libhost/include/host/CopyFile.h
diff --git a/tools/makeparallel/Makefile b/tools/makeparallel/Makefile
index 4e12b10..82a4abf 100644
--- a/tools/makeparallel/Makefile
+++ b/tools/makeparallel/Makefile
@@ -65,8 +65,9 @@
 makeparallel_test: $(MAKEPARALLEL)
 	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) -j1234
 	@EXPECTED="-j123"  $(MAKEPARALLEL_TEST) -j123
-	@EXPECTED="-j1"    $(MAKEPARALLEL_TEST) -j1
-	@EXPECTED="-j1"    $(MAKEPARALLEL_TEST)
+	@EXPECTED=""       $(MAKEPARALLEL_TEST) -j1
+	@EXPECTED="-j$$(($$(nproc) + 2))"   $(MAKEPARALLEL_TEST) -j
+	@EXPECTED=""       $(MAKEPARALLEL_TEST)
 
 	@EXPECTED="-j1234" $(MAKEPARALLEL_NINJA_TEST) -j1234
 	@EXPECTED="-j123"  $(MAKEPARALLEL_NINJA_TEST) -j123
@@ -87,8 +88,6 @@
 	@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -j1234 -k
 	@EXPECTED="-j1234 -k0" $(MAKEPARALLEL_NINJA_TEST) -kt -j1234
 
-	@EXPECTED="-j1"    $(MAKEPARALLEL_TEST) A=-j1234
-	@EXPECTED="-j1"    $(MAKEPARALLEL_TEST) A\ -j1234=-j1234
-	@EXPECTED="-j1234" $(MAKEPARALLEL_TEST) A\ -j1234=-j1234 -j1234
+	@EXPECTED=""       $(MAKEPARALLEL_TEST) A=-j1234
 
 	@EXPECTED="-j1234 args" ARGS="args" $(MAKEPARALLEL_TEST) -j1234
diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp
index 3c39846..66babdf 100644
--- a/tools/makeparallel/makeparallel.cpp
+++ b/tools/makeparallel/makeparallel.cpp
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/resource.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -316,33 +317,83 @@
     }
   }
 
-  std::string jarg = "-j" + std::to_string(tokens + 1);
+  std::string jarg;
+  if (parallel) {
+    if (tokens == 0) {
+      if (ninja) {
+        // ninja is parallel by default
+        jarg = "";
+      } else {
+        // make -j with no argument, guess a reasonable parallelism like ninja does
+        jarg = "-j" + std::to_string(sysconf(_SC_NPROCESSORS_ONLN) + 2);
+      }
+    } else {
+      jarg = "-j" + std::to_string(tokens + 1);
+    }
+  }
+
 
   if (ninja) {
     if (!parallel) {
       // ninja is parallel by default, pass -j1 to disable parallelism if make wasn't parallel
       args.push_back(strdup("-j1"));
-    } else if (tokens > 0) {
-      args.push_back(strdup(jarg.c_str()));
+    } else {
+      if (jarg != "") {
+        args.push_back(strdup(jarg.c_str()));
+      }
     }
     if (keep_going) {
       args.push_back(strdup("-k0"));
     }
   } else {
-    args.push_back(strdup(jarg.c_str()));
+    if (jarg != "") {
+      args.push_back(strdup(jarg.c_str()));
+    }
   }
 
   args.insert(args.end(), &argv[2], &argv[argc]);
 
   args.push_back(nullptr);
 
-  pid_t pid = fork();
+  static pid_t pid;
+
+  // Set up signal handlers to forward SIGTERM to child.
+  // Assume that all other signals are sent to the entire process group,
+  // and that we'll wait for our child to exit instead of handling them.
+  struct sigaction action = {};
+  action.sa_flags = SA_RESTART;
+  action.sa_handler = [](int signal) {
+    if (signal == SIGTERM && 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) {
     // child
     unsetenv("MAKEFLAGS");
     unsetenv("MAKELEVEL");
+
+    // make 3.81 sets the stack ulimit to unlimited, which may cause problems
+    // for child processes
+    struct rlimit rlim{};
+    if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur == RLIM_INFINITY) {
+      rlim.rlim_cur = 8*1024*1024;
+      setrlimit(RLIMIT_STACK, &rlim);
+    }
+
     int ret = execvp(path, args.data());
     if (ret < 0) {
       error(errno, errno, "exec %s failed", path);
@@ -351,9 +402,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/post_process_props.py b/tools/post_process_props.py
index 9dcaadf..9355e4b 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -19,10 +19,9 @@
 # Usage: post_process_props.py file.prop [blacklist_key, ...]
 # Blacklisted keys are removed from the property file, if present
 
-# See PROP_NAME_MAX and PROP_VALUE_MAX system_properties.h.
-# The constants in system_properties.h includes the termination NUL,
-# so we decrease the values by 1 here.
-PROP_NAME_MAX = 31
+# See PROP_VALUE_MAX in system_properties.h.
+# The constant in system_properties.h includes the terminating NUL,
+# so we decrease the value by 1 here.
 PROP_VALUE_MAX = 91
 
 # Put the modifications that you need to make into the /system/build.prop into this
@@ -30,7 +29,13 @@
 def mangle_build_prop(prop):
   pass
 
-# Put the modifications that you need to make into the /default.prop into this
+# Put the modifications that you need to make into /vendor/default.prop and
+# /odm/default.prop into this function. The prop object has get(name) and
+# put(name,value) methods.
+def mangle_default_prop_override(prop):
+  pass
+
+# Put the modifications that you need to make into the /system/etc/prop.default into this
 # function. The prop object has get(name) and put(name,value) methods.
 def mangle_default_prop(prop):
   # If ro.debuggable is 1, then enable adb on USB by default
@@ -59,11 +64,6 @@
   buildprops = prop.to_dict()
   for key, value in buildprops.iteritems():
     # Check build properties' length.
-    if len(key) > PROP_NAME_MAX:
-      check_pass = False
-      sys.stderr.write("error: %s cannot exceed %d bytes: " %
-                       (key, PROP_NAME_MAX))
-      sys.stderr.write("%s (%d)\n" % (key, len(key)))
     if len(value) > PROP_VALUE_MAX:
       check_pass = False
       sys.stderr.write("error: %s cannot exceed %d bytes: " %
@@ -119,7 +119,11 @@
 
   if filename.endswith("/build.prop"):
     mangle_build_prop(properties)
-  elif filename.endswith("/default.prop"):
+  elif (filename.endswith("/vendor/default.prop") or
+        filename.endswith("/odm/default.prop")):
+    mangle_default_prop_override(properties)
+  elif (filename.endswith("/default.prop") or # legacy
+        filename.endswith("/prop.default")):
     mangle_default_prop(properties)
   else:
     sys.stderr.write("bad command line: " + str(argv) + "\n")
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 5a0a411..7c3679c 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -41,26 +41,28 @@
   --is_signing
       Skip building & adding the images for "userdata" and "cache" if we
       are signing the target files.
-
-  --verity_signer_path
-      Specify the signer path to build verity metadata.
 """
 
+from __future__ import print_function
+
 import sys
 
 if sys.hexversion < 0x02070000:
-  print >> sys.stderr, "Python 2.7 or newer is required."
+  print("Python 2.7 or newer is required.", file=sys.stderr)
   sys.exit(1)
 
 import datetime
 import errno
 import os
+import shlex
 import shutil
+import subprocess
 import tempfile
 import zipfile
 
 import build_image
 import common
+import rangelib
 import sparse_img
 
 OPTIONS = common.OPTIONS
@@ -70,29 +72,55 @@
 OPTIONS.replace_verity_public_key = False
 OPTIONS.replace_verity_private_key = False
 OPTIONS.is_signing = False
-OPTIONS.verity_signer_path = None
+
+
+class OutputFile(object):
+  def __init__(self, output_zip, input_dir, prefix, name):
+    self._output_zip = output_zip
+    self.input_name = os.path.join(input_dir, prefix, name)
+
+    if self._output_zip:
+      self._zip_name = os.path.join(prefix, name)
+
+      root, suffix = os.path.splitext(name)
+      self.name = common.MakeTempFile(prefix=root + '-', suffix=suffix)
+    else:
+      self.name = self.input_name
+
+  def Write(self):
+    if self._output_zip:
+      common.ZipWrite(self._output_zip, self.name, self._zip_name)
+
 
 def GetCareMap(which, imgname):
   """Generate care_map of system (or vendor) partition"""
 
   assert which in ("system", "vendor")
-  _, blk_device = common.GetTypeAndDevice("/" + which, OPTIONS.info_dict)
 
   simg = sparse_img.SparseImage(imgname)
   care_map_list = []
-  care_map_list.append(blk_device)
-  care_map_list.append(simg.care_map.to_string_raw())
+  care_map_list.append(which)
+
+  care_map_ranges = simg.care_map
+  key = which + "_adjusted_partition_size"
+  adjusted_blocks = OPTIONS.info_dict.get(key)
+  if adjusted_blocks:
+    assert adjusted_blocks > 0, "blocks should be positive for " + which
+    care_map_ranges = care_map_ranges.intersect(rangelib.RangeSet(
+        "0-%d" % (adjusted_blocks,)))
+
+  care_map_list.append(care_map_ranges.to_string_raw())
   return care_map_list
 
 
 def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None):
   """Turn the contents of SYSTEM into a system image and store it in
-  output_zip."""
+  output_zip. Returns the name of the system image file."""
 
-  prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system.img")
-  if os.path.exists(prebuilt_path):
-    print "system.img already exists in %s, no need to rebuild..." % (prefix,)
-    return prebuilt_path
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "system.img")
+  if os.path.exists(img.input_name):
+    print("system.img already exists in %s, no need to rebuild..." % (prefix,))
+    return img.input_name
 
   def output_sink(fn, data):
     ofile = open(os.path.join(OPTIONS.input_tmp, "SYSTEM", fn), "w")
@@ -100,76 +128,56 @@
     ofile.close()
 
   if OPTIONS.rebuild_recovery:
-    print "Building new recovery patch"
+    print("Building new recovery patch")
     common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img,
                              boot_img, info_dict=OPTIONS.info_dict)
 
-  block_list = common.MakeTempFile(prefix="system-blocklist-", suffix=".map")
-  imgname = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict,
-                        block_list=block_list)
-  common.ZipWrite(output_zip, imgname, prefix + "system.img")
-  common.ZipWrite(output_zip, block_list, prefix + "system.map")
-  return imgname
+  block_list = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "system.map")
+  CreateImage(OPTIONS.input_tmp, OPTIONS.info_dict, "system", img,
+              block_list=block_list)
 
-
-def BuildSystem(input_dir, info_dict, block_list=None):
-  """Build the (sparse) system image and return the name of a temp
-  file containing it."""
-  return CreateImage(input_dir, info_dict, "system", block_list=block_list)
+  return img.name
 
 
 def AddSystemOther(output_zip, prefix="IMAGES/"):
   """Turn the contents of SYSTEM_OTHER into a system_other image
   and store it in output_zip."""
 
-  prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "system_other.img")
-  if os.path.exists(prebuilt_path):
-    print "system_other.img already exists in %s, no need to rebuild..." % (prefix,)
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "system_other.img")
+  if os.path.exists(img.input_name):
+    print("system_other.img already exists in %s, no need to rebuild..." % (
+        prefix,))
     return
 
-  imgname = BuildSystemOther(OPTIONS.input_tmp, OPTIONS.info_dict)
-  common.ZipWrite(output_zip, imgname, prefix + "system_other.img")
-
-def BuildSystemOther(input_dir, info_dict):
-  """Build the (sparse) system_other image and return the name of a temp
-  file containing it."""
-  return CreateImage(input_dir, info_dict, "system_other", block_list=None)
+  CreateImage(OPTIONS.input_tmp, OPTIONS.info_dict, "system_other", img)
 
 
 def AddVendor(output_zip, prefix="IMAGES/"):
   """Turn the contents of VENDOR into a vendor image and store in it
   output_zip."""
 
-  prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img")
-  if os.path.exists(prebuilt_path):
-    print "vendor.img already exists in %s, no need to rebuild..." % (prefix,)
-    return prebuilt_path
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "vendor.img")
+  if os.path.exists(img.input_name):
+    print("vendor.img already exists in %s, no need to rebuild..." % (prefix,))
+    return img.input_name
 
-  block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map")
-  imgname = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict,
-                        block_list=block_list)
-  common.ZipWrite(output_zip, imgname, prefix + "vendor.img")
-  common.ZipWrite(output_zip, block_list, prefix + "vendor.map")
-  return imgname
+  block_list = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "vendor.map")
+  CreateImage(OPTIONS.input_tmp, OPTIONS.info_dict, "vendor", img,
+              block_list=block_list)
+  return img.name
 
 
-def BuildVendor(input_dir, info_dict, block_list=None):
-  """Build the (sparse) vendor image and return the name of a temp
-  file containing it."""
-  return CreateImage(input_dir, info_dict, "vendor", block_list=block_list)
-
-
-def CreateImage(input_dir, info_dict, what, block_list=None):
-  print "creating " + what + ".img..."
-
-  img = common.MakeTempFile(prefix=what + "-", suffix=".img")
+def CreateImage(input_dir, info_dict, what, output_file, block_list=None):
+  print("creating " + what + ".img...")
 
   # The name of the directory it is making an image out of matters to
   # mkyaffs2image.  It wants "system" but we have a directory named
   # "SYSTEM", so create a symlink.
+  temp_dir = tempfile.mkdtemp()
+  OPTIONS.tempfiles.append(temp_dir)
   try:
     os.symlink(os.path.join(input_dir, what.upper()),
-               os.path.join(input_dir, what))
+               os.path.join(temp_dir, what))
   except OSError as e:
     # bogus error on my mac version?
     #   File "./build/tools/releasetools/img_from_target_files"
@@ -204,13 +212,23 @@
   if fs_config:
     image_props["fs_config"] = fs_config
   if block_list:
-    image_props["block_list"] = block_list
+    image_props["block_list"] = block_list.name
 
-  succ = build_image.BuildImage(os.path.join(input_dir, what),
-                                image_props, img)
+  succ = build_image.BuildImage(os.path.join(temp_dir, what),
+                                image_props, output_file.name)
   assert succ, "build " + what + ".img image failed"
 
-  return img
+  output_file.Write()
+  if block_list:
+    block_list.Write()
+
+  is_verity_partition = "verity_block_device" in image_props
+  verity_supported = image_props.get("verity") == "true"
+  if is_verity_partition and verity_supported:
+    adjusted_blocks_value = image_props.get("partition_size")
+    if adjusted_blocks_value:
+      adjusted_blocks_key = what + "_adjusted_partition_size"
+      info_dict[adjusted_blocks_key] = int(adjusted_blocks_value)/4096 - 1
 
 
 def AddUserdata(output_zip, prefix="IMAGES/"):
@@ -222,19 +240,18 @@
   in OPTIONS.info_dict.
   """
 
-  prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "userdata.img")
-  if os.path.exists(prebuilt_path):
-    print "userdata.img already exists in %s, no need to rebuild..." % (prefix,)
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "userdata.img")
+  if os.path.exists(img.input_name):
+    print("userdata.img already exists in %s, no need to rebuild..." % (
+        prefix,))
     return
 
+  # Skip userdata.img if no size.
   image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "data")
-  # We only allow yaffs to have a 0/missing partition_size.
-  # Extfs, f2fs must have a size. Skip userdata.img if no size.
-  if (not image_props.get("fs_type", "").startswith("yaffs") and
-      not image_props.get("partition_size")):
+  if not image_props.get("partition_size"):
     return
 
-  print "creating userdata.img..."
+  print("creating userdata.img...")
 
   # Use a fixed timestamp (01/01/2009) when packaging the image.
   # Bug: 24377993
@@ -247,6 +264,7 @@
   # empty dir named "data", or a symlink to the DATA dir,
   # and build the image from that.
   temp_dir = tempfile.mkdtemp()
+  OPTIONS.tempfiles.append(temp_dir)
   user_dir = os.path.join(temp_dir, "data")
   empty = (OPTIONS.info_dict.get("userdata_img_with_data") != "true")
   if empty:
@@ -257,8 +275,6 @@
     os.symlink(os.path.join(OPTIONS.input_tmp, "DATA"),
                user_dir)
 
-  img = tempfile.NamedTemporaryFile()
-
   fstab = OPTIONS.info_dict["fstab"]
   if fstab:
     image_props["fs_type"] = fstab["/data"].fs_type
@@ -266,17 +282,67 @@
   assert succ, "build userdata.img image failed"
 
   common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict)
-  common.ZipWrite(output_zip, img.name, prefix + "userdata.img")
-  img.close()
-  shutil.rmtree(temp_dir)
+  img.Write()
+
+
+def AddVBMeta(output_zip, boot_img_path, system_img_path, vendor_img_path,
+              prefix="IMAGES/"):
+  """Create a VBMeta image and store it in output_zip."""
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "vbmeta.img")
+  avbtool = os.getenv('AVBTOOL') or "avbtool"
+  cmd = [avbtool, "make_vbmeta_image",
+         "--output", img.name,
+         "--include_descriptors_from_image", boot_img_path,
+         "--include_descriptors_from_image", system_img_path]
+  if vendor_img_path is not None:
+    cmd.extend(["--include_descriptors_from_image", vendor_img_path])
+  if OPTIONS.info_dict.get("system_root_image", None) == "true":
+    cmd.extend(["--setup_rootfs_from_kernel", 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"
+  img.Write()
+
+
+def AddPartitionTable(output_zip, prefix="IMAGES/"):
+  """Create a partition table image and store it in output_zip."""
+
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "partition-table.img")
+  bpt = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "partition-table.bpt")
+
+  # use BPTTOOL from environ, or "bpttool" if empty or not set.
+  bpttool = os.getenv("BPTTOOL") or "bpttool"
+  cmd = [bpttool, "make_table", "--output_json", bpt.name,
+         "--output_gpt", img.name]
+  input_files_str = OPTIONS.info_dict["board_bpt_input_files"]
+  input_files = input_files_str.split(" ")
+  for i in input_files:
+    cmd.extend(["--input", i])
+  disk_size = OPTIONS.info_dict.get("board_bpt_disk_size")
+  if disk_size:
+    cmd.extend(["--disk_size", disk_size])
+  args = OPTIONS.info_dict.get("board_bpt_make_table_args")
+  if args:
+    cmd.extend(shlex.split(args))
+
+  p = common.Run(cmd, stdout=subprocess.PIPE)
+  p.communicate()
+  assert p.returncode == 0, "bpttool make_table failed"
+
+  img.Write()
+  bpt.Write()
 
 
 def AddCache(output_zip, prefix="IMAGES/"):
   """Create an empty cache image and store it in output_zip."""
 
-  prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "cache.img")
-  if os.path.exists(prebuilt_path):
-    print "cache.img already exists in %s, no need to rebuild..." % (prefix,)
+  img = OutputFile(output_zip, OPTIONS.input_tmp, prefix, "cache.img")
+  if os.path.exists(img.input_name):
+    print("cache.img already exists in %s, no need to rebuild..." % (prefix,))
     return
 
   image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict, "cache")
@@ -284,7 +350,7 @@
   if "fs_type" not in image_props:
     return
 
-  print "creating cache.img..."
+  print("creating cache.img...")
 
   # Use a fixed timestamp (01/01/2009) when packaging the image.
   # Bug: 24377993
@@ -296,9 +362,9 @@
   # mkyaffs2image.  So we create a temp dir, and within it we create an
   # empty dir named "cache", and build the image from that.
   temp_dir = tempfile.mkdtemp()
+  OPTIONS.tempfiles.append(temp_dir)
   user_dir = os.path.join(temp_dir, "cache")
   os.mkdir(user_dir)
-  img = tempfile.NamedTemporaryFile()
 
   fstab = OPTIONS.info_dict["fstab"]
   if fstab:
@@ -307,60 +373,69 @@
   assert succ, "build cache.img image failed"
 
   common.CheckSize(img.name, "cache.img", OPTIONS.info_dict)
-  common.ZipWrite(output_zip, img.name, prefix + "cache.img")
-  img.close()
-  os.rmdir(user_dir)
-  os.rmdir(temp_dir)
+  img.Write()
 
 
 def AddImagesToTargetFiles(filename):
-  OPTIONS.input_tmp, input_zip = common.UnzipTemp(filename)
+  if os.path.isdir(filename):
+    OPTIONS.input_tmp = os.path.abspath(filename)
+    input_zip = None
+  else:
+    OPTIONS.input_tmp, input_zip = common.UnzipTemp(filename)
 
   if not OPTIONS.add_missing:
-    for n in input_zip.namelist():
-      if n.startswith("IMAGES/"):
-        print "target_files appears to already contain images."
-        sys.exit(1)
+    if os.path.isdir(os.path.join(OPTIONS.input_tmp, "IMAGES")):
+      print("target_files appears to already contain images.")
+      sys.exit(1)
 
-  try:
-    input_zip.getinfo("VENDOR/")
-    has_vendor = True
-  except KeyError:
-    has_vendor = False
+  has_vendor = os.path.isdir(os.path.join(OPTIONS.input_tmp, "VENDOR"))
+  has_system_other = os.path.isdir(os.path.join(OPTIONS.input_tmp,
+                                                "SYSTEM_OTHER"))
 
-  has_system_other = "SYSTEM_OTHER/" in input_zip.namelist()
+  if input_zip:
+    OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp)
 
-  OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.input_tmp)
-
-  common.ZipClose(input_zip)
-  output_zip = zipfile.ZipFile(filename, "a",
-                               compression=zipfile.ZIP_DEFLATED)
+    common.ZipClose(input_zip)
+    output_zip = zipfile.ZipFile(filename, "a",
+                                 compression=zipfile.ZIP_DEFLATED,
+                                 allowZip64=True)
+  else:
+    OPTIONS.info_dict = common.LoadInfoDict(filename, filename)
+    output_zip = None
+    images_dir = os.path.join(OPTIONS.input_tmp, "IMAGES")
+    if not os.path.isdir(images_dir):
+      os.makedirs(images_dir)
+    images_dir = None
 
   has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
 
   def banner(s):
-    print "\n\n++++ " + s + " ++++\n\n"
+    print("\n\n++++ " + s + " ++++\n\n")
 
-  banner("boot")
   prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "boot.img")
   boot_image = None
   if os.path.exists(prebuilt_path):
-    print "boot.img already exists in IMAGES/, no need to rebuild..."
+    banner("boot")
+    print("boot.img already exists in IMAGES/, no need to rebuild...")
     if OPTIONS.rebuild_recovery:
       boot_image = common.GetBootableImage(
           "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
   else:
+    banner("boot")
     boot_image = common.GetBootableImage(
         "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
     if boot_image:
-      boot_image.AddToZip(output_zip)
+      if output_zip:
+        boot_image.AddToZip(output_zip)
+      else:
+        boot_image.WriteToDir(OPTIONS.input_tmp)
 
   recovery_image = None
   if has_recovery:
     banner("recovery")
     prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", "recovery.img")
     if os.path.exists(prebuilt_path):
-      print "recovery.img already exists in IMAGES/, no need to rebuild..."
+      print("recovery.img already exists in IMAGES/, no need to rebuild...")
       if OPTIONS.rebuild_recovery:
         recovery_image = common.GetBootableImage(
             "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp,
@@ -369,7 +444,10 @@
       recovery_image = common.GetBootableImage(
           "IMAGES/recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
       if recovery_image:
-        recovery_image.AddToZip(output_zip)
+        if output_zip:
+          recovery_image.AddToZip(output_zip)
+        else:
+          recovery_image.WriteToDir(OPTIONS.input_tmp)
 
       banner("recovery (two-step image)")
       # The special recovery.img for two-step package use.
@@ -377,15 +455,18 @@
           "IMAGES/recovery-two-step.img", "recovery-two-step.img",
           OPTIONS.input_tmp, "RECOVERY", two_step_image=True)
       if recovery_two_step_image:
-        recovery_two_step_image.AddToZip(output_zip)
+        if output_zip:
+          recovery_two_step_image.AddToZip(output_zip)
+        else:
+          recovery_two_step_image.WriteToDir(OPTIONS.input_tmp)
 
   banner("system")
-  system_imgname = AddSystem(output_zip, recovery_img=recovery_image,
-                             boot_img=boot_image)
-  vendor_imgname = None
+  system_img_path = AddSystem(
+    output_zip, recovery_img=recovery_image, boot_img=boot_image)
+  vendor_img_path = None
   if has_vendor:
     banner("vendor")
-    vendor_imgname = AddVendor(output_zip)
+    vendor_img_path = AddVendor(output_zip)
   if has_system_other:
     banner("system_other")
     AddSystemOther(output_zip)
@@ -394,9 +475,18 @@
     AddUserdata(output_zip)
     banner("cache")
     AddCache(output_zip)
+  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, vendor_img_path)
 
-  # For devices using A/B update, copy over images from RADIO/ to IMAGES/ and
-  # make sure we have all the needed images ready under IMAGES/.
+  # 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
+  # images ready under IMAGES/. All images should have '.img' as extension.
+  banner("radio")
   ab_partitions = os.path.join(OPTIONS.input_tmp, "META", "ab_partitions.txt")
   if os.path.exists(ab_partitions):
     with open(ab_partitions, 'r') as f:
@@ -407,28 +497,56 @@
     for line in lines:
       if line.strip() == "system" and OPTIONS.info_dict.get(
           "system_verity_block_device", None) is not None:
-        assert os.path.exists(system_imgname)
-        care_map_list += GetCareMap("system", system_imgname)
+        assert os.path.exists(system_img_path)
+        care_map_list += GetCareMap("system", system_img_path)
       if line.strip() == "vendor" and OPTIONS.info_dict.get(
           "vendor_verity_block_device", None) is not None:
-        assert os.path.exists(vendor_imgname)
-        care_map_list += GetCareMap("vendor", vendor_imgname)
+        assert os.path.exists(vendor_img_path)
+        care_map_list += GetCareMap("vendor", vendor_img_path)
 
       img_name = line.strip() + ".img"
-      img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name)
-      if os.path.exists(img_radio_path):
-        common.ZipWrite(output_zip, img_radio_path,
-                        os.path.join("IMAGES", img_name))
+      prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name)
+      if os.path.exists(prebuilt_path):
+        print("%s already exists, no need to overwrite..." % (img_name,))
+        continue
 
-      # Zip spec says: All slashes MUST be forward slashes.
-      img_path = 'IMAGES/' + img_name
-      assert img_path in output_zip.namelist(), "cannot find " + img_name
+      img_radio_path = os.path.join(OPTIONS.input_tmp, "RADIO", img_name)
+      img_vendor_dir = os.path.join(
+        OPTIONS.input_tmp, "VENDOR_IMAGES")
+      if os.path.exists(img_radio_path):
+        if output_zip:
+          common.ZipWrite(output_zip, img_radio_path,
+                          os.path.join("IMAGES", img_name))
+        else:
+          shutil.copy(img_radio_path, prebuilt_path)
+      else:
+        for root, _, files in os.walk(img_vendor_dir):
+          if img_name in files:
+            if output_zip:
+              common.ZipWrite(output_zip, os.path.join(root, img_name),
+                os.path.join("IMAGES", img_name))
+            else:
+              shutil.copy(os.path.join(root, img_name), prebuilt_path)
+            break
+
+      if output_zip:
+        # Zip spec says: All slashes MUST be forward slashes.
+        img_path = 'IMAGES/' + img_name
+        assert img_path in output_zip.namelist(), "cannot find " + img_name
+      else:
+        img_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name)
+        assert os.path.exists(img_path), "cannot find " + img_name
 
     if care_map_list:
       file_path = "META/care_map.txt"
-      common.ZipWriteStr(output_zip, file_path, '\n'.join(care_map_list))
+      if output_zip:
+        common.ZipWriteStr(output_zip, file_path, '\n'.join(care_map_list))
+      else:
+        with open(os.path.join(OPTIONS.input_tmp, file_path), 'w') as fp:
+          fp.write('\n'.join(care_map_list))
 
-  common.ZipClose(output_zip)
+  if output_zip:
+    common.ZipClose(output_zip)
 
 def main(argv):
   def option_handler(o, a):
@@ -442,8 +560,6 @@
       OPTIONS.replace_verity_public_key = (True, a)
     elif o == "--is_signing":
       OPTIONS.is_signing = True
-    elif o == "--verity_signer_path":
-      OPTIONS.verity_signer_path = a
     else:
       return False
     return True
@@ -453,8 +569,7 @@
       extra_long_opts=["add_missing", "rebuild_recovery",
                        "replace_verity_public_key=",
                        "replace_verity_private_key=",
-                       "is_signing",
-                       "verity_signer_path="],
+                       "is_signing"],
       extra_option_handler=option_handler)
 
 
@@ -463,16 +578,14 @@
     sys.exit(1)
 
   AddImagesToTargetFiles(args[0])
-  print "done."
+  print("done.")
 
 if __name__ == '__main__':
   try:
     common.CloseInheritedPipes()
     main(sys.argv[1:])
   except common.ExternalError as e:
-    print
-    print "   ERROR: %s" % (e,)
-    print
+    print("\n   ERROR: %s\n" % (e,))
     sys.exit(1)
   finally:
     common.Cleanup()
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index cc06a42..e385866 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -14,8 +14,6 @@
 
 from __future__ import print_function
 
-from collections import deque, OrderedDict
-from hashlib import sha1
 import array
 import common
 import functools
@@ -23,81 +21,79 @@
 import itertools
 import multiprocessing
 import os
+import os.path
 import re
 import subprocess
+import sys
 import threading
-import time
-import tempfile
 
+from collections import deque, OrderedDict
+from hashlib import sha1
 from rangelib import RangeSet
 
 
 __all__ = ["EmptyImage", "DataImage", "BlockImageDiff"]
 
 
-def compute_patch(src, tgt, imgdiff=False):
-  srcfd, srcfile = tempfile.mkstemp(prefix="src-")
-  tgtfd, tgtfile = tempfile.mkstemp(prefix="tgt-")
-  patchfd, patchfile = tempfile.mkstemp(prefix="patch-")
-  os.close(patchfd)
+def compute_patch(srcfile, tgtfile, imgdiff=False):
+  patchfile = common.MakeTempFile(prefix='patch-')
 
-  try:
-    with os.fdopen(srcfd, "wb") as f_src:
-      for p in src:
-        f_src.write(p)
+  cmd = ['imgdiff', '-z'] if imgdiff else ['bsdiff']
+  cmd.extend([srcfile, tgtfile, patchfile])
 
-    with os.fdopen(tgtfd, "wb") as f_tgt:
-      for p in tgt:
-        f_tgt.write(p)
-    try:
-      os.unlink(patchfile)
-    except OSError:
-      pass
-    if imgdiff:
-      p = subprocess.call(["imgdiff", "-z", srcfile, tgtfile, patchfile],
-                          stdout=open("/dev/null", "a"),
-                          stderr=subprocess.STDOUT)
-    else:
-      p = subprocess.call(["bsdiff", srcfile, tgtfile, patchfile])
+  # Not using common.Run(), which would otherwise dump all the bsdiff/imgdiff
+  # commands when OPTIONS.verbose is True - not useful for the case here, since
+  # they contain temp filenames only.
+  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+  output, _ = p.communicate()
 
-    if p:
-      raise ValueError("diff failed: " + str(p))
+  if p.returncode != 0:
+    raise ValueError(output)
 
-    with open(patchfile, "rb") as f:
-      return f.read()
-  finally:
-    try:
-      os.unlink(srcfile)
-      os.unlink(tgtfile)
-      os.unlink(patchfile)
-    except OSError:
-      pass
+  with open(patchfile, 'rb') as f:
+    return f.read()
 
 
 class Image(object):
+  def RangeSha1(self, ranges):
+    raise NotImplementedError
+
   def ReadRangeSet(self, ranges):
     raise NotImplementedError
 
   def TotalSha1(self, include_clobbered_blocks=False):
     raise NotImplementedError
 
+  def WriteRangeDataToFd(self, ranges, fd):
+    raise NotImplementedError
+
 
 class EmptyImage(Image):
   """A zero-length image."""
-  blocksize = 4096
-  care_map = RangeSet()
-  clobbered_blocks = RangeSet()
-  extended = RangeSet()
-  total_blocks = 0
-  file_map = {}
+
+  def __init__(self):
+    self.blocksize = 4096
+    self.care_map = RangeSet()
+    self.clobbered_blocks = RangeSet()
+    self.extended = RangeSet()
+    self.total_blocks = 0
+    self.file_map = {}
+
+  def RangeSha1(self, ranges):
+    return sha1().hexdigest()
+
   def ReadRangeSet(self, ranges):
     return ()
+
   def TotalSha1(self, include_clobbered_blocks=False):
     # EmptyImage always carries empty clobbered_blocks, so
     # include_clobbered_blocks can be ignored.
     assert self.clobbered_blocks.size() == 0
     return sha1().hexdigest()
 
+  def WriteRangeDataToFd(self, ranges, fd):
+    raise ValueError("Can't write data from EmptyImage to file")
+
 
 class DataImage(Image):
   """An image wrapped around a single string of data."""
@@ -160,23 +156,39 @@
     if clobbered_blocks:
       self.file_map["__COPY"] = RangeSet(data=clobbered_blocks)
 
+  def _GetRangeData(self, ranges):
+    for s, e in ranges:
+      yield self.data[s*self.blocksize:e*self.blocksize]
+
+  def RangeSha1(self, ranges):
+    h = sha1()
+    for data in self._GetRangeData(ranges):
+      h.update(data)
+    return h.hexdigest()
+
   def ReadRangeSet(self, ranges):
-    return [self.data[s*self.blocksize:e*self.blocksize] for (s, e) in ranges]
+    return [self._GetRangeData(ranges)]
 
   def TotalSha1(self, include_clobbered_blocks=False):
     if not include_clobbered_blocks:
-      ranges = self.care_map.subtract(self.clobbered_blocks)
-      return sha1(self.ReadRangeSet(ranges)).hexdigest()
+      return self.RangeSha1(self.care_map.subtract(self.clobbered_blocks))
     else:
       return sha1(self.data).hexdigest()
 
+  def WriteRangeDataToFd(self, ranges, fd):
+    for data in self._GetRangeData(ranges):
+      fd.write(data)
+
 
 class Transfer(object):
-  def __init__(self, tgt_name, src_name, tgt_ranges, src_ranges, style, by_id):
+  def __init__(self, tgt_name, src_name, tgt_ranges, src_ranges, tgt_sha1,
+               src_sha1, style, by_id):
     self.tgt_name = tgt_name
     self.src_name = src_name
     self.tgt_ranges = tgt_ranges
     self.src_ranges = src_ranges
+    self.tgt_sha1 = tgt_sha1
+    self.src_sha1 = src_sha1
     self.style = style
     self.intact = (getattr(tgt_ranges, "monotonic", False) and
                    getattr(src_ranges, "monotonic", False))
@@ -251,6 +263,9 @@
 #      Implementations are free to break up the data into list/tuple
 #      elements in any way that is convenient.
 #
+#    RangeSha1(): a function that returns (as a hex string) the SHA-1
+#      hash of all the data in the specified range.
+#
 #    TotalSha1(): a function that returns (as a hex string) the SHA-1
 #      hash of all the data in the image (ie, all the blocks in the
 #      care_map minus clobbered_blocks, or including the clobbered
@@ -277,7 +292,7 @@
     self.touched_src_sha1 = None
     self.disable_imgdiff = disable_imgdiff
 
-    assert version in (1, 2, 3, 4)
+    assert version in (3, 4)
 
     self.tgt = tgt
     if src is None:
@@ -316,14 +331,11 @@
     self.FindVertexSequence()
     # Fix up the ordering dependencies that the sequence didn't
     # satisfy.
-    if self.version == 1:
-      self.RemoveBackwardEdges()
-    else:
-      self.ReverseBackwardEdges()
-      self.ImproveVertexSequence()
+    self.ReverseBackwardEdges()
+    self.ImproveVertexSequence()
 
     # Ensure the runtime stash size is under the limit.
-    if self.version >= 2 and common.OPTIONS.cache_size is not None:
+    if common.OPTIONS.cache_size is not None:
       self.ReviseStashSize()
 
     # Double-check our work.
@@ -332,15 +344,6 @@
     self.ComputePatches(prefix)
     self.WriteTransfers(prefix)
 
-  def HashBlocks(self, source, ranges): # pylint: disable=no-self-use
-    data = source.ReadRangeSet(ranges)
-    ctx = sha1()
-
-    for p in data:
-      ctx.update(p)
-
-    return ctx.hexdigest()
-
   def WriteTransfers(self, prefix):
     def WriteSplitTransfers(out, style, target_blocks):
       """Limit the size of operand in command 'new' and 'zero' to 1024 blocks.
@@ -348,7 +351,7 @@
       This prevents the target size of one command from being too large; and
       might help to avoid fsync errors on some devices."""
 
-      assert (style == "new" or style == "zero")
+      assert style == "new" or style == "zero"
       blocks_limit = 1024
       total = 0
       while target_blocks:
@@ -359,42 +362,26 @@
       return total
 
     out = []
-
     total = 0
 
+    # In BBOTA v3+, it uses the hash of the stashed blocks as the stash slot
+    # id. 'stashes' records the map from 'hash' to the ref count. The stash
+    # will be freed only if the count decrements to zero.
     stashes = {}
     stashed_blocks = 0
     max_stashed_blocks = 0
 
-    free_stash_ids = []
-    next_stash_id = 0
-
     for xf in self.transfers:
 
-      if self.version < 2:
-        assert not xf.stash_before
-        assert not xf.use_stash
-
-      for s, sr in xf.stash_before:
-        assert s not in stashes
-        if free_stash_ids:
-          sid = heapq.heappop(free_stash_ids)
+      for _, sr in xf.stash_before:
+        sh = self.src.RangeSha1(sr)
+        if sh in stashes:
+          stashes[sh] += 1
         else:
-          sid = next_stash_id
-          next_stash_id += 1
-        stashes[s] = sid
-        if self.version == 2:
+          stashes[sh] = 1
           stashed_blocks += sr.size()
-          out.append("stash %d %s\n" % (sid, sr.to_string_raw()))
-        else:
-          sh = self.HashBlocks(self.src, sr)
-          if sh in stashes:
-            stashes[sh] += 1
-          else:
-            stashes[sh] = 1
-            stashed_blocks += sr.size()
-            self.touched_src_ranges = self.touched_src_ranges.union(sr)
-            out.append("stash %s %s\n" % (sh, sr.to_string_raw()))
+          self.touched_src_ranges = self.touched_src_ranges.union(sr)
+          out.append("stash %s %s\n" % (sh, sr.to_string_raw()))
 
       if stashed_blocks > max_stashed_blocks:
         max_stashed_blocks = stashed_blocks
@@ -402,75 +389,47 @@
       free_string = []
       free_size = 0
 
-      if self.version == 1:
-        src_str = xf.src_ranges.to_string_raw() if xf.src_ranges else ""
-      elif self.version >= 2:
+      #   <# blocks> <src ranges>
+      #     OR
+      #   <# blocks> <src ranges> <src locs> <stash refs...>
+      #     OR
+      #   <# blocks> - <stash refs...>
 
-        #   <# blocks> <src ranges>
-        #     OR
-        #   <# blocks> <src ranges> <src locs> <stash refs...>
-        #     OR
-        #   <# blocks> - <stash refs...>
+      size = xf.src_ranges.size()
+      src_str = [str(size)]
 
-        size = xf.src_ranges.size()
-        src_str = [str(size)]
+      unstashed_src_ranges = xf.src_ranges
+      mapped_stashes = []
+      for _, sr in xf.use_stash:
+        unstashed_src_ranges = unstashed_src_ranges.subtract(sr)
+        sh = self.src.RangeSha1(sr)
+        sr = xf.src_ranges.map_within(sr)
+        mapped_stashes.append(sr)
+        assert sh in stashes
+        src_str.append("%s:%s" % (sh, sr.to_string_raw()))
+        stashes[sh] -= 1
+        if stashes[sh] == 0:
+          free_string.append("free %s\n" % (sh,))
+          free_size += sr.size()
+          stashes.pop(sh)
 
-        unstashed_src_ranges = xf.src_ranges
-        mapped_stashes = []
-        for s, sr in xf.use_stash:
-          sid = stashes.pop(s)
-          unstashed_src_ranges = unstashed_src_ranges.subtract(sr)
-          sh = self.HashBlocks(self.src, sr)
-          sr = xf.src_ranges.map_within(sr)
-          mapped_stashes.append(sr)
-          if self.version == 2:
-            src_str.append("%d:%s" % (sid, sr.to_string_raw()))
-            # A stash will be used only once. We need to free the stash
-            # immediately after the use, instead of waiting for the automatic
-            # clean-up at the end. Because otherwise it may take up extra space
-            # and lead to OTA failures.
-            # Bug: 23119955
-            free_string.append("free %d\n" % (sid,))
-            free_size += sr.size()
-          else:
-            assert sh in stashes
-            src_str.append("%s:%s" % (sh, sr.to_string_raw()))
-            stashes[sh] -= 1
-            if stashes[sh] == 0:
-              free_size += sr.size()
-              free_string.append("free %s\n" % (sh))
-              stashes.pop(sh)
-          heapq.heappush(free_stash_ids, sid)
-
-        if unstashed_src_ranges:
-          src_str.insert(1, unstashed_src_ranges.to_string_raw())
-          if xf.use_stash:
-            mapped_unstashed = xf.src_ranges.map_within(unstashed_src_ranges)
-            src_str.insert(2, mapped_unstashed.to_string_raw())
-            mapped_stashes.append(mapped_unstashed)
-            self.AssertPartition(RangeSet(data=(0, size)), mapped_stashes)
-        else:
-          src_str.insert(1, "-")
+      if unstashed_src_ranges:
+        src_str.insert(1, unstashed_src_ranges.to_string_raw())
+        if xf.use_stash:
+          mapped_unstashed = xf.src_ranges.map_within(unstashed_src_ranges)
+          src_str.insert(2, mapped_unstashed.to_string_raw())
+          mapped_stashes.append(mapped_unstashed)
           self.AssertPartition(RangeSet(data=(0, size)), mapped_stashes)
+      else:
+        src_str.insert(1, "-")
+        self.AssertPartition(RangeSet(data=(0, size)), mapped_stashes)
 
-        src_str = " ".join(src_str)
+      src_str = " ".join(src_str)
 
-      # all versions:
+      # version 3+:
       #   zero <rangeset>
       #   new <rangeset>
       #   erase <rangeset>
-      #
-      # version 1:
-      #   bsdiff patchstart patchlen <src rangeset> <tgt rangeset>
-      #   imgdiff patchstart patchlen <src rangeset> <tgt rangeset>
-      #   move <src rangeset> <tgt rangeset>
-      #
-      # version 2:
-      #   bsdiff patchstart patchlen <tgt rangeset> <src_str>
-      #   imgdiff patchstart patchlen <tgt rangeset> <src_str>
-      #   move <tgt rangeset> <src_str>
-      #
-      # version 3:
       #   bsdiff patchstart patchlen srchash tgthash <tgt rangeset> <src_str>
       #   imgdiff patchstart patchlen srchash tgthash <tgt rangeset> <src_str>
       #   move hash <tgt rangeset> <src_str>
@@ -485,41 +444,6 @@
         assert xf.tgt_ranges
         assert xf.src_ranges.size() == tgt_size
         if xf.src_ranges != xf.tgt_ranges:
-          if self.version == 1:
-            out.append("%s %s %s\n" % (
-                xf.style,
-                xf.src_ranges.to_string_raw(), xf.tgt_ranges.to_string_raw()))
-          elif self.version == 2:
-            out.append("%s %s %s\n" % (
-                xf.style,
-                xf.tgt_ranges.to_string_raw(), src_str))
-          elif self.version >= 3:
-            # take into account automatic stashing of overlapping blocks
-            if xf.src_ranges.overlaps(xf.tgt_ranges):
-              temp_stash_usage = stashed_blocks + xf.src_ranges.size()
-              if temp_stash_usage > max_stashed_blocks:
-                max_stashed_blocks = temp_stash_usage
-
-            self.touched_src_ranges = self.touched_src_ranges.union(
-                xf.src_ranges)
-
-            out.append("%s %s %s %s\n" % (
-                xf.style,
-                self.HashBlocks(self.tgt, xf.tgt_ranges),
-                xf.tgt_ranges.to_string_raw(), src_str))
-          total += tgt_size
-      elif xf.style in ("bsdiff", "imgdiff"):
-        assert xf.tgt_ranges
-        assert xf.src_ranges
-        if self.version == 1:
-          out.append("%s %d %d %s %s\n" % (
-              xf.style, xf.patch_start, xf.patch_len,
-              xf.src_ranges.to_string_raw(), xf.tgt_ranges.to_string_raw()))
-        elif self.version == 2:
-          out.append("%s %d %d %s %s\n" % (
-              xf.style, xf.patch_start, xf.patch_len,
-              xf.tgt_ranges.to_string_raw(), src_str))
-        elif self.version >= 3:
           # take into account automatic stashing of overlapping blocks
           if xf.src_ranges.overlaps(xf.tgt_ranges):
             temp_stash_usage = stashed_blocks + xf.src_ranges.size()
@@ -529,12 +453,28 @@
           self.touched_src_ranges = self.touched_src_ranges.union(
               xf.src_ranges)
 
-          out.append("%s %d %d %s %s %s %s\n" % (
+          out.append("%s %s %s %s\n" % (
               xf.style,
-              xf.patch_start, xf.patch_len,
-              self.HashBlocks(self.src, xf.src_ranges),
-              self.HashBlocks(self.tgt, xf.tgt_ranges),
+              xf.tgt_sha1,
               xf.tgt_ranges.to_string_raw(), src_str))
+          total += tgt_size
+      elif xf.style in ("bsdiff", "imgdiff"):
+        assert xf.tgt_ranges
+        assert xf.src_ranges
+        # take into account automatic stashing of overlapping blocks
+        if xf.src_ranges.overlaps(xf.tgt_ranges):
+          temp_stash_usage = stashed_blocks + xf.src_ranges.size()
+          if temp_stash_usage > max_stashed_blocks:
+            max_stashed_blocks = temp_stash_usage
+
+        self.touched_src_ranges = self.touched_src_ranges.union(xf.src_ranges)
+
+        out.append("%s %d %d %s %s %s %s\n" % (
+            xf.style,
+            xf.patch_start, xf.patch_len,
+            xf.src_sha1,
+            xf.tgt_sha1,
+            xf.tgt_ranges.to_string_raw(), src_str))
         total += tgt_size
       elif xf.style == "zero":
         assert xf.tgt_ranges
@@ -548,7 +488,7 @@
         out.append("".join(free_string))
         stashed_blocks -= free_size
 
-      if self.version >= 2 and common.OPTIONS.cache_size is not None:
+      if common.OPTIONS.cache_size is not None:
         # Sanity check: abort if we're going to need more stash space than
         # the allowed size (cache_size * threshold). There are two purposes
         # of having a threshold here. a) Part of the cache may have been
@@ -557,15 +497,13 @@
         cache_size = common.OPTIONS.cache_size
         stash_threshold = common.OPTIONS.stash_threshold
         max_allowed = cache_size * stash_threshold
-        assert max_stashed_blocks * self.tgt.blocksize < max_allowed, \
+        assert max_stashed_blocks * self.tgt.blocksize <= max_allowed, \
                'Stash size %d (%d * %d) exceeds the limit %d (%d * %.2f)' % (
                    max_stashed_blocks * self.tgt.blocksize, max_stashed_blocks,
                    self.tgt.blocksize, max_allowed, cache_size,
                    stash_threshold)
 
-    if self.version >= 3:
-      self.touched_src_sha1 = self.HashBlocks(
-          self.src, self.touched_src_ranges)
+    self.touched_src_sha1 = self.src.RangeSha1(self.touched_src_ranges)
 
     # Zero out extended blocks as a workaround for bug 20881595.
     if self.tgt.extended:
@@ -593,43 +531,40 @@
 
     out.insert(0, "%d\n" % (self.version,))   # format version number
     out.insert(1, "%d\n" % (total,))
-    if self.version >= 2:
-      # version 2 only: after the total block count, we give the number
-      # of stash slots needed, and the maximum size needed (in blocks)
-      out.insert(2, str(next_stash_id) + "\n")
-      out.insert(3, str(max_stashed_blocks) + "\n")
+    # v3+: the number of stash slots is unused.
+    out.insert(2, "0\n")
+    out.insert(3, str(max_stashed_blocks) + "\n")
 
     with open(prefix + ".transfer.list", "wb") as f:
       for i in out:
         f.write(i)
 
-    if self.version >= 2:
-      self._max_stashed_size = max_stashed_blocks * self.tgt.blocksize
-      OPTIONS = common.OPTIONS
-      if OPTIONS.cache_size is not None:
-        max_allowed = OPTIONS.cache_size * OPTIONS.stash_threshold
-        print("max stashed blocks: %d  (%d bytes), "
-              "limit: %d bytes (%.2f%%)\n" % (
-              max_stashed_blocks, self._max_stashed_size, max_allowed,
-              self._max_stashed_size * 100.0 / max_allowed))
-      else:
-        print("max stashed blocks: %d  (%d bytes), limit: <unknown>\n" % (
-              max_stashed_blocks, self._max_stashed_size))
+    self._max_stashed_size = max_stashed_blocks * self.tgt.blocksize
+    OPTIONS = common.OPTIONS
+    if OPTIONS.cache_size is not None:
+      max_allowed = OPTIONS.cache_size * OPTIONS.stash_threshold
+      print("max stashed blocks: %d  (%d bytes), "
+            "limit: %d bytes (%.2f%%)\n" % (
+            max_stashed_blocks, self._max_stashed_size, max_allowed,
+            self._max_stashed_size * 100.0 / max_allowed))
+    else:
+      print("max stashed blocks: %d  (%d bytes), limit: <unknown>\n" % (
+            max_stashed_blocks, self._max_stashed_size))
 
   def ReviseStashSize(self):
     print("Revising stash size...")
-    stashes = {}
+    stash_map = {}
 
     # Create the map between a stash and its def/use points. For example, for a
-    # given stash of (idx, sr), stashes[idx] = (sr, def_cmd, use_cmd).
+    # given stash of (raw_id, sr), stash_map[raw_id] = (sr, def_cmd, use_cmd).
     for xf in self.transfers:
       # Command xf defines (stores) all the stashes in stash_before.
-      for idx, sr in xf.stash_before:
-        stashes[idx] = (sr, xf)
+      for stash_raw_id, sr in xf.stash_before:
+        stash_map[stash_raw_id] = (sr, xf)
 
       # Record all the stashes command xf uses.
-      for idx, _ in xf.use_stash:
-        stashes[idx] += (xf,)
+      for stash_raw_id, _ in xf.use_stash:
+        stash_map[stash_raw_id] += (xf,)
 
     # Compute the maximum blocks available for stash based on /cache size and
     # the threshold.
@@ -637,6 +572,8 @@
     stash_threshold = common.OPTIONS.stash_threshold
     max_allowed = cache_size * stash_threshold / self.tgt.blocksize
 
+    # See the comments for 'stashes' in WriteTransfers().
+    stashes = {}
     stashed_blocks = 0
     new_blocks = 0
 
@@ -648,23 +585,30 @@
       replaced_cmds = []
 
       # xf.stash_before generates explicit stash commands.
-      for idx, sr in xf.stash_before:
-        if stashed_blocks + sr.size() > max_allowed:
+      for stash_raw_id, sr in xf.stash_before:
+        # Check the post-command stashed_blocks.
+        stashed_blocks_after = stashed_blocks
+        sh = self.src.RangeSha1(sr)
+        if sh not in stashes:
+          stashed_blocks_after += sr.size()
+
+        if stashed_blocks_after > max_allowed:
           # We cannot stash this one for a later command. Find out the command
           # that will use this stash and replace the command with "new".
-          use_cmd = stashes[idx][2]
+          use_cmd = stash_map[stash_raw_id][2]
           replaced_cmds.append(use_cmd)
           print("%10d  %9s  %s" % (sr.size(), "explicit", use_cmd))
         else:
-          stashed_blocks += sr.size()
-
-      # xf.use_stash generates free commands.
-      for _, sr in xf.use_stash:
-        stashed_blocks -= sr.size()
+          # Update the stashes map.
+          if sh in stashes:
+            stashes[sh] += 1
+          else:
+            stashes[sh] = 1
+          stashed_blocks = stashed_blocks_after
 
       # "move" and "diff" may introduce implicit stashes in BBOTA v3. Prior to
       # ComputePatches(), they both have the style of "diff".
-      if xf.style == "diff" and self.version >= 3:
+      if xf.style == "diff":
         assert xf.tgt_ranges and xf.src_ranges
         if xf.src_ranges.overlaps(xf.tgt_ranges):
           if stashed_blocks + xf.src_ranges.size() > max_allowed:
@@ -675,26 +619,36 @@
       for cmd in replaced_cmds:
         # It no longer uses any commands in "use_stash". Remove the def points
         # for all those stashes.
-        for idx, sr in cmd.use_stash:
-          def_cmd = stashes[idx][1]
-          assert (idx, sr) in def_cmd.stash_before
-          def_cmd.stash_before.remove((idx, sr))
+        for stash_raw_id, sr in cmd.use_stash:
+          def_cmd = stash_map[stash_raw_id][1]
+          assert (stash_raw_id, sr) in def_cmd.stash_before
+          def_cmd.stash_before.remove((stash_raw_id, sr))
 
         # Add up blocks that violates space limit and print total number to
         # screen later.
         new_blocks += cmd.tgt_ranges.size()
         cmd.ConvertToNew()
 
+      # xf.use_stash may generate free commands.
+      for _, sr in xf.use_stash:
+        sh = self.src.RangeSha1(sr)
+        assert sh in stashes
+        stashes[sh] -= 1
+        if stashes[sh] == 0:
+          stashed_blocks -= sr.size()
+          stashes.pop(sh)
+
     num_of_bytes = new_blocks * self.tgt.blocksize
     print("  Total %d blocks (%d bytes) are packed as new blocks due to "
           "insufficient cache size." % (new_blocks, num_of_bytes))
+    return new_blocks
 
   def ComputePatches(self, prefix):
     print("Reticulating splines...")
-    diff_q = []
+    diff_queue = []
     patch_num = 0
     with open(prefix + ".new.dat", "wb") as new_f:
-      for xf in self.transfers:
+      for index, xf in enumerate(self.transfers):
         if xf.style == "zero":
           tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
           print("%10d %10d (%6.2f%%) %7s %s %s" % (
@@ -702,17 +656,13 @@
               str(xf.tgt_ranges)))
 
         elif xf.style == "new":
-          for piece in self.tgt.ReadRangeSet(xf.tgt_ranges):
-            new_f.write(piece)
+          self.tgt.WriteRangeDataToFd(xf.tgt_ranges, new_f)
           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)
-
           # We can't compare src and tgt directly because they may have
           # the same content but be broken up into blocks differently, eg:
           #
@@ -721,20 +671,11 @@
           # We want those to compare equal, ideally without having to
           # actually concatenate the strings (these may be tens of
           # megabytes).
-
-          src_sha1 = sha1()
-          for p in src:
-            src_sha1.update(p)
-          tgt_sha1 = sha1()
-          tgt_size = 0
-          for p in tgt:
-            tgt_sha1.update(p)
-            tgt_size += len(p)
-
-          if src_sha1.digest() == tgt_sha1.digest():
+          if xf.src_sha1 == xf.tgt_sha1:
             # These are identical; we don't need to generate a patch,
             # just issue copy commands on the device.
             xf.style = "move"
+            tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
             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,
@@ -761,38 +702,74 @@
                        xf.tgt_name.split(".")[-1].lower()
                        in ("apk", "jar", "zip"))
             xf.style = "imgdiff" if imgdiff else "bsdiff"
-            diff_q.append((tgt_size, src, tgt, xf, patch_num))
+            diff_queue.append((index, imgdiff, patch_num))
             patch_num += 1
 
         else:
           assert False, "unknown style " + xf.style
 
-    if diff_q:
+    if diff_queue:
       if self.threads > 1:
         print("Computing patches (using %d threads)..." % (self.threads,))
       else:
         print("Computing patches...")
-      diff_q.sort()
 
-      patches = [None] * patch_num
+      diff_total = len(diff_queue)
+      patches = [None] * diff_total
+      error_messages = []
+      if sys.stdout.isatty():
+        global diff_done
+        diff_done = 0
 
-      # TODO: Rewrite with multiprocessing.ThreadPool?
+      # Using multiprocessing doesn't give additional benefits, due to the
+      # pattern of the code. The diffing work is done by subprocess.call, which
+      # already runs in a separate process (not affected much by the GIL -
+      # Global Interpreter Lock). Using multiprocess also requires either a)
+      # writing the diff input files in the main process before forking, or b)
+      # reopening the image file (SparseImage) in the worker processes. Doing
+      # neither of them further improves the performance.
       lock = threading.Lock()
       def diff_worker():
         while True:
           with lock:
-            if not diff_q:
+            if not diff_queue:
               return
-            tgt_size, src, tgt, xf, patchnum = diff_q.pop()
-          patch = compute_patch(src, tgt, imgdiff=(xf.style == "imgdiff"))
-          size = len(patch)
+            xf_index, imgdiff, patch_index = diff_queue.pop()
+
+          xf = self.transfers[xf_index]
+          src_ranges = xf.src_ranges
+          tgt_ranges = xf.tgt_ranges
+
+          # Needs lock since WriteRangeDataToFd() is stateful (calling seek).
           with lock:
-            patches[patchnum] = (patch, xf)
-            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 + ")"),
-                str(xf.tgt_ranges), str(xf.src_ranges)))
+            src_file = common.MakeTempFile(prefix="src-")
+            with open(src_file, "wb") as fd:
+              self.src.WriteRangeDataToFd(src_ranges, fd)
+
+            tgt_file = common.MakeTempFile(prefix="tgt-")
+            with open(tgt_file, "wb") as fd:
+              self.tgt.WriteRangeDataToFd(tgt_ranges, fd)
+
+          try:
+            patch = compute_patch(src_file, tgt_file, imgdiff)
+          except ValueError as e:
+            with lock:
+              error_messages.append(
+                  "Failed to generate %s for %s: tgt=%s, src=%s:\n%s" % (
+                      "imgdiff" if imgdiff else "bsdiff",
+                      xf.tgt_name if xf.tgt_name == xf.src_name else
+                          xf.tgt_name + " (from " + xf.src_name + ")",
+                      xf.tgt_ranges, xf.src_ranges, e.message))
+
+          with lock:
+            patches[patch_index] = (xf_index, patch)
+            if sys.stdout.isatty():
+              global diff_done
+              diff_done += 1
+              progress = diff_done * 100 / diff_total
+              # '\033[K' is to clear to EOL.
+              print(' [%d%%] %s\033[K' % (progress, xf.tgt_name), end='\r')
+              sys.stdout.flush()
 
       threads = [threading.Thread(target=diff_worker)
                  for _ in range(self.threads)]
@@ -800,16 +777,33 @@
         th.start()
       while threads:
         threads.pop().join()
+
+      if sys.stdout.isatty():
+        print('\n')
+
+      if error_messages:
+        print('\n'.join(error_messages))
+        sys.exit(1)
     else:
       patches = []
 
-    p = 0
-    with open(prefix + ".patch.dat", "wb") as patch_f:
-      for patch, xf in patches:
-        xf.patch_start = p
+    offset = 0
+    with open(prefix + ".patch.dat", "wb") as patch_fd:
+      for index, patch in patches:
+        xf = self.transfers[index]
         xf.patch_len = len(patch)
-        patch_f.write(patch)
-        p += len(patch)
+        xf.patch_start = offset
+        offset += xf.patch_len
+        patch_fd.write(patch)
+
+        if common.OPTIONS.verbose:
+          tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
+          print("%10d %10d (%6.2f%%) %7s %s %s %s" % (
+                xf.patch_len, tgt_size, xf.patch_len * 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_ranges, xf.src_ranges))
 
   def AssertSequenceGood(self):
     # Simulate the sequences of transfers we will output, and check that:
@@ -824,9 +818,8 @@
       # Check that the input blocks for this transfer haven't yet been touched.
 
       x = xf.src_ranges
-      if self.version >= 2:
-        for _, sr in xf.use_stash:
-          x = x.subtract(sr)
+      for _, sr in xf.use_stash:
+        x = x.subtract(sr)
 
       for s, e in x:
         # Source image could be larger. Don't check the blocks that are in the
@@ -926,10 +919,21 @@
            lost_source))
 
   def ReverseBackwardEdges(self):
+    """Reverse unsatisfying edges and compute pairs of stashed blocks.
+
+    For each transfer, make sure it properly stashes the blocks it touches and
+    will be used by later transfers. It uses pairs of (stash_raw_id, range) to
+    record the blocks to be stashed. 'stash_raw_id' is an id that uniquely
+    identifies each pair. Note that for the same range (e.g. RangeSet("1-5")),
+    it is possible to have multiple pairs with different 'stash_raw_id's. Each
+    'stash_raw_id' will be consumed by one transfer. In BBOTA v3+, identical
+    blocks will be written to the same stash slot in WriteTransfers().
+    """
+
     print("Reversing backward edges...")
     in_order = 0
     out_of_order = 0
-    stashes = 0
+    stash_raw_id = 0
     stash_size = 0
 
     for xf in self.transfers:
@@ -947,9 +951,9 @@
           overlap = xf.src_ranges.intersect(u.tgt_ranges)
           assert overlap
 
-          u.stash_before.append((stashes, overlap))
-          xf.use_stash.append((stashes, overlap))
-          stashes += 1
+          u.stash_before.append((stash_raw_id, overlap))
+          xf.use_stash.append((stash_raw_id, overlap))
+          stash_raw_id += 1
           stash_size += overlap.size()
 
           # reverse the edge direction; now xf must go after u
@@ -1146,7 +1150,9 @@
       # Change nothing for small files.
       if (tgt_ranges.size() <= max_blocks_per_transfer and
           src_ranges.size() <= max_blocks_per_transfer):
-        Transfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id)
+        Transfer(tgt_name, src_name, tgt_ranges, src_ranges,
+                 self.tgt.RangeSha1(tgt_ranges), self.src.RangeSha1(src_ranges),
+                 style, by_id)
         return
 
       while (tgt_ranges.size() > max_blocks_per_transfer and
@@ -1156,8 +1162,9 @@
         tgt_first = tgt_ranges.first(max_blocks_per_transfer)
         src_first = src_ranges.first(max_blocks_per_transfer)
 
-        Transfer(tgt_split_name, src_split_name, tgt_first, src_first, style,
-                 by_id)
+        Transfer(tgt_split_name, src_split_name, tgt_first, src_first,
+                 self.tgt.RangeSha1(tgt_first), self.src.RangeSha1(src_first),
+                 style, by_id)
 
         tgt_ranges = tgt_ranges.subtract(tgt_first)
         src_ranges = src_ranges.subtract(src_first)
@@ -1169,8 +1176,9 @@
         assert tgt_ranges.size() and src_ranges.size()
         tgt_split_name = "%s-%d" % (tgt_name, pieces)
         src_split_name = "%s-%d" % (src_name, pieces)
-        Transfer(tgt_split_name, src_split_name, tgt_ranges, src_ranges, style,
-                 by_id)
+        Transfer(tgt_split_name, src_split_name, tgt_ranges, src_ranges,
+                 self.tgt.RangeSha1(tgt_ranges), self.src.RangeSha1(src_ranges),
+                 style, by_id)
 
     def AddTransfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id,
                     split=False):
@@ -1179,7 +1187,9 @@
       # 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)
+        Transfer(tgt_name, src_name, tgt_ranges, src_ranges,
+                 self.tgt.RangeSha1(tgt_ranges), self.src.RangeSha1(src_ranges),
+                 style, by_id)
         return
 
       # Handle .odex files specially to analyze the block-wise difference. If
@@ -1260,7 +1270,7 @@
       elif tgt_fn in self.src.file_map:
         # Look for an exact pathname match in the source.
         AddTransfer(tgt_fn, tgt_fn, tgt_ranges, self.src.file_map[tgt_fn],
-                    "diff", self.transfers, self.version >= 3)
+                    "diff", self.transfers, True)
         continue
 
       b = os.path.basename(tgt_fn)
@@ -1268,7 +1278,7 @@
         # Look for an exact basename match in the source.
         src_fn = self.src_basenames[b]
         AddTransfer(tgt_fn, src_fn, tgt_ranges, self.src.file_map[src_fn],
-                    "diff", self.transfers, self.version >= 3)
+                    "diff", self.transfers, True)
         continue
 
       b = re.sub("[0-9]+", "#", b)
@@ -1279,7 +1289,7 @@
         # that get bumped.)
         src_fn = self.src_numpatterns[b]
         AddTransfer(tgt_fn, src_fn, tgt_ranges, self.src.file_map[src_fn],
-                    "diff", self.transfers, self.version >= 3)
+                    "diff", self.transfers, True)
         continue
 
       AddTransfer(tgt_fn, None, tgt_ranges, empty, "new", self.transfers)
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index cd61246..3094dca 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -15,9 +15,9 @@
 # limitations under the License.
 
 """
-Build image output_image_file from input_directory and properties_file.
+Build image output_image_file from input_directory, properties_file, and target_out_dir
 
-Usage:  build_image input_directory properties_file output_image_file
+Usage:  build_image input_directory properties_file output_image_file target_out_dir
 
 """
 import os
@@ -25,8 +25,8 @@
 import re
 import subprocess
 import sys
-import commands
 import common
+import shlex
 import shutil
 import sparse_img
 import tempfile
@@ -51,29 +51,24 @@
   return (output, p.returncode)
 
 def GetVerityFECSize(partition_size):
-  cmd = "fec -s %d" % partition_size
-  status, output = commands.getstatusoutput(cmd)
-  if status:
-    print output
+  cmd = ["fec", "-s", str(partition_size)]
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     return False, 0
   return True, int(output)
 
 def GetVerityTreeSize(partition_size):
-  cmd = "build_verity_tree -s %d"
-  cmd %= partition_size
-  status, output = commands.getstatusoutput(cmd)
-  if status:
-    print output
+  cmd = ["build_verity_tree", "-s", str(partition_size)]
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     return False, 0
   return True, int(output)
 
 def GetVerityMetadataSize(partition_size):
-  cmd = "system/extras/verity/build_verity_metadata.py size %d"
-  cmd %= partition_size
-
-  status, output = commands.getstatusoutput(cmd)
-  if status:
-    print output
+  cmd = ["system/extras/verity/build_verity_metadata.py", "size",
+         str(partition_size)]
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     return False, 0
   return True, int(output)
 
@@ -102,6 +97,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.
 
@@ -145,21 +185,19 @@
 
 def BuildVerityFEC(sparse_image_path, verity_path, verity_fec_path,
                    padding_size):
-  cmd = "fec -e -p %d %s %s %s" % (padding_size, sparse_image_path,
-                                   verity_path, verity_fec_path)
-  print cmd
-  status, output = commands.getstatusoutput(cmd)
-  if status:
+  cmd = ["fec", "-e", "-p", str(padding_size), sparse_image_path,
+         verity_path, verity_fec_path]
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     print "Could not build FEC data! Error: %s" % output
     return False
   return True
 
 def BuildVerityTree(sparse_image_path, verity_image_path, prop_dict):
-  cmd = "build_verity_tree -A %s %s %s" % (
-      FIXED_SALT, sparse_image_path, verity_image_path)
-  print cmd
-  status, output = commands.getstatusoutput(cmd)
-  if status:
+  cmd = ["build_verity_tree", "-A", FIXED_SALT, sparse_image_path,
+         verity_image_path]
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     print "Could not build verity tree! Error: %s" % output
     return False
   root, salt = output.split()
@@ -169,16 +207,13 @@
 
 def BuildVerityMetadata(image_size, verity_metadata_path, root_hash, salt,
                         block_device, signer_path, key, signer_args):
-  cmd_template = (
-      "system/extras/verity/build_verity_metadata.py build " +
-      "%s %s %s %s %s %s %s")
-  cmd = cmd_template % (image_size, verity_metadata_path, root_hash, salt,
-                        block_device, signer_path, key)
+  cmd = ["system/extras/verity/build_verity_metadata.py", "build",
+         str(image_size), verity_metadata_path, root_hash, salt, block_device,
+         signer_path, key]
   if signer_args:
-    cmd += " --signer_args=\"%s\"" % (' '.join(signer_args),)
-  print cmd
-  status, output = commands.getstatusoutput(cmd)
-  if status:
+    cmd.append("--signer_args=\"%s\"" % (' '.join(signer_args),))
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     print "Could not build verity metadata! Error: %s" % output
     return False
   return True
@@ -192,22 +227,19 @@
   Returns:
     True on success, False on failure.
   """
-  cmd = "append2simg %s %s"
-  cmd %= (sparse_image_path, unsparse_image_path)
-  print cmd
-  status, output = commands.getstatusoutput(cmd)
-  if status:
+  cmd = ["append2simg", sparse_image_path, unsparse_image_path]
+  output, exit_code = RunCommand(cmd)
+  if exit_code != 0:
     print "%s: %s" % (error_message, output)
     return False
   return True
 
 def Append(target, file_to_append, error_message):
-  cmd = 'cat %s >> %s' % (file_to_append, target)
-  print cmd
-  status, output = commands.getstatusoutput(cmd)
-  if status:
-    print "%s: %s" % (error_message, output)
-    return False
+  print "appending %s to %s" % (file_to_append, target)
+  with open(target, "a") as out_file:
+    with open(file_to_append, "r") as input_file:
+      for line in input_file:
+        out_file.write(line)
   return True
 
 def BuildVerifiedImage(data_image_path, verity_image_path,
@@ -378,8 +410,20 @@
     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"]
+    build_command = [prop_dict["ext_mkuserimg"]]
     if "extfs_sparse_flag" in prop_dict:
       build_command.append(prop_dict["extfs_sparse_flag"])
       run_fsck = True
@@ -404,6 +448,10 @@
     build_command.extend(["-L", prop_dict["mount_point"]])
     if "extfs_inode_count" in prop_dict:
       build_command.extend(["-i", prop_dict["extfs_inode_count"]])
+    if "flash_erase_block_size" in prop_dict:
+      build_command.extend(["-e", prop_dict["flash_erase_block_size"]])
+    if "flash_logical_block_size" in prop_dict:
+      build_command.extend(["-o", prop_dict["flash_logical_block_size"]])
     if "selinux_fc" in prop_dict:
       build_command.append(prop_dict["selinux_fc"])
   elif fs_type.startswith("squash"):
@@ -432,14 +480,8 @@
     build_command = ["mkf2fsuserimg.sh"]
     build_command.extend([out_file, prop_dict["partition_size"]])
   else:
-    build_command = ["mkyaffs2image", "-f"]
-    if prop_dict.get("mkyaffs2_extra_flags", None):
-      build_command.extend(prop_dict["mkyaffs2_extra_flags"].split())
-    build_command.append(in_dir)
-    build_command.append(out_file)
-    if "selinux_fc" in prop_dict:
-      build_command.append(prop_dict["selinux_fc"])
-      build_command.append(prop_dict["mount_point"])
+    print("Error: unknown filesystem type '%s'" % (fs_type))
+    return False
 
   if in_dir != origin_in:
     # Construct a staging directory of the root file system.
@@ -519,6 +561,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:
@@ -554,13 +607,15 @@
   common_props = (
       "extfs_sparse_flag",
       "squashfs_sparse_flag",
-      "mkyaffs2_extra_flags",
       "selinux_fc",
       "skip_fsck",
+      "ext_mkuserimg",
       "verity",
       "verity_key",
       "verity_signer_cmd",
-      "verity_fec"
+      "verity_fec",
+      "avb_signing_args",
+      "avb_avbtool"
       )
   for p in common_props:
     copy_prop(p, p)
@@ -584,6 +639,9 @@
     copy_prop("system_squashfs_block_size", "squashfs_block_size")
     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")
     copy_prop("system_extfs_inode_count", "extfs_inode_count")
   elif mount_point == "system_other":
     # We inherit the selinux policies of /system since we contain some of its files.
@@ -598,12 +656,17 @@
     copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt")
     copy_prop("system_squashfs_block_size", "squashfs_block_size")
     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")
     copy_prop("system_extfs_inode_count", "extfs_inode_count")
   elif mount_point == "data":
     # Copy the generic fs type first, override with specific one if available.
     copy_prop("fs_type", "fs_type")
     copy_prop("userdata_fs_type", "fs_type")
     copy_prop("userdata_size", "partition_size")
+    copy_prop("flash_logical_block_size","flash_logical_block_size")
+    copy_prop("flash_erase_block_size", "flash_erase_block_size")
   elif mount_point == "cache":
     copy_prop("cache_fs_type", "fs_type")
     copy_prop("cache_size", "partition_size")
@@ -618,6 +681,9 @@
     copy_prop("vendor_squashfs_block_size", "squashfs_block_size")
     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")
     copy_prop("vendor_extfs_inode_count", "extfs_inode_count")
   elif mount_point == "oem":
     copy_prop("fs_type", "fs_type")
@@ -625,7 +691,7 @@
     copy_prop("oem_journal_size", "journal_size")
     copy_prop("has_ext4_reserved_blocks", "has_ext4_reserved_blocks")
     copy_prop("oem_extfs_inode_count", "extfs_inode_count")
-
+  d["partition_name"] = mount_point
   return d
 
 
diff --git a/tools/releasetools/check_ota_package_signature.py b/tools/releasetools/check_ota_package_signature.py
new file mode 100755
index 0000000..548b619
--- /dev/null
+++ b/tools/releasetools/check_ota_package_signature.py
@@ -0,0 +1,161 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016 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.
+
+"""
+Verify a given OTA package with the specifed certificate.
+"""
+
+from __future__ import print_function
+
+import argparse
+import common
+import re
+import subprocess
+import sys
+
+from hashlib import sha1
+from hashlib import sha256
+
+
+def cert_uses_sha256(cert):
+  """Check if the cert uses SHA-256 hashing algorithm."""
+
+  cmd = ['openssl', 'x509', '-text', '-noout', '-in', cert]
+  p1 = common.Run(cmd, stdout=subprocess.PIPE)
+  cert_dump, _ = p1.communicate()
+
+  algorithm = re.search(r'Signature Algorithm: ([a-zA-Z0-9]+)', cert_dump)
+  assert algorithm, "Failed to identify the signature algorithm."
+
+  assert not algorithm.group(1).startswith('ecdsa'), (
+      'This script doesn\'t support verifying ECDSA signed package yet.')
+
+  return algorithm.group(1).startswith('sha256')
+
+
+def verify_package(cert, package):
+  """Verify the given package with the certificate.
+
+  (Comments from bootable/recovery/verifier.cpp:)
+
+  An archive with a whole-file signature will end in six bytes:
+
+    (2-byte signature start) $ff $ff (2-byte comment size)
+
+  (As far as the ZIP format is concerned, these are part of the
+  archive comment.) We start by reading this footer, this tells
+  us how far back from the end we have to start reading to find
+  the whole comment.
+  """
+
+  print('Package: %s' % (package,))
+  print('Certificate: %s' % (cert,))
+
+  # Read in the package.
+  with open(package) as package_file:
+    package_bytes = package_file.read()
+
+  length = len(package_bytes)
+  assert length >= 6, "Not big enough to contain footer."
+
+  footer = [ord(x) for x in package_bytes[-6:]]
+  assert footer[2] == 0xff and footer[3] == 0xff, "Footer is wrong."
+
+  signature_start_from_end = (footer[1] << 8) + footer[0]
+  assert signature_start_from_end > 6, "Signature start is in the footer."
+
+  signature_start = length - signature_start_from_end
+
+  # Determine how much of the file is covered by the signature. This is
+  # everything except the signature data and length, which includes all of the
+  # EOCD except for the comment length field (2 bytes) and the comment data.
+  comment_len = (footer[5] << 8) + footer[4]
+  signed_len = length - comment_len - 2
+
+  print('Package length: %d' % (length,))
+  print('Comment length: %d' % (comment_len,))
+  print('Signed data length: %d' % (signed_len,))
+  print('Signature start: %d' % (signature_start,))
+
+  use_sha256 = cert_uses_sha256(cert)
+  print('Use SHA-256: %s' % (use_sha256,))
+
+  if use_sha256:
+    h = sha256()
+  else:
+    h = sha1()
+  h.update(package_bytes[:signed_len])
+  package_digest = h.hexdigest().lower()
+
+  print('Digest: %s\n' % (package_digest,))
+
+  # Get the signature from the input package.
+  signature = package_bytes[signature_start:-6]
+  sig_file = common.MakeTempFile(prefix='sig-')
+  with open(sig_file, 'wb') as f:
+    f.write(signature)
+
+  # Parse the signature and get the hash.
+  cmd = ['openssl', 'asn1parse', '-inform', 'DER', '-in', sig_file]
+  p1 = common.Run(cmd, stdout=subprocess.PIPE)
+  sig, _ = p1.communicate()
+  assert p1.returncode == 0, "Failed to parse the signature."
+
+  digest_line = sig.strip().split('\n')[-1]
+  digest_string = digest_line.split(':')[3]
+  digest_file = common.MakeTempFile(prefix='digest-')
+  with open(digest_file, 'wb') as f:
+    f.write(digest_string.decode('hex'))
+
+  # Verify the digest by outputing the decrypted result in ASN.1 structure.
+  decrypted_file = common.MakeTempFile(prefix='decrypted-')
+  cmd = ['openssl', 'rsautl', '-verify', '-certin', '-inkey', cert,
+         '-in', digest_file, '-out', decrypted_file]
+  p1 = common.Run(cmd, stdout=subprocess.PIPE)
+  p1.communicate()
+  assert p1.returncode == 0, "Failed to run openssl rsautl -verify."
+
+  # Parse the output ASN.1 structure.
+  cmd = ['openssl', 'asn1parse', '-inform', 'DER', '-in', decrypted_file]
+  p1 = common.Run(cmd, stdout=subprocess.PIPE)
+  decrypted_output, _ = p1.communicate()
+  assert p1.returncode == 0, "Failed to parse the output."
+
+  digest_line = decrypted_output.strip().split('\n')[-1]
+  digest_string = digest_line.split(':')[3].lower()
+
+  # Verify that the two digest strings match.
+  assert package_digest == digest_string, "Verification failed."
+
+  # Verified successfully upon reaching here.
+  print('VERIFIED\n')
+
+
+def main():
+  parser = argparse.ArgumentParser()
+  parser.add_argument('certificate', help='The certificate to be used.')
+  parser.add_argument('package', help='The OTA package to be verified.')
+  args = parser.parse_args()
+
+  verify_package(args.certificate, args.package)
+
+
+if __name__ == '__main__':
+  try:
+    main()
+  except AssertionError as err:
+    print('\n    ERROR: %s\n' % (err,))
+    sys.exit(1)
diff --git a/tools/releasetools/check_target_files_signatures.py b/tools/releasetools/check_target_files_signatures.py
index 3048488..f9aa4fa 100755
--- a/tools/releasetools/check_target_files_signatures.py
+++ b/tools/releasetools/check_target_files_signatures.py
@@ -235,7 +235,7 @@
     self.certmap = None
 
   def LoadZipFile(self, filename):
-    d, z = common.UnzipTemp(filename, '*.apk')
+    d, z = common.UnzipTemp(filename, ['*.apk'])
     try:
       self.apks = {}
       self.apks_by_basename = {}
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index c4bf893..e200f9f 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import print_function
+
 import copy
 import errno
 import getopt
@@ -109,7 +111,7 @@
   """Create and return a subprocess.Popen object, printing the command
   line on the terminal if -v was specified."""
   if OPTIONS.verbose:
-    print "  running: ", " ".join(args)
+    print("  running: ", " ".join(args))
   return subprocess.Popen(args, **kwargs)
 
 
@@ -144,41 +146,14 @@
       except IOError as e:
         if e.errno == errno.ENOENT:
           raise KeyError(fn)
-  d = {}
+
   try:
     d = LoadDictionaryFromLines(read_helper("META/misc_info.txt").split("\n"))
   except KeyError:
-    # ok if misc_info.txt doesn't exist
-    pass
+    raise ValueError("can't find META/misc_info.txt in input target-files")
 
-  # backwards compatibility: These values used to be in their own
-  # files.  Look for them, in case we're processing an old
-  # target_files zip.
-
-  if "mkyaffs2_extra_flags" not in d:
-    try:
-      d["mkyaffs2_extra_flags"] = read_helper(
-          "META/mkyaffs2-extra-flags.txt").strip()
-    except KeyError:
-      # ok if flags don't exist
-      pass
-
-  if "recovery_api_version" not in d:
-    try:
-      d["recovery_api_version"] = read_helper(
-          "META/recovery-api-version.txt").strip()
-    except KeyError:
-      raise ValueError("can't find recovery API version in input target-files")
-
-  if "tool_extensions" not in d:
-    try:
-      d["tool_extensions"] = read_helper("META/tool-extensions.txt").strip()
-    except KeyError:
-      # ok if extensions don't exist
-      pass
-
-  if "fstab_version" not in d:
-    d["fstab_version"] = "1"
+  assert "recovery_api_version" in d
+  assert "fstab_version" in d
 
   # A few properties are stored as links to the files in the out/ directory.
   # It works fine with the build system. However, they are no longer available
@@ -216,8 +191,8 @@
       if os.path.exists(system_base_fs_file):
         d["system_base_fs_file"] = system_base_fs_file
       else:
-        print "Warning: failed to find system base fs file: %s" % (
-            system_base_fs_file,)
+        print("Warning: failed to find system base fs file: %s" % (
+            system_base_fs_file,))
         del d["system_base_fs_file"]
 
     if "vendor_base_fs_file" in d:
@@ -226,8 +201,8 @@
       if os.path.exists(vendor_base_fs_file):
         d["vendor_base_fs_file"] = vendor_base_fs_file
       else:
-        print "Warning: failed to find vendor base fs file: %s" % (
-            vendor_base_fs_file,)
+        print("Warning: failed to find vendor base fs file: %s" % (
+            vendor_base_fs_file,))
         del d["vendor_base_fs_file"]
 
   try:
@@ -274,14 +249,16 @@
   d["build.prop"] = LoadBuildProp(read_helper)
   return d
 
+
 def LoadBuildProp(read_helper):
   try:
     data = read_helper("SYSTEM/build.prop")
   except KeyError:
-    print "Warning: could not find SYSTEM/build.prop in %s" % zip
+    print("Warning: could not find SYSTEM/build.prop in %s" % (zip,))
     data = ""
   return LoadDictionaryFromLines(data.split("\n"))
 
+
 def LoadDictionaryFromLines(lines):
   d = {}
   for line in lines:
@@ -293,98 +270,61 @@
       d[name] = value
   return d
 
+
 def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,
                       system_root_image=False):
   class Partition(object):
-    def __init__(self, mount_point, fs_type, device, length, device2, context):
+    def __init__(self, mount_point, fs_type, device, length, context):
       self.mount_point = mount_point
       self.fs_type = fs_type
       self.device = device
       self.length = length
-      self.device2 = device2
       self.context = context
 
   try:
     data = read_helper(recovery_fstab_path)
   except KeyError:
-    print "Warning: could not find {}".format(recovery_fstab_path)
+    print("Warning: could not find {}".format(recovery_fstab_path))
     data = ""
 
-  if fstab_version == 1:
-    d = {}
-    for line in data.split("\n"):
-      line = line.strip()
-      if not line or line.startswith("#"):
-        continue
-      pieces = line.split()
-      if not 3 <= len(pieces) <= 4:
-        raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))
-      options = None
-      if len(pieces) >= 4:
-        if pieces[3].startswith("/"):
-          device2 = pieces[3]
-          if len(pieces) >= 5:
-            options = pieces[4]
-        else:
-          device2 = None
-          options = pieces[3]
+  assert fstab_version == 2
+
+  d = {}
+  for line in data.split("\n"):
+    line = line.strip()
+    if not line or line.startswith("#"):
+      continue
+
+    # <src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
+    pieces = line.split()
+    if len(pieces) != 5:
+      raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))
+
+    # Ignore entries that are managed by vold.
+    options = pieces[4]
+    if "voldmanaged=" in options:
+      continue
+
+    # It's a good line, parse it.
+    length = 0
+    options = options.split(",")
+    for i in options:
+      if i.startswith("length="):
+        length = int(i[7:])
       else:
-        device2 = None
-
-      mount_point = pieces[0]
-      length = 0
-      if options:
-        options = options.split(",")
-        for i in options:
-          if i.startswith("length="):
-            length = int(i[7:])
-          else:
-            print "%s: unknown option \"%s\"" % (mount_point, i)
-
-      d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[1],
-                                 device=pieces[2], length=length,
-                                 device2=device2)
-
-  elif fstab_version == 2:
-    d = {}
-    for line in data.split("\n"):
-      line = line.strip()
-      if not line or line.startswith("#"):
-        continue
-      # <src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
-      pieces = line.split()
-      if len(pieces) != 5:
-        raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))
-
-      # Ignore entries that are managed by vold
-      options = pieces[4]
-      if "voldmanaged=" in options:
+        # Ignore all unknown options in the unified fstab.
         continue
 
-      # It's a good line, parse it
-      length = 0
-      options = options.split(",")
-      for i in options:
-        if i.startswith("length="):
-          length = int(i[7:])
-        else:
-          # Ignore all unknown options in the unified fstab
-          continue
+    mount_flags = pieces[3]
+    # Honor the SELinux context if present.
+    context = None
+    for i in mount_flags.split(","):
+      if i.startswith("context="):
+        context = i
 
-      mount_flags = pieces[3]
-      # Honor the SELinux context if present.
-      context = None
-      for i in mount_flags.split(","):
-        if i.startswith("context="):
-          context = i
-
-      mount_point = pieces[1]
-      d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[2],
-                                 device=pieces[0], length=length,
-                                 device2=None, context=context)
-
-  else:
-    raise ValueError("Unknown fstab_version: \"%d\"" % (fstab_version,))
+    mount_point = pieces[1]
+    d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[2],
+                               device=pieces[0], length=length, context=context)
 
   # / is used for the system mount point when the root directory is included in
   # system. Other areas assume system is always at "/system" so point /system
@@ -397,7 +337,17 @@
 
 def DumpInfoDict(d):
   for k, v in sorted(d.items()):
-    print "%-25s = (%s) %s" % (k, type(v).__name__, v)
+    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,
@@ -534,6 +484,21 @@
     img_unsigned.close()
     img_keyblock.close()
 
+  # 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()
 
@@ -554,15 +519,15 @@
 
   prebuilt_path = os.path.join(unpack_dir, "BOOTABLE_IMAGES", prebuilt_name)
   if os.path.exists(prebuilt_path):
-    print "using prebuilt %s from BOOTABLE_IMAGES..." % (prebuilt_name,)
+    print("using prebuilt %s from BOOTABLE_IMAGES..." % (prebuilt_name,))
     return File.FromLocalFile(name, prebuilt_path)
 
   prebuilt_path = os.path.join(unpack_dir, "IMAGES", prebuilt_name)
   if os.path.exists(prebuilt_path):
-    print "using prebuilt %s from IMAGES..." % (prebuilt_name,)
+    print("using prebuilt %s from IMAGES..." % (prebuilt_name,))
     return File.FromLocalFile(name, prebuilt_path)
 
-  print "building image from target_files %s..." % (tree_subdir,)
+  print("building image from target_files %s..." % (tree_subdir,))
 
   if info_dict is None:
     info_dict = OPTIONS.info_dict
@@ -599,7 +564,7 @@
   def unzip_to_dir(filename, dirname):
     cmd = ["unzip", "-o", "-q", filename, "-d", dirname]
     if pattern is not None:
-      cmd.append(pattern)
+      cmd.extend(pattern)
     p = Run(cmd, stdout=subprocess.PIPE)
     p.communicate()
     if p.returncode != 0:
@@ -775,21 +740,15 @@
   if not fs_type or not limit:
     return
 
-  if fs_type == "yaffs2":
-    # image size should be increased by 1/64th to account for the
-    # spare area (64 bytes per 2k page)
-    limit = limit / 2048 * (2048+64)
   size = len(data)
   pct = float(size) * 100.0 / limit
   msg = "%s size (%d) is %.2f%% of limit (%d)" % (target, size, pct, limit)
   if pct >= 99.0:
     raise ExternalError(msg)
   elif pct >= 95.0:
-    print
-    print "  WARNING: ", msg
-    print
+    print("\n  WARNING: %s\n" % (msg,))
   elif OPTIONS.verbose:
-    print "  ", msg
+    print("  ", msg)
 
 
 def ReadApkCerts(tf_zip):
@@ -838,8 +797,8 @@
 """
 
 def Usage(docstring):
-  print docstring.rstrip("\n")
-  print COMMON_DOCSTRING
+  print(docstring.rstrip("\n"))
+  print(COMMON_DOCSTRING)
 
 
 def ParseOptions(argv,
@@ -864,7 +823,7 @@
         list(extra_long_opts))
   except getopt.GetoptError as err:
     Usage(docstring)
-    print "**", str(err), "**"
+    print("**", str(err), "**")
     sys.exit(2)
 
   for o, a in opts:
@@ -913,7 +872,7 @@
   return args
 
 
-def MakeTempFile(prefix=None, suffix=None):
+def MakeTempFile(prefix='tmp', suffix=''):
   """Make a temp file and add it to the list of things to be deleted
   when Cleanup() is called.  Return the filename."""
   fd, fn = tempfile.mkstemp(prefix=prefix, suffix=suffix)
@@ -962,7 +921,7 @@
         current[i] = ""
 
       if not first:
-        print "key file %s still missing some passwords." % (self.pwfile,)
+        print("key file %s still missing some passwords." % (self.pwfile,))
         answer = raw_input("try to edit again? [y]> ").strip()
         if answer and answer[0] not in 'yY':
           raise RuntimeError("key passwords unavailable")
@@ -1022,13 +981,13 @@
           continue
         m = re.match(r"^\[\[\[\s*(.*?)\s*\]\]\]\s*(\S+)$", line)
         if not m:
-          print "failed to parse password file: ", line
+          print("failed to parse password file: ", line)
         else:
           result[m.group(2)] = m.group(1)
       f.close()
     except IOError as e:
       if e.errno != errno.ENOENT:
-        print "error reading password file: ", str(e)
+        print("error reading password file: ", str(e))
     return result
 
 
@@ -1149,10 +1108,10 @@
           if x == ".py":
             f = b
           info = imp.find_module(f, [d])
-        print "loaded device-specific extensions from", path
+        print("loaded device-specific extensions from", path)
         self.module = imp.load_module("device_specific", *info)
       except ImportError:
-        print "unable to load device-specific module; assuming none"
+        print("unable to load device-specific module; assuming none")
 
   def _DoCall(self, function_name, *args, **kwargs):
     """Call the named function in the device-specific module, passing
@@ -1212,10 +1171,11 @@
     return self._DoCall("VerifyOTA_Assertions")
 
 class File(object):
-  def __init__(self, name, data):
+  def __init__(self, name, data, compress_size = None):
     self.name = name
     self.data = data
     self.size = len(data)
+    self.compress_size = compress_size or self.size
     self.sha1 = sha1(data).hexdigest()
 
   @classmethod
@@ -1231,6 +1191,10 @@
     t.flush()
     return t
 
+  def WriteToDir(self, d):
+    with open(os.path.join(d, self.name), "wb") as fp:
+      fp.write(self.data)
+
   def AddToZip(self, z, compression=None):
     ZipWriteStr(z, self.name, self.data, compress_type=compression)
 
@@ -1286,7 +1250,7 @@
       th.start()
       th.join(timeout=300)   # 5 mins
       if th.is_alive():
-        print "WARNING: diff command timed out"
+        print("WARNING: diff command timed out")
         p.terminate()
         th.join(5)
         if th.is_alive():
@@ -1294,8 +1258,8 @@
           th.join()
 
       if err or p.returncode != 0:
-        print "WARNING: failure running %s:\n%s\n" % (
-            diff_program, "".join(err))
+        print("WARNING: failure running %s:\n%s\n" % (
+            diff_program, "".join(err)))
         self.patch = None
         return None, None, None
       diff = ptemp.read()
@@ -1317,7 +1281,7 @@
 
 def ComputeDifferences(diffs):
   """Call ComputePatch on all the Difference objects in 'diffs'."""
-  print len(diffs), "diffs to compute"
+  print(len(diffs), "diffs to compute")
 
   # Do the largest files first, to try and reduce the long-pole effect.
   by_size = [(i.tf.size, i) for i in diffs]
@@ -1343,13 +1307,13 @@
         else:
           name = "%s (%s)" % (tf.name, sf.name)
         if patch is None:
-          print "patching failed!                                  %s" % (name,)
+          print("patching failed!                                  %s" % (name,))
         else:
-          print "%8.2f sec %8d / %8d bytes (%6.2f%%) %s" % (
-              dur, len(patch), tf.size, 100.0 * len(patch) / tf.size, name)
+          print("%8.2f sec %8d / %8d bytes (%6.2f%%) %s" % (
+              dur, len(patch), tf.size, 100.0 * len(patch) / tf.size, name))
       lock.release()
     except Exception as e:
-      print e
+      print(e)
       raise
 
   # start worker threads; wait for them all to finish.
@@ -1376,6 +1340,7 @@
         version = max(
             int(i) for i in
             OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(","))
+    assert version >= 3
     self.version = version
 
     b = blockimgdiff.BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads,
@@ -1440,7 +1405,7 @@
 
     # incremental OTA
     else:
-      if touched_blocks_only and self.version >= 3:
+      if touched_blocks_only:
         ranges = self.touched_src_ranges
         expected_sha1 = self.touched_src_sha1
       else:
@@ -1452,23 +1417,12 @@
         return
 
       ranges_str = ranges.to_string_raw()
-      if self.version >= 4:
-        script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
-                            'block_image_verify("%s", '
-                            'package_extract_file("%s.transfer.list"), '
-                            '"%s.new.dat", "%s.patch.dat")) then') % (
-                            self.device, ranges_str, expected_sha1,
-                            self.device, partition, partition, partition))
-      elif self.version == 3:
-        script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
-                            'block_image_verify("%s", '
-                            'package_extract_file("%s.transfer.list"), '
-                            '"%s.new.dat", "%s.patch.dat")) then') % (
-                            self.device, ranges_str, expected_sha1,
-                            self.device, partition, partition, partition))
-      else:
-        script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
-                           self.device, ranges_str, self.src.TotalSha1()))
+      script.AppendExtra(('if (range_sha1("%s", "%s") == "%s" || '
+                          'block_image_verify("%s", '
+                          'package_extract_file("%s.transfer.list"), '
+                          '"%s.new.dat", "%s.patch.dat")) then') % (
+                          self.device, ranges_str, expected_sha1,
+                          self.device, partition, partition, partition))
       script.Print('Verified %s image...' % (partition,))
       script.AppendExtra('else')
 
@@ -1600,8 +1554,6 @@
 
 # map recovery.fstab's fs_types to mount/format "partition types"
 PARTITION_TYPES = {
-    "yaffs2": "MTD",
-    "mtd": "MTD",
     "ext4": "EMMC",
     "emmc": "EMMC",
     "f2fs": "EMMC",
@@ -1730,6 +1682,6 @@
     if found:
       break
 
-  print "putting script in", sh_location
+  print("putting script in", sh_location)
 
   output_sink(sh_location, sh)
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 73131a6..860853c 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -172,7 +172,7 @@
     self.script.append("set_progress(%f);" % (frac,))
 
   def PatchCheck(self, filename, *sha1):
-    """Check that the given file (or MTD reference) has one of the
+    """Check that the given file has one of the
     given *sha1 hashes, checking the version saved in cache if the
     file does not match."""
     self.script.append(
@@ -182,7 +182,7 @@
             common.ErrorCode.BAD_PATCH_FILE, filename))
 
   def Verify(self, filename):
-    """Check that the given file (or MTD reference) has one of the
+    """Check that the given file has one of the
     given hashes (encoded in the filename)."""
     self.script.append(
         'apply_patch_check("{filename}") && '
@@ -191,7 +191,7 @@
             filename=filename))
 
   def FileCheck(self, filename, *sha1):
-    """Check that the given file (or MTD reference) has one of the
+    """Check that the given file has one of the
     given *sha1 hashes."""
     self.script.append('assert(sha1_check(read_file("%s")' % (filename,) +
                        "".join([', "%s"' % (i,) for i in sha1]) +
@@ -277,36 +277,6 @@
 
     self.script.append('wipe_block_device("%s", %s);' % (device, size))
 
-  def DeleteFiles(self, file_list):
-    """Delete all files in file_list."""
-    if not file_list:
-      return
-    cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");"
-    self.script.append(self.WordWrap(cmd))
-
-  def DeleteFilesIfNotMatching(self, file_list):
-    """Delete the file in file_list if not matching the checksum."""
-    if not file_list:
-      return
-    for name, sha1 in file_list:
-      cmd = ('sha1_check(read_file("{name}"), "{sha1}") || '
-             'delete("{name}");'.format(name=name, sha1=sha1))
-      self.script.append(self.WordWrap(cmd))
-
-  def RenameFile(self, srcfile, tgtfile):
-    """Moves a file from one location to another."""
-    if self.info.get("update_rename_support", False):
-      self.script.append('rename("%s", "%s");' % (srcfile, tgtfile))
-    else:
-      raise ValueError("Rename not supported by update binary")
-
-  def SkipNextActionIfTargetExists(self, tgtfile, tgtsha1):
-    """Prepend an action with an apply_patch_check in order to
-       skip the action if the file exists.  Used when a patch
-       is later renamed."""
-    cmd = ('sha1_check(read_file("%s"), %s) ||' % (tgtfile, tgtsha1))
-    self.script.append(self.WordWrap(cmd))
-
   def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
     """Apply binary patches (in *patchpairs) to the given srcfile to
     produce tgtfile (which may be "-" to indicate overwriting the
@@ -331,11 +301,7 @@
       p = fstab[mount_point]
       partition_type = common.PARTITION_TYPES[p.fs_type]
       args = {'device': p.device, 'fn': fn}
-      if partition_type == "MTD":
-        self.script.append(
-            'write_raw_image(package_extract_file("%(fn)s"), "%(device)s");'
-            % args)
-      elif partition_type == "EMMC":
+      if partition_type == "EMMC":
         if mapfn:
           args["map"] = mapfn
           self.script.append(
@@ -347,48 +313,6 @@
         raise ValueError(
             "don't know how to write \"%s\" partitions" % p.fs_type)
 
-  def SetPermissions(self, fn, uid, gid, mode, selabel, capabilities):
-    """Set file ownership and permissions."""
-    if not self.info.get("use_set_metadata", False):
-      self.script.append('set_perm(%d, %d, 0%o, "%s");' % (uid, gid, mode, fn))
-    else:
-      if capabilities is None:
-        capabilities = "0x0"
-      cmd = 'set_metadata("%s", "uid", %d, "gid", %d, "mode", 0%o, ' \
-          '"capabilities", %s' % (fn, uid, gid, mode, capabilities)
-      if selabel is not None:
-        cmd += ', "selabel", "%s"' % selabel
-      cmd += ');'
-      self.script.append(cmd)
-
-  def SetPermissionsRecursive(self, fn, uid, gid, dmode, fmode, selabel,
-                              capabilities):
-    """Recursively set path ownership and permissions."""
-    if not self.info.get("use_set_metadata", False):
-      self.script.append('set_perm_recursive(%d, %d, 0%o, 0%o, "%s");'
-                         % (uid, gid, dmode, fmode, fn))
-    else:
-      if capabilities is None:
-        capabilities = "0x0"
-      cmd = 'set_metadata_recursive("%s", "uid", %d, "gid", %d, ' \
-          '"dmode", 0%o, "fmode", 0%o, "capabilities", %s' \
-          % (fn, uid, gid, dmode, fmode, capabilities)
-      if selabel is not None:
-        cmd += ', "selabel", "%s"' % selabel
-      cmd += ');'
-      self.script.append(cmd)
-
-  def MakeSymlinks(self, symlink_list):
-    """Create symlinks, given a list of (dest, link) pairs."""
-    by_dest = {}
-    for d, l in symlink_list:
-      by_dest.setdefault(d, []).append(l)
-
-    for dest, links in sorted(by_dest.iteritems()):
-      cmd = ('symlink("%s", ' % (dest,) +
-             ",\0".join(['"' + i + '"' for i in sorted(links)]) + ");")
-      self.script.append(self.WordWrap(cmd))
-
   def AppendExtra(self, extra):
     """Append text verbatim to the output script."""
     self.script.append(extra)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 84e0e63..fd98ad2 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -26,10 +26,12 @@
 
 """
 
+from __future__ import print_function
+
 import sys
 
 if sys.hexversion < 0x02070000:
-  print >> sys.stderr, "Python 2.7 or newer is required."
+  print("Python 2.7 or newer is required.", file=sys.stderr)
   sys.exit(1)
 
 import os
@@ -111,7 +113,7 @@
           recovery_image.AddToZip(output_zip)
 
       def banner(s):
-        print "\n\n++++ " + s + " ++++\n\n"
+        print("\n\n++++ " + s + " ++++\n\n")
 
       if not bootable_only:
         banner("AddSystem")
@@ -128,11 +130,11 @@
         add_img_to_target_files.AddCache(output_zip, prefix="")
 
   finally:
-    print "cleaning up..."
+    print("cleaning up...")
     common.ZipClose(output_zip)
     shutil.rmtree(OPTIONS.input_tmp)
 
-  print "done."
+  print("done.")
 
 
 if __name__ == '__main__':
@@ -140,7 +142,5 @@
     common.CloseInheritedPipes()
     main(sys.argv[1:])
   except common.ExternalError as e:
-    print
-    print "   ERROR: %s" % (e,)
-    print
+    print("\n   ERROR: %s\n" % (e,))
     sys.exit(1)
diff --git a/tools/releasetools/make_recovery_patch.py b/tools/releasetools/make_recovery_patch.py
index 08d1450..7c6007e 100755
--- a/tools/releasetools/make_recovery_patch.py
+++ b/tools/releasetools/make_recovery_patch.py
@@ -14,10 +14,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import print_function
+
 import sys
 
 if sys.hexversion < 0x02070000:
-  print >> sys.stderr, "Python 2.7 or newer is required."
+  print("Python 2.7 or newer is required.", file=sys.stderr)
   sys.exit(1)
 
 import os
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 199e700..1a7e10e 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -55,7 +55,6 @@
       properties on the OEM partition of the intended device.
       Multiple expected values can be used by providing multiple files.
 
-
   --oem_no_mount
       For devices with OEM-specific properties but without an OEM partition,
       do not mount the OEM partition in the updater-script. This should be
@@ -66,11 +65,6 @@
       Generate an OTA package that will wipe the user data partition
       when installed.
 
-  -n  (--no_prereq)
-      Omit the timestamp prereq check normally included at the top of
-      the build scripts (used for developer OTA packages which
-      legitimately need to go back and forth).
-
   --downgrade
       Intentionally generate an incremental OTA that updates from a newer
       build to an older one (based on timestamp comparison). "post-timestamp"
@@ -94,18 +88,16 @@
   -e  (--extra_script)  <file>
       Insert the contents of file at the end of the update script.
 
-  -a  (--aslr_mode)  <on|off>
-      Specify whether to turn on ASLR for the package (on by default).
-
   -2  (--two_step)
       Generate a 'two-step' OTA package, where recovery is updated
       first, so that any changes made to the system partition are done
       using the new recovery (new kernel, etc.).
 
   --block
-      Generate a block-based OTA if possible.  Will fall back to a
-      file-based OTA if the target_files is older and doesn't support
-      block-based OTAs.
+      Generate a block-based OTA for non-A/B device. We have deprecated the
+      support for file-based OTA since O. Block-based OTA will be used by
+      default for all non-A/B devices. Keeping this flag here to not break
+      existing callers.
 
   -b  (--binary)  <file>
       Use the given binary as the update-binary in the output package,
@@ -140,14 +132,17 @@
       Specify the arguments needed for payload signer.
 """
 
+from __future__ import print_function
+
 import sys
 
 if sys.hexversion < 0x02070000:
-  print >> sys.stderr, "Python 2.7 or newer is required."
+  print("Python 2.7 or newer is required.", file=sys.stderr)
   sys.exit(1)
 
+import copy
 import multiprocessing
-import os
+import os.path
 import subprocess
 import shlex
 import tempfile
@@ -161,21 +156,17 @@
 OPTIONS.package_key = None
 OPTIONS.incremental_source = None
 OPTIONS.verify = False
-OPTIONS.require_verbatim = set()
-OPTIONS.prohibit_verbatim = set(("system/build.prop",))
 OPTIONS.patch_threshold = 0.95
 OPTIONS.wipe_user_data = False
-OPTIONS.omit_prereq = False
 OPTIONS.downgrade = False
 OPTIONS.timestamp = False
 OPTIONS.extra_script = None
-OPTIONS.aslr_mode = True
 OPTIONS.worker_threads = multiprocessing.cpu_count() // 2
 if OPTIONS.worker_threads == 0:
   OPTIONS.worker_threads = 1
 OPTIONS.two_step = False
 OPTIONS.no_signing = False
-OPTIONS.block_based = False
+OPTIONS.block_based = True
 OPTIONS.updater_binary = None
 OPTIONS.oem_source = None
 OPTIONS.oem_no_mount = False
@@ -189,273 +180,10 @@
 OPTIONS.log_diff = None
 OPTIONS.payload_signer = None
 OPTIONS.payload_signer_args = []
+OPTIONS.extracted_input = None
 
-def MostPopularKey(d, default):
-  """Given a dict, return the key corresponding to the largest
-  value.  Returns 'default' if the dict is empty."""
-  x = [(v, k) for (k, v) in d.iteritems()]
-  if not x:
-    return default
-  x.sort()
-  return x[-1][1]
-
-
-def IsSymlink(info):
-  """Return true if the zipfile.ZipInfo object passed in represents a
-  symlink."""
-  return (info.external_attr >> 16) & 0o770000 == 0o120000
-
-def IsRegular(info):
-  """Return true if the zipfile.ZipInfo object passed in represents a
-  regular file."""
-  return (info.external_attr >> 16) & 0o770000 == 0o100000
-
-def ClosestFileMatch(src, tgtfiles, existing):
-  """Returns the closest file match between a source file and list
-     of potential matches.  The exact filename match is preferred,
-     then the sha1 is searched for, and finally a file with the same
-     basename is evaluated.  Rename support in the updater-binary is
-     required for the latter checks to be used."""
-
-  result = tgtfiles.get("path:" + src.name)
-  if result is not None:
-    return result
-
-  if not OPTIONS.target_info_dict.get("update_rename_support", False):
-    return None
-
-  if src.size < 1000:
-    return None
-
-  result = tgtfiles.get("sha1:" + src.sha1)
-  if result is not None and existing.get(result.name) is None:
-    return result
-  result = tgtfiles.get("file:" + src.name.split("/")[-1])
-  if result is not None and existing.get(result.name) is None:
-    return result
-  return None
-
-class ItemSet(object):
-  def __init__(self, partition, fs_config):
-    self.partition = partition
-    self.fs_config = fs_config
-    self.ITEMS = {}
-
-  def Get(self, name, is_dir=False):
-    if name not in self.ITEMS:
-      self.ITEMS[name] = Item(self, name, is_dir=is_dir)
-    return self.ITEMS[name]
-
-  def GetMetadata(self, input_zip):
-    # The target_files contains a record of what the uid,
-    # gid, and mode are supposed to be.
-    output = input_zip.read(self.fs_config)
-
-    for line in output.split("\n"):
-      if not line:
-        continue
-      columns = line.split()
-      name, uid, gid, mode = columns[:4]
-      selabel = None
-      capabilities = None
-
-      # After the first 4 columns, there are a series of key=value
-      # pairs. Extract out the fields we care about.
-      for element in columns[4:]:
-        key, value = element.split("=")
-        if key == "selabel":
-          selabel = value
-        if key == "capabilities":
-          capabilities = value
-
-      i = self.ITEMS.get(name, None)
-      if i is not None:
-        i.uid = int(uid)
-        i.gid = int(gid)
-        i.mode = int(mode, 8)
-        i.selabel = selabel
-        i.capabilities = capabilities
-        if i.is_dir:
-          i.children.sort(key=lambda i: i.name)
-
-    # Set metadata for the files generated by this script. For full recovery
-    # image at system/etc/recovery.img, it will be taken care by fs_config.
-    i = self.ITEMS.get("system/recovery-from-boot.p", None)
-    if i:
-      i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0o644, None, None
-    i = self.ITEMS.get("system/etc/install-recovery.sh", None)
-    if i:
-      i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0o544, None, None
-
-
-class Item(object):
-  """Items represent the metadata (user, group, mode) of files and
-  directories in the system image."""
-  def __init__(self, itemset, name, is_dir=False):
-    self.itemset = itemset
-    self.name = name
-    self.uid = None
-    self.gid = None
-    self.mode = None
-    self.selabel = None
-    self.capabilities = None
-    self.is_dir = is_dir
-    self.descendants = None
-    self.best_subtree = None
-
-    if name:
-      self.parent = itemset.Get(os.path.dirname(name), is_dir=True)
-      self.parent.children.append(self)
-    else:
-      self.parent = None
-    if self.is_dir:
-      self.children = []
-
-  def Dump(self, indent=0):
-    if self.uid is not None:
-      print "%s%s %d %d %o" % (
-          "  " * indent, self.name, self.uid, self.gid, self.mode)
-    else:
-      print "%s%s %s %s %s" % (
-          "  " * indent, self.name, self.uid, self.gid, self.mode)
-    if self.is_dir:
-      print "%s%s" % ("  "*indent, self.descendants)
-      print "%s%s" % ("  "*indent, self.best_subtree)
-      for i in self.children:
-        i.Dump(indent=indent+1)
-
-  def CountChildMetadata(self):
-    """Count up the (uid, gid, mode, selabel, capabilities) tuples for
-    all children and determine the best strategy for using set_perm_recursive
-    and set_perm to correctly chown/chmod all the files to their desired
-    values.  Recursively calls itself for all descendants.
-
-    Returns a dict of {(uid, gid, dmode, fmode, selabel, capabilities): count}
-    counting up all descendants of this node.  (dmode or fmode may be None.)
-    Also sets the best_subtree of each directory Item to the (uid, gid, dmode,
-    fmode, selabel, capabilities) tuple that will match the most descendants of
-    that Item.
-    """
-
-    assert self.is_dir
-    key = (self.uid, self.gid, self.mode, None, self.selabel,
-           self.capabilities)
-    self.descendants = {key: 1}
-    d = self.descendants
-    for i in self.children:
-      if i.is_dir:
-        for k, v in i.CountChildMetadata().iteritems():
-          d[k] = d.get(k, 0) + v
-      else:
-        k = (i.uid, i.gid, None, i.mode, i.selabel, i.capabilities)
-        d[k] = d.get(k, 0) + 1
-
-    # Find the (uid, gid, dmode, fmode, selabel, capabilities)
-    # tuple that matches the most descendants.
-
-    # First, find the (uid, gid) pair that matches the most
-    # descendants.
-    ug = {}
-    for (uid, gid, _, _, _, _), count in d.iteritems():
-      ug[(uid, gid)] = ug.get((uid, gid), 0) + count
-    ug = MostPopularKey(ug, (0, 0))
-
-    # Now find the dmode, fmode, selabel, and capabilities that match
-    # the most descendants with that (uid, gid), and choose those.
-    best_dmode = (0, 0o755)
-    best_fmode = (0, 0o644)
-    best_selabel = (0, None)
-    best_capabilities = (0, None)
-    for k, count in d.iteritems():
-      if k[:2] != ug:
-        continue
-      if k[2] is not None and count >= best_dmode[0]:
-        best_dmode = (count, k[2])
-      if k[3] is not None and count >= best_fmode[0]:
-        best_fmode = (count, k[3])
-      if k[4] is not None and count >= best_selabel[0]:
-        best_selabel = (count, k[4])
-      if k[5] is not None and count >= best_capabilities[0]:
-        best_capabilities = (count, k[5])
-    self.best_subtree = ug + (
-        best_dmode[1], best_fmode[1], best_selabel[1], best_capabilities[1])
-
-    return d
-
-  def SetPermissions(self, script):
-    """Append set_perm/set_perm_recursive commands to 'script' to
-    set all permissions, users, and groups for the tree of files
-    rooted at 'self'."""
-
-    self.CountChildMetadata()
-
-    def recurse(item, current):
-      # current is the (uid, gid, dmode, fmode, selabel, capabilities) tuple
-      # that the current item (and all its children) have already been set to.
-      # We only need to issue set_perm/set_perm_recursive commands if we're
-      # supposed to be something different.
-      if item.is_dir:
-        if current != item.best_subtree:
-          script.SetPermissionsRecursive("/"+item.name, *item.best_subtree)
-          current = item.best_subtree
-
-        if item.uid != current[0] or item.gid != current[1] or \
-           item.mode != current[2] or item.selabel != current[4] or \
-           item.capabilities != current[5]:
-          script.SetPermissions("/"+item.name, item.uid, item.gid,
-                                item.mode, item.selabel, item.capabilities)
-
-        for i in item.children:
-          recurse(i, current)
-      else:
-        if item.uid != current[0] or item.gid != current[1] or \
-               item.mode != current[3] or item.selabel != current[4] or \
-               item.capabilities != current[5]:
-          script.SetPermissions("/"+item.name, item.uid, item.gid,
-                                item.mode, item.selabel, item.capabilities)
-
-    recurse(self, (-1, -1, -1, -1, None, None))
-
-
-def CopyPartitionFiles(itemset, input_zip, output_zip=None, substitute=None):
-  """Copies files for the partition in the input zip to the output
-  zip.  Populates the Item class with their metadata, and returns a
-  list of symlinks.  output_zip may be None, in which case the copy is
-  skipped (but the other side effects still happen).  substitute is an
-  optional dict of {output filename: contents} to be output instead of
-  certain input files.
-  """
-
-  symlinks = []
-
-  partition = itemset.partition
-
-  for info in input_zip.infolist():
-    prefix = partition.upper() + "/"
-    if info.filename.startswith(prefix):
-      basefilename = info.filename[len(prefix):]
-      if IsSymlink(info):
-        symlinks.append((input_zip.read(info.filename),
-                         "/" + partition + "/" + basefilename))
-      else:
-        import copy
-        info2 = copy.copy(info)
-        fn = info2.filename = partition + "/" + basefilename
-        if substitute and fn in substitute and substitute[fn] is None:
-          continue
-        if output_zip is not None:
-          if substitute and fn in substitute:
-            data = substitute[fn]
-          else:
-            data = input_zip.read(info.filename)
-          common.ZipWriteStr(output_zip, info2, data)
-        if fn.endswith("/"):
-          itemset.Get(fn[:-1], is_dir=True)
-        else:
-          itemset.Get(fn)
-
-  symlinks.sort()
-  return symlinks
+METADATA_NAME = 'META-INF/com/android/metadata'
+UNZIP_PATTERN = ['IMAGES/*', 'META/*']
 
 
 def SignOutput(temp_zip_name, output_zip_name):
@@ -491,7 +219,7 @@
   oem_dicts = None
   if OPTIONS.oem_source is None:
     raise common.ExternalError("OEM source required for this build")
-  if not OPTIONS.oem_no_mount:
+  if not OPTIONS.oem_no_mount and script:
     script.Mount("/oem", recovery_mount_options)
   oem_dicts = []
   for oem_file in OPTIONS.oem_source:
@@ -524,11 +252,11 @@
         OPTIONS.input_tmp, "RECOVERY")
     common.ZipWriteStr(
         output_zip, recovery_two_step_img_name, recovery_two_step_img.data)
-    print "two-step package: using %s in stage 1/3" % (
-        recovery_two_step_img_name,)
+    print("two-step package: using %s in stage 1/3" % (
+        recovery_two_step_img_name,))
     script.WriteRawImage("/boot", recovery_two_step_img_name)
   else:
-    print "two-step package: using recovery.img in stage 1/3"
+    print("two-step package: using recovery.img in stage 1/3")
     # The "recovery.img" entry has been written into package earlier.
     script.WriteRawImage("/boot", "recovery.img")
 
@@ -538,6 +266,7 @@
   return ("SYSTEM/recovery-from-boot.p" in namelist or
           "SYSTEM/etc/recovery.img" in namelist)
 
+
 def HasVendorPartition(target_files_zip):
   try:
     target_files_zip.getinfo("VENDOR/")
@@ -545,6 +274,7 @@
   except KeyError:
     return False
 
+
 def GetOemProperty(name, oem_props, oem_dict, info_dict):
   if oem_props is not None and name in oem_props:
     return oem_dict[name]
@@ -561,36 +291,21 @@
       GetBuildProp("ro.build.thumbprint", info_dict))
 
 
-def GetImage(which, tmpdir, info_dict):
-  # Return an image object (suitable for passing to BlockImageDiff)
-  # for the 'which' partition (most be "system" or "vendor").  If a
-  # prebuilt image and file map are found in tmpdir they are used,
-  # otherwise they are reconstructed from the individual files.
+def GetImage(which, tmpdir):
+  """Returns an image object suitable for passing to BlockImageDiff.
+
+  'which' partition must be "system" or "vendor". A prebuilt image and file
+  map must already exist in tmpdir.
+  """
 
   assert which in ("system", "vendor")
 
   path = os.path.join(tmpdir, "IMAGES", which + ".img")
   mappath = os.path.join(tmpdir, "IMAGES", which + ".map")
-  if os.path.exists(path) and os.path.exists(mappath):
-    print "using %s.img from target-files" % (which,)
-    # This is a 'new' target-files, which already has the image in it.
 
-  else:
-    print "building %s.img from target-files" % (which,)
-
-    # This is an 'old' target-files, which does not contain images
-    # already built.  Build them.
-
-    mappath = tempfile.mkstemp()[1]
-    OPTIONS.tempfiles.append(mappath)
-
-    import add_img_to_target_files
-    if which == "system":
-      path = add_img_to_target_files.BuildSystem(
-          tmpdir, info_dict, block_list=mappath)
-    elif which == "vendor":
-      path = add_img_to_target_files.BuildVendor(
-          tmpdir, info_dict, block_list=mappath)
+  # The image and map files must have been created prior to calling
+  # ota_from_target_files.py (since LMP).
+  assert os.path.exists(path) and os.path.exists(mappath)
 
   # Bug: http://b/20939131
   # In ext4 filesystems, block 0 might be changed even being mounted
@@ -601,6 +316,59 @@
   return sparse_img.SparseImage(path, mappath, clobbered_blocks)
 
 
+def AddCompatibilityArchive(target_zip, output_zip, system_included=True,
+                            vendor_included=True):
+  """Adds compatibility info from target files into the output zip.
+
+  Metadata used for on-device compatibility verification is retrieved from
+  target_zip then added to compatibility.zip which is added to the output_zip
+  archive.
+
+  Compatibility archive should only be included for devices with a vendor
+  partition as checking provides value when system and vendor are independently
+  versioned.
+
+  Args:
+    target_zip: Zip file containing the source files to be included for OTA.
+    output_zip: Zip file that will be sent for OTA.
+    system_included: If True, the system image will be updated and therefore
+        its metadata should be included.
+    vendor_included: If True, the vendor image will be updated and therefore
+        its metadata should be included.
+  """
+
+  # Determine what metadata we need. Files are names relative to META/.
+  compatibility_files = []
+  vendor_metadata = ("vendor_manifest.xml", "vendor_matrix.xml")
+  system_metadata = ("system_manifest.xml", "system_matrix.xml")
+  if vendor_included:
+    compatibility_files += vendor_metadata
+  if system_included:
+    compatibility_files += system_metadata
+
+  # Create new archive.
+  compatibility_archive = tempfile.NamedTemporaryFile()
+  compatibility_archive_zip = zipfile.ZipFile(compatibility_archive, "w",
+      compression=zipfile.ZIP_DEFLATED)
+
+  # Add metadata.
+  for file_name in compatibility_files:
+    target_file_name = "META/" + file_name
+
+    if target_file_name in target_zip.namelist():
+      data = target_zip.read(target_file_name)
+      common.ZipWriteStr(compatibility_archive_zip, file_name, data)
+
+  # Ensure files are written before we copy into output_zip.
+  compatibility_archive_zip.close()
+
+  # Only add the archive if we have any compatibility info.
+  if compatibility_archive_zip.namelist():
+    common.ZipWrite(output_zip, compatibility_archive.name,
+                    arcname="compatibility.zip",
+                    compress_type=zipfile.ZIP_STORED)
+
+
 def WriteFullOTAPackage(input_zip, output_zip):
   # TODO: how to determine this?  We don't know what version it will
   # be installed on top of. For now, we expect the API just won't
@@ -608,15 +376,16 @@
   # in the target build.
   script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
 
-  oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
   recovery_mount_options = OPTIONS.info_dict.get("recovery_mount_options")
+  oem_props = OPTIONS.info_dict.get("oem_fingerprint_properties")
   oem_dicts = None
   if oem_props:
     oem_dicts = _LoadOemDicts(script, recovery_mount_options)
 
+  target_fp = CalculateFingerprint(oem_props, oem_dicts and oem_dicts[0],
+                                   OPTIONS.info_dict)
   metadata = {
-      "post-build": CalculateFingerprint(oem_props, oem_dicts and oem_dicts[0],
-                                         OPTIONS.info_dict),
+      "post-build": target_fp,
       "pre-device": GetOemProperty("ro.product.device", oem_props,
                                    oem_dicts and oem_dicts[0],
                                    OPTIONS.info_dict),
@@ -632,15 +401,13 @@
       metadata=metadata,
       info_dict=OPTIONS.info_dict)
 
-  has_recovery_patch = HasRecoveryPatch(input_zip)
-  block_based = OPTIONS.block_based and has_recovery_patch
+  assert HasRecoveryPatch(input_zip)
 
-  metadata["ota-type"] = "BLOCK" if block_based else "FILE"
+  metadata["ota-type"] = "BLOCK"
 
-  if not OPTIONS.omit_prereq:
-    ts = GetBuildProp("ro.build.date.utc", OPTIONS.info_dict)
-    ts_text = GetBuildProp("ro.build.date", OPTIONS.info_dict)
-    script.AssertOlderBuild(ts, ts_text)
+  ts = GetBuildProp("ro.build.date.utc", OPTIONS.info_dict)
+  ts_text = GetBuildProp("ro.build.date", OPTIONS.info_dict)
+  script.AssertOlderBuild(ts, ts_text)
 
   AppendAssertions(script, OPTIONS.info_dict, oem_dicts)
   device_specific.FullOTA_Assertions()
@@ -692,8 +459,7 @@
     script.Comment("Stage 3/3")
 
   # Dump fingerprints
-  script.Print("Target: %s" % CalculateFingerprint(
-      oem_props, oem_dicts and oem_dicts[0], OPTIONS.info_dict))
+  script.Print("Target: %s" % target_fp)
 
   device_specific.FullOTA_InstallBegin()
 
@@ -711,61 +477,27 @@
 
   recovery_mount_options = OPTIONS.info_dict.get("recovery_mount_options")
 
-  system_items = ItemSet("system", "META/filesystem_config.txt")
   script.ShowProgress(system_progress, 0)
 
-  if block_based:
-    # Full OTA is done as an "incremental" against an empty source
-    # image.  This has the effect of writing new data from the package
-    # to the entire partition, but lets us reuse the updater code that
-    # writes incrementals to do it.
-    system_tgt = GetImage("system", OPTIONS.input_tmp, OPTIONS.info_dict)
-    system_tgt.ResetFileMap()
-    system_diff = common.BlockDifference("system", system_tgt, src=None)
-    system_diff.WriteScript(script, output_zip)
-  else:
-    script.FormatPartition("/system")
-    script.Mount("/system", recovery_mount_options)
-    if not has_recovery_patch:
-      script.UnpackPackageDir("recovery", "/system")
-    script.UnpackPackageDir("system", "/system")
-
-    symlinks = CopyPartitionFiles(system_items, input_zip, output_zip)
-    script.MakeSymlinks(symlinks)
+  # Full OTA is done as an "incremental" against an empty source image. This
+  # has the effect of writing new data from the package to the entire
+  # partition, but lets us reuse the updater code that writes incrementals to
+  # do it.
+  system_tgt = GetImage("system", OPTIONS.input_tmp)
+  system_tgt.ResetFileMap()
+  system_diff = common.BlockDifference("system", system_tgt, src=None)
+  system_diff.WriteScript(script, output_zip)
 
   boot_img = common.GetBootableImage(
       "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
 
-  if not block_based:
-    def output_sink(fn, data):
-      common.ZipWriteStr(output_zip, "recovery/" + fn, data)
-      system_items.Get("system/" + fn)
-
-    common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink,
-                             recovery_img, boot_img)
-
-    system_items.GetMetadata(input_zip)
-    system_items.Get("system").SetPermissions(script)
-
   if HasVendorPartition(input_zip):
-    vendor_items = ItemSet("vendor", "META/vendor_filesystem_config.txt")
     script.ShowProgress(0.1, 0)
 
-    if block_based:
-      vendor_tgt = GetImage("vendor", OPTIONS.input_tmp, OPTIONS.info_dict)
-      vendor_tgt.ResetFileMap()
-      vendor_diff = common.BlockDifference("vendor", vendor_tgt)
-      vendor_diff.WriteScript(script, output_zip)
-    else:
-      script.FormatPartition("/vendor")
-      script.Mount("/vendor", recovery_mount_options)
-      script.UnpackPackageDir("vendor", "/vendor")
-
-      symlinks = CopyPartitionFiles(vendor_items, input_zip, output_zip)
-      script.MakeSymlinks(symlinks)
-
-      vendor_items.GetMetadata(input_zip)
-      vendor_items.Get("vendor").SetPermissions(script)
+    vendor_tgt = GetImage("vendor", OPTIONS.input_tmp)
+    vendor_tgt.ResetFileMap()
+    vendor_diff = common.BlockDifference("vendor", vendor_tgt)
+    vendor_diff.WriteScript(script, output_zip)
 
   common.CheckSize(boot_img.data, "boot.img", OPTIONS.info_dict)
   common.ZipWriteStr(output_zip, "boot.img", boot_img.data)
@@ -813,23 +545,9 @@
 
 
 def WriteMetadata(metadata, output_zip):
-  common.ZipWriteStr(output_zip, "META-INF/com/android/metadata",
-                     "".join(["%s=%s\n" % kv
-                              for kv in sorted(metadata.iteritems())]))
-
-
-def LoadPartitionFiles(z, partition):
-  """Load all the files from the given partition in a given target-files
-  ZipFile, and return a dict of {filename: File object}."""
-  out = {}
-  prefix = partition.upper() + "/"
-  for info in z.infolist():
-    if info.filename.startswith(prefix) and not IsSymlink(info):
-      basefilename = info.filename[len(prefix):]
-      fn = partition + "/" + basefilename
-      data = z.read(info.filename)
-      out[fn] = common.File(fn, data)
-  return out
+  value = "".join(["%s=%s\n" % kv for kv in sorted(metadata.iteritems())])
+  common.ZipWriteStr(output_zip, METADATA_NAME, value,
+                     compress_type=zipfile.ZIP_STORED)
 
 
 def GetBuildProp(prop, info_dict):
@@ -840,18 +558,6 @@
     raise common.ExternalError("couldn't find %s in build.prop" % (prop,))
 
 
-def AddToKnownPaths(filename, known_paths):
-  if filename[-1] == "/":
-    return
-  dirs = filename.split("/")[:-1]
-  while len(dirs) > 0:
-    path = "/".join(dirs)
-    if path in known_paths:
-      break
-    known_paths.add(path)
-    dirs.pop()
-
-
 def HandleDowngradeMetadata(metadata):
   # Only incremental OTAs are allowed to reach here.
   assert OPTIONS.incremental_source is not None
@@ -880,14 +586,12 @@
 
 
 def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
-  # TODO(tbao): We should factor out the common parts between
-  # WriteBlockIncrementalOTAPackage() and WriteIncrementalOTAPackage().
   source_version = OPTIONS.source_info_dict["recovery_api_version"]
   target_version = OPTIONS.target_info_dict["recovery_api_version"]
 
   if source_version == 0:
-    print ("WARNING: generating edify script for a source that "
-           "can't install it.")
+    print("WARNING: generating edify script for a source that "
+          "can't install it.")
   script = edify_generator.EdifyGenerator(
       source_version, OPTIONS.target_info_dict,
       fstab=OPTIONS.source_info_dict["fstab"])
@@ -897,7 +601,7 @@
   source_oem_props = OPTIONS.source_info_dict.get("oem_fingerprint_properties")
   target_oem_props = OPTIONS.target_info_dict.get("oem_fingerprint_properties")
   oem_dicts = None
-  if source_oem_props or target_oem_props:
+  if source_oem_props and target_oem_props:
     oem_dicts = _LoadOemDicts(script, recovery_mount_options)
 
   metadata = {
@@ -941,8 +645,8 @@
   target_recovery = common.GetBootableImage(
       "/tmp/recovery.img", "recovery.img", OPTIONS.target_tmp, "RECOVERY")
 
-  system_src = GetImage("system", OPTIONS.source_tmp, OPTIONS.source_info_dict)
-  system_tgt = GetImage("system", OPTIONS.target_tmp, OPTIONS.target_info_dict)
+  system_src = GetImage("system", OPTIONS.source_tmp)
+  system_tgt = GetImage("system", OPTIONS.target_tmp)
 
   blockimgdiff_version = 1
   if OPTIONS.info_dict:
@@ -969,10 +673,8 @@
   if HasVendorPartition(target_zip):
     if not HasVendorPartition(source_zip):
       raise RuntimeError("can't generate incremental that adds /vendor")
-    vendor_src = GetImage("vendor", OPTIONS.source_tmp,
-                          OPTIONS.source_info_dict)
-    vendor_tgt = GetImage("vendor", OPTIONS.target_tmp,
-                          OPTIONS.target_info_dict)
+    vendor_src = GetImage("vendor", OPTIONS.source_tmp)
+    vendor_tgt = GetImage("vendor", OPTIONS.target_tmp)
 
     # Check first block of vendor partition for remount R/W only if
     # disk type is ext4
@@ -1089,8 +791,8 @@
     else:
       include_full_boot = False
 
-      print "boot      target: %d  source: %d  diff: %d" % (
-          target_boot.size, source_boot.size, len(d))
+      print("boot      target: %d  source: %d  diff: %d" % (
+          target_boot.size, source_boot.size, len(d)))
 
       common.ZipWriteStr(output_zip, "patch/boot.img.p", d)
 
@@ -1136,19 +838,19 @@
   if OPTIONS.two_step:
     common.ZipWriteStr(output_zip, "boot.img", target_boot.data)
     script.WriteRawImage("/boot", "boot.img")
-    print "writing full boot image (forced by two-step mode)"
+    print("writing full boot image (forced by two-step mode)")
 
   if not OPTIONS.two_step:
     if updating_boot:
       if include_full_boot:
-        print "boot image changed; including full."
+        print("boot image changed; including full.")
         script.Print("Installing boot image...")
         script.WriteRawImage("/boot", "boot.img")
       else:
         # Produce the boot image by applying a patch to the current
         # contents of the boot partition, and write it back to the
         # partition.
-        print "boot image changed; including patch."
+        print("boot image changed; including patch.")
         script.Print("Patching boot image...")
         script.ShowProgress(0.1, 10)
         script.ApplyPatch("%s:%s:%d:%s:%d:%s"
@@ -1159,7 +861,7 @@
                           target_boot.size, target_boot.sha1,
                           source_boot.sha1, "patch/boot.img.p")
     else:
-      print "boot image unchanged; skipping."
+      print("boot image unchanged; skipping.")
 
   # Do device-specific installation (eg, write radio image).
   device_specific.IncrementalOTA_InstallEnd()
@@ -1242,13 +944,13 @@
       recovery_type, recovery_device, recovery_img.size, recovery_img.sha1))
   script.AppendExtra("")
 
-  system_tgt = GetImage("system", OPTIONS.input_tmp, OPTIONS.info_dict)
+  system_tgt = GetImage("system", OPTIONS.input_tmp)
   system_tgt.ResetFileMap()
   system_diff = common.BlockDifference("system", system_tgt, src=None)
   system_diff.WriteStrictVerifyScript(script)
 
   if HasVendorPartition(input_zip):
-    vendor_tgt = GetImage("vendor", OPTIONS.input_tmp, OPTIONS.info_dict)
+    vendor_tgt = GetImage("vendor", OPTIONS.input_tmp)
     vendor_tgt.ResetFileMap()
     vendor_diff = common.BlockDifference("vendor", vendor_tgt, src=None)
     vendor_diff.WriteStrictVerifyScript(script)
@@ -1266,6 +968,59 @@
                                       source_file=None):
   """Generate an Android OTA package that has A/B update payload."""
 
+  def ComputeStreamingMetadata(zip_file, reserve_space=False,
+                               expected_length=None):
+    """Compute the streaming metadata for a given zip.
+
+    When 'reserve_space' is True, we reserve extra space for the offset and
+    length of the metadata entry itself, although we don't know the final
+    values until the package gets signed. This function will be called again
+    after signing. We then write the actual values and pad the string to the
+    length we set earlier. Note that we can't use the actual length of the
+    metadata entry in the second run. Otherwise the offsets for other entries
+    will be changing again.
+    """
+
+    def ComputeEntryOffsetSize(name):
+      """Compute the zip entry offset and size."""
+      info = zip_file.getinfo(name)
+      offset = info.header_offset + len(info.FileHeader())
+      size = info.file_size
+      return '%s:%d:%d' % (os.path.basename(name), offset, size)
+
+    # payload.bin and payload_properties.txt must exist.
+    offsets = [ComputeEntryOffsetSize('payload.bin'),
+               ComputeEntryOffsetSize('payload_properties.txt')]
+
+    # care_map.txt is available only if dm-verity is enabled.
+    if 'care_map.txt' in zip_file.namelist():
+      offsets.append(ComputeEntryOffsetSize('care_map.txt'))
+
+    if 'compatibility.zip' in zip_file.namelist():
+      offsets.append(ComputeEntryOffsetSize('compatibility.zip'))
+
+    # 'META-INF/com/android/metadata' is required. We don't know its actual
+    # offset and length (as well as the values for other entries). So we
+    # reserve 10-byte as a placeholder, which is to cover the space for metadata
+    # entry ('xx:xxx', since it's ZIP_STORED which should appear at the
+    # beginning of the zip), as well as the possible value changes in other
+    # entries.
+    if reserve_space:
+      offsets.append('metadata:' + ' ' * 10)
+    else:
+      offsets.append(ComputeEntryOffsetSize(METADATA_NAME))
+
+    value = ','.join(offsets)
+    if expected_length is not None:
+      assert len(value) <= expected_length, \
+          'Insufficient reserved space: reserved=%d, actual=%d' % (
+              expected_length, len(value))
+      value += ' ' * (expected_length - len(value))
+    return value
+
+  # The place where the output from the subprocess should go.
+  log_file = sys.stdout if OPTIONS.verbose else subprocess.PIPE
+
   # Setup signing keys.
   if OPTIONS.package_key is None:
     OPTIONS.package_key = OPTIONS.info_dict.get(
@@ -1280,8 +1035,8 @@
            "-inform", "DER", "-nocrypt"]
     rsa_key = common.MakeTempFile(prefix="key-", suffix=".key")
     cmd.extend(["-out", rsa_key])
-    p1 = common.Run(cmd, stdout=subprocess.PIPE)
-    p1.wait()
+    p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+    p1.communicate()
     assert p1.returncode == 0, "openssl pkcs8 failed"
 
   # Stage the output zip package for package signing.
@@ -1326,8 +1081,8 @@
          "--target_image", target_file]
   if source_file is not None:
     cmd.extend(["--source_image", source_file])
-  p1 = common.Run(cmd, stdout=subprocess.PIPE)
-  p1.wait()
+  p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+  p1.communicate()
   assert p1.returncode == 0, "brillo_update_payload generate failed"
 
   # 2. Generate hashes of the payload and metadata files.
@@ -1338,8 +1093,8 @@
          "--signature_size", "256",
          "--metadata_hash_file", metadata_sig_file,
          "--payload_hash_file", payload_sig_file]
-  p1 = common.Run(cmd, stdout=subprocess.PIPE)
-  p1.wait()
+  p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+  p1.communicate()
   assert p1.returncode == 0, "brillo_update_payload hash failed"
 
   # 3. Sign the hashes and insert them back into the payload file.
@@ -1357,9 +1112,8 @@
            "-pkeyopt", "digest:sha256"]
   cmd.extend(["-in", payload_sig_file,
               "-out", signed_payload_sig_file])
-
-  p1 = common.Run(cmd, stdout=subprocess.PIPE)
-  p1.wait()
+  p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+  p1.communicate()
   assert p1.returncode == 0, "openssl sign payload failed"
 
   # 3b. Sign the metadata hash.
@@ -1372,8 +1126,8 @@
            "-pkeyopt", "digest:sha256"]
   cmd.extend(["-in", metadata_sig_file,
               "-out", signed_metadata_sig_file])
-  p1 = common.Run(cmd, stdout=subprocess.PIPE)
-  p1.wait()
+  p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+  p1.communicate()
   assert p1.returncode == 0, "openssl sign metadata failed"
 
   # 3c. Insert the signatures back into the payload file.
@@ -1385,8 +1139,8 @@
          "--signature_size", "256",
          "--metadata_signature_file", signed_metadata_sig_file,
          "--payload_signature_file", signed_payload_sig_file]
-  p1 = common.Run(cmd, stdout=subprocess.PIPE)
-  p1.wait()
+  p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+  p1.communicate()
   assert p1.returncode == 0, "brillo_update_payload sign failed"
 
   # 4. Dump the signed payload properties.
@@ -1395,8 +1149,8 @@
   cmd = ["brillo_update_payload", "properties",
          "--payload", signed_payload_file,
          "--properties_file", properties_file]
-  p1 = common.Run(cmd, stdout=subprocess.PIPE)
-  p1.wait()
+  p1 = common.Run(cmd, stdout=log_file, stderr=subprocess.STDOUT)
+  p1.communicate()
   assert p1.returncode == 0, "brillo_update_payload properties failed"
 
   if OPTIONS.wipe_user_data:
@@ -1404,579 +1158,107 @@
       f.write("POWERWASH=1\n")
     metadata["ota-wipe"] = "yes"
 
-  # Add the signed payload file and properties into the zip.
-  common.ZipWrite(output_zip, properties_file, arcname="payload_properties.txt")
+  # Add the signed payload file and properties into the zip. In order to
+  # support streaming, we pack payload.bin, payload_properties.txt and
+  # care_map.txt as ZIP_STORED. So these entries can be read directly with
+  # the offset and length pairs.
   common.ZipWrite(output_zip, signed_payload_file, arcname="payload.bin",
                   compress_type=zipfile.ZIP_STORED)
-  WriteMetadata(metadata, output_zip)
+  common.ZipWrite(output_zip, properties_file,
+                  arcname="payload_properties.txt",
+                  compress_type=zipfile.ZIP_STORED)
 
   # If dm-verity is supported for the device, copy contents of care_map
   # into A/B OTA package.
+  target_zip = zipfile.ZipFile(target_file, "r")
   if OPTIONS.info_dict.get("verity") == "true":
-    target_zip = zipfile.ZipFile(target_file, "r")
     care_map_path = "META/care_map.txt"
     namelist = target_zip.namelist()
     if care_map_path in namelist:
       care_map_data = target_zip.read(care_map_path)
-      common.ZipWriteStr(output_zip, "care_map.txt", care_map_data)
+      common.ZipWriteStr(output_zip, "care_map.txt", care_map_data,
+          compress_type=zipfile.ZIP_STORED)
     else:
-      print "Warning: cannot find care map file in target_file package"
-    common.ZipClose(target_zip)
+      print("Warning: cannot find care map file in target_file package")
 
-  # Sign the whole package to comply with the Android OTA package format.
-  common.ZipClose(output_zip)
-  SignOutput(temp_zip_file.name, output_file)
-  temp_zip_file.close()
-
-
-class FileDifference(object):
-  def __init__(self, partition, source_zip, target_zip, output_zip):
-    self.deferred_patch_list = None
-    print "Loading target..."
-    self.target_data = target_data = LoadPartitionFiles(target_zip, partition)
-    print "Loading source..."
-    self.source_data = source_data = LoadPartitionFiles(source_zip, partition)
-
-    self.verbatim_targets = verbatim_targets = []
-    self.patch_list = patch_list = []
-    diffs = []
-    self.renames = renames = {}
-    known_paths = set()
-    largest_source_size = 0
-
-    matching_file_cache = {}
-    for fn, sf in source_data.items():
-      assert fn == sf.name
-      matching_file_cache["path:" + fn] = sf
-      if fn in target_data.keys():
-        AddToKnownPaths(fn, known_paths)
-      # Only allow eligibility for filename/sha matching
-      # if there isn't a perfect path match.
-      if target_data.get(sf.name) is None:
-        matching_file_cache["file:" + fn.split("/")[-1]] = sf
-        matching_file_cache["sha:" + sf.sha1] = sf
-
-    for fn in sorted(target_data.keys()):
-      tf = target_data[fn]
-      assert fn == tf.name
-      sf = ClosestFileMatch(tf, matching_file_cache, renames)
-      if sf is not None and sf.name != tf.name:
-        print "File has moved from " + sf.name + " to " + tf.name
-        renames[sf.name] = tf
-
-      if sf is None or fn in OPTIONS.require_verbatim:
-        # This file should be included verbatim
-        if fn in OPTIONS.prohibit_verbatim:
-          raise common.ExternalError("\"%s\" must be sent verbatim" % (fn,))
-        print "send", fn, "verbatim"
-        tf.AddToZip(output_zip)
-        verbatim_targets.append((fn, tf.size, tf.sha1))
-        if fn in target_data.keys():
-          AddToKnownPaths(fn, known_paths)
-      elif tf.sha1 != sf.sha1:
-        # File is different; consider sending as a patch
-        diffs.append(common.Difference(tf, sf))
-      else:
-        # Target file data identical to source (may still be renamed)
-        pass
-
-    common.ComputeDifferences(diffs)
-
-    for diff in diffs:
-      tf, sf, d = diff.GetPatch()
-      path = "/".join(tf.name.split("/")[:-1])
-      if d is None or len(d) > tf.size * OPTIONS.patch_threshold or \
-          path not in known_paths:
-        # patch is almost as big as the file; don't bother patching
-        # or a patch + rename cannot take place due to the target
-        # directory not existing
-        tf.AddToZip(output_zip)
-        verbatim_targets.append((tf.name, tf.size, tf.sha1))
-        if sf.name in renames:
-          del renames[sf.name]
-        AddToKnownPaths(tf.name, known_paths)
-      else:
-        common.ZipWriteStr(output_zip, "patch/" + sf.name + ".p", d)
-        patch_list.append((tf, sf, tf.size, common.sha1(d).hexdigest()))
-        largest_source_size = max(largest_source_size, sf.size)
-
-    self.largest_source_size = largest_source_size
-
-  def EmitVerification(self, script):
-    so_far = 0
-    for tf, sf, _, _ in self.patch_list:
-      if tf.name != sf.name:
-        script.SkipNextActionIfTargetExists(tf.name, tf.sha1)
-      script.PatchCheck("/"+sf.name, tf.sha1, sf.sha1)
-      so_far += sf.size
-    return so_far
-
-  def EmitExplicitTargetVerification(self, script):
-    for fn, _, sha1 in self.verbatim_targets:
-      if fn[-1] != "/":
-        script.FileCheck("/"+fn, sha1)
-    for tf, _, _, _ in self.patch_list:
-      script.FileCheck(tf.name, tf.sha1)
-
-  def RemoveUnneededFiles(self, script, extras=()):
-    file_list = ["/" + i[0] for i in self.verbatim_targets]
-    file_list += ["/" + i for i in self.source_data
-                  if i not in self.target_data and i not in self.renames]
-    file_list += list(extras)
-    # Sort the list in descending order, which removes all the files first
-    # before attempting to remove the folder. (Bug: 22960996)
-    script.DeleteFiles(sorted(file_list, reverse=True))
-
-  def TotalPatchSize(self):
-    return sum(i[1].size for i in self.patch_list)
-
-  def EmitPatches(self, script, total_patch_size, so_far):
-    self.deferred_patch_list = deferred_patch_list = []
-    for item in self.patch_list:
-      tf, sf, _, _ = item
-      if tf.name == "system/build.prop":
-        deferred_patch_list.append(item)
-        continue
-      if sf.name != tf.name:
-        script.SkipNextActionIfTargetExists(tf.name, tf.sha1)
-      script.ApplyPatch("/" + sf.name, "-", tf.size, tf.sha1, sf.sha1,
-                        "patch/" + sf.name + ".p")
-      so_far += tf.size
-      script.SetProgress(so_far / total_patch_size)
-    return so_far
-
-  def EmitDeferredPatches(self, script):
-    for item in self.deferred_patch_list:
-      tf, sf, _, _ = item
-      script.ApplyPatch("/"+sf.name, "-", tf.size, tf.sha1, sf.sha1,
-                        "patch/" + sf.name + ".p")
-    script.SetPermissions("/system/build.prop", 0, 0, 0o644, None, None)
-
-  def EmitRenames(self, script):
-    if len(self.renames) > 0:
-      script.Print("Renaming files...")
-      for src, tgt in self.renames.iteritems():
-        print "Renaming " + src + " to " + tgt.name
-        script.RenameFile(src, tgt.name)
-
-
-def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
-  target_has_recovery_patch = HasRecoveryPatch(target_zip)
-  source_has_recovery_patch = HasRecoveryPatch(source_zip)
-
-  if (OPTIONS.block_based and
-      target_has_recovery_patch and
-      source_has_recovery_patch):
-    return WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip)
-
-  source_version = OPTIONS.source_info_dict["recovery_api_version"]
-  target_version = OPTIONS.target_info_dict["recovery_api_version"]
-
-  if source_version == 0:
-    print ("WARNING: generating edify script for a source that "
-           "can't install it.")
-  script = edify_generator.EdifyGenerator(
-      source_version, OPTIONS.target_info_dict,
-      fstab=OPTIONS.source_info_dict["fstab"])
-
-  recovery_mount_options = OPTIONS.source_info_dict.get(
-      "recovery_mount_options")
-  source_oem_props = OPTIONS.source_info_dict.get("oem_fingerprint_properties")
-  target_oem_props = OPTIONS.target_info_dict.get("oem_fingerprint_properties")
-  oem_dicts = None
-  if source_oem_props or target_oem_props:
-    oem_dicts = _LoadOemDicts(script, recovery_mount_options)
-
-  metadata = {
-      "pre-device": GetOemProperty("ro.product.device", source_oem_props,
-                                   oem_dicts and oem_dicts[0],
-                                   OPTIONS.source_info_dict),
-      "ota-type": "FILE",
-  }
-
-  HandleDowngradeMetadata(metadata)
-
-  device_specific = common.DeviceSpecificParams(
-      source_zip=source_zip,
-      source_version=source_version,
-      target_zip=target_zip,
-      target_version=target_version,
-      output_zip=output_zip,
-      script=script,
-      metadata=metadata,
-      info_dict=OPTIONS.source_info_dict)
-
-  system_diff = FileDifference("system", source_zip, target_zip, output_zip)
-  script.Mount("/system", recovery_mount_options)
   if HasVendorPartition(target_zip):
-    vendor_diff = FileDifference("vendor", source_zip, target_zip, output_zip)
-    script.Mount("/vendor", recovery_mount_options)
-  else:
-    vendor_diff = None
+    update_vendor = True
+    update_system = True
 
-  target_fp = CalculateFingerprint(target_oem_props, oem_dicts and oem_dicts[0],
-                                   OPTIONS.target_info_dict)
-  source_fp = CalculateFingerprint(source_oem_props, oem_dicts and oem_dicts[0],
-                                   OPTIONS.source_info_dict)
+    # If incremental then figure out what is being updated so metadata only for
+    # the updated image is included.
+    if source_file is not None:
+      input_tmp, input_zip = common.UnzipTemp(
+          target_file, UNZIP_PATTERN)
+      source_tmp, source_zip = common.UnzipTemp(
+          source_file, UNZIP_PATTERN)
 
-  if source_oem_props is None and target_oem_props is None:
-    script.AssertSomeFingerprint(source_fp, target_fp)
-  elif source_oem_props is not None and target_oem_props is not None:
-    script.AssertSomeThumbprint(
-        GetBuildProp("ro.build.thumbprint", OPTIONS.target_info_dict),
-        GetBuildProp("ro.build.thumbprint", OPTIONS.source_info_dict))
-  elif source_oem_props is None and target_oem_props is not None:
-    script.AssertFingerprintOrThumbprint(
-        source_fp,
-        GetBuildProp("ro.build.thumbprint", OPTIONS.target_info_dict))
-  else:
-    script.AssertFingerprintOrThumbprint(
-        target_fp,
-        GetBuildProp("ro.build.thumbprint", OPTIONS.source_info_dict))
+      vendor_src = GetImage("vendor", source_tmp)
+      vendor_tgt = GetImage("vendor", input_tmp)
+      system_src = GetImage("system", source_tmp)
+      system_tgt = GetImage("system", input_tmp)
 
-  metadata["pre-build"] = source_fp
-  metadata["post-build"] = target_fp
-  metadata["pre-build-incremental"] = GetBuildProp(
-      "ro.build.version.incremental", OPTIONS.source_info_dict)
-  metadata["post-build-incremental"] = GetBuildProp(
-      "ro.build.version.incremental", OPTIONS.target_info_dict)
+      update_system = system_src.TotalSha1() != system_tgt.TotalSha1()
+      update_vendor = vendor_src.TotalSha1() != vendor_tgt.TotalSha1()
 
-  source_boot = common.GetBootableImage(
-      "/tmp/boot.img", "boot.img", OPTIONS.source_tmp, "BOOT",
-      OPTIONS.source_info_dict)
-  target_boot = common.GetBootableImage(
-      "/tmp/boot.img", "boot.img", OPTIONS.target_tmp, "BOOT")
-  updating_boot = (not OPTIONS.two_step and
-                   (source_boot.data != target_boot.data))
+      input_zip.close()
+      source_zip.close()
 
-  source_recovery = common.GetBootableImage(
-      "/tmp/recovery.img", "recovery.img", OPTIONS.source_tmp, "RECOVERY",
-      OPTIONS.source_info_dict)
-  target_recovery = common.GetBootableImage(
-      "/tmp/recovery.img", "recovery.img", OPTIONS.target_tmp, "RECOVERY")
-  updating_recovery = (source_recovery.data != target_recovery.data)
+    target_zip = zipfile.ZipFile(target_file, "r")
+    AddCompatibilityArchive(target_zip, output_zip, update_system,
+                            update_vendor)
+  common.ZipClose(target_zip)
 
-  # Here's how we divide up the progress bar:
-  #  0.1 for verifying the start state (PatchCheck calls)
-  #  0.8 for applying patches (ApplyPatch calls)
-  #  0.1 for unpacking verbatim files, symlinking, and doing the
-  #      device-specific commands.
-
-  AppendAssertions(script, OPTIONS.target_info_dict, oem_dicts)
-  device_specific.IncrementalOTA_Assertions()
-
-  # Two-step incremental package strategy (in chronological order,
-  # which is *not* the order in which the generated script has
-  # things):
-  #
-  # if stage is not "2/3" or "3/3":
-  #    do verification on current system
-  #    write recovery image to boot partition
-  #    set stage to "2/3"
-  #    reboot to boot partition and restart recovery
-  # else if stage is "2/3":
-  #    write recovery image to recovery partition
-  #    set stage to "3/3"
-  #    reboot to recovery partition and restart recovery
-  # else:
-  #    (stage must be "3/3")
-  #    perform update:
-  #       patch system files, etc.
-  #       force full install of new boot image
-  #       set up system to update recovery partition on first boot
-  #    complete script normally
-  #    (allow recovery to mark itself finished and reboot)
-
-  if OPTIONS.two_step:
-    if not OPTIONS.source_info_dict.get("multistage_support", None):
-      assert False, "two-step packages not supported by this build"
-    fs = OPTIONS.source_info_dict["fstab"]["/misc"]
-    assert fs.fs_type.upper() == "EMMC", \
-        "two-step packages only supported on devices with EMMC /misc partitions"
-    bcb_dev = {"bcb_dev": fs.device}
-    common.ZipWriteStr(output_zip, "recovery.img", target_recovery.data)
-    script.AppendExtra("""
-if get_stage("%(bcb_dev)s") == "2/3" then
-""" % bcb_dev)
-
-    # Stage 2/3: Write recovery image to /recovery (currently running /boot).
-    script.Comment("Stage 2/3")
-    script.AppendExtra("sleep(20);\n")
-    script.WriteRawImage("/recovery", "recovery.img")
-    script.AppendExtra("""
-set_stage("%(bcb_dev)s", "3/3");
-reboot_now("%(bcb_dev)s", "recovery");
-else if get_stage("%(bcb_dev)s") != "3/3" then
-""" % bcb_dev)
-
-    # Stage 1/3: (a) Verify the current system.
-    script.Comment("Stage 1/3")
-
-  # Dump fingerprints
-  script.Print("Source: %s" % (source_fp,))
-  script.Print("Target: %s" % (target_fp,))
-
-  script.Print("Verifying current system...")
-
-  device_specific.IncrementalOTA_VerifyBegin()
-
-  script.ShowProgress(0.1, 0)
-  so_far = system_diff.EmitVerification(script)
-  if vendor_diff:
-    so_far += vendor_diff.EmitVerification(script)
-
-  size = []
-  if system_diff.patch_list:
-    size.append(system_diff.largest_source_size)
-  if vendor_diff:
-    if vendor_diff.patch_list:
-      size.append(vendor_diff.largest_source_size)
-
-  if updating_boot:
-    d = common.Difference(target_boot, source_boot)
-    _, _, d = d.ComputePatch()
-    print "boot      target: %d  source: %d  diff: %d" % (
-        target_boot.size, source_boot.size, len(d))
-
-    common.ZipWriteStr(output_zip, "patch/boot.img.p", d)
-
-    boot_type, boot_device = common.GetTypeAndDevice(
-        "/boot", OPTIONS.source_info_dict)
-
-    script.PatchCheck("%s:%s:%d:%s:%d:%s" %
-                      (boot_type, boot_device,
-                       source_boot.size, source_boot.sha1,
-                       target_boot.size, target_boot.sha1))
-    so_far += source_boot.size
-    size.append(target_boot.size)
-
-  if size:
-    script.CacheFreeSpaceCheck(max(size))
-
-  device_specific.IncrementalOTA_VerifyEnd()
-
-  if OPTIONS.two_step:
-    # Stage 1/3: (b) Write recovery image to /boot.
-    _WriteRecoveryImageToBoot(script, output_zip)
-
-    script.AppendExtra("""
-set_stage("%(bcb_dev)s", "2/3");
-reboot_now("%(bcb_dev)s", "");
-else
-""" % bcb_dev)
-
-    # Stage 3/3: Make changes.
-    script.Comment("Stage 3/3")
-
-  script.Comment("---- start making changes here ----")
-
-  device_specific.IncrementalOTA_InstallBegin()
-
-  if OPTIONS.two_step:
-    common.ZipWriteStr(output_zip, "boot.img", target_boot.data)
-    script.WriteRawImage("/boot", "boot.img")
-    print "writing full boot image (forced by two-step mode)"
-
-  script.Print("Removing unneeded files...")
-  system_diff.RemoveUnneededFiles(script, ("/system/recovery.img",))
-  if vendor_diff:
-    vendor_diff.RemoveUnneededFiles(script)
-
-  script.ShowProgress(0.8, 0)
-  total_patch_size = 1.0 + system_diff.TotalPatchSize()
-  if vendor_diff:
-    total_patch_size += vendor_diff.TotalPatchSize()
-  if updating_boot:
-    total_patch_size += target_boot.size
-
-  script.Print("Patching system files...")
-  so_far = system_diff.EmitPatches(script, total_patch_size, 0)
-  if vendor_diff:
-    script.Print("Patching vendor files...")
-    so_far = vendor_diff.EmitPatches(script, total_patch_size, so_far)
-
-  if not OPTIONS.two_step:
-    if updating_boot:
-      # Produce the boot image by applying a patch to the current
-      # contents of the boot partition, and write it back to the
-      # partition.
-      script.Print("Patching boot image...")
-      script.ApplyPatch("%s:%s:%d:%s:%d:%s"
-                        % (boot_type, boot_device,
-                           source_boot.size, source_boot.sha1,
-                           target_boot.size, target_boot.sha1),
-                        "-",
-                        target_boot.size, target_boot.sha1,
-                        source_boot.sha1, "patch/boot.img.p")
-      so_far += target_boot.size
-      script.SetProgress(so_far / total_patch_size)
-      print "boot image changed; including."
-    else:
-      print "boot image unchanged; skipping."
-
-  system_items = ItemSet("system", "META/filesystem_config.txt")
-  if vendor_diff:
-    vendor_items = ItemSet("vendor", "META/vendor_filesystem_config.txt")
-
-  if updating_recovery:
-    # Recovery is generated as a patch using both the boot image
-    # (which contains the same linux kernel as recovery) and the file
-    # /system/etc/recovery-resource.dat (which contains all the images
-    # used in the recovery UI) as sources.  This lets us minimize the
-    # size of the patch, which must be included in every OTA package.
-    #
-    # For older builds where recovery-resource.dat is not present, we
-    # use only the boot image as the source.
-
-    if not target_has_recovery_patch:
-      def output_sink(fn, data):
-        common.ZipWriteStr(output_zip, "recovery/" + fn, data)
-        system_items.Get("system/" + fn)
-
-      common.MakeRecoveryPatch(OPTIONS.target_tmp, output_sink,
-                               target_recovery, target_boot)
-      script.DeleteFiles(["/system/recovery-from-boot.p",
-                          "/system/etc/recovery.img",
-                          "/system/etc/install-recovery.sh"])
-    print "recovery image changed; including as patch from boot."
-  else:
-    print "recovery image unchanged; skipping."
-
-  script.ShowProgress(0.1, 10)
-
-  target_symlinks = CopyPartitionFiles(system_items, target_zip, None)
-  if vendor_diff:
-    target_symlinks.extend(CopyPartitionFiles(vendor_items, target_zip, None))
-
-  temp_script = script.MakeTemporary()
-  system_items.GetMetadata(target_zip)
-  system_items.Get("system").SetPermissions(temp_script)
-  if vendor_diff:
-    vendor_items.GetMetadata(target_zip)
-    vendor_items.Get("vendor").SetPermissions(temp_script)
-
-  # Note that this call will mess up the trees of Items, so make sure
-  # we're done with them.
-  source_symlinks = CopyPartitionFiles(system_items, source_zip, None)
-  if vendor_diff:
-    source_symlinks.extend(CopyPartitionFiles(vendor_items, source_zip, None))
-
-  target_symlinks_d = dict([(i[1], i[0]) for i in target_symlinks])
-  source_symlinks_d = dict([(i[1], i[0]) for i in source_symlinks])
-
-  # Delete all the symlinks in source that aren't in target.  This
-  # needs to happen before verbatim files are unpacked, in case a
-  # symlink in the source is replaced by a real file in the target.
-
-  # If a symlink in the source will be replaced by a regular file, we cannot
-  # delete the symlink/file in case the package gets applied again. For such
-  # a symlink, we prepend a sha1_check() to detect if it has been updated.
-  # (Bug: 23646151)
-  replaced_symlinks = dict()
-  if system_diff:
-    for i in system_diff.verbatim_targets:
-      replaced_symlinks["/%s" % (i[0],)] = i[2]
-  if vendor_diff:
-    for i in vendor_diff.verbatim_targets:
-      replaced_symlinks["/%s" % (i[0],)] = i[2]
-
-  if system_diff:
-    for tf in system_diff.renames.values():
-      replaced_symlinks["/%s" % (tf.name,)] = tf.sha1
-  if vendor_diff:
-    for tf in vendor_diff.renames.values():
-      replaced_symlinks["/%s" % (tf.name,)] = tf.sha1
-
-  always_delete = []
-  may_delete = []
-  for dest, link in source_symlinks:
-    if link not in target_symlinks_d:
-      if link in replaced_symlinks:
-        may_delete.append((link, replaced_symlinks[link]))
-      else:
-        always_delete.append(link)
-  script.DeleteFiles(always_delete)
-  script.DeleteFilesIfNotMatching(may_delete)
-
-  if system_diff.verbatim_targets:
-    script.Print("Unpacking new system files...")
-    script.UnpackPackageDir("system", "/system")
-  if vendor_diff and vendor_diff.verbatim_targets:
-    script.Print("Unpacking new vendor files...")
-    script.UnpackPackageDir("vendor", "/vendor")
-
-  if updating_recovery and not target_has_recovery_patch:
-    script.Print("Unpacking new recovery...")
-    script.UnpackPackageDir("recovery", "/system")
-
-  system_diff.EmitRenames(script)
-  if vendor_diff:
-    vendor_diff.EmitRenames(script)
-
-  script.Print("Symlinks and permissions...")
-
-  # Create all the symlinks that don't already exist, or point to
-  # somewhere different than what we want.  Delete each symlink before
-  # creating it, since the 'symlink' command won't overwrite.
-  to_create = []
-  for dest, link in target_symlinks:
-    if link in source_symlinks_d:
-      if dest != source_symlinks_d[link]:
-        to_create.append((dest, link))
-    else:
-      to_create.append((dest, link))
-  script.DeleteFiles([i[1] for i in to_create])
-  script.MakeSymlinks(to_create)
-
-  # Now that the symlinks are created, we can set all the
-  # permissions.
-  script.AppendScript(temp_script)
-
-  # Do device-specific installation (eg, write radio image).
-  device_specific.IncrementalOTA_InstallEnd()
-
-  if OPTIONS.extra_script is not None:
-    script.AppendExtra(OPTIONS.extra_script)
-
-  # Patch the build.prop file last, so if something fails but the
-  # device can still come up, it appears to be the old build and will
-  # get set the OTA package again to retry.
-  script.Print("Patching remaining system files...")
-  system_diff.EmitDeferredPatches(script)
-
-  if OPTIONS.wipe_user_data:
-    script.Print("Erasing user data...")
-    script.FormatPartition("/data")
-    metadata["ota-wipe"] = "yes"
-
-  if OPTIONS.two_step:
-    script.AppendExtra("""
-set_stage("%(bcb_dev)s", "");
-endif;
-endif;
-""" % bcb_dev)
-
-  if OPTIONS.verify and system_diff:
-    script.Print("Remounting and verifying system partition files...")
-    script.Unmount("/system")
-    script.Mount("/system", recovery_mount_options)
-    system_diff.EmitExplicitTargetVerification(script)
-
-  if OPTIONS.verify and vendor_diff:
-    script.Print("Remounting and verifying vendor partition files...")
-    script.Unmount("/vendor")
-    script.Mount("/vendor", recovery_mount_options)
-    vendor_diff.EmitExplicitTargetVerification(script)
-
-  # For downgrade OTAs, we prefer to use the update-binary in the source
-  # build that is actually newer than the one in the target build.
-  if OPTIONS.downgrade:
-    script.AddToZip(source_zip, output_zip, input_path=OPTIONS.updater_binary)
-  else:
-    script.AddToZip(target_zip, output_zip, input_path=OPTIONS.updater_binary)
-
-  metadata["ota-required-cache"] = str(script.required_cache)
+  # Write the current metadata entry with placeholders.
+  metadata['ota-streaming-property-files'] = ComputeStreamingMetadata(
+      output_zip, reserve_space=True)
   WriteMetadata(metadata, output_zip)
+  common.ZipClose(output_zip)
+
+  # SignOutput(), which in turn calls signapk.jar, will possibly reorder the
+  # zip entries, as well as padding the entry headers. We do a preliminary
+  # signing (with an incomplete metadata entry) to allow that to happen. Then
+  # compute the zip entry offsets, write back the final metadata and do the
+  # final signing.
+  prelim_signing = tempfile.NamedTemporaryFile()
+  SignOutput(temp_zip_file.name, prelim_signing.name)
+  common.ZipClose(temp_zip_file)
+
+  # Open the signed zip. Compute the final metadata that's needed for streaming.
+  prelim_zip = zipfile.ZipFile(prelim_signing, "r",
+                               compression=zipfile.ZIP_DEFLATED)
+  expected_length = len(metadata['ota-streaming-property-files'])
+  metadata['ota-streaming-property-files'] = ComputeStreamingMetadata(
+      prelim_zip, reserve_space=False, expected_length=expected_length)
+
+  # Copy the zip entries, as we cannot update / delete entries with zipfile.
+  final_signing = tempfile.NamedTemporaryFile()
+  output_zip = zipfile.ZipFile(final_signing, "w",
+                               compression=zipfile.ZIP_DEFLATED)
+  for item in prelim_zip.infolist():
+    if item.filename == METADATA_NAME:
+      continue
+
+    data = prelim_zip.read(item.filename)
+    out_info = copy.copy(item)
+    common.ZipWriteStr(output_zip, out_info, data)
+
+  # Now write the final metadata entry.
+  WriteMetadata(metadata, output_zip)
+  common.ZipClose(prelim_zip)
+  common.ZipClose(output_zip)
+
+  # Re-sign the package after updating the metadata entry.
+  SignOutput(final_signing.name, output_file)
+  final_signing.close()
+
+  # Reopen the final signed zip to double check the streaming metadata.
+  output_zip = zipfile.ZipFile(output_file, "r")
+  actual = metadata['ota-streaming-property-files'].strip()
+  expected = ComputeStreamingMetadata(output_zip)
+  assert actual == expected, \
+      "Mismatching streaming metadata: %s vs %s." % (actual, expected)
+  common.ZipClose(output_zip)
 
 
 def main(argv):
@@ -1994,8 +1276,6 @@
       OPTIONS.full_bootloader = True
     elif o in ("-w", "--wipe_user_data"):
       OPTIONS.wipe_user_data = True
-    elif o in ("-n", "--no_prereq"):
-      OPTIONS.omit_prereq = True
     elif o == "--downgrade":
       OPTIONS.downgrade = True
       OPTIONS.wipe_user_data = True
@@ -2007,11 +1287,6 @@
       OPTIONS.oem_no_mount = True
     elif o in ("-e", "--extra_script"):
       OPTIONS.extra_script = a
-    elif o in ("-a", "--aslr_mode"):
-      if a in ("on", "On", "true", "True", "yes", "Yes"):
-        OPTIONS.aslr_mode = True
-      else:
-        OPTIONS.aslr_mode = False
     elif o in ("-t", "--worker_threads"):
       if a.isdigit():
         OPTIONS.worker_threads = int(a)
@@ -2044,12 +1319,14 @@
       OPTIONS.payload_signer = a
     elif o == "--payload_signer_args":
       OPTIONS.payload_signer_args = shlex.split(a)
+    elif o == "--extracted_input_target_files":
+      OPTIONS.extracted_input = a
     else:
       return False
     return True
 
   args = common.ParseOptions(argv, __doc__,
-                             extra_opts="b:k:i:d:wne:t:a:2o:",
+                             extra_opts="b:k:i:d:we:t:2o:",
                              extra_long_opts=[
                                  "board_config=",
                                  "package_key=",
@@ -2057,12 +1334,10 @@
                                  "full_radio",
                                  "full_bootloader",
                                  "wipe_user_data",
-                                 "no_prereq",
                                  "downgrade",
                                  "override_timestamp",
                                  "extra_script=",
                                  "worker_threads=",
-                                 "aslr_mode=",
                                  "two_step",
                                  "no_signing",
                                  "block",
@@ -2076,6 +1351,7 @@
                                  "log_diff=",
                                  "payload_signer=",
                                  "payload_signer_args=",
+                                 "extracted_input_target_files=",
                              ], extra_option_handler=option_handler)
 
   if len(args) != 2:
@@ -2091,17 +1367,19 @@
     # Otherwise the device may go back from arbitrary build with this full
     # OTA package.
     if OPTIONS.incremental_source is None:
-      raise ValueError("Cannot generate downgradable full OTAs - consider"
-                       "using --omit_prereq?")
+      raise ValueError("Cannot generate downgradable full OTAs")
 
   assert not (OPTIONS.downgrade and OPTIONS.timestamp), \
       "Cannot have --downgrade AND --override_timestamp both"
 
   # Load the dict file from the zip directly to have a peek at the OTA type.
   # For packages using A/B update, unzipping is not needed.
-  input_zip = zipfile.ZipFile(args[0], "r")
-  OPTIONS.info_dict = common.LoadInfoDict(input_zip)
-  common.ZipClose(input_zip)
+  if OPTIONS.extracted_input is not None:
+    OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.extracted_input, OPTIONS.extracted_input)
+  else:
+    input_zip = zipfile.ZipFile(args[0], "r")
+    OPTIONS.info_dict = common.LoadInfoDict(input_zip)
+    common.ZipClose(input_zip)
 
   ab_update = OPTIONS.info_dict.get("ab_update") == "true"
 
@@ -2113,11 +1391,11 @@
       common.ZipClose(source_zip)
 
     if OPTIONS.verbose:
-      print "--- target info ---"
+      print("--- target info ---")
       common.DumpInfoDict(OPTIONS.info_dict)
 
       if OPTIONS.incremental_source is not None:
-        print "--- source info ---"
+        print("--- source info ---")
         common.DumpInfoDict(OPTIONS.source_info_dict)
 
     WriteABOTAPackageWithBrilloScript(
@@ -2125,20 +1403,27 @@
         output_file=args[1],
         source_file=OPTIONS.incremental_source)
 
-    print "done."
+    print("done.")
     return
 
   if OPTIONS.extra_script is not None:
     OPTIONS.extra_script = open(OPTIONS.extra_script).read()
 
-  print "unzipping target target-files..."
-  OPTIONS.input_tmp, input_zip = common.UnzipTemp(args[0])
+  if OPTIONS.extracted_input is not None:
+    OPTIONS.input_tmp = OPTIONS.extracted_input
+    OPTIONS.target_tmp = OPTIONS.input_tmp
+    OPTIONS.info_dict = common.LoadInfoDict(OPTIONS.input_tmp, OPTIONS.input_tmp)
+    input_zip = zipfile.ZipFile(args[0], "r")
+  else:
+    print("unzipping target target-files...")
+    OPTIONS.input_tmp, input_zip = common.UnzipTemp(
+        args[0], UNZIP_PATTERN)
 
-  OPTIONS.target_tmp = OPTIONS.input_tmp
-  OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp)
+    OPTIONS.target_tmp = OPTIONS.input_tmp
+    OPTIONS.info_dict = common.LoadInfoDict(input_zip, OPTIONS.target_tmp)
 
   if OPTIONS.verbose:
-    print "--- target info ---"
+    print("--- target info ---")
     common.DumpInfoDict(OPTIONS.info_dict)
 
   # If the caller explicitly specified the device-specific extensions
@@ -2151,7 +1436,7 @@
   if OPTIONS.device_specific is None:
     from_input = os.path.join(OPTIONS.input_tmp, "META", "releasetools.py")
     if os.path.exists(from_input):
-      print "(using device-specific extensions from target_files)"
+      print("(using device-specific extensions from target_files)")
       OPTIONS.device_specific = from_input
     else:
       OPTIONS.device_specific = OPTIONS.info_dict.get("tool_extensions", None)
@@ -2184,7 +1469,7 @@
   # Non A/B OTAs rely on /cache partition to store temporary files.
   cache_size = OPTIONS.info_dict.get("cache_size", None)
   if cache_size is None:
-    print "--- can't determine the cache partition size ---"
+    print("--- can't determine the cache partition size ---")
   OPTIONS.cache_size = cache_size
 
   # Generate a verify package.
@@ -2198,17 +1483,18 @@
   # Generate an incremental OTA. It will fall back to generate a full OTA on
   # failure unless no_fallback_to_full is specified.
   else:
-    print "unzipping source target-files..."
+    print("unzipping source target-files...")
     OPTIONS.source_tmp, source_zip = common.UnzipTemp(
-        OPTIONS.incremental_source)
+        OPTIONS.incremental_source,
+        UNZIP_PATTERN)
     OPTIONS.target_info_dict = OPTIONS.info_dict
     OPTIONS.source_info_dict = common.LoadInfoDict(source_zip,
                                                    OPTIONS.source_tmp)
     if OPTIONS.verbose:
-      print "--- source info ---"
+      print("--- source info ---")
       common.DumpInfoDict(OPTIONS.source_info_dict)
     try:
-      WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
+      WriteBlockIncrementalOTAPackage(input_zip, source_zip, output_zip)
       if OPTIONS.log_diff:
         out_file = open(OPTIONS.log_diff, 'w')
         import target_files_diff
@@ -2220,7 +1506,7 @@
     except ValueError:
       if not OPTIONS.fallback_to_full:
         raise
-      print "--- failed to build incremental; falling back to full ---"
+      print("--- failed to build incremental; falling back to full ---")
       OPTIONS.incremental_source = None
       WriteFullOTAPackage(input_zip, output_zip)
 
@@ -2231,7 +1517,7 @@
     SignOutput(temp_zip_file.name, args[1])
     temp_zip_file.close()
 
-  print "done."
+  print("done.")
 
 
 if __name__ == '__main__':
@@ -2239,9 +1525,7 @@
     common.CloseInheritedPipes()
     main(sys.argv[1:])
   except common.ExternalError as e:
-    print
-    print "   ERROR: %s" % (e,)
-    print
+    print("\n   ERROR: %s\n" % (e,))
     sys.exit(1)
   finally:
     common.Cleanup()
diff --git a/tools/releasetools/rangelib.py b/tools/releasetools/rangelib.py
index c9bd375..fa6eec1 100644
--- a/tools/releasetools/rangelib.py
+++ b/tools/releasetools/rangelib.py
@@ -71,6 +71,19 @@
     """
     return cls(text)
 
+  @classmethod
+  def parse_raw(cls, text):
+    """Parse a string generated by RangeSet.to_string_raw().
+
+    >>> RangeSet.parse_raw(RangeSet("0-9").to_string_raw())
+    <RangeSet("0-9")>
+    """
+
+    raw = [int(i) for i in text.split(',')]
+    assert raw[0] == len(raw[1:]), "Invalid raw string."
+
+    return cls(data=raw[1:])
+
   def _parse_internal(self, text):
     data = []
     last = -1
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 52b526c..0fe72cc 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -93,6 +93,7 @@
 import os
 import re
 import shutil
+import stat
 import subprocess
 import tempfile
 import zipfile
@@ -191,6 +192,9 @@
 
   # tmpdir will only be used to regenerate the recovery-from-boot patch.
   tmpdir = tempfile.mkdtemp()
+  # We're not setting the permissions precisely as in attr, because that work
+  # will be handled by mkbootfs (using the values from the canned or the
+  # compiled-in fs_config).
   def write_to_temp(fn, attr, data):
     fn = os.path.join(tmpdir, fn)
     if fn.endswith("/"):
@@ -201,7 +205,7 @@
       if d and not os.path.exists(d):
         os.makedirs(d)
 
-      if attr >> 16 == 0xa1ff:
+      if stat.S_ISLNK(attr >> 16):
         os.symlink(data, fn)
       else:
         with open(fn, "wb") as f:
@@ -231,15 +235,23 @@
     # System properties.
     elif info.filename in ("SYSTEM/build.prop",
                            "VENDOR/build.prop",
-                           "BOOT/RAMDISK/default.prop",
-                           "ROOT/default.prop",
-                           "RECOVERY/RAMDISK/default.prop"):
+                           "SYSTEM/etc/prop.default",
+                           "BOOT/RAMDISK/prop.default",
+                           "BOOT/RAMDISK/default.prop",  # legacy
+                           "ROOT/default.prop",  # legacy
+                           "RECOVERY/RAMDISK/prop.default",
+                           "RECOVERY/RAMDISK/default.prop"):  # legacy
       print "rewriting %s:" % (info.filename,)
-      new_data = RewriteProps(data, misc_info)
+      if stat.S_ISLNK(info.external_attr >> 16):
+        new_data = data
+      else:
+        new_data = RewriteProps(data, misc_info)
       common.ZipWriteStr(output_tf_zip, out_info, new_data)
-      if info.filename in ("BOOT/RAMDISK/default.prop",
-                           "ROOT/default.prop",
-                           "RECOVERY/RAMDISK/default.prop"):
+      if info.filename in ("BOOT/RAMDISK/prop.default",
+                           "BOOT/RAMDISK/default.prop",  # legacy
+                           "ROOT/default.prop",  # legacy
+                           "RECOVERY/RAMDISK/prop.default",
+                           "RECOVERY/RAMDISK/default.prop"):  # legacy
         write_to_temp(info.filename, info.external_attr, new_data)
 
     elif info.filename.endswith("mac_permissions.xml"):
@@ -280,7 +292,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 +565,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 +607,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 +629,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 +711,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/sparse_img.py b/tools/releasetools/sparse_img.py
index 4ba7560..7eb60d9 100644
--- a/tools/releasetools/sparse_img.py
+++ b/tools/releasetools/sparse_img.py
@@ -144,6 +144,12 @@
     f.seek(16, os.SEEK_SET)
     f.write(struct.pack("<2I", self.total_blocks, self.total_chunks))
 
+  def RangeSha1(self, ranges):
+    h = sha1()
+    for data in self._GetRangeData(ranges):
+      h.update(data)
+    return h.hexdigest()
+
   def ReadRangeSet(self, ranges):
     return [d for d in self._GetRangeData(ranges)]
 
@@ -155,10 +161,11 @@
     ranges = self.care_map
     if not include_clobbered_blocks:
       ranges = ranges.subtract(self.clobbered_blocks)
-    h = sha1()
-    for d in self._GetRangeData(ranges):
-      h.update(d)
-    return h.hexdigest()
+    return self.RangeSha1(ranges)
+
+  def WriteRangeDataToFd(self, ranges, fd):
+    for data in self._GetRangeData(ranges):
+      fd.write(data)
 
   def _GetRangeData(self, ranges):
     """Generator that produces all the image data in 'ranges'.  The
diff --git a/tools/releasetools/target_files_diff.py b/tools/releasetools/target_files_diff.py
index 0f717e0..7415f27 100755
--- a/tools/releasetools/target_files_diff.py
+++ b/tools/releasetools/target_files_diff.py
@@ -51,10 +51,6 @@
               'RECOVERY/RAMDISK/selinux_version']:
     return True
 
-  # b/26956807 .odex files are not deterministic
-  if name.endswith('.odex'):
-    return True
-
   return False
 
 
diff --git a/tools/releasetools/test_blockimgdiff.py b/tools/releasetools/test_blockimgdiff.py
index 03e8c8b..e5a3694 100644
--- a/tools/releasetools/test_blockimgdiff.py
+++ b/tools/releasetools/test_blockimgdiff.py
@@ -19,8 +19,7 @@
 import common
 import unittest
 
-from collections import OrderedDict
-from blockimgdiff import BlockImageDiff, EmptyImage, DataImage, Transfer
+from blockimgdiff import BlockImageDiff, EmptyImage, Transfer
 from rangelib import RangeSet
 
 class BlockImageDiffTest(unittest.TestCase):
@@ -42,14 +41,14 @@
     block_image_diff = BlockImageDiff(tgt, src)
 
     transfers = block_image_diff.transfers
-    t0 = Transfer(
-        "t1", "t1", RangeSet("10-15"), RangeSet("0-5"), "move", transfers)
-    t1 = Transfer(
-        "t2", "t2", RangeSet("20-25"), RangeSet("0-7"), "move", transfers)
-    t2 = Transfer(
-        "t3", "t3", RangeSet("30-35"), RangeSet("0-4"), "move", transfers)
-    t3 = Transfer(
-        "t4", "t4", RangeSet("0-10"), RangeSet("40-50"), "move", transfers)
+    t0 = Transfer("t1", "t1", RangeSet("10-15"), RangeSet("0-5"), "t1hash",
+                  "t1hash", "move", transfers)
+    t1 = Transfer("t2", "t2", RangeSet("20-25"), RangeSet("0-7"), "t2hash",
+                  "t2hash", "move", transfers)
+    t2 = Transfer("t3", "t3", RangeSet("30-35"), RangeSet("0-4"), "t3hash",
+                  "t3hash", "move", transfers)
+    t3 = Transfer("t4", "t4", RangeSet("0-10"), RangeSet("40-50"), "t4hash",
+                  "t4hash", "move", transfers)
 
     block_image_diff.GenerateDigraph()
     t3_goes_after_copy = t3.goes_after.copy()
@@ -75,3 +74,70 @@
     self.assertEqual(t2, elements[0])
     self.assertEqual(t0, elements[1])
     self.assertEqual(t1, elements[2])
+
+  def test_ReviseStashSize(self):
+    """ReviseStashSize should convert transfers to 'new' commands as needed.
+
+    t1: diff <20-29> => <11-15>
+    t2: diff <11-15> => <20-29>
+    """
+
+    src = EmptyImage()
+    tgt = EmptyImage()
+    block_image_diff = BlockImageDiff(tgt, src, version=3)
+
+    transfers = block_image_diff.transfers
+    Transfer("t1", "t1", RangeSet("11-15"), RangeSet("20-29"), "t1hash",
+             "t1hash", "diff", transfers)
+    Transfer("t2", "t2", RangeSet("20-29"), RangeSet("11-15"), "t2hash",
+             "t2hash", "diff", transfers)
+
+    block_image_diff.GenerateDigraph()
+    block_image_diff.FindVertexSequence()
+    block_image_diff.ReverseBackwardEdges()
+
+    # Sufficient cache to stash 5 blocks (size * 0.8 >= 5).
+    common.OPTIONS.cache_size = 7 * 4096
+    self.assertEqual(0, block_image_diff.ReviseStashSize())
+
+    # Insufficient cache to stash 5 blocks (size * 0.8 < 5).
+    common.OPTIONS.cache_size = 6 * 4096
+    self.assertEqual(10, block_image_diff.ReviseStashSize())
+
+  def test_ReviseStashSize_bug_33687949(self):
+    """ReviseStashSize() should "free" the used stash _after_ the command.
+
+    t1: diff <1-5> => <11-15>
+    t2: diff <11-15> => <21-25>
+    t3: diff <11-15 30-39> => <1-5 30-39>
+
+    For transfer t3, the used stash "11-15" should not be freed until the
+    command finishes. Assume the allowed cache size is 12-block, it should
+    convert the command to 'new' due to insufficient cache (12 < 5 + 10).
+    """
+
+    src = EmptyImage()
+    tgt = EmptyImage()
+    block_image_diff = BlockImageDiff(tgt, src, version=3)
+
+    transfers = block_image_diff.transfers
+    t1 = Transfer("t1", "t1", RangeSet("11-15"), RangeSet("1-5"), "t1hash",
+                  "t1hash", "diff", transfers)
+    t2 = Transfer("t2", "t2", RangeSet("21-25"), RangeSet("11-15"), "t2hash",
+                  "t2hash", "diff", transfers)
+    t3 = Transfer("t3", "t3", RangeSet("1-5 30-39"), RangeSet("11-15 30-39"),
+                  "t3hash", "t3hash", "diff", transfers)
+
+    block_image_diff.GenerateDigraph()
+
+    # Instead of calling FindVertexSequence() and ReverseBackwardEdges(), we
+    # just set up the stash_before and use_stash manually. Otherwise it will
+    # reorder the transfer, which makes testing ReviseStashSize() harder.
+    t1.stash_before.append((0, RangeSet("11-15")))
+    t2.use_stash.append((0, RangeSet("11-15")))
+    t1.stash_before.append((1, RangeSet("11-15")))
+    t3.use_stash.append((1, RangeSet("11-15")))
+
+    # Insufficient cache to stash 15 blocks (size * 0.8 < 15).
+    common.OPTIONS.cache_size = 15 * 4096
+    self.assertEqual(15, block_image_diff.ReviseStashSize())
diff --git a/tools/releasetools/test_rangelib.py b/tools/releasetools/test_rangelib.py
index edf1c4b..e181187 100644
--- a/tools/releasetools/test_rangelib.py
+++ b/tools/releasetools/test_rangelib.py
@@ -125,6 +125,20 @@
     self.assertTrue(RangeSet(data=[0, 5, 5, 10]).monotonic)
     self.assertFalse(RangeSet(data=[5, 10, 0, 5]).monotonic)
 
+  def test_parse_raw(self):
+    self.assertEqual(
+        RangeSet.parse_raw(RangeSet("0-9").to_string_raw()),
+        RangeSet("0-9"))
+    self.assertEqual(RangeSet.parse_raw(
+        RangeSet("2-10 12").to_string_raw()),
+        RangeSet("2-10 12"))
+    self.assertEqual(
+        RangeSet.parse_raw(RangeSet("11 2-10 12 1 0").to_string_raw()),
+        RangeSet("11 2-10 12 1 0"))
+
+    with self.assertRaises(AssertionError):
+      RangeSet.parse_raw("4,0,10")
+
   def test_next_item(self):
     self.assertEqual(
         list(RangeSet("0-9").next_item()),
diff --git a/tools/rgb2565/Android.mk b/tools/rgb2565/Android.mk
deleted file mode 100644
index 189584d..0000000
--- a/tools/rgb2565/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2008 The Android Open Source Project
-#
-# Android.mk for rgb2565
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-# rgb2565 host tool
-# =========================================================
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := to565.c
-
-LOCAL_CFLAGS += -O2 -Wall -Wno-unused-parameter
-LOCAL_MODULE := rgb2565
-
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/rgb2565/to565.c b/tools/rgb2565/to565.c
deleted file mode 100644
index abf9cdb..0000000
--- a/tools/rgb2565/to565.c
+++ /dev/null
@@ -1,143 +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.
- */
-	
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#define to565(r,g,b)                                            \
-    ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
-
-#define from565_r(x) ((((x) >> 11) & 0x1f) * 255 / 31)
-#define from565_g(x) ((((x) >> 5) & 0x3f) * 255 / 63)
-#define from565_b(x) (((x) & 0x1f) * 255 / 31)
-
-void to_565_raw(void)
-{
-    unsigned char in[3];
-    unsigned short out;
-
-    while(read(0, in, 3) == 3) {
-        out = to565(in[0],in[1],in[2]);
-        write(1, &out, 2);
-    }
-    return;
-}
-
-void to_565_raw_dither(int width)
-{
-    unsigned char in[3];
-    unsigned short out;
-    int i = 0;
-    int e;
-
-    int* error = malloc((width+2) * 3 * sizeof(int));
-    int* next_error = malloc((width+2) * 3 * sizeof(int));
-    memset(error, 0, (width+2) * 3 * sizeof(int));
-    memset(next_error, 0, (width+2) * 3 * sizeof(int));
-    error += 3;        // array goes from [-3..((width+1)*3+2)]
-    next_error += 3;
-
-    while(read(0, in, 3) == 3) {
-        int r = in[0] + error[i*3+0];
-        int rb = (r < 0) ? 0 : ((r > 255) ? 255 : r);
-
-        int g = in[1] + error[i*3+1];
-        int gb = (g < 0) ? 0 : ((g > 255) ? 255 : g);
-
-        int b = in[2] + error[i*3+2];
-        int bb = (b < 0) ? 0 : ((b > 255) ? 255 : b);
-
-        out = to565(rb, gb, bb);
-        write(1, &out, 2);
-
-#define apply_error(ch) {                                               \
-            next_error[(i-1)*3+ch] += e * 3 / 16;                       \
-            next_error[(i)*3+ch] += e * 5 / 16;                         \
-            next_error[(i+1)*3+ch] += e * 1 / 16;                       \
-            error[(i+1)*3+ch] += e - ((e*1/16) + (e*3/16) + (e*5/16));  \
-        }
-
-        e = r - from565_r(out);
-        apply_error(0);
-
-        e = g - from565_g(out);
-        apply_error(1);
-
-        e = b - from565_b(out);
-        apply_error(2);
-
-#undef apply_error
-
-        ++i;
-        if (i == width) {
-            // error <- next_error; next_error <- 0
-            int* temp = error; error = next_error; next_error = temp;
-            memset(next_error, 0, (width+1) * 3 * sizeof(int));
-            i = 0;
-        }
-    }
-
-    free(error-3);
-    free(next_error-3);
-
-    return;
-}
-
-void to_565_rle(void)
-{
-    unsigned char in[3];
-    unsigned short last, color, count;
-    unsigned total = 0;
-    count = 0;
-
-    while(read(0, in, 3) == 3) {
-        color = to565(in[0],in[1],in[2]);
-        if (count) {
-            if ((color == last) && (count != 65535)) {
-                count++;
-                continue;
-            } else {
-                write(1, &count, 2);
-                write(1, &last, 2);
-                total += count;
-            }
-        }
-        last = color;
-        count = 1;
-    }
-    if (count) {
-        write(1, &count, 2);
-        write(1, &last, 2);
-        total += count;
-    }
-    fprintf(stderr,"%d pixels\n",total);
-}
-
-int main(int argc, char **argv)
-{
-    if ((argc == 2) && (!strcmp(argv[1],"-rle"))) {
-        to_565_rle();
-    } else {
-        if (argc > 2 && (!strcmp(argv[1], "-w"))) {
-            to_565_raw_dither(atoi(argv[2]));
-        } else {
-            to_565_raw();
-        }
-    }
-    return 0;
-}
diff --git a/tools/signapk/Android.mk b/tools/signapk/Android.mk
index ac217c7..4506e2f 100644
--- a/tools/signapk/Android.mk
+++ b/tools/signapk/Android.mk
@@ -21,7 +21,11 @@
 LOCAL_MODULE := signapk
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_JAR_MANIFEST := SignApk.mf
-LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-host bouncycastle-bcpkix-host conscrypt-host
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    apksig \
+    bouncycastle-host \
+    bouncycastle-bcpkix-host \
+    conscrypt-host
 LOCAL_REQUIRED_MODULES := libconscrypt_openjdk_jni
 include $(BUILD_HOST_JAVA_LIBRARY)
 
diff --git a/tools/signapk/src/com/android/signapk/ApkSignerV2.java b/tools/signapk/src/com/android/signapk/ApkSignerV2.java
deleted file mode 100644
index 46cd11e..0000000
--- a/tools/signapk/src/com/android/signapk/ApkSignerV2.java
+++ /dev/null
@@ -1,729 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-package com.android.signapk;
-
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.security.DigestException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.KeyFactory;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.X509Certificate;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.MGF1ParameterSpec;
-import java.security.spec.PSSParameterSpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * APK Signature Scheme v2 signer.
- *
- * <p>APK Signature Scheme v2 is a whole-file signature scheme which aims to protect every single
- * bit of the APK, as opposed to the JAR Signature Scheme which protects only the names and
- * uncompressed contents of ZIP entries.
- */
-public abstract class ApkSignerV2 {
-    /*
-     * The two main goals of APK Signature Scheme v2 are:
-     * 1. Detect any unauthorized modifications to the APK. This is achieved by making the signature
-     *    cover every byte of the APK being signed.
-     * 2. Enable much faster signature and integrity verification. This is achieved by requiring
-     *    only a minimal amount of APK parsing before the signature is verified, thus completely
-     *    bypassing ZIP entry decompression and by making integrity verification parallelizable by
-     *    employing a hash tree.
-     *
-     * The generated signature block is wrapped into an APK Signing Block and inserted into the
-     * original APK immediately before the start of ZIP Central Directory. This is to ensure that
-     * JAR and ZIP parsers continue to work on the signed APK. The APK Signing Block is designed for
-     * extensibility. For example, a future signature scheme could insert its signatures there as
-     * well. The contract of the APK Signing Block is that all contents outside of the block must be
-     * protected by signatures inside the block.
-     */
-
-    public static final int SIGNATURE_RSA_PSS_WITH_SHA256 = 0x0101;
-    public static final int SIGNATURE_RSA_PSS_WITH_SHA512 = 0x0102;
-    public static final int SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA256 = 0x0103;
-    public static final int SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA512 = 0x0104;
-    public static final int SIGNATURE_ECDSA_WITH_SHA256 = 0x0201;
-    public static final int SIGNATURE_ECDSA_WITH_SHA512 = 0x0202;
-    public static final int SIGNATURE_DSA_WITH_SHA256 = 0x0301;
-    public static final int SIGNATURE_DSA_WITH_SHA512 = 0x0302;
-
-    /**
-     * {@code .SF} file header section attribute indicating that the APK is signed not just with
-     * JAR signature scheme but also with APK Signature Scheme v2 or newer. This attribute
-     * facilitates v2 signature stripping detection.
-     *
-     * <p>The attribute contains a comma-separated set of signature scheme IDs.
-     */
-    public static final String SF_ATTRIBUTE_ANDROID_APK_SIGNED_NAME = "X-Android-APK-Signed";
-    public static final String SF_ATTRIBUTE_ANDROID_APK_SIGNED_VALUE = "2";
-
-    private static final int CONTENT_DIGEST_CHUNKED_SHA256 = 0;
-    private static final int CONTENT_DIGEST_CHUNKED_SHA512 = 1;
-
-    private static final int CONTENT_DIGESTED_CHUNK_MAX_SIZE_BYTES = 1024 * 1024;
-
-    private static final byte[] APK_SIGNING_BLOCK_MAGIC =
-          new byte[] {
-              0x41, 0x50, 0x4b, 0x20, 0x53, 0x69, 0x67, 0x20,
-              0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x34, 0x32,
-          };
-    private static final int APK_SIGNATURE_SCHEME_V2_BLOCK_ID = 0x7109871a;
-
-    private ApkSignerV2() {}
-
-    /**
-     * Signer configuration.
-     */
-    public static final class SignerConfig {
-        /** Private key. */
-        public PrivateKey privateKey;
-
-        /**
-         * Certificates, with the first certificate containing the public key corresponding to
-         * {@link #privateKey}.
-         */
-        public List<X509Certificate> certificates;
-
-        /**
-         * List of signature algorithms with which to sign (see {@code SIGNATURE_...} constants).
-         */
-        public List<Integer> signatureAlgorithms;
-    }
-
-    /**
-     * Signs the provided APK using APK Signature Scheme v2 and returns the signed APK as a list of
-     * consecutive chunks.
-     *
-     * <p>NOTE: To enable APK signature verifier to detect v2 signature stripping, header sections
-     * of META-INF/*.SF files of APK being signed must contain the
-     * {@code X-Android-APK-Signed: true} attribute.
-     *
-     * @param inputApk contents of the APK to be signed. The APK starts at the current position
-     *        of the buffer and ends at the limit of the buffer.
-     * @param signerConfigs signer configurations, one for each signer.
-     *
-     * @throws ApkParseException if the APK cannot be parsed.
-     * @throws InvalidKeyException if a signing key is not suitable for this signature scheme or
-     *         cannot be used in general.
-     * @throws SignatureException if an error occurs when computing digests of generating
-     *         signatures.
-     */
-    public static ByteBuffer[] sign(
-            ByteBuffer inputApk,
-            List<SignerConfig> signerConfigs)
-                    throws ApkParseException, InvalidKeyException, SignatureException {
-        // Slice/create a view in the inputApk to make sure that:
-        // 1. inputApk is what's between position and limit of the original inputApk, and
-        // 2. changes to position, limit, and byte order are not reflected in the original.
-        ByteBuffer originalInputApk = inputApk;
-        inputApk = originalInputApk.slice();
-        inputApk.order(ByteOrder.LITTLE_ENDIAN);
-
-        // Locate ZIP End of Central Directory (EoCD), Central Directory, and check that Central
-        // Directory is immediately followed by the ZIP End of Central Directory.
-        int eocdOffset = ZipUtils.findZipEndOfCentralDirectoryRecord(inputApk);
-        if (eocdOffset == -1) {
-            throw new ApkParseException("Failed to locate ZIP End of Central Directory");
-        }
-        if (ZipUtils.isZip64EndOfCentralDirectoryLocatorPresent(inputApk, eocdOffset)) {
-            throw new ApkParseException("ZIP64 format not supported");
-        }
-        inputApk.position(eocdOffset);
-        long centralDirSizeLong = ZipUtils.getZipEocdCentralDirectorySizeBytes(inputApk);
-        if (centralDirSizeLong > Integer.MAX_VALUE) {
-            throw new ApkParseException(
-                    "ZIP Central Directory size out of range: " + centralDirSizeLong);
-        }
-        int centralDirSize = (int) centralDirSizeLong;
-        long centralDirOffsetLong = ZipUtils.getZipEocdCentralDirectoryOffset(inputApk);
-        if (centralDirOffsetLong > Integer.MAX_VALUE) {
-            throw new ApkParseException(
-                    "ZIP Central Directory offset in file out of range: " + centralDirOffsetLong);
-        }
-        int centralDirOffset = (int) centralDirOffsetLong;
-        int expectedEocdOffset = centralDirOffset + centralDirSize;
-        if (expectedEocdOffset < centralDirOffset) {
-            throw new ApkParseException(
-                    "ZIP Central Directory extent too large. Offset: " + centralDirOffset
-                            + ", size: " + centralDirSize);
-        }
-        if (eocdOffset != expectedEocdOffset) {
-            throw new ApkParseException(
-                    "ZIP Central Directory not immeiately followed by ZIP End of"
-                            + " Central Directory. CD end: " + expectedEocdOffset
-                            + ", EoCD start: " + eocdOffset);
-        }
-
-        // Create ByteBuffers holding the contents of everything before ZIP Central Directory,
-        // ZIP Central Directory, and ZIP End of Central Directory.
-        inputApk.clear();
-        ByteBuffer beforeCentralDir = getByteBuffer(inputApk, centralDirOffset);
-        ByteBuffer centralDir = getByteBuffer(inputApk, eocdOffset - centralDirOffset);
-        // Create a copy of End of Central Directory because we'll need modify its contents later.
-        byte[] eocdBytes = new byte[inputApk.remaining()];
-        inputApk.get(eocdBytes);
-        ByteBuffer eocd = ByteBuffer.wrap(eocdBytes);
-        eocd.order(inputApk.order());
-
-        // Figure which which digests to use for APK contents.
-        Set<Integer> contentDigestAlgorithms = new HashSet<>();
-        for (SignerConfig signerConfig : signerConfigs) {
-            for (int signatureAlgorithm : signerConfig.signatureAlgorithms) {
-                contentDigestAlgorithms.add(
-                        getSignatureAlgorithmContentDigestAlgorithm(signatureAlgorithm));
-            }
-        }
-
-        // Compute digests of APK contents.
-        Map<Integer, byte[]> contentDigests; // digest algorithm ID -> digest
-        try {
-            contentDigests =
-                    computeContentDigests(
-                            contentDigestAlgorithms,
-                            new ByteBuffer[] {beforeCentralDir, centralDir, eocd});
-        } catch (DigestException e) {
-            throw new SignatureException("Failed to compute digests of APK", e);
-        }
-
-        // Sign the digests and wrap the signatures and signer info into an APK Signing Block.
-        ByteBuffer apkSigningBlock =
-                ByteBuffer.wrap(generateApkSigningBlock(signerConfigs, contentDigests));
-
-        // Update Central Directory Offset in End of Central Directory Record. Central Directory
-        // follows the APK Signing Block and thus is shifted by the size of the APK Signing Block.
-        centralDirOffset += apkSigningBlock.remaining();
-        eocd.clear();
-        ZipUtils.setZipEocdCentralDirectoryOffset(eocd, centralDirOffset);
-
-        // Follow the Java NIO pattern for ByteBuffer whose contents have been consumed.
-        originalInputApk.position(originalInputApk.limit());
-
-        // Reset positions (to 0) and limits (to capacity) in the ByteBuffers below to follow the
-        // Java NIO pattern for ByteBuffers which are ready for their contents to be read by caller.
-        // Contrary to the name, this does not clear the contents of these ByteBuffer.
-        beforeCentralDir.clear();
-        centralDir.clear();
-        eocd.clear();
-
-        // Insert APK Signing Block immediately before the ZIP Central Directory.
-        return new ByteBuffer[] {
-            beforeCentralDir,
-            apkSigningBlock,
-            centralDir,
-            eocd,
-        };
-    }
-
-    private static Map<Integer, byte[]> computeContentDigests(
-            Set<Integer> digestAlgorithms,
-            ByteBuffer[] contents) throws DigestException {
-        // For each digest algorithm the result is computed as follows:
-        // 1. Each segment of contents is split into consecutive chunks of 1 MB in size.
-        //    The final chunk will be shorter iff the length of segment is not a multiple of 1 MB.
-        //    No chunks are produced for empty (zero length) segments.
-        // 2. The digest of each chunk is computed over the concatenation of byte 0xa5, the chunk's
-        //    length in bytes (uint32 little-endian) and the chunk's contents.
-        // 3. The output digest is computed over the concatenation of the byte 0x5a, the number of
-        //    chunks (uint32 little-endian) and the concatenation of digests of chunks of all
-        //    segments in-order.
-
-        int chunkCount = 0;
-        for (ByteBuffer input : contents) {
-            chunkCount += getChunkCount(input.remaining(), CONTENT_DIGESTED_CHUNK_MAX_SIZE_BYTES);
-        }
-
-        final Map<Integer, byte[]> digestsOfChunks = new HashMap<>(digestAlgorithms.size());
-        for (int digestAlgorithm : digestAlgorithms) {
-            int digestOutputSizeBytes = getContentDigestAlgorithmOutputSizeBytes(digestAlgorithm);
-            byte[] concatenationOfChunkCountAndChunkDigests =
-                    new byte[5 + chunkCount * digestOutputSizeBytes];
-            concatenationOfChunkCountAndChunkDigests[0] = 0x5a;
-            setUnsignedInt32LittleEngian(
-                    chunkCount, concatenationOfChunkCountAndChunkDigests, 1);
-            digestsOfChunks.put(digestAlgorithm, concatenationOfChunkCountAndChunkDigests);
-        }
-
-        int chunkIndex = 0;
-        byte[] chunkContentPrefix = new byte[5];
-        chunkContentPrefix[0] = (byte) 0xa5;
-        // Optimization opportunity: digests of chunks can be computed in parallel.
-        for (ByteBuffer input : contents) {
-            while (input.hasRemaining()) {
-                int chunkSize =
-                        Math.min(input.remaining(), CONTENT_DIGESTED_CHUNK_MAX_SIZE_BYTES);
-                final ByteBuffer chunk = getByteBuffer(input, chunkSize);
-                for (int digestAlgorithm : digestAlgorithms) {
-                    String jcaAlgorithmName =
-                            getContentDigestAlgorithmJcaDigestAlgorithm(digestAlgorithm);
-                    MessageDigest md;
-                    try {
-                        md = MessageDigest.getInstance(jcaAlgorithmName);
-                    } catch (NoSuchAlgorithmException e) {
-                        throw new DigestException(
-                                jcaAlgorithmName + " MessageDigest not supported", e);
-                    }
-                    // Reset position to 0 and limit to capacity. Position would've been modified
-                    // by the preceding iteration of this loop. NOTE: Contrary to the method name,
-                    // this does not modify the contents of the chunk.
-                    chunk.clear();
-                    setUnsignedInt32LittleEngian(chunk.remaining(), chunkContentPrefix, 1);
-                    md.update(chunkContentPrefix);
-                    md.update(chunk);
-                    byte[] concatenationOfChunkCountAndChunkDigests =
-                            digestsOfChunks.get(digestAlgorithm);
-                    int expectedDigestSizeBytes =
-                            getContentDigestAlgorithmOutputSizeBytes(digestAlgorithm);
-                    int actualDigestSizeBytes =
-                            md.digest(
-                                    concatenationOfChunkCountAndChunkDigests,
-                                    5 + chunkIndex * expectedDigestSizeBytes,
-                                    expectedDigestSizeBytes);
-                    if (actualDigestSizeBytes != expectedDigestSizeBytes) {
-                        throw new DigestException(
-                                "Unexpected output size of " + md.getAlgorithm()
-                                        + " digest: " + actualDigestSizeBytes);
-                    }
-                }
-                chunkIndex++;
-            }
-        }
-
-        Map<Integer, byte[]> result = new HashMap<>(digestAlgorithms.size());
-        for (Map.Entry<Integer, byte[]> entry : digestsOfChunks.entrySet()) {
-            int digestAlgorithm = entry.getKey();
-            byte[] concatenationOfChunkCountAndChunkDigests = entry.getValue();
-            String jcaAlgorithmName = getContentDigestAlgorithmJcaDigestAlgorithm(digestAlgorithm);
-            MessageDigest md;
-            try {
-                md = MessageDigest.getInstance(jcaAlgorithmName);
-            } catch (NoSuchAlgorithmException e) {
-                throw new DigestException(jcaAlgorithmName + " MessageDigest not supported", e);
-            }
-            result.put(digestAlgorithm, md.digest(concatenationOfChunkCountAndChunkDigests));
-        }
-        return result;
-    }
-
-    private static final int getChunkCount(int inputSize, int chunkSize) {
-        return (inputSize + chunkSize - 1) / chunkSize;
-    }
-
-    private static void setUnsignedInt32LittleEngian(int value, byte[] result, int offset) {
-        result[offset] = (byte) (value & 0xff);
-        result[offset + 1] = (byte) ((value >> 8) & 0xff);
-        result[offset + 2] = (byte) ((value >> 16) & 0xff);
-        result[offset + 3] = (byte) ((value >> 24) & 0xff);
-    }
-
-    private static byte[] generateApkSigningBlock(
-            List<SignerConfig> signerConfigs,
-            Map<Integer, byte[]> contentDigests) throws InvalidKeyException, SignatureException {
-        byte[] apkSignatureSchemeV2Block =
-                generateApkSignatureSchemeV2Block(signerConfigs, contentDigests);
-        return generateApkSigningBlock(apkSignatureSchemeV2Block);
-    }
-
-    private static byte[] generateApkSigningBlock(byte[] apkSignatureSchemeV2Block) {
-        // FORMAT:
-        // uint64:  size (excluding this field)
-        // repeated ID-value pairs:
-        //     uint64:           size (excluding this field)
-        //     uint32:           ID
-        //     (size - 4) bytes: value
-        // uint64:  size (same as the one above)
-        // uint128: magic
-
-        int resultSize =
-                8 // size
-                + 8 + 4 + apkSignatureSchemeV2Block.length // v2Block as ID-value pair
-                + 8 // size
-                + 16 // magic
-                ;
-        ByteBuffer result = ByteBuffer.allocate(resultSize);
-        result.order(ByteOrder.LITTLE_ENDIAN);
-        long blockSizeFieldValue = resultSize - 8;
-        result.putLong(blockSizeFieldValue);
-
-        long pairSizeFieldValue = 4 + apkSignatureSchemeV2Block.length;
-        result.putLong(pairSizeFieldValue);
-        result.putInt(APK_SIGNATURE_SCHEME_V2_BLOCK_ID);
-        result.put(apkSignatureSchemeV2Block);
-
-        result.putLong(blockSizeFieldValue);
-        result.put(APK_SIGNING_BLOCK_MAGIC);
-
-        return result.array();
-    }
-
-    private static byte[] generateApkSignatureSchemeV2Block(
-            List<SignerConfig> signerConfigs,
-            Map<Integer, byte[]> contentDigests) throws InvalidKeyException, SignatureException {
-        // FORMAT:
-        // * length-prefixed sequence of length-prefixed signer blocks.
-
-        List<byte[]> signerBlocks = new ArrayList<>(signerConfigs.size());
-        int signerNumber = 0;
-        for (SignerConfig signerConfig : signerConfigs) {
-            signerNumber++;
-            byte[] signerBlock;
-            try {
-                signerBlock = generateSignerBlock(signerConfig, contentDigests);
-            } catch (InvalidKeyException e) {
-                throw new InvalidKeyException("Signer #" + signerNumber + " failed", e);
-            } catch (SignatureException e) {
-                throw new SignatureException("Signer #" + signerNumber + " failed", e);
-            }
-            signerBlocks.add(signerBlock);
-        }
-
-        return encodeAsSequenceOfLengthPrefixedElements(
-                new byte[][] {
-                    encodeAsSequenceOfLengthPrefixedElements(signerBlocks),
-                });
-    }
-
-    private static byte[] generateSignerBlock(
-            SignerConfig signerConfig,
-            Map<Integer, byte[]> contentDigests) throws InvalidKeyException, SignatureException {
-        if (signerConfig.certificates.isEmpty()) {
-            throw new SignatureException("No certificates configured for signer");
-        }
-        PublicKey publicKey = signerConfig.certificates.get(0).getPublicKey();
-
-        byte[] encodedPublicKey = encodePublicKey(publicKey);
-
-        V2SignatureSchemeBlock.SignedData signedData = new V2SignatureSchemeBlock.SignedData();
-        try {
-            signedData.certificates = encodeCertificates(signerConfig.certificates);
-        } catch (CertificateEncodingException e) {
-            throw new SignatureException("Failed to encode certificates", e);
-        }
-
-        List<Pair<Integer, byte[]>> digests =
-                new ArrayList<>(signerConfig.signatureAlgorithms.size());
-        for (int signatureAlgorithm : signerConfig.signatureAlgorithms) {
-            int contentDigestAlgorithm =
-                    getSignatureAlgorithmContentDigestAlgorithm(signatureAlgorithm);
-            byte[] contentDigest = contentDigests.get(contentDigestAlgorithm);
-            if (contentDigest == null) {
-                throw new RuntimeException(
-                        getContentDigestAlgorithmJcaDigestAlgorithm(contentDigestAlgorithm)
-                        + " content digest for "
-                        + getSignatureAlgorithmJcaSignatureAlgorithm(signatureAlgorithm)
-                        + " not computed");
-            }
-            digests.add(Pair.create(signatureAlgorithm, contentDigest));
-        }
-        signedData.digests = digests;
-
-        V2SignatureSchemeBlock.Signer signer = new V2SignatureSchemeBlock.Signer();
-        // FORMAT:
-        // * length-prefixed sequence of length-prefixed digests:
-        //   * uint32: signature algorithm ID
-        //   * length-prefixed bytes: digest of contents
-        // * length-prefixed sequence of certificates:
-        //   * length-prefixed bytes: X.509 certificate (ASN.1 DER encoded).
-        // * length-prefixed sequence of length-prefixed additional attributes:
-        //   * uint32: ID
-        //   * (length - 4) bytes: value
-        signer.signedData = encodeAsSequenceOfLengthPrefixedElements(new byte[][] {
-            encodeAsSequenceOfLengthPrefixedPairsOfIntAndLengthPrefixedBytes(signedData.digests),
-            encodeAsSequenceOfLengthPrefixedElements(signedData.certificates),
-            // additional attributes
-            new byte[0],
-        });
-        signer.publicKey = encodedPublicKey;
-        signer.signatures = new ArrayList<>();
-        for (int signatureAlgorithm : signerConfig.signatureAlgorithms) {
-            Pair<String, ? extends AlgorithmParameterSpec> signatureParams =
-                    getSignatureAlgorithmJcaSignatureAlgorithm(signatureAlgorithm);
-            String jcaSignatureAlgorithm = signatureParams.getFirst();
-            AlgorithmParameterSpec jcaSignatureAlgorithmParams = signatureParams.getSecond();
-            byte[] signatureBytes;
-            try {
-                Signature signature = Signature.getInstance(jcaSignatureAlgorithm);
-                signature.initSign(signerConfig.privateKey);
-                if (jcaSignatureAlgorithmParams != null) {
-                    signature.setParameter(jcaSignatureAlgorithmParams);
-                }
-                signature.update(signer.signedData);
-                signatureBytes = signature.sign();
-            } catch (InvalidKeyException e) {
-                throw new InvalidKeyException("Failed sign using " + jcaSignatureAlgorithm, e);
-            } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException
-                    | SignatureException e) {
-                throw new SignatureException("Failed sign using " + jcaSignatureAlgorithm, e);
-            }
-
-            try {
-                Signature signature = Signature.getInstance(jcaSignatureAlgorithm);
-                signature.initVerify(publicKey);
-                if (jcaSignatureAlgorithmParams != null) {
-                    signature.setParameter(jcaSignatureAlgorithmParams);
-                }
-                signature.update(signer.signedData);
-                if (!signature.verify(signatureBytes)) {
-                    throw new SignatureException("Signature did not verify");
-                }
-            } catch (InvalidKeyException e) {
-                throw new InvalidKeyException("Failed to verify generated " + jcaSignatureAlgorithm
-                        + " signature using public key from certificate", e);
-            } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException
-                    | SignatureException e) {
-                throw new SignatureException("Failed to verify generated " + jcaSignatureAlgorithm
-                        + " signature using public key from certificate", e);
-            }
-
-            signer.signatures.add(Pair.create(signatureAlgorithm, signatureBytes));
-        }
-
-        // FORMAT:
-        // * length-prefixed signed data
-        // * length-prefixed sequence of length-prefixed signatures:
-        //   * uint32: signature algorithm ID
-        //   * length-prefixed bytes: signature of signed data
-        // * length-prefixed bytes: public key (X.509 SubjectPublicKeyInfo, ASN.1 DER encoded)
-        return encodeAsSequenceOfLengthPrefixedElements(
-                new byte[][] {
-                    signer.signedData,
-                    encodeAsSequenceOfLengthPrefixedPairsOfIntAndLengthPrefixedBytes(
-                            signer.signatures),
-                    signer.publicKey,
-                });
-    }
-
-    private static final class V2SignatureSchemeBlock {
-        private static final class Signer {
-            public byte[] signedData;
-            public List<Pair<Integer, byte[]>> signatures;
-            public byte[] publicKey;
-        }
-
-        private static final class SignedData {
-            public List<Pair<Integer, byte[]>> digests;
-            public List<byte[]> certificates;
-        }
-    }
-
-    private static byte[] encodePublicKey(PublicKey publicKey) throws InvalidKeyException {
-        byte[] encodedPublicKey = null;
-        if ("X.509".equals(publicKey.getFormat())) {
-            encodedPublicKey = publicKey.getEncoded();
-        }
-        if (encodedPublicKey == null) {
-            try {
-                encodedPublicKey =
-                        KeyFactory.getInstance(publicKey.getAlgorithm())
-                                .getKeySpec(publicKey, X509EncodedKeySpec.class)
-                                .getEncoded();
-            } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
-                throw new InvalidKeyException(
-                        "Failed to obtain X.509 encoded form of public key " + publicKey
-                                + " of class " + publicKey.getClass().getName(),
-                        e);
-            }
-        }
-        if ((encodedPublicKey == null) || (encodedPublicKey.length == 0)) {
-            throw new InvalidKeyException(
-                    "Failed to obtain X.509 encoded form of public key " + publicKey
-                            + " of class " + publicKey.getClass().getName());
-        }
-        return encodedPublicKey;
-    }
-
-    public static List<byte[]> encodeCertificates(List<X509Certificate> certificates)
-            throws CertificateEncodingException {
-        List<byte[]> result = new ArrayList<>();
-        for (X509Certificate certificate : certificates) {
-            result.add(certificate.getEncoded());
-        }
-        return result;
-    }
-
-    private static byte[] encodeAsSequenceOfLengthPrefixedElements(List<byte[]> sequence) {
-        return encodeAsSequenceOfLengthPrefixedElements(
-                sequence.toArray(new byte[sequence.size()][]));
-    }
-
-    private static byte[] encodeAsSequenceOfLengthPrefixedElements(byte[][] sequence) {
-        int payloadSize = 0;
-        for (byte[] element : sequence) {
-            payloadSize += 4 + element.length;
-        }
-        ByteBuffer result = ByteBuffer.allocate(payloadSize);
-        result.order(ByteOrder.LITTLE_ENDIAN);
-        for (byte[] element : sequence) {
-            result.putInt(element.length);
-            result.put(element);
-        }
-        return result.array();
-      }
-
-    private static byte[] encodeAsSequenceOfLengthPrefixedPairsOfIntAndLengthPrefixedBytes(
-            List<Pair<Integer, byte[]>> sequence) {
-        int resultSize = 0;
-        for (Pair<Integer, byte[]> element : sequence) {
-            resultSize += 12 + element.getSecond().length;
-        }
-        ByteBuffer result = ByteBuffer.allocate(resultSize);
-        result.order(ByteOrder.LITTLE_ENDIAN);
-        for (Pair<Integer, byte[]> element : sequence) {
-            byte[] second = element.getSecond();
-            result.putInt(8 + second.length);
-            result.putInt(element.getFirst());
-            result.putInt(second.length);
-            result.put(second);
-        }
-        return result.array();
-    }
-
-    /**
-     * Relative <em>get</em> method for reading {@code size} number of bytes from the current
-     * position of this buffer.
-     *
-     * <p>This method reads the next {@code size} bytes at this buffer's current position,
-     * returning them as a {@code ByteBuffer} with start set to 0, limit and capacity set to
-     * {@code size}, byte order set to this buffer's byte order; and then increments the position by
-     * {@code size}.
-     */
-    private static ByteBuffer getByteBuffer(ByteBuffer source, int size) {
-        if (size < 0) {
-            throw new IllegalArgumentException("size: " + size);
-        }
-        int originalLimit = source.limit();
-        int position = source.position();
-        int limit = position + size;
-        if ((limit < position) || (limit > originalLimit)) {
-            throw new BufferUnderflowException();
-        }
-        source.limit(limit);
-        try {
-            ByteBuffer result = source.slice();
-            result.order(source.order());
-            source.position(limit);
-            return result;
-        } finally {
-            source.limit(originalLimit);
-        }
-    }
-
-    private static Pair<String, ? extends AlgorithmParameterSpec>
-            getSignatureAlgorithmJcaSignatureAlgorithm(int sigAlgorithm) {
-        switch (sigAlgorithm) {
-            case SIGNATURE_RSA_PSS_WITH_SHA256:
-                return Pair.create(
-                        "SHA256withRSA/PSS",
-                        new PSSParameterSpec(
-                                "SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 256 / 8, 1));
-            case SIGNATURE_RSA_PSS_WITH_SHA512:
-                return Pair.create(
-                        "SHA512withRSA/PSS",
-                        new PSSParameterSpec(
-                                "SHA-512", "MGF1", MGF1ParameterSpec.SHA512, 512 / 8, 1));
-            case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA256:
-                return Pair.create("SHA256withRSA", null);
-            case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA512:
-                return Pair.create("SHA512withRSA", null);
-            case SIGNATURE_ECDSA_WITH_SHA256:
-                return Pair.create("SHA256withECDSA", null);
-            case SIGNATURE_ECDSA_WITH_SHA512:
-                return Pair.create("SHA512withECDSA", null);
-            case SIGNATURE_DSA_WITH_SHA256:
-                return Pair.create("SHA256withDSA", null);
-            case SIGNATURE_DSA_WITH_SHA512:
-                return Pair.create("SHA512withDSA", null);
-            default:
-                throw new IllegalArgumentException(
-                        "Unknown signature algorithm: 0x"
-                                + Long.toHexString(sigAlgorithm & 0xffffffff));
-        }
-    }
-
-    private static int getSignatureAlgorithmContentDigestAlgorithm(int sigAlgorithm) {
-        switch (sigAlgorithm) {
-            case SIGNATURE_RSA_PSS_WITH_SHA256:
-            case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA256:
-            case SIGNATURE_ECDSA_WITH_SHA256:
-            case SIGNATURE_DSA_WITH_SHA256:
-                return CONTENT_DIGEST_CHUNKED_SHA256;
-            case SIGNATURE_RSA_PSS_WITH_SHA512:
-            case SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA512:
-            case SIGNATURE_ECDSA_WITH_SHA512:
-            case SIGNATURE_DSA_WITH_SHA512:
-                return CONTENT_DIGEST_CHUNKED_SHA512;
-            default:
-                throw new IllegalArgumentException(
-                        "Unknown signature algorithm: 0x"
-                                + Long.toHexString(sigAlgorithm & 0xffffffff));
-        }
-    }
-
-    private static String getContentDigestAlgorithmJcaDigestAlgorithm(int digestAlgorithm) {
-        switch (digestAlgorithm) {
-            case CONTENT_DIGEST_CHUNKED_SHA256:
-                return "SHA-256";
-            case CONTENT_DIGEST_CHUNKED_SHA512:
-                return "SHA-512";
-            default:
-                throw new IllegalArgumentException(
-                        "Unknown content digest algorthm: " + digestAlgorithm);
-        }
-    }
-
-    private static int getContentDigestAlgorithmOutputSizeBytes(int digestAlgorithm) {
-        switch (digestAlgorithm) {
-            case CONTENT_DIGEST_CHUNKED_SHA256:
-                return 256 / 8;
-            case CONTENT_DIGEST_CHUNKED_SHA512:
-                return 512 / 8;
-            default:
-                throw new IllegalArgumentException(
-                        "Unknown content digest algorthm: " + digestAlgorithm);
-        }
-    }
-
-    /**
-     * Indicates that APK file could not be parsed.
-     */
-    public static class ApkParseException extends Exception {
-        private static final long serialVersionUID = 1L;
-
-        public ApkParseException(String message) {
-            super(message);
-        }
-
-        public ApkParseException(String message, Throwable cause) {
-            super(message, cause);
-        }
-    }
-}
diff --git a/tools/signapk/src/com/android/signapk/Pair.java b/tools/signapk/src/com/android/signapk/Pair.java
deleted file mode 100644
index e4a6c92..0000000
--- a/tools/signapk/src/com/android/signapk/Pair.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-package com.android.signapk;
-
-/**
- * Pair of two elements.
- */
-public final class Pair<A, B> {
-    private final A mFirst;
-    private final B mSecond;
-
-    private Pair(A first, B second) {
-        mFirst = first;
-        mSecond = second;
-    }
-
-    public static <A, B> Pair<A, B> create(A first, B second) {
-        return new Pair<A, B>(first, second);
-    }
-
-    public A getFirst() {
-        return mFirst;
-    }
-
-    public B getSecond() {
-        return mSecond;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((mFirst == null) ? 0 : mFirst.hashCode());
-        result = prime * result + ((mSecond == null) ? 0 : mSecond.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        @SuppressWarnings("rawtypes")
-        Pair other = (Pair) obj;
-        if (mFirst == null) {
-            if (other.mFirst != null) {
-                return false;
-            }
-        } else if (!mFirst.equals(other.mFirst)) {
-            return false;
-        }
-        if (mSecond == null) {
-            if (other.mSecond != null) {
-                return false;
-            }
-        } else if (!mSecond.equals(other.mSecond)) {
-            return false;
-        }
-        return true;
-    }
-}
diff --git a/tools/signapk/src/com/android/signapk/SignApk.java b/tools/signapk/src/com/android/signapk/SignApk.java
index ba84b42..3b00599 100644
--- a/tools/signapk/src/com/android/signapk/SignApk.java
+++ b/tools/signapk/src/com/android/signapk/SignApk.java
@@ -23,7 +23,6 @@
 import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
 import org.bouncycastle.cert.jcajce.JcaCertStore;
 import org.bouncycastle.cms.CMSException;
-import org.bouncycastle.cms.CMSProcessableByteArray;
 import org.bouncycastle.cms.CMSSignedData;
 import org.bouncycastle.cms.CMSSignedDataGenerator;
 import org.bouncycastle.cms.CMSTypedData;
@@ -33,9 +32,16 @@
 import org.bouncycastle.operator.OperatorCreationException;
 import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
 import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
-import org.bouncycastle.util.encoders.Base64;
 import org.conscrypt.OpenSSLProvider;
 
+import com.android.apksig.ApkSignerEngine;
+import com.android.apksig.DefaultApkSignerEngine;
+import com.android.apksig.apk.ApkUtils;
+import com.android.apksig.apk.MinSdkVersionException;
+import com.android.apksig.util.DataSink;
+import com.android.apksig.util.DataSources;
+import com.android.apksig.zip.ZipFormatException;
+
 import java.io.Console;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
@@ -49,18 +55,15 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
-import java.io.PrintStream;
 import java.lang.reflect.Constructor;
 import java.nio.ByteBuffer;
-import java.security.DigestOutputStream;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
 import java.security.GeneralSecurityException;
-import java.security.InvalidKeyException;
 import java.security.Key;
 import java.security.KeyFactory;
-import java.security.MessageDigest;
 import java.security.PrivateKey;
 import java.security.Provider;
-import java.security.PublicKey;
 import java.security.Security;
 import java.security.cert.CertificateEncodingException;
 import java.security.cert.CertificateFactory;
@@ -70,18 +73,14 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 import java.util.TimeZone;
-import java.util.TreeMap;
-import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
 import java.util.regex.Pattern;
+
 import javax.crypto.Cipher;
 import javax.crypto.EncryptedPrivateKeyInfo;
 import javax.crypto.SecretKeyFactory;
@@ -111,39 +110,35 @@
  * APK Signature Scheme v2.
  */
 class SignApk {
-    private static final String CERT_SF_NAME = "META-INF/CERT.SF";
-    private static final String CERT_SIG_NAME = "META-INF/CERT.%s";
-    private static final String CERT_SF_MULTI_NAME = "META-INF/CERT%d.SF";
-    private static final String CERT_SIG_MULTI_NAME = "META-INF/CERT%d.%s";
-
     private static final String OTACERT_NAME = "META-INF/com/android/otacert";
 
+    /**
+     * Extensible data block/field header ID used for storing information about alignment of
+     * uncompressed entries as well as for aligning the entries's data. See ZIP appnote.txt section
+     * 4.5 Extensible data fields.
+     */
+    private static final short ALIGNMENT_ZIP_EXTRA_DATA_FIELD_HEADER_ID = (short) 0xd935;
+
+    /**
+     * Minimum size (in bytes) of the extensible data block/field used for alignment of uncompressed
+     * entries.
+     */
+    private static final short ALIGNMENT_ZIP_EXTRA_DATA_FIELD_MIN_SIZE_BYTES = 6;
+
     // bitmasks for which hash algorithms we need the manifest to include.
     private static final int USE_SHA1 = 1;
     private static final int USE_SHA256 = 2;
 
-    /** Digest algorithm used when signing the APK using APK Signature Scheme v2. */
-    private static final String APK_SIG_SCHEME_V2_DIGEST_ALGORITHM = "SHA-256";
-
     /**
-     * Minimum Android SDK API Level which accepts JAR signatures which use SHA-256. Older platform
-     * versions accept only SHA-1 signatures.
+     * Returns the digest algorithm ID (one of {@code USE_SHA1} or {@code USE_SHA256}) to be used
+     * for signing an OTA update package using the private key corresponding to the provided
+     * certificate.
      */
-    private static final int MIN_API_LEVEL_FOR_SHA256_JAR_SIGNATURES = 18;
-
-    /**
-     * Return one of USE_SHA1 or USE_SHA256 according to the signature
-     * algorithm specified in the cert.
-     */
-    private static int getDigestAlgorithm(X509Certificate cert, int minSdkVersion) {
+    private static int getDigestAlgorithmForOta(X509Certificate cert) {
         String sigAlg = cert.getSigAlgName().toUpperCase(Locale.US);
         if ("SHA1WITHRSA".equals(sigAlg) || "MD5WITHRSA".equals(sigAlg)) {
             // see "HISTORICAL NOTE" above.
-            if (minSdkVersion < MIN_API_LEVEL_FOR_SHA256_JAR_SIGNATURES) {
-                return USE_SHA1;
-            } else {
-                return USE_SHA256;
-            }
+            return USE_SHA1;
         } else if (sigAlg.startsWith("SHA256WITH")) {
             return USE_SHA256;
         } else {
@@ -152,28 +147,35 @@
         }
     }
 
-    /** Returns the expected signature algorithm for this key type. */
-    private static String getSignatureAlgorithm(X509Certificate cert, int minSdkVersion) {
-        String keyType = cert.getPublicKey().getAlgorithm().toUpperCase(Locale.US);
-        if ("RSA".equalsIgnoreCase(keyType)) {
-            if ((minSdkVersion >= MIN_API_LEVEL_FOR_SHA256_JAR_SIGNATURES)
-                    || (getDigestAlgorithm(cert, minSdkVersion) == USE_SHA256)) {
-                return "SHA256withRSA";
-            } else {
-                return "SHA1withRSA";
-            }
-        } else if ("EC".equalsIgnoreCase(keyType)) {
-            return "SHA256withECDSA";
+    /**
+     * Returns the JCA {@link java.security.Signature} algorithm to be used for signing and OTA
+     * update package using the private key corresponding to the provided certificate and the
+     * provided digest algorithm (see {@code USE_SHA1} and {@code USE_SHA256} constants).
+     */
+    private static String getJcaSignatureAlgorithmForOta(
+            X509Certificate cert, int hash) {
+        String sigAlgDigestPrefix;
+        switch (hash) {
+            case USE_SHA1:
+                sigAlgDigestPrefix = "SHA1";
+                break;
+            case USE_SHA256:
+                sigAlgDigestPrefix = "SHA256";
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown hash ID: " + hash);
+        }
+
+        String keyAlgorithm = cert.getPublicKey().getAlgorithm();
+        if ("RSA".equalsIgnoreCase(keyAlgorithm)) {
+            return sigAlgDigestPrefix + "withRSA";
+        } else if ("EC".equalsIgnoreCase(keyAlgorithm)) {
+            return sigAlgDigestPrefix + "withECDSA";
         } else {
-            throw new IllegalArgumentException("unsupported key type: " + keyType);
+            throw new IllegalArgumentException("Unsupported key algorithm: " + keyAlgorithm);
         }
     }
 
-    // Files matching this pattern are not copied to the output.
-    private static Pattern stripPattern =
-        Pattern.compile("^(META-INF/((.*)[.](SF|RSA|DSA|EC)|com/android/otacert))|(" +
-                        Pattern.quote(JarFile.MANIFEST_NAME) + ")$");
-
     private static X509Certificate readPublicKey(File file)
         throws IOException, GeneralSecurityException {
         FileInputStream input = new FileInputStream(file);
@@ -279,100 +281,16 @@
     }
 
     /**
-     * Add the hash(es) of every file to the manifest, creating it if
-     * necessary.
-     */
-    private static Manifest addDigestsToManifest(JarFile jar, int hashes)
-        throws IOException, GeneralSecurityException {
-        Manifest input = jar.getManifest();
-        Manifest output = new Manifest();
-        Attributes main = output.getMainAttributes();
-        if (input != null) {
-            main.putAll(input.getMainAttributes());
-        } else {
-            main.putValue("Manifest-Version", "1.0");
-            main.putValue("Created-By", "1.0 (Android SignApk)");
-        }
-
-        MessageDigest md_sha1 = null;
-        MessageDigest md_sha256 = null;
-        if ((hashes & USE_SHA1) != 0) {
-            md_sha1 = MessageDigest.getInstance("SHA1");
-        }
-        if ((hashes & USE_SHA256) != 0) {
-            md_sha256 = MessageDigest.getInstance("SHA256");
-        }
-
-        byte[] buffer = new byte[4096];
-        int num;
-
-        // We sort the input entries by name, and add them to the
-        // output manifest in sorted order.  We expect that the output
-        // map will be deterministic.
-
-        TreeMap<String, JarEntry> byName = new TreeMap<String, JarEntry>();
-
-        for (Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements(); ) {
-            JarEntry entry = e.nextElement();
-            byName.put(entry.getName(), entry);
-        }
-
-        for (JarEntry entry: byName.values()) {
-            String name = entry.getName();
-            if (!entry.isDirectory() &&
-                (stripPattern == null || !stripPattern.matcher(name).matches())) {
-                InputStream data = jar.getInputStream(entry);
-                while ((num = data.read(buffer)) > 0) {
-                    if (md_sha1 != null) md_sha1.update(buffer, 0, num);
-                    if (md_sha256 != null) md_sha256.update(buffer, 0, num);
-                }
-
-                Attributes attr = null;
-                if (input != null) attr = input.getAttributes(name);
-                attr = attr != null ? new Attributes(attr) : new Attributes();
-                // Remove any previously computed digests from this entry's attributes.
-                for (Iterator<Object> i = attr.keySet().iterator(); i.hasNext();) {
-                    Object key = i.next();
-                    if (!(key instanceof Attributes.Name)) {
-                        continue;
-                    }
-                    String attributeNameLowerCase =
-                            ((Attributes.Name) key).toString().toLowerCase(Locale.US);
-                    if (attributeNameLowerCase.endsWith("-digest")) {
-                        i.remove();
-                    }
-                }
-                // Add SHA-1 digest if requested
-                if (md_sha1 != null) {
-                    attr.putValue("SHA1-Digest",
-                                  new String(Base64.encode(md_sha1.digest()), "ASCII"));
-                }
-                // Add SHA-256 digest if requested
-                if (md_sha256 != null) {
-                    attr.putValue("SHA-256-Digest",
-                                  new String(Base64.encode(md_sha256.digest()), "ASCII"));
-                }
-                output.getEntries().put(name, attr);
-            }
-        }
-
-        return output;
-    }
-
-    /**
      * Add a copy of the public key to the archive; this should
      * exactly match one of the files in
      * /system/etc/security/otacerts.zip on the device.  (The same
-     * cert can be extracted from the CERT.RSA file but this is much
-     * easier to get at.)
+     * cert can be extracted from the OTA update package's signature
+     * block but this is much easier to get at.)
      */
     private static void addOtacert(JarOutputStream outputJar,
                                    File publicKeyFile,
-                                   long timestamp,
-                                   Manifest manifest,
-                                   int hash)
-        throws IOException, GeneralSecurityException {
-        MessageDigest md = MessageDigest.getInstance(hash == USE_SHA1 ? "SHA1" : "SHA256");
+                                   long timestamp)
+        throws IOException {
 
         JarEntry je = new JarEntry(OTACERT_NAME);
         je.setTime(timestamp);
@@ -382,108 +300,14 @@
         int read;
         while ((read = input.read(b)) != -1) {
             outputJar.write(b, 0, read);
-            md.update(b, 0, read);
         }
         input.close();
-
-        Attributes attr = new Attributes();
-        attr.putValue(hash == USE_SHA1 ? "SHA1-Digest" : "SHA-256-Digest",
-                      new String(Base64.encode(md.digest()), "ASCII"));
-        manifest.getEntries().put(OTACERT_NAME, attr);
     }
 
 
-    /** Write to another stream and track how many bytes have been
-     *  written.
-     */
-    private static class CountOutputStream extends FilterOutputStream {
-        private int mCount;
-
-        public CountOutputStream(OutputStream out) {
-            super(out);
-            mCount = 0;
-        }
-
-        @Override
-        public void write(int b) throws IOException {
-            super.write(b);
-            mCount++;
-        }
-
-        @Override
-        public void write(byte[] b, int off, int len) throws IOException {
-            super.write(b, off, len);
-            mCount += len;
-        }
-
-        public int size() {
-            return mCount;
-        }
-    }
-
-    /** Write a .SF file with a digest of the specified manifest. */
-    private static void writeSignatureFile(Manifest manifest, OutputStream out,
-            int hash, boolean additionallySignedUsingAnApkSignatureScheme)
-        throws IOException, GeneralSecurityException {
-        Manifest sf = new Manifest();
-        Attributes main = sf.getMainAttributes();
-        main.putValue("Signature-Version", "1.0");
-        main.putValue("Created-By", "1.0 (Android SignApk)");
-        if (additionallySignedUsingAnApkSignatureScheme) {
-            // Add APK Signature Scheme v2 signature stripping protection.
-            // This attribute indicates that this APK is supposed to have been signed using one or
-            // more APK-specific signature schemes in addition to the standard JAR signature scheme
-            // used by this code. APK signature verifier should reject the APK if it does not
-            // contain a signature for the signature scheme the verifier prefers out of this set.
-            main.putValue(
-                    ApkSignerV2.SF_ATTRIBUTE_ANDROID_APK_SIGNED_NAME,
-                    ApkSignerV2.SF_ATTRIBUTE_ANDROID_APK_SIGNED_VALUE);
-        }
-
-        MessageDigest md = MessageDigest.getInstance(
-            hash == USE_SHA256 ? "SHA256" : "SHA1");
-        PrintStream print = new PrintStream(
-            new DigestOutputStream(new ByteArrayOutputStream(), md),
-            true, "UTF-8");
-
-        // Digest of the entire manifest
-        manifest.write(print);
-        print.flush();
-        main.putValue(hash == USE_SHA256 ? "SHA-256-Digest-Manifest" : "SHA1-Digest-Manifest",
-                      new String(Base64.encode(md.digest()), "ASCII"));
-
-        Map<String, Attributes> entries = manifest.getEntries();
-        for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
-            // Digest of the manifest stanza for this entry.
-            print.print("Name: " + entry.getKey() + "\r\n");
-            for (Map.Entry<Object, Object> att : entry.getValue().entrySet()) {
-                print.print(att.getKey() + ": " + att.getValue() + "\r\n");
-            }
-            print.print("\r\n");
-            print.flush();
-
-            Attributes sfAttr = new Attributes();
-            sfAttr.putValue(hash == USE_SHA256 ? "SHA-256-Digest" : "SHA1-Digest",
-                            new String(Base64.encode(md.digest()), "ASCII"));
-            sf.getEntries().put(entry.getKey(), sfAttr);
-        }
-
-        CountOutputStream cout = new CountOutputStream(out);
-        sf.write(cout);
-
-        // A bug in the java.util.jar implementation of Android platforms
-        // up to version 1.6 will cause a spurious IOException to be thrown
-        // if the length of the signature file is a multiple of 1024 bytes.
-        // As a workaround, add an extra CRLF in this case.
-        if ((cout.size() % 1024) == 0) {
-            cout.write('\r');
-            cout.write('\n');
-        }
-    }
-
     /** Sign data and write the digital signature to 'out'. */
     private static void writeSignatureBlock(
-        CMSTypedData data, X509Certificate publicKey, PrivateKey privateKey, int minSdkVersion,
+        CMSTypedData data, X509Certificate publicKey, PrivateKey privateKey, int hash,
         OutputStream out)
         throws IOException,
                CertificateEncodingException,
@@ -495,7 +319,8 @@
 
         CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
         ContentSigner signer =
-                new JcaContentSignerBuilder(getSignatureAlgorithm(publicKey, minSdkVersion))
+                new JcaContentSignerBuilder(
+                        getJcaSignatureAlgorithmForOta(publicKey, hash))
                         .build(privateKey);
         gen.addSignerInfoGenerator(
             new JcaSignerInfoGeneratorBuilder(
@@ -513,18 +338,58 @@
     }
 
     /**
-     * Copy all the files in a manifest from input to output.  We set
-     * the modification times in the output to a fixed time, so as to
-     * reduce variation in the output file and make incremental OTAs
-     * more efficient.
+     * Adds ZIP entries which represent the v1 signature (JAR signature scheme).
      */
-    private static void copyFiles(Manifest manifest, JarFile in, JarOutputStream out,
-                                  long timestamp, int defaultAlignment) throws IOException {
+    private static void addV1Signature(
+            ApkSignerEngine apkSigner,
+            ApkSignerEngine.OutputJarSignatureRequest v1Signature,
+            JarOutputStream out,
+            long timestamp) throws IOException {
+        for (ApkSignerEngine.OutputJarSignatureRequest.JarEntry entry
+                : v1Signature.getAdditionalJarEntries()) {
+            String entryName = entry.getName();
+            JarEntry outEntry = new JarEntry(entryName);
+            outEntry.setTime(timestamp);
+            out.putNextEntry(outEntry);
+            byte[] entryData = entry.getData();
+            out.write(entryData);
+            ApkSignerEngine.InspectJarEntryRequest inspectEntryRequest =
+                    apkSigner.outputJarEntry(entryName);
+            if (inspectEntryRequest != null) {
+                inspectEntryRequest.getDataSink().consume(entryData, 0, entryData.length);
+                inspectEntryRequest.done();
+            }
+        }
+    }
+
+    /**
+     * Copy all JAR entries from input to output. We set the modification times in the output to a
+     * fixed time, so as to reduce variation in the output file and make incremental OTAs more
+     * efficient.
+     */
+    private static void copyFiles(
+            JarFile in,
+            Pattern ignoredFilenamePattern,
+            ApkSignerEngine apkSigner,
+            JarOutputStream out,
+            long timestamp,
+            int defaultAlignment) throws IOException {
         byte[] buffer = new byte[4096];
         int num;
 
-        Map<String, Attributes> entries = manifest.getEntries();
-        ArrayList<String> names = new ArrayList<String>(entries.keySet());
+        ArrayList<String> names = new ArrayList<String>();
+        for (Enumeration<JarEntry> e = in.entries(); e.hasMoreElements();) {
+            JarEntry entry = e.nextElement();
+            if (entry.isDirectory()) {
+                continue;
+            }
+            String entryName = entry.getName();
+            if ((ignoredFilenamePattern != null)
+                    && (ignoredFilenamePattern.matcher(entryName).matches())) {
+                continue;
+            }
+            names.add(entryName);
+        }
         Collections.sort(names);
 
         boolean firstEntry = true;
@@ -537,12 +402,21 @@
         // the start of the file and makes it easier to do alignment
         // on them (since only stored entries are aligned).
 
+        List<String> remainingNames = new ArrayList<>(names.size());
         for (String name : names) {
             JarEntry inEntry = in.getJarEntry(name);
-            JarEntry outEntry = null;
-            if (inEntry.getMethod() != JarEntry.STORED) continue;
+            if (inEntry.getMethod() != JarEntry.STORED) {
+                // Defer outputting this entry until we're ready to output compressed entries.
+                remainingNames.add(name);
+                continue;
+            }
+
+            if (!shouldOutputApkEntry(apkSigner, in, inEntry, buffer)) {
+                continue;
+            }
+
             // Preserve the STORED method of the input entry.
-            outEntry = new JarEntry(inEntry);
+            JarEntry outEntry = new JarEntry(inEntry);
             outEntry.setTime(timestamp);
             // Discard comment and extra fields of this entry to
             // simplify alignment logic below and for consistency with
@@ -550,57 +424,134 @@
             outEntry.setComment(null);
             outEntry.setExtra(null);
 
-            // 'offset' is the offset into the file at which we expect
-            // the file data to begin.  This is the value we need to
-            // make a multiple of 'alignement'.
+            int alignment = getStoredEntryDataAlignment(name, defaultAlignment);
+            // Alignment of the entry's data is achieved by adding a data block to the entry's Local
+            // File Header extra field. The data block contains information about the alignment
+            // value and the necessary padding bytes (0x00) to achieve the alignment.  This works
+            // because the entry's data will be located immediately after the extra field.
+            // See ZIP APPNOTE.txt section "4.5 Extensible data fields" for details about the format
+            // of the extra field.
+
+            // 'offset' is the offset into the file at which we expect the entry's data to begin.
+            // This is the value we need to make a multiple of 'alignment'.
             offset += JarFile.LOCHDR + outEntry.getName().length();
             if (firstEntry) {
-                // The first entry in a jar file has an extra field of
-                // four bytes that you can't get rid of; any extra
-                // data you specify in the JarEntry is appended to
-                // these forced four bytes.  This is JAR_MAGIC in
-                // JarOutputStream; the bytes are 0xfeca0000.
+                // The first entry in a jar file has an extra field of four bytes that you can't get
+                // rid of; any extra data you specify in the JarEntry is appended to these forced
+                // four bytes.  This is JAR_MAGIC in JarOutputStream; the bytes are 0xfeca0000.
+                // See http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6808540
+                // and http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4138619.
                 offset += 4;
                 firstEntry = false;
             }
-            int alignment = getStoredEntryDataAlignment(name, defaultAlignment);
-            if (alignment > 0 && (offset % alignment != 0)) {
-                // Set the "extra data" of the entry to between 1 and
-                // alignment-1 bytes, to make the file data begin at
-                // an aligned offset.
-                int needed = alignment - (int)(offset % alignment);
-                outEntry.setExtra(new byte[needed]);
-                offset += needed;
+            int extraPaddingSizeBytes = 0;
+            if (alignment > 0) {
+                long paddingStartOffset = offset + ALIGNMENT_ZIP_EXTRA_DATA_FIELD_MIN_SIZE_BYTES;
+                extraPaddingSizeBytes =
+                        (alignment - (int) (paddingStartOffset % alignment)) % alignment;
             }
+            byte[] extra =
+                    new byte[ALIGNMENT_ZIP_EXTRA_DATA_FIELD_MIN_SIZE_BYTES + extraPaddingSizeBytes];
+            ByteBuffer extraBuf = ByteBuffer.wrap(extra);
+            extraBuf.order(ByteOrder.LITTLE_ENDIAN);
+            extraBuf.putShort(ALIGNMENT_ZIP_EXTRA_DATA_FIELD_HEADER_ID); // Header ID
+            extraBuf.putShort((short) (2 + extraPaddingSizeBytes)); // Data Size
+            extraBuf.putShort((short) alignment);
+            outEntry.setExtra(extra);
+            offset += extra.length;
 
             out.putNextEntry(outEntry);
+            ApkSignerEngine.InspectJarEntryRequest inspectEntryRequest =
+                    (apkSigner != null) ? apkSigner.outputJarEntry(name) : null;
+            DataSink entryDataSink =
+                    (inspectEntryRequest != null) ? inspectEntryRequest.getDataSink() : null;
 
-            InputStream data = in.getInputStream(inEntry);
-            while ((num = data.read(buffer)) > 0) {
-                out.write(buffer, 0, num);
-                offset += num;
+            try (InputStream data = in.getInputStream(inEntry)) {
+                while ((num = data.read(buffer)) > 0) {
+                    out.write(buffer, 0, num);
+                    if (entryDataSink != null) {
+                        entryDataSink.consume(buffer, 0, num);
+                    }
+                    offset += num;
+                }
             }
             out.flush();
+            if (inspectEntryRequest != null) {
+                inspectEntryRequest.done();
+            }
         }
 
         // Copy all the non-STORED entries.  We don't attempt to
         // maintain the 'offset' variable past this point; we don't do
         // alignment on these entries.
 
-        for (String name : names) {
+        for (String name : remainingNames) {
             JarEntry inEntry = in.getJarEntry(name);
-            JarEntry outEntry = null;
-            if (inEntry.getMethod() == JarEntry.STORED) continue;
+            if (!shouldOutputApkEntry(apkSigner, in, inEntry, buffer)) {
+                continue;
+            }
+
             // Create a new entry so that the compressed len is recomputed.
-            outEntry = new JarEntry(name);
+            JarEntry outEntry = new JarEntry(name);
             outEntry.setTime(timestamp);
             out.putNextEntry(outEntry);
+            ApkSignerEngine.InspectJarEntryRequest inspectEntryRequest =
+                    (apkSigner != null) ? apkSigner.outputJarEntry(name) : null;
+            DataSink entryDataSink =
+                    (inspectEntryRequest != null) ? inspectEntryRequest.getDataSink() : null;
 
             InputStream data = in.getInputStream(inEntry);
             while ((num = data.read(buffer)) > 0) {
                 out.write(buffer, 0, num);
+                if (entryDataSink != null) {
+                    entryDataSink.consume(buffer, 0, num);
+                }
             }
             out.flush();
+            if (inspectEntryRequest != null) {
+                inspectEntryRequest.done();
+            }
+        }
+    }
+
+    private static boolean shouldOutputApkEntry(
+            ApkSignerEngine apkSigner, JarFile inFile, JarEntry inEntry, byte[] tmpbuf)
+                    throws IOException {
+        if (apkSigner == null) {
+            return true;
+        }
+
+        ApkSignerEngine.InputJarEntryInstructions instructions =
+                apkSigner.inputJarEntry(inEntry.getName());
+        ApkSignerEngine.InspectJarEntryRequest inspectEntryRequest =
+                instructions.getInspectJarEntryRequest();
+        if (inspectEntryRequest != null) {
+            provideJarEntry(inFile, inEntry, inspectEntryRequest, tmpbuf);
+        }
+        switch (instructions.getOutputPolicy()) {
+            case OUTPUT:
+                return true;
+            case SKIP:
+            case OUTPUT_BY_ENGINE:
+                return false;
+            default:
+                throw new RuntimeException(
+                        "Unsupported output policy: " + instructions.getOutputPolicy());
+        }
+    }
+
+    private static void provideJarEntry(
+            JarFile jarFile,
+            JarEntry jarEntry,
+            ApkSignerEngine.InspectJarEntryRequest request,
+            byte[] tmpbuf) throws IOException {
+        DataSink dataSink = request.getDataSink();
+        try (InputStream in = jarFile.getInputStream(jarEntry)) {
+            int chunkSize;
+            while ((chunkSize = in.read(tmpbuf)) > 0) {
+                dataSink.consume(tmpbuf, 0, chunkSize);
+            }
+            request.done();
         }
     }
 
@@ -686,21 +637,26 @@
         private final File publicKeyFile;
         private final X509Certificate publicKey;
         private final PrivateKey privateKey;
+        private final int hash;
         private final long timestamp;
-        private final int minSdkVersion;
         private final OutputStream outputStream;
         private final ASN1ObjectIdentifier type;
         private WholeFileSignerOutputStream signer;
 
+        // Files matching this pattern are not copied to the output.
+        private static final Pattern STRIP_PATTERN =
+                Pattern.compile("^(META-INF/((.*)[.](SF|RSA|DSA|EC)|com/android/otacert))|("
+                        + Pattern.quote(JarFile.MANIFEST_NAME) + ")$");
+
         public CMSSigner(JarFile inputJar, File publicKeyFile,
-                         X509Certificate publicKey, PrivateKey privateKey, long timestamp,
-                         int minSdkVersion, OutputStream outputStream) {
+                         X509Certificate publicKey, PrivateKey privateKey, int hash,
+                         long timestamp, OutputStream outputStream) {
             this.inputJar = inputJar;
             this.publicKeyFile = publicKeyFile;
             this.publicKey = publicKey;
             this.privateKey = privateKey;
+            this.hash = hash;
             this.timestamp = timestamp;
-            this.minSdkVersion = minSdkVersion;
             this.outputStream = outputStream;
             this.type = new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId());
         }
@@ -725,19 +681,8 @@
                 signer = new WholeFileSignerOutputStream(out, outputStream);
                 JarOutputStream outputJar = new JarOutputStream(signer);
 
-                int hash = getDigestAlgorithm(publicKey, minSdkVersion);
-
-                Manifest manifest = addDigestsToManifest(inputJar, hash);
-                copyFiles(manifest, inputJar, outputJar, timestamp, 0);
-                addOtacert(outputJar, publicKeyFile, timestamp, manifest, hash);
-
-                signFile(manifest,
-                         new X509Certificate[]{ publicKey },
-                         new PrivateKey[]{ privateKey },
-                         timestamp,
-                         minSdkVersion,
-                         false, // Don't sign using APK Signature Scheme v2
-                         outputJar);
+                copyFiles(inputJar, STRIP_PATTERN, null, outputJar, timestamp, 0);
+                addOtacert(outputJar, publicKeyFile, timestamp);
 
                 signer.notifyClosing();
                 outputJar.close();
@@ -753,7 +698,7 @@
                    CertificateEncodingException,
                    OperatorCreationException,
                    CMSException {
-            SignApk.writeSignatureBlock(this, publicKey, privateKey, minSdkVersion, temp);
+            SignApk.writeSignatureBlock(this, publicKey, privateKey, hash, temp);
         }
 
         public WholeFileSignerOutputStream getSigner() {
@@ -763,10 +708,10 @@
 
     private static void signWholeFile(JarFile inputJar, File publicKeyFile,
                                       X509Certificate publicKey, PrivateKey privateKey,
-                                      long timestamp, int minSdkVersion,
+                                      int hash, long timestamp,
                                       OutputStream outputStream) throws Exception {
         CMSSigner cmsOut = new CMSSigner(inputJar, publicKeyFile,
-                publicKey, privateKey, timestamp, minSdkVersion, outputStream);
+                publicKey, privateKey, hash, timestamp, outputStream);
 
         ByteArrayOutputStream temp = new ByteArrayOutputStream();
 
@@ -774,7 +719,7 @@
         // archive comment, so that tools that display the comment
         // (hopefully) show something sensible.
         // TODO: anything more useful we can put in this message?
-        byte[] message = "signed by SignApk".getBytes("UTF-8");
+        byte[] message = "signed by SignApk".getBytes(StandardCharsets.UTF_8);
         temp.write(message);
         temp.write(0);
 
@@ -830,48 +775,6 @@
         temp.writeTo(outputStream);
     }
 
-    private static void signFile(Manifest manifest,
-                                 X509Certificate[] publicKey, PrivateKey[] privateKey,
-                                 long timestamp,
-                                 int minSdkVersion,
-                                 boolean additionallySignedUsingAnApkSignatureScheme,
-                                 JarOutputStream outputJar)
-        throws Exception {
-
-        // MANIFEST.MF
-        JarEntry je = new JarEntry(JarFile.MANIFEST_NAME);
-        je.setTime(timestamp);
-        outputJar.putNextEntry(je);
-        manifest.write(outputJar);
-
-        int numKeys = publicKey.length;
-        for (int k = 0; k < numKeys; ++k) {
-            // CERT.SF / CERT#.SF
-            je = new JarEntry(numKeys == 1 ? CERT_SF_NAME :
-                              (String.format(CERT_SF_MULTI_NAME, k)));
-            je.setTime(timestamp);
-            outputJar.putNextEntry(je);
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            writeSignatureFile(
-                    manifest,
-                    baos,
-                    getDigestAlgorithm(publicKey[k], minSdkVersion),
-                    additionallySignedUsingAnApkSignatureScheme);
-            byte[] signedData = baos.toByteArray();
-            outputJar.write(signedData);
-
-            // CERT.{EC,RSA} / CERT#.{EC,RSA}
-            final String keyType = publicKey[k].getPublicKey().getAlgorithm();
-            je = new JarEntry(numKeys == 1 ?
-                              (String.format(CERT_SIG_NAME, keyType)) :
-                              (String.format(CERT_SIG_MULTI_NAME, k, keyType)));
-            je.setTime(timestamp);
-            outputJar.putNextEntry(je);
-            writeSignatureBlock(new CMSProcessableByteArray(signedData),
-                                publicKey[k], privateKey[k], minSdkVersion, outputJar);
-        }
-    }
-
     /**
      * Tries to load a JSE Provider by class name. This is for custom PrivateKey
      * types that might be stored in PKCS#11-like storage.
@@ -924,81 +827,99 @@
         Security.insertProviderAt((Provider) o, 1);
     }
 
-    /**
-     * Converts the provided lists of private keys, their X.509 certificates, and digest algorithms
-     * into a list of APK Signature Scheme v2 {@code SignerConfig} instances.
-     */
-    public static List<ApkSignerV2.SignerConfig> createV2SignerConfigs(
-            PrivateKey[] privateKeys, X509Certificate[] certificates, String[] digestAlgorithms)
-                    throws InvalidKeyException {
+    private static List<DefaultApkSignerEngine.SignerConfig> createSignerConfigs(
+            PrivateKey[] privateKeys, X509Certificate[] certificates) {
         if (privateKeys.length != certificates.length) {
             throw new IllegalArgumentException(
                     "The number of private keys must match the number of certificates: "
                             + privateKeys.length + " vs" + certificates.length);
         }
-        List<ApkSignerV2.SignerConfig> result = new ArrayList<>(privateKeys.length);
+        List<DefaultApkSignerEngine.SignerConfig> signerConfigs = new ArrayList<>();
+        String signerNameFormat = (privateKeys.length == 1) ? "CERT" : "CERT%s";
         for (int i = 0; i < privateKeys.length; i++) {
-            PrivateKey privateKey = privateKeys[i];
-            X509Certificate certificate = certificates[i];
-            PublicKey publicKey = certificate.getPublicKey();
-            String keyAlgorithm = privateKey.getAlgorithm();
-            if (!keyAlgorithm.equalsIgnoreCase(publicKey.getAlgorithm())) {
-                throw new InvalidKeyException(
-                        "Key algorithm of private key #" + (i + 1) + " does not match key"
-                        + " algorithm of public key #" + (i + 1) + ": " + keyAlgorithm
-                        + " vs " + publicKey.getAlgorithm());
-            }
-            ApkSignerV2.SignerConfig signerConfig = new ApkSignerV2.SignerConfig();
-            signerConfig.privateKey = privateKey;
-            signerConfig.certificates = Collections.singletonList(certificate);
-            List<Integer> signatureAlgorithms = new ArrayList<>(digestAlgorithms.length);
-            for (String digestAlgorithm : digestAlgorithms) {
-                try {
-                    signatureAlgorithms.add(
-                            getV2SignatureAlgorithm(keyAlgorithm, digestAlgorithm));
-                } catch (IllegalArgumentException e) {
-                    throw new InvalidKeyException(
-                            "Unsupported key and digest algorithm combination for signer #"
-                                    + (i + 1),
-                            e);
-                }
-            }
-            signerConfig.signatureAlgorithms = signatureAlgorithms;
-            result.add(signerConfig);
+            String signerName = String.format(Locale.US, signerNameFormat, (i + 1));
+            DefaultApkSignerEngine.SignerConfig signerConfig =
+                    new DefaultApkSignerEngine.SignerConfig.Builder(
+                            signerName,
+                            privateKeys[i],
+                            Collections.singletonList(certificates[i]))
+                            .build();
+            signerConfigs.add(signerConfig);
         }
+        return signerConfigs;
+    }
+
+    private static class ZipSections {
+        ByteBuffer beforeCentralDir;
+        ByteBuffer centralDir;
+        ByteBuffer eocd;
+    }
+
+    private static ZipSections findMainZipSections(ByteBuffer apk)
+            throws IOException, ZipFormatException {
+        apk.slice();
+        ApkUtils.ZipSections sections = ApkUtils.findZipSections(DataSources.asDataSource(apk));
+        long centralDirStartOffset = sections.getZipCentralDirectoryOffset();
+        long centralDirSizeBytes = sections.getZipCentralDirectorySizeBytes();
+        long centralDirEndOffset = centralDirStartOffset + centralDirSizeBytes;
+        long eocdStartOffset = sections.getZipEndOfCentralDirectoryOffset();
+        if (centralDirEndOffset != eocdStartOffset) {
+            throw new ZipFormatException(
+                    "ZIP Central Directory is not immediately followed by End of Central Directory"
+                            + ". CD end: " + centralDirEndOffset
+                            + ", EoCD start: " + eocdStartOffset);
+        }
+        apk.position(0);
+        apk.limit((int) centralDirStartOffset);
+        ByteBuffer beforeCentralDir = apk.slice();
+
+        apk.position((int) centralDirStartOffset);
+        apk.limit((int) centralDirEndOffset);
+        ByteBuffer centralDir = apk.slice();
+
+        apk.position((int) eocdStartOffset);
+        apk.limit(apk.capacity());
+        ByteBuffer eocd = apk.slice();
+
+        apk.position(0);
+        apk.limit(apk.capacity());
+
+        ZipSections result = new ZipSections();
+        result.beforeCentralDir = beforeCentralDir;
+        result.centralDir = centralDir;
+        result.eocd = eocd;
         return result;
     }
 
-    private static int getV2SignatureAlgorithm(String keyAlgorithm, String digestAlgorithm) {
-        if ("SHA-256".equalsIgnoreCase(digestAlgorithm)) {
-            if ("RSA".equalsIgnoreCase(keyAlgorithm)) {
-                // Use RSASSA-PKCS1-v1_5 signature scheme instead of RSASSA-PSS to guarantee
-                // deterministic signatures which make life easier for OTA updates (fewer files
-                // changed when deterministic signature schemes are used).
-                return ApkSignerV2.SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA256;
-            } else if ("EC".equalsIgnoreCase(keyAlgorithm)) {
-                return ApkSignerV2.SIGNATURE_ECDSA_WITH_SHA256;
-            } else if ("DSA".equalsIgnoreCase(keyAlgorithm)) {
-                return ApkSignerV2.SIGNATURE_DSA_WITH_SHA256;
-            } else {
-                throw new IllegalArgumentException("Unsupported key algorithm: " + keyAlgorithm);
-            }
-        } else if ("SHA-512".equalsIgnoreCase(digestAlgorithm)) {
-            if ("RSA".equalsIgnoreCase(keyAlgorithm)) {
-                // Use RSASSA-PKCS1-v1_5 signature scheme instead of RSASSA-PSS to guarantee
-                // deterministic signatures which make life easier for OTA updates (fewer files
-                // changed when deterministic signature schemes are used).
-                return ApkSignerV2.SIGNATURE_RSA_PKCS1_V1_5_WITH_SHA512;
-            } else if ("EC".equalsIgnoreCase(keyAlgorithm)) {
-                return ApkSignerV2.SIGNATURE_ECDSA_WITH_SHA512;
-            } else if ("DSA".equalsIgnoreCase(keyAlgorithm)) {
-                return ApkSignerV2.SIGNATURE_DSA_WITH_SHA512;
-            } else {
-                throw new IllegalArgumentException("Unsupported key algorithm: " + keyAlgorithm);
-            }
-        } else {
-            throw new IllegalArgumentException("Unsupported digest algorithm: " + digestAlgorithm);
+    /**
+     * Returns the API Level corresponding to the APK's minSdkVersion.
+     *
+     * @throws MinSdkVersionException if the API Level cannot be determined from the APK.
+     */
+    private static final int getMinSdkVersion(JarFile apk) throws MinSdkVersionException {
+        JarEntry manifestEntry = apk.getJarEntry("AndroidManifest.xml");
+        if (manifestEntry == null) {
+            throw new MinSdkVersionException("No AndroidManifest.xml in APK");
         }
+        byte[] manifestBytes;
+        try {
+            try (InputStream manifestIn = apk.getInputStream(manifestEntry)) {
+                manifestBytes = toByteArray(manifestIn);
+            }
+        } catch (IOException e) {
+            throw new MinSdkVersionException("Failed to read AndroidManifest.xml", e);
+        }
+        return ApkUtils.getMinSdkVersionFromBinaryAndroidManifest(ByteBuffer.wrap(manifestBytes));
+    }
+
+    private static byte[] toByteArray(InputStream in) throws IOException {
+        ByteArrayOutputStream result = new ByteArrayOutputStream();
+        byte[] buf = new byte[65536];
+        int chunkSize;
+        while ((chunkSize = in.read(buf)) != -1) {
+            result.write(buf, 0, chunkSize);
+        }
+        return result.toByteArray();
     }
 
     private static void usage() {
@@ -1027,7 +948,7 @@
         boolean signWholeFile = false;
         String providerClass = null;
         int alignment = 4;
-        int minSdkVersion = 0;
+        Integer minSdkVersionOverride = null;
         boolean signUsingApkSignatureSchemeV2 = true;
 
         int argstart = 0;
@@ -1047,7 +968,7 @@
             } else if ("--min-sdk-version".equals(args[argstart])) {
                 String minSdkVersionString = args[++argstart];
                 try {
-                    minSdkVersion = Integer.parseInt(minSdkVersionString);
+                    minSdkVersionOverride = Integer.parseInt(minSdkVersionString);
                 } catch (NumberFormatException e) {
                     throw new IllegalArgumentException(
                             "--min-sdk-version must be a decimal number: " + minSdkVersionString);
@@ -1075,7 +996,6 @@
 
         JarFile inputJar = null;
         FileOutputStream outputFile = null;
-        int hashes = 0;
 
         try {
             File firstPublicKeyFile = new File(args[argstart+0]);
@@ -1085,7 +1005,6 @@
                 for (int i = 0; i < numKeys; ++i) {
                     int argNum = argstart + i*2;
                     publicKey[i] = readPublicKey(new File(args[argNum]));
-                    hashes |= getDigestAlgorithm(publicKey[i], minSdkVersion);
                 }
             } catch (IllegalArgumentException e) {
                 System.err.println(e);
@@ -1111,55 +1030,101 @@
             // NOTE: Signing currently recompresses any compressed entries using Deflate (default
             // compression level for OTA update files and maximum compession level for APKs).
             if (signWholeFile) {
-                SignApk.signWholeFile(inputJar, firstPublicKeyFile,
-                                      publicKey[0], privateKey[0],
-                                      timestamp, minSdkVersion,
-                                      outputFile);
+                int digestAlgorithm = getDigestAlgorithmForOta(publicKey[0]);
+                signWholeFile(inputJar, firstPublicKeyFile,
+                        publicKey[0], privateKey[0], digestAlgorithm,
+                        timestamp,
+                        outputFile);
             } else {
-                // Generate, in memory, an APK signed using standard JAR Signature Scheme.
-                ByteArrayOutputStream v1SignedApkBuf = new ByteArrayOutputStream();
-                JarOutputStream outputJar = new JarOutputStream(v1SignedApkBuf);
-                // Use maximum compression for compressed entries because the APK lives forever on
-                // the system partition.
-                outputJar.setLevel(9);
-                Manifest manifest = addDigestsToManifest(inputJar, hashes);
-                copyFiles(manifest, inputJar, outputJar, timestamp, alignment);
-                signFile(
-                        manifest,
-                        publicKey, privateKey,
-                        timestamp, minSdkVersion, signUsingApkSignatureSchemeV2,
-                        outputJar);
-                outputJar.close();
-                ByteBuffer v1SignedApk = ByteBuffer.wrap(v1SignedApkBuf.toByteArray());
-                v1SignedApkBuf.reset();
-
-                ByteBuffer[] outputChunks;
-                if (signUsingApkSignatureSchemeV2) {
-                    // Additionally sign the APK using the APK Signature Scheme v2.
-                    ByteBuffer apkContents = v1SignedApk;
-                    List<ApkSignerV2.SignerConfig> signerConfigs =
-                            createV2SignerConfigs(
-                                    privateKey,
-                                    publicKey,
-                                    new String[] {APK_SIG_SCHEME_V2_DIGEST_ALGORITHM});
-                    outputChunks = ApkSignerV2.sign(apkContents, signerConfigs);
+                // Determine the value to use as minSdkVersion of the APK being signed
+                int minSdkVersion;
+                if (minSdkVersionOverride != null) {
+                    minSdkVersion = minSdkVersionOverride;
                 } else {
-                    // Output the JAR-signed APK as is.
-                    outputChunks = new ByteBuffer[] {v1SignedApk};
+                    try {
+                        minSdkVersion = getMinSdkVersion(inputJar);
+                    } catch (MinSdkVersionException e) {
+                        throw new IllegalArgumentException(
+                                "Cannot detect minSdkVersion. Use --min-sdk-version to override",
+                                e);
+                    }
                 }
 
-                // This assumes outputChunks are array-backed. To avoid this assumption, the
-                // code could be rewritten to use FileChannel.
-                for (ByteBuffer outputChunk : outputChunks) {
-                    outputFile.write(
-                            outputChunk.array(),
-                            outputChunk.arrayOffset() + outputChunk.position(),
-                            outputChunk.remaining());
-                    outputChunk.position(outputChunk.limit());
+                try (ApkSignerEngine apkSigner =
+                        new DefaultApkSignerEngine.Builder(
+                                createSignerConfigs(privateKey, publicKey), minSdkVersion)
+                                .setV1SigningEnabled(true)
+                                .setV2SigningEnabled(signUsingApkSignatureSchemeV2)
+                                .setOtherSignersSignaturesPreserved(false)
+                                .setCreatedBy("1.0 (Android SignApk)")
+                                .build()) {
+                    // We don't preserve the input APK's APK Signing Block (which contains v2
+                    // signatures)
+                    apkSigner.inputApkSigningBlock(null);
+
+                    // Build the output APK in memory, by copying input APK's ZIP entries across
+                    // and then signing the output APK.
+                    ByteArrayOutputStream v1SignedApkBuf = new ByteArrayOutputStream();
+                    JarOutputStream outputJar = new JarOutputStream(v1SignedApkBuf);
+                    // Use maximum compression for compressed entries because the APK lives forever
+                    // on the system partition.
+                    outputJar.setLevel(9);
+                    copyFiles(inputJar, null, apkSigner, outputJar, timestamp, alignment);
+                    ApkSignerEngine.OutputJarSignatureRequest addV1SignatureRequest =
+                            apkSigner.outputJarEntries();
+                    if (addV1SignatureRequest != null) {
+                        addV1Signature(apkSigner, addV1SignatureRequest, outputJar, timestamp);
+                        addV1SignatureRequest.done();
+                    }
+                    outputJar.close();
+                    ByteBuffer v1SignedApk = ByteBuffer.wrap(v1SignedApkBuf.toByteArray());
+                    v1SignedApkBuf.reset();
+                    ByteBuffer[] outputChunks = new ByteBuffer[] {v1SignedApk};
+
+                    ZipSections zipSections = findMainZipSections(v1SignedApk);
+                    ApkSignerEngine.OutputApkSigningBlockRequest addV2SignatureRequest =
+                            apkSigner.outputZipSections(
+                                    DataSources.asDataSource(zipSections.beforeCentralDir),
+                                    DataSources.asDataSource(zipSections.centralDir),
+                                    DataSources.asDataSource(zipSections.eocd));
+                    if (addV2SignatureRequest != null) {
+                        // Need to insert the returned APK Signing Block before ZIP Central
+                        // Directory.
+                        byte[] apkSigningBlock = addV2SignatureRequest.getApkSigningBlock();
+                        // Because the APK Signing Block is inserted before the Central Directory,
+                        // we need to adjust accordingly the offset of Central Directory inside the
+                        // ZIP End of Central Directory (EoCD) record.
+                        ByteBuffer modifiedEocd = ByteBuffer.allocate(zipSections.eocd.remaining());
+                        modifiedEocd.put(zipSections.eocd);
+                        modifiedEocd.flip();
+                        modifiedEocd.order(ByteOrder.LITTLE_ENDIAN);
+                        ApkUtils.setZipEocdCentralDirectoryOffset(
+                                modifiedEocd,
+                                zipSections.beforeCentralDir.remaining() + apkSigningBlock.length);
+                        outputChunks =
+                                new ByteBuffer[] {
+                                        zipSections.beforeCentralDir,
+                                        ByteBuffer.wrap(apkSigningBlock),
+                                        zipSections.centralDir,
+                                        modifiedEocd};
+                        addV2SignatureRequest.done();
+                    }
+
+                    // This assumes outputChunks are array-backed. To avoid this assumption, the
+                    // code could be rewritten to use FileChannel.
+                    for (ByteBuffer outputChunk : outputChunks) {
+                        outputFile.write(
+                                outputChunk.array(),
+                                outputChunk.arrayOffset() + outputChunk.position(),
+                                outputChunk.remaining());
+                        outputChunk.position(outputChunk.limit());
+                    }
+
+                    outputFile.close();
+                    outputFile = null;
+                    apkSigner.outputDone();
                 }
 
-                outputFile.close();
-                outputFile = null;
                 return;
             }
         } catch (Exception e) {
diff --git a/tools/signapk/src/com/android/signapk/ZipUtils.java b/tools/signapk/src/com/android/signapk/ZipUtils.java
deleted file mode 100644
index 7575a77..0000000
--- a/tools/signapk/src/com/android/signapk/ZipUtils.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-package com.android.signapk;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * Assorted ZIP format helpers.
- *
- * <p>NOTE: Most helper methods operating on {@code ByteBuffer} instances expect that the byte
- * order of these buffers is little-endian.
- */
-public abstract class ZipUtils {
-    private ZipUtils() {}
-
-    private static final int ZIP_EOCD_REC_MIN_SIZE = 22;
-    private static final int ZIP_EOCD_REC_SIG = 0x06054b50;
-    private static final int ZIP_EOCD_CENTRAL_DIR_SIZE_FIELD_OFFSET = 12;
-    private static final int ZIP_EOCD_CENTRAL_DIR_OFFSET_FIELD_OFFSET = 16;
-    private static final int ZIP_EOCD_COMMENT_LENGTH_FIELD_OFFSET = 20;
-
-    private static final int ZIP64_EOCD_LOCATOR_SIZE = 20;
-    private static final int ZIP64_EOCD_LOCATOR_SIG = 0x07064b50;
-
-    private static final int UINT16_MAX_VALUE = 0xffff;
-
-    /**
-     * Returns the position at which ZIP End of Central Directory record starts in the provided
-     * buffer or {@code -1} if the record is not present.
-     *
-     * <p>NOTE: Byte order of {@code zipContents} must be little-endian.
-     */
-    public static int findZipEndOfCentralDirectoryRecord(ByteBuffer zipContents) {
-        assertByteOrderLittleEndian(zipContents);
-
-        // ZIP End of Central Directory (EOCD) record is located at the very end of the ZIP archive.
-        // The record can be identified by its 4-byte signature/magic which is located at the very
-        // beginning of the record. A complication is that the record is variable-length because of
-        // the comment field.
-        // The algorithm for locating the ZIP EOCD record is as follows. We search backwards from
-        // end of the buffer for the EOCD record signature. Whenever we find a signature, we check
-        // the candidate record's comment length is such that the remainder of the record takes up
-        // exactly the remaining bytes in the buffer. The search is bounded because the maximum
-        // size of the comment field is 65535 bytes because the field is an unsigned 16-bit number.
-
-        int archiveSize = zipContents.capacity();
-        if (archiveSize < ZIP_EOCD_REC_MIN_SIZE) {
-            return -1;
-        }
-        int maxCommentLength = Math.min(archiveSize - ZIP_EOCD_REC_MIN_SIZE, UINT16_MAX_VALUE);
-        int eocdWithEmptyCommentStartPosition = archiveSize - ZIP_EOCD_REC_MIN_SIZE;
-        for (int expectedCommentLength = 0; expectedCommentLength < maxCommentLength;
-                expectedCommentLength++) {
-            int eocdStartPos = eocdWithEmptyCommentStartPosition - expectedCommentLength;
-            if (zipContents.getInt(eocdStartPos) == ZIP_EOCD_REC_SIG) {
-                int actualCommentLength =
-                        getUnsignedInt16(
-                                zipContents, eocdStartPos + ZIP_EOCD_COMMENT_LENGTH_FIELD_OFFSET);
-                if (actualCommentLength == expectedCommentLength) {
-                    return eocdStartPos;
-                }
-            }
-        }
-
-        return -1;
-    }
-
-    /**
-     * Returns {@code true} if the provided buffer contains a ZIP64 End of Central Directory
-     * Locator.
-     *
-     * <p>NOTE: Byte order of {@code zipContents} must be little-endian.
-     */
-    public static final boolean isZip64EndOfCentralDirectoryLocatorPresent(
-            ByteBuffer zipContents, int zipEndOfCentralDirectoryPosition) {
-        assertByteOrderLittleEndian(zipContents);
-
-        // ZIP64 End of Central Directory Locator immediately precedes the ZIP End of Central
-        // Directory Record.
-
-        int locatorPosition = zipEndOfCentralDirectoryPosition - ZIP64_EOCD_LOCATOR_SIZE;
-        if (locatorPosition < 0) {
-            return false;
-        }
-
-        return zipContents.getInt(locatorPosition) == ZIP64_EOCD_LOCATOR_SIG;
-    }
-
-    /**
-     * Returns the offset of the start of the ZIP Central Directory in the archive.
-     *
-     * <p>NOTE: Byte order of {@code zipEndOfCentralDirectory} must be little-endian.
-     */
-    public static long getZipEocdCentralDirectoryOffset(ByteBuffer zipEndOfCentralDirectory) {
-        assertByteOrderLittleEndian(zipEndOfCentralDirectory);
-        return getUnsignedInt32(
-                zipEndOfCentralDirectory,
-                zipEndOfCentralDirectory.position() + ZIP_EOCD_CENTRAL_DIR_OFFSET_FIELD_OFFSET);
-    }
-
-    /**
-     * Sets the offset of the start of the ZIP Central Directory in the archive.
-     *
-     * <p>NOTE: Byte order of {@code zipEndOfCentralDirectory} must be little-endian.
-     */
-    public static void setZipEocdCentralDirectoryOffset(
-            ByteBuffer zipEndOfCentralDirectory, long offset) {
-        assertByteOrderLittleEndian(zipEndOfCentralDirectory);
-        setUnsignedInt32(
-                zipEndOfCentralDirectory,
-                zipEndOfCentralDirectory.position() + ZIP_EOCD_CENTRAL_DIR_OFFSET_FIELD_OFFSET,
-                offset);
-    }
-
-    /**
-     * Returns the size (in bytes) of the ZIP Central Directory.
-     *
-     * <p>NOTE: Byte order of {@code zipEndOfCentralDirectory} must be little-endian.
-     */
-    public static long getZipEocdCentralDirectorySizeBytes(ByteBuffer zipEndOfCentralDirectory) {
-        assertByteOrderLittleEndian(zipEndOfCentralDirectory);
-        return getUnsignedInt32(
-                zipEndOfCentralDirectory,
-                zipEndOfCentralDirectory.position() + ZIP_EOCD_CENTRAL_DIR_SIZE_FIELD_OFFSET);
-    }
-
-    private static void assertByteOrderLittleEndian(ByteBuffer buffer) {
-        if (buffer.order() != ByteOrder.LITTLE_ENDIAN) {
-            throw new IllegalArgumentException("ByteBuffer byte order must be little endian");
-        }
-    }
-
-    private static int getUnsignedInt16(ByteBuffer buffer, int offset) {
-        return buffer.getShort(offset) & 0xffff;
-    }
-
-    private static long getUnsignedInt32(ByteBuffer buffer, int offset) {
-        return buffer.getInt(offset) & 0xffffffffL;
-    }
-
-    private static void setUnsignedInt32(ByteBuffer buffer, int offset, long value) {
-        if ((value < 0) || (value > 0xffffffffL)) {
-            throw new IllegalArgumentException("uint32 value of out range: " + value);
-        }
-        buffer.putInt(buffer.position() + offset, (int) value);
-    }
-}
diff --git a/tools/soong_to_convert.py b/tools/soong_to_convert.py
new file mode 100755
index 0000000..3d62d43
--- /dev/null
+++ b/tools/soong_to_convert.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016 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.
+
+"""Tool to prioritize which modules to convert to Soong.
+
+Generally, you'd use this through the make integration, which automatically
+generates the CSV input file that this tool expects:
+
+  $ m $OUT/soong_to_convert.txt
+  $ less $OUT/soong_to_convert.txt
+
+The output is a list of modules that are probably ready to convert to Soong:
+
+  # Blocked on Module (potential problems)
+           283 libEGL (srcs_dotarm)
+           246 libicuuc (dotdot_incs dotdot_srcs)
+           221 libspeexresampler
+           215 libcamera_metadata
+               ...
+             0 zram-perf (dotdot_incs)
+
+The number at the beginning of the line shows how many native modules depend
+on that module.
+
+All of their dependencies have been satisfied, and any potential problems
+that Make can detect are listed in parenthesis after the module:
+
+  dotdot_srcs: LOCAL_SRC_FILES contains paths outside $(LOCAL_PATH)
+  dotdot_incs: LOCAL_C_INCLUDES contains paths include '..'
+  srcs_dotarm: LOCAL_SRC_FILES contains source files like <...>.c.arm
+  aidl: LOCAL_SRC_FILES contains .aidl sources
+  objc: LOCAL_SRC_FILES contains Objective-C sources
+  proto: LOCAL_SRC_FILES contains .proto sources
+  rs: LOCAL_SRC_FILES contains renderscript sources
+  vts: LOCAL_SRC_FILES contains .vts sources
+
+Not all problems can be discovered, but this is a starting point.
+
+"""
+
+from __future__ import print_function
+
+import csv
+import sys
+
+def count_deps(depsdb, module, seen):
+    """Based on the depsdb, count the number of transitive dependencies.
+
+    You can pass in an reversed dependency graph to conut the number of
+    modules that depend on the module."""
+    count = 0
+    seen.append(module)
+    if module in depsdb:
+        for dep in depsdb[module]:
+            if dep in seen:
+                continue
+            count += 1 + count_deps(depsdb, dep, seen)
+    return count
+
+def process(reader):
+    """Read the input file and produce a list of modules ready to move to Soong
+    """
+    problems = dict()
+    deps = dict()
+    reverse_deps = dict()
+
+    for (module, problem, dependencies) in reader:
+        problems[module] = problem
+        deps[module] = [d for d in dependencies.strip().split(' ') if d != ""]
+        for dep in deps[module]:
+            if not dep in reverse_deps:
+                reverse_deps[dep] = []
+            reverse_deps[dep].append(module)
+
+    results = []
+    for module in problems:
+        # Only display actionable conversions, ones without missing dependencies
+        if len(deps[module]) != 0:
+            continue
+
+        extra = ""
+        if len(problems[module]) > 0:
+            extra = " ({})".format(problems[module])
+        results.append((count_deps(reverse_deps, module, []), module + extra))
+
+    return sorted(results, key=lambda result: (-result[0], result[1]))
+
+def display(results):
+    """Displays the results"""
+    count_header = "# Blocked on"
+    count_width = len(count_header)
+    print("{} Module (potential problems)".format(count_header))
+    for (count, module) in results:
+        print("{:>{}} {}".format(count, count_width, module))
+
+def main(filename):
+    """Read the CSV file, print the results"""
+    with open(filename, 'rb') as csvfile:
+        results = process(csv.reader(csvfile))
+
+    display(results)
+
+if __name__ == "__main__":
+    if len(sys.argv) != 2:
+        print("usage: soong_conversion.py <file>", file=sys.stderr)
+        sys.exit(1)
+
+    main(sys.argv[1])
diff --git a/tools/vendor_buildinfo.sh b/tools/vendor_buildinfo.sh
new file mode 100755
index 0000000..2854fa8
--- /dev/null
+++ b/tools/vendor_buildinfo.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+echo "# begin build properties"
+echo "# autogenerated by vendor_buildinfo.sh"
+
+echo "ro.product.board=$TARGET_BOOTLOADER_BOARD_NAME"
+echo "ro.board.platform=$TARGET_BOARD_PLATFORM"
+
+echo "# end build properties"
diff --git a/tools/warn.py b/tools/warn.py
index 8097123..5be6d9d 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1,563 +1,2723 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 # This file uses the following encoding: utf-8
 
-import sys
+"""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 multiprocessing
+import os
 import re
+import signal
+import sys
 
-if len(sys.argv) == 1:
-    print 'usage: ' + sys.argv[0] + ' <build.log>'
-    sys.exit()
+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',
+                    default=False)
+parser.add_argument('--byproject',
+                    help='Separate warnings in HTML output by project names',
+                    action='store_true',
+                    default=False)
+parser.add_argument('--url',
+                    help='Root URL of an Android source code tree prefixed '
+                    'before files in warnings')
+parser.add_argument('--separator',
+                    help='Separator between the end of a URL and the line '
+                    'number argument. e.g. #')
+parser.add_argument('--processes',
+                    type=int,
+                    default=multiprocessing.cpu_count(),
+                    help='Number of parallel processes to process warnings')
+parser.add_argument(dest='buildlog', metavar='build.log',
+                    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
-    SKIP=100
-    FIXMENOW=1
-    HIGH=2
-    MEDIUM=3
-    LOW=4
-    HARMLESS=5
 
-def colorforseverity(sev):
-    if sev == severity.FIXMENOW:
-        return 'fuchsia'
-    if sev == severity.HIGH:
-        return 'red'
-    if sev == severity.MEDIUM:
-        return 'orange'
-    if sev == severity.LOW:
-        return 'yellow'
-    if sev == severity.HARMLESS:
-        return 'limegreen'
-    if sev == severity.UNKNOWN:
-        return 'blue'
-    return 'grey'
+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]
 
-warnpatterns = [
-    { 'category':'make',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'make: overriding commands/ignoring old commands',
-        'patterns':[r".*: warning: overriding commands for target .+",
-                    r".*: warning: ignoring old commands for target .+"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], 'option':'-Wimplicit-function-declaration',
-        'description':'Implicit function declaration',
-        'patterns':[r".*: warning: implicit declaration of function .+"] },
-    { 'category':'C/C++',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: conflicting types for '.+'"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], 'option':'-Wtype-limits',
-        'description':'Expression always evaluates to true or false',
-        'patterns':[r".*: warning: comparison is always false due to limited range of data type",
-                    r".*: warning: comparison of unsigned expression >= 0 is always true",
-                    r".*: warning: comparison of unsigned expression < 0 is always false"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,     'members':[], '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.MEDIUM,   'members':[], 'option':'-Wunused-parameter',
-        'description':'Unused parameter',
-        'patterns':[r".*: warning: unused parameter '.*'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wunused',
-        'description':'Unused function, variable or label',
-        'patterns':[r".*: warning: '.+' defined but not used",
-                    r".*: warning: unused variable '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wunused-value',
-        'description':'Statement with no effect',
-        'patterns':[r".*: warning: statement with no effect"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wmissing-field-initializers',
-        'description':'Missing initializer',
-        'patterns':[r".*: warning: missing initializer"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wformat',
-        'description':'Format string does not match arguments',
-        'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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,   'members':[], '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,   'members':[], 'option':'',
-        'description':'Comparison between enum and non-enum',
-        'patterns':[r".*: warning: enumeral and non-enumeral type in conditional expression"] },
-    { 'category':'libpng',  'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'libpng: zero area',
-        'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'aapt: no comment for public symbol',
-        'patterns':[r".*: warning: No comment for public symbol .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wmissing-braces',
-        'description':'Missing braces around initializer',
-        'patterns':[r".*: warning: missing braces around initializer.*"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS, 'members':[], 'option':'',
-        'description':'No newline at end of file',
-        'patterns':[r".*: warning: no newline at end of file"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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: return discards qualifiers from pointer target type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wattributes',
-        'description':'Attribute ignored',
-        'patterns':[r".*: warning: '_*packed_*' attribute ignored"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wattributes',
-        'description':'Visibility mismatch',
-        'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'Shift count greater than width of type',
-        'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'extern &lt;foo&gt; is initialized',
-        'patterns':[r".*: warning: '.+' initialized and declared 'extern'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wold-style-declaration',
-        'description':'Old style declaration',
-        'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wuninitialized',
-        'description':'Variable may be used uninitialized',
-        'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], 'option':'-Wuninitialized',
-        'description':'Variable is used uninitialized',
-        'patterns':[r".*: warning: '.+' is used uninitialized in this function"] },
-    { 'category':'ld',      'severity':severity.MEDIUM,   'members':[], '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,   'members':[], '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,   'members':[], '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,   'members':[], '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,   'members':[], '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: suggest parentheses around '.+?' .+ '.+?'",
-                    r".*: warning: suggest parentheses around assignment used as truth value"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], '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':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: type defaults to 'int' in declaration of '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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,   'members':[], '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"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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,   'members':[], 'option':'',
-        'description':'Symbol redefined',
-        'patterns':[r".*: warning: "".+"" redefined"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: this is the location of the previous definition"] },
-    { 'category':'ld',      'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], 'option':'',
-        'description':'Pointer from integer without cast',
-        'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], 'option':'',
-        'description':'Integer from pointer without cast',
-        'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], 'option':'',
-        'description':'Integer from pointer without cast',
-        'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wunknown-pragmas',
-        'description':'Ignoring pragma',
-        'patterns':[r".*: warning: ignoring #pragma .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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,   'members':[], '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,   'members':[], 'option':'-Wredundant-decls',
-        'description':'Redundant declaration',
-        'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: previous declaration of '.+' was here"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wswitch-enum',
-        'description':'Enum value not handled in switch',
-        'patterns':[r".*: warning: enumeration value '.+' not handled in switch"] },
-    { 'category':'java',    'severity':severity.MEDIUM,   'members':[], '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,   'members':[], 'option':'',
-        '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':'aapt',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'aapt: No default translation',
-        'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'aapt: Missing default or required localization',
-        'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'aapt: String marked untranslatable, but translation exists',
-        'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'aapt: empty span in string',
-        'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'Taking address of temporary',
-        'patterns':[r".*: warning: taking address of temporary"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'Possible broken line continuation',
-        'patterns':[r".*: warning: backslash and newline separated by space"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Warray-bounds',
-        'description':'Array subscript out of bounds',
-        'patterns':[r".*: warning: array subscript is above array bounds",
-                    r".*: warning: array subscript is below array bounds"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], 'option':'-Wmain',
-        'description':'main is usually a function',
-        'patterns':[r".*: warning: 'main' is usually a function"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'Typedef ignored',
-        'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], '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, 'members':[], 'option':'',
-        'description':'Freeing a non-heap object',
-        'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wchar-subscripts',
-        'description':'Array subscript has type char',
-        'patterns':[r".*: warning: array subscript has type 'char'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'Constant too large for type',
-        'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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,   'members':[], 'option':'-Woverflow',
-        'description':'Overflow in implicit constant conversion',
-        'patterns':[r".*: warning: overflow in implicit constant conversion"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        'description':'Declaration does not declare anything',
-        'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wreorder',
-        'description':'Initialization order will be different',
-        'patterns':[r".*: warning: '.+' will be initialized after"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning:   '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning:   base '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning:   when initialized here"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wmissing-parameter-type',
-        'description':'Parameter type not specified',
-        'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
-    { 'category':'gcc',     'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], 'option':'',
-        'description':'User warning',
-        'patterns':[r".*: warning: #warning "".+"""] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wextra',
-        'description':'Dereferencing void*',
-        'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wextra',
-        'description':'Comparison of pointer to zero',
-        'patterns':[r".*: warning: ordered comparison of pointer with integer zero"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], '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,   'members':[], '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,   'members':[], 'option':'-Wignored-qualifiers',
-        'description':'Type qualifiers ignored on function return value',
-        'patterns':[r".*: warning: type qualifiers ignored on function return type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,     'members':[], 'option':'',
-        '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,      'members':[], 'option':'-Wcomment',
-        'description':'Line continuation inside comment',
-        'patterns':[r".*: warning: multi-line comment"] },
-    { 'category':'C/C++',   'severity':severity.LOW,      'members':[], 'option':'-Wcomment',
-        'description':'Comment inside comment',
-        'patterns':[r".*: warning: "".+"" within comment"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS, 'members':[], 'option':'',
-        'description':'Extra tokens after #endif',
-        'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wenum-compare',
-        'description':'Comparison between different enums',
-        'patterns':[r".*: warning: comparison between 'enum .+' and 'enum .+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wconversion',
-        'description':'Implicit conversion of negative number to unsigned type',
-        'patterns':[r".*: warning: converting negative value '.+' to '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'',
-        '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,   'members':[], 'option':'-Wctor-dtor-privacy',
-        'description':'Class seems unusable because of private ctor/dtor' ,
-        'patterns':[r".*: warning: all member functions in class '.+' are private"] },
+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 Javac
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description': 'Java: Use of deprecated member',
+     'patterns': [r'.*: warning: \[deprecation\] .+']},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description': 'Java: Unchecked conversion',
+     'patterns': [r'.*: warning: \[unchecked\] .+']},
+
+    # Begin warnings generated by Error Prone
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: @Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.',
+     'patterns': [r".*: warning: \[EmptySetMultibindingContributions\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Add a private constructor to modules that will not be instantiated by Dagger.',
+     'patterns': [r".*: warning: \[PrivateConstructorForNoninstantiableModuleTest\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: @Binds is a more efficient and declarative mechanism for delegating a binding.',
+     'patterns': [r".*: warning: \[UseBinds\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Field name is CONSTANT CASE, but field is not static and final',
+     'patterns': [r".*: warning: \[ConstantField\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Deprecated item is not annotated with @Deprecated',
+     'patterns': [r".*: warning: \[DepAnn\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
+     'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: C-style array declarations should not be used',
+     'patterns': [r".*: warning: \[MixedArrayDimensions\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Variable declarations should declare only one variable',
+     'patterns': [r".*: warning: \[MultiVariableDeclaration\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Source files should not contain multiple top-level class declarations',
+     'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Package names should match the directory they are declared in',
+     'patterns': [r".*: warning: \[PackageLocation\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Utility classes (only static members) are not designed to be instantiated and should be made noninstantiable with a default constructor.',
+     'patterns': [r".*: warning: \[PrivateConstructorForUtilityClass\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Unused imports',
+     'patterns': [r".*: warning: \[RemoveUnusedImports\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Unchecked exceptions do not need to be declared in the method signature.',
+     'patterns': [r".*: warning: \[ThrowsUncheckedException\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Using static imports for types is unnecessary',
+     'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
+    {'category': 'java',
+     'severity': Severity.LOW,
+     'description':
+         'Java: Wildcard imports, static or otherwise, should not be used',
+     'patterns': [r".*: warning: \[WildcardImport\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Hardcoded reference to /sdcard',
+     'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Constructors on abstract classes are never directly @Injected, only the constructors of their subclasses can be @Inject\'ed.',
+     'patterns': [r".*: warning: \[InjectOnConstructorOfAbstractClass\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Injection frameworks currently don\'t understand Qualifiers in TYPE PARAMETER or TYPE USE contexts.',
+     'patterns': [r".*: warning: \[QualifierWithTypeUse\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: This code declares a binding for a common value type without a Qualifier annotation.',
+     'patterns': [r".*: warning: \[BindingToUnqualifiedCommonType\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Double-checked locking on non-volatile fields is unsafe',
+     'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Enums should always be immutable',
+     'patterns': [r".*: warning: \[ImmutableEnumChecker\] .+"]},
+    {'category': 'java',
+     '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,
+     '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.MEDIUM,
+     'description':
+         'Java: Method reference is ambiguous',
+     'patterns': [r".*: warning: \[AmbiguousMethodReference\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: A different potential argument is more similar to the name of the parameter than the existing argument; this may be an error',
+     'patterns': [r".*: warning: \[ArgumentParameterMismatch\] .+"]},
+    {'category': 'java',
+     '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,
+     '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,
+     'description':
+         'Java: Possible sign flip from narrowing conversion',
+     'patterns': [r".*: warning: \[BadComparable\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: valueOf or autoboxing provides better time and space performance',
+     'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Mockito cannot mock final classes',
+     'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Inner class is non-static but does not reference enclosing class',
+     'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Class.newInstance() bypasses exception checking; prefer getConstructor().newInstance()',
+     'patterns': [r".*: warning: \[ClassNewInstance\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Implicit use of the platform default charset, which can result in e.g. non-ASCII characters being silently replaced with \'?\' in many environments',
+     'patterns': [r".*: warning: \[DefaultCharset\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Empty top-level type declaration',
+     'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Classes that override equals should also override hashCode.',
+     'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
+    {'category': 'java',
+     '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,
+     '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,
+     'description':
+         'Java: Overloads will be ambiguous when passing lambda arguments',
+     'patterns': [r".*: warning: \[FunctionalInterfaceClash\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Calling getClass() on an enum may return a subclass of the enum type',
+     'patterns': [r".*: warning: \[GetClassOnEnum\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Please also override int read(byte[], int, int), otherwise multi-byte reads from this input stream are likely to be slow.',
+     'patterns': [r".*: warning: \[InputStreamSlowMultibyteRead\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Class should not implement both `Iterable` and `Iterator`',
+     'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Floating-point comparison without error tolerance',
+     'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: The Google Java Style Guide requires switch statements to have an explicit default',
+     'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Not calling fail() when expecting an exception masks bugs',
+     'patterns': [r".*: warning: \[MissingFail\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: method overrides method in supertype; expected @Override',
+     'patterns': [r".*: warning: \[MissingOverride\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
+     'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: This update of a volatile variable is non-atomic',
+     'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Static import of member uses non-canonical name',
+     'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: equals method doesn\'t override Object.equals',
+     'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: @Nullable should not be used for primitive types since they cannot be null',
+     'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Use grouping parenthesis to make the operator precedence explicit',
+     'patterns': [r".*: warning: \[OperatorPrecedence\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Preconditions only accepts the %s placeholder in error message strings',
+     'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Protobuf fields cannot be null, so this check is redundant',
+     'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Thrown exception is a subtype of another',
+     'patterns': [r".*: warning: \[RedundantThrows\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Comparison using reference equality instead of value equality',
+     'patterns': [r".*: warning: \[ReferenceEquality\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: A static variable or method should not be accessed from an object instance',
+     'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: String comparison using reference equality instead of value equality',
+     'patterns': [r".*: warning: \[StringEquality\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Truth Library assert is called on a constant.',
+     'patterns': [r".*: warning: \[TruthConstantAsserts\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: An object is tested for equality to itself using Truth Libraries.',
+     'patterns': [r".*: warning: \[TruthSelfEquals\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Unsynchronized method overrides a synchronized method.',
+     'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
+    {'category': 'java',
+     'severity': Severity.MEDIUM,
+     'description':
+         'Java: Non-constant variable missing @Var annotation',
+     'patterns': [r".*: warning: \[Var\] .+"]},
+    {'category': 'java',
+     '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.HIGH,
+     'description':
+         'Java: Log tag too long, cannot exceed 23 characters.',
+     'patterns': [r".*: warning: \[IsLoggableTagLength\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Return value of android.graphics.Rect.intersect() must be checked',
+     'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Static and default methods in interfaces are not allowed in android builds.',
+     'patterns': [r".*: warning: \[StaticOrDefaultInterfaceMethod\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Incompatible type as argument to Object-accepting Java collections method',
+     'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: @CompatibleWith\'s value is not a type argument.',
+     'patterns': [r".*: warning: \[CompatibleWithAnnotationMisuse\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Passing argument to a generic method with an incompatible type.',
+     'patterns': [r".*: warning: \[IncompatibleArgumentType\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Invalid printf-style format string',
+     'patterns': [r".*: warning: \[FormatString\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Invalid format string passed to formatting method.',
+     'patterns': [r".*: warning: \[FormatStringAnnotation\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
+     'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: @AutoFactory and @Inject should not be used in the same type.',
+     'patterns': [r".*: warning: \[AutoFactoryAtInject\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Injected constructors cannot be optional nor have binding annotations',
+     'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: A scoping annotation\'s Target should include TYPE and METHOD.',
+     'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Abstract and default methods are not injectable with javax.inject.Inject',
+     'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: @javax.inject.Inject cannot be put on a final field.',
+     'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: This class has more than one @Inject-annotated constructor. Please remove the @Inject annotation from all but one of them.',
+     'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: A class can be annotated with at most one scope annotation.',
+     'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Annotations cannot be both Scope annotations and Qualifier annotations: this causes confusion when trying to use them.',
+     'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Qualifier applied to a method that isn\'t a @Provides method. This method won\'t be used for dependency injection',
+     'patterns': [r".*: warning: \[QualifierOnMethodWithoutProvides\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Scoping and qualifier annotations must have runtime retention.',
+     'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: `@Multibinds` is the new way to declare multibindings.',
+     'patterns': [r".*: warning: \[MultibindsInsteadOfMultibindings\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
+     'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Although Guice allows injecting final fields, doing so is disallowed because the injected value may not be visible to other threads.',
+     'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: This method is not annotated with @Inject, but it overrides a method that is  annotated with @javax.inject.Inject. The method will not be Injected.',
+     'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: @Provides methods need to be declared in a Module to have any effect.',
+     'patterns': [r".*: warning: \[ProvidesMethodOutsideOfModule\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Invalid @GuardedBy expression',
+     'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Type declaration annotated with @Immutable is not immutable',
+     'patterns': [r".*: warning: \[Immutable\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
+     'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: An argument is more similar to a different parameter; the arguments may have been swapped.',
+     'patterns': [r".*: warning: \[ArgumentParameterSwap\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Reference equality used to compare arrays',
+     'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: hashcode method on array does not hash array contents',
+     'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Calling toString on an array does not provide useful information',
+     'patterns': [r".*: warning: \[ArrayToString\] .+"]},
+    {'category': 'java',
+     '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,
+     '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,
+     '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,
+     'description':
+         'Java: Shift by an amount that is out of range',
+     'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Ignored return value of method that is annotated with @CheckReturnValue',
+     'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: This comparison method violates the contract',
+     'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
+     'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Compile-time constant expression overflows',
+     'patterns': [r".*: warning: \[ConstantOverflow\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Exception created but not thrown',
+     'patterns': [r".*: warning: \[DeadException\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Division by integer literal zero',
+     'patterns': [r".*: warning: \[DivZero\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Empty statement after if',
+     'patterns': [r".*: warning: \[EmptyIf\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: == NaN always returns false; use the isNaN methods instead',
+     'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Casting a lambda to this @FunctionalInterface can cause a behavior change from casting to a functional superinterface, which is surprising to users.  Prefer decorator methods to this surprising behavior.',
+     'patterns': [r".*: warning: \[FunctionalInterfaceMethodChanged\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Calling getClass() on an annotation may return a proxy class',
+     'patterns': [r".*: warning: \[GetClassOnAnnotation\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: An object is tested for equality to itself using Guava Libraries',
+     'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: contains() is a legacy method that is equivalent to containsValue()',
+     'patterns': [r".*: warning: \[HashtableContains\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Writing "a && a", "a || a", "a & a", or "a | a" is equivalent to "a".',
+     'patterns': [r".*: warning: \[IdentityBinaryExpression\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Modifying an immutable collection is guaranteed to throw an exception and leave the collection unmodified',
+     'patterns': [r".*: warning: \[ImmutableModification\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: This method always recurses, and will cause a StackOverflowError',
+     'patterns': [r".*: warning: \[InfiniteRecursion\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: A standard cryptographic operation is used in a mode that is prone to vulnerabilities',
+     'patterns': [r".*: warning: \[InsecureCryptoUsage\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Invalid syntax used for a regular expression',
+     'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
+    {'category': 'java',
+     '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,
+     '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,
+     'description':
+         'Java: Test method will not be run; please prefix name with "test"',
+     'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: tearDown() method will not be run; Please add an @After annotation',
+     'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Test method will not be run; please add @Test annotation',
+     'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
+    {'category': 'java',
+     '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,
+     '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,
+     'description':
+         'Java: Missing method call for verify(mock) here',
+     'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Using a collection function with itself as the argument.',
+     'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Static import of type uses non-canonical name',
+     'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: @CompileTimeConstant parameters should be final or effectively final',
+     'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Numeric comparison using reference equality instead of value equality',
+     'patterns': [r".*: warning: \[NumericEquality\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Comparison using reference equality instead of value equality',
+     'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Varargs doesn\'t agree for overridden method',
+     'patterns': [r".*: warning: \[Overrides\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Declaring types inside package-info.java files is very bad form',
+     'patterns': [r".*: warning: \[PackageInfo\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
+     'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Protobuf fields cannot be null',
+     'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Comparing protobuf fields of type String using reference equality',
+     'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Use Random.nextInt(int).  Random.nextInt() % n can have negative results',
+     'patterns': [r".*: warning: \[RandomModInteger\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java:  Check for non-whitelisted callers to RestrictedApiChecker.',
+     'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Return value of this method must be used',
+     'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Variable assigned to itself',
+     'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: An object is compared to itself',
+     'patterns': [r".*: warning: \[SelfComparison\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Variable compared to itself',
+     'patterns': [r".*: warning: \[SelfEquality\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: An object is tested for equality to itself',
+     'patterns': [r".*: warning: \[SelfEquals\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Calling toString on a Stream does not provide useful information',
+     'patterns': [r".*: warning: \[StreamToString\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
+     'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
+     'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
+    {'category': 'java',
+     '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,
+     'description':
+         'Java: Type parameter used as type qualifier',
+     'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Non-generic methods should not be invoked with type arguments',
+     'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Instance created but never used',
+     'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Collection is modified in place, but the result is not used',
+     'patterns': [r".*: warning: \[UnusedCollectionModifiedInPlace\] .+"]},
+    {'category': 'java',
+     'severity': Severity.HIGH,
+     'description':
+         'Java: Method parameter has wrong package',
+     'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
+
+    # End warnings generated by Error Prone
+
+    {'category': 'java',
+     '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': '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.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,     'members':[], '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,   'members':[], '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,   'members':[], 'option':'-Wpointer-arith',
-        'description':'void* used in arithmetic' ,
-        'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
-                    r".*: warning: wrong type argument to increment"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,   'members':[], 'option':'-Wsign-promo',
-        'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
-        'patterns':[r".*: warning: passing '.+' chooses 'int' over '.* int'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning:   in call to '.+'"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,     'members':[], '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,     'members':[], 'option':'',
-        'description':'Converting from <type> to <other type>',
-        'patterns':[r".*: warning: converting to '.+' from '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,     'members':[], 'option':'',
-        'description':'Return value from void function',
-        'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
-    { 'category':'C/C++',   'severity':severity.LOW,     'members':[], 'option':'',
-        'description':'Useless specifier',
-        'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
-    { 'category':'logtags',   'severity':severity.LOW,     'members':[], 'option':'',
-        'description':'Duplicate logtag',
-        'patterns':[r".*: warning: tag "".+"" \(None\) duplicated in .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,     'members':[], 'option':'',
-        '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,     'members':[], 'option':'',
-        'description':'NULL used in arithmetic',
-        'patterns':[r".*: warning: NULL used in arithmetic"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,     'members':[], 'option':'',
-        'description':'Use of deprecated method',
-        'patterns':[r".*: warning: '.+' is deprecated .+"] },
+    {'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.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,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: ,$"] },
-    { 'category':'C/C++',   'severity':severity.SKIP,     'members':[], 'option':'',
-        'description':'',
-        'patterns':[r".*: warning: $"] },
-    { 'category':'C/C++',   'severity':severity.SKIP,     'members':[], 'option':'',
-        '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.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,  'members':[], 'option':'',
-        'description':'Unclassified/unrecognized warnings',
-        'patterns':[r".*: warning: .+"] },
+    {'category': 'C/C++', 'severity': Severity.UNKNOWN,
+     'description': 'Unclassified/unrecognized warnings',
+     'patterns': [r".*: warning: .+"]},
 ]
 
-anchor = 0
-cur_row_color = 0
-row_colors = [ 'e0e0e0', 'd0d0d0' ]
 
-def output(text):
-    print text,
-
-def htmlbig(param):
-    return '<font size="+2">' + param + '</font>'
-
-def dumphtmlprologue(title):
-    output('<html>\n<head>\n<title>' + title + '</title>\n<body>\n')
-    output(htmlbig(title))
-    output('<p>\n')
-
-def tablerow(text):
-    global cur_row_color
-    output('<tr bgcolor="' + row_colors[cur_row_color] + '"><td colspan="2">',)
-    cur_row_color = 1 - cur_row_color
-    output(text,)
-    output('</td></tr>')
-
-def begintable(text, backgroundcolor):
-    global anchor
-    output('<table border="1" rules="cols" frame="box" width="100%" bgcolor="black"><tr bgcolor="' +
-        backgroundcolor + '"><a name="anchor' + str(anchor) + '"><td>')
-    output(htmlbig(text[0]) + '<br>')
-    for i in text[1:]:
-        output(i + '<br>')
-    output('</td>')
-    output('<td width="100" bgcolor="grey"><a align="right" href="#anchor' + str(anchor-1) +
-        '">previous</a><br><a align="right" href="#anchor' + str(anchor+1) + '">next</a>')
-    output('</td></a></tr>')
-    anchor += 1
-
-def endtable():
-    output('</table><p>')
+def project_name_and_pattern(name, pattern):
+  return [name, '(^|.*/)' + pattern + '/.*: warning:']
 
 
-# dump some stats about total number of warnings and such
-def dumpstats():
-    known = 0
-    unknown = 0
-    for i in warnpatterns:
-        if i['severity'] == severity.UNKNOWN:
-            unknown += len(i['members'])
-        elif i['severity'] != severity.SKIP:
-            known += len(i['members'])
-    output('Number of classified warnings: <b>' + str(known) + '</b><br>' )
-    output('Number of unclassified warnings: <b>' + str(unknown) + '</b><br>')
-    total = unknown + known
-    output('Total number of warnings: <b>' + str(total) + '</b>')
-    if total < 1000:
-        output('(low count may indicate incremental build)')
-    output('<p>')
-
-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)
+def simple_project_pattern(pattern):
+  return project_name_and_pattern(pattern, pattern)
 
 
-# show which warnings no longer occur
-def dumpfixed():
-    tablestarted = False
-    for i in warnpatterns:
-        if len(i['members']) == 0 and i['severity'] != severity.SKIP:
-            if tablestarted == False:
-                tablestarted = True
-                begintable(['Fixed warnings', 'No more occurences. Please consider turning these in to errors if possible, before they are reintroduced in to the build'], 'blue')
-            tablerow(i['description'] + ' (' + allpatterns(i) + ') ' + i['option'])
-    if tablestarted:
-        endtable()
+# A list of [project_name, file_path_pattern].
+# project_name should not contain comma, to be used in CSV output.
+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/
+    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/common_time'),
+    simple_project_pattern('frameworks/av/media/img_utils'),
+    simple_project_pattern('frameworks/av/media/libcpustats'),
+    simple_project_pattern('frameworks/av/media/libeffects'),
+    simple_project_pattern('frameworks/av/media/libmediaplayerservice'),
+    simple_project_pattern('frameworks/av/media/libmedia'),
+    simple_project_pattern('frameworks/av/media/libstagefright'),
+    simple_project_pattern('frameworks/av/media/mtp'),
+    simple_project_pattern('frameworks/av/media/ndk'),
+    simple_project_pattern('frameworks/av/media/utils'),
+    project_name_and_pattern('frameworks/av/media/Other',
+                             'frameworks/av/media'),
+    simple_project_pattern('frameworks/av/radio'),
+    simple_project_pattern('frameworks/av/services'),
+    simple_project_pattern('frameworks/av/soundtrigger'),
+    project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
+    simple_project_pattern('frameworks/base/cmds'),
+    simple_project_pattern('frameworks/base/core'),
+    simple_project_pattern('frameworks/base/drm'),
+    simple_project_pattern('frameworks/base/media'),
+    simple_project_pattern('frameworks/base/libs'),
+    simple_project_pattern('frameworks/base/native'),
+    simple_project_pattern('frameworks/base/packages'),
+    simple_project_pattern('frameworks/base/rs'),
+    simple_project_pattern('frameworks/base/services'),
+    simple_project_pattern('frameworks/base/tests'),
+    simple_project_pattern('frameworks/base/tools'),
+    project_name_and_pattern('frameworks/base/Other', 'frameworks/base'),
+    simple_project_pattern('frameworks/compile/libbcc'),
+    simple_project_pattern('frameworks/compile/mclinker'),
+    simple_project_pattern('frameworks/compile/slang'),
+    project_name_and_pattern('frameworks/compile/Other', 'frameworks/compile'),
+    simple_project_pattern('frameworks/minikin'),
+    simple_project_pattern('frameworks/ml'),
+    simple_project_pattern('frameworks/native/cmds'),
+    simple_project_pattern('frameworks/native/include'),
+    simple_project_pattern('frameworks/native/libs'),
+    simple_project_pattern('frameworks/native/opengl'),
+    simple_project_pattern('frameworks/native/services'),
+    simple_project_pattern('frameworks/native/vulkan'),
+    project_name_and_pattern('frameworks/native/Other', '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/adb'),
+    simple_project_pattern('system/core/base'),
+    simple_project_pattern('system/core/debuggerd'),
+    simple_project_pattern('system/core/fastboot'),
+    simple_project_pattern('system/core/fingerprintd'),
+    simple_project_pattern('system/core/fs_mgr'),
+    simple_project_pattern('system/core/gatekeeperd'),
+    simple_project_pattern('system/core/healthd'),
+    simple_project_pattern('system/core/include'),
+    simple_project_pattern('system/core/init'),
+    simple_project_pattern('system/core/libbacktrace'),
+    simple_project_pattern('system/core/liblog'),
+    simple_project_pattern('system/core/libpixelflinger'),
+    simple_project_pattern('system/core/libprocessgroup'),
+    simple_project_pattern('system/core/libsysutils'),
+    simple_project_pattern('system/core/logcat'),
+    simple_project_pattern('system/core/logd'),
+    simple_project_pattern('system/core/run-as'),
+    simple_project_pattern('system/core/sdcard'),
+    simple_project_pattern('system/core/toolbox'),
+    project_name_and_pattern('system/core/Other', 'system/core'),
+    simple_project_pattern('system/extras/ANRdaemon'),
+    simple_project_pattern('system/extras/cpustats'),
+    simple_project_pattern('system/extras/crypto-perf'),
+    simple_project_pattern('system/extras/ext4_utils'),
+    simple_project_pattern('system/extras/f2fs_utils'),
+    simple_project_pattern('system/extras/iotop'),
+    simple_project_pattern('system/extras/libfec'),
+    simple_project_pattern('system/extras/memory_replay'),
+    simple_project_pattern('system/extras/micro_bench'),
+    simple_project_pattern('system/extras/mmap-perf'),
+    simple_project_pattern('system/extras/multinetwork'),
+    simple_project_pattern('system/extras/perfprofd'),
+    simple_project_pattern('system/extras/procrank'),
+    simple_project_pattern('system/extras/runconuid'),
+    simple_project_pattern('system/extras/showmap'),
+    simple_project_pattern('system/extras/simpleperf'),
+    simple_project_pattern('system/extras/su'),
+    simple_project_pattern('system/extras/tests'),
+    simple_project_pattern('system/extras/verity'),
+    project_name_and_pattern('system/extras/Other', 'system/extras'),
+    simple_project_pattern('system/gatekeeper'),
+    simple_project_pattern('system/keymaster'),
+    simple_project_pattern('system/libhidl'),
+    simple_project_pattern('system/libhwbinder'),
+    simple_project_pattern('system/media'),
+    simple_project_pattern('system/netd'),
+    simple_project_pattern('system/nvram'),
+    simple_project_pattern('system/security'),
+    simple_project_pattern('system/sepolicy'),
+    simple_project_pattern('system/tools'),
+    simple_project_pattern('system/update_engine'),
+    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/
+    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',
+     '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
+     'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
+    ['other', '.*']  # all other unrecognized patterns
+]
+
+project_patterns = []
+project_names = []
+warning_messages = []
+warning_records = []
 
 
-# dump a category, provided it is not marked as 'SKIP' and has more than 0 occurrences
-def dumpcategory(cat):
-    if cat['severity'] != severity.SKIP and len(cat['members']) != 0:
-        header = [descriptionfor(cat),str(len(cat['members'])) + ' occurences:']
-        if cat['option'] != '':
-            header[1:1] = [' (related option: ' + cat['option'] +')']
-        begintable(header, colorforseverity(cat['severity']))
-        for i in cat['members']:
-            tablerow(i)
-        endtable()
+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'] = {}
 
 
-# dump everything for a given severity
-def dumpseverity(sev):
-    for i in warnpatterns:
-        if i['severity'] == sev:
-            dumpcategory(i)
+initialize_arrays()
 
 
-def classifywarning(line):
-    for i in warnpatterns:
-        for cpat in i['compiledpatterns']:
-            if cpat.match(line):
-                i['members'].append(line)
-                return
+android_root = ''
+platform_version = 'unknown'
+target_product = 'unknown'
+target_variant = 'unknown'
+
+
+##### Data and functions to dump html file. ##################################
+
+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 || !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 html_big(param):
+  return '<font size="+2">' + param + '</font>'
+
+
+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 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
+    print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
+  print '</table></div>'
+  print '</blockquote>'
+
+
+def find_project_index(line):
+  for p in range(len(project_patterns)):
+    if project_patterns[p].match(line):
+      return p
+  return -1
+
+
+def classify_one_warning(line, results):
+  for i in range(len(warn_patterns)):
+    w = warn_patterns[i]
+    for cpat in w['compiled_patterns']:
+      if cpat.match(line):
+        p = find_project_index(line)
+        results.append([line, i, p])
+        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))
 
-infile = open(sys.argv[1], 'r')
-warnings = []
+def classify_warnings(lines):
+  results = []
+  for line in lines:
+    classify_one_warning(line, results)
+  # After the main work, ignore all other signals to a child process,
+  # to avoid bad warning/error messages from the exit clean-up process.
+  if args.processes > 1:
+    signal.signal(signal.SIGTERM, lambda *args: sys.exit(-signal.SIGTERM))
+  return results
 
-platformversion = 'unknown'
-targetproduct = 'unknown'
-targetvariant = 'unknown'
-linecounter = 0
 
-warningpattern = re.compile('.* warning:.*')
-compilepatterns()
+def parallel_classify_warnings(warning_lines):
+  """Classify all warning lines with num_cpu parallel processes."""
+  compile_patterns()
+  num_cpu = args.processes
+  if num_cpu > 1:
+    groups = [[] for x in range(num_cpu)]
+    i = 0
+    for x in warning_lines:
+      groups[i].append(x)
+      i = (i + 1) % num_cpu
+    pool = multiprocessing.Pool(num_cpu)
+    group_results = pool.map(classify_warnings, groups)
+  else:
+    group_results = [classify_warnings(warning_lines)]
 
-# read the log file and classify all the warnings
-lastmatchedline = ''
-for line in infile:
-    # replace fancy quotes with plain ol' quotes
-    line = line.replace("‘", "'");
-    line = line.replace("’", "'");
-    if warningpattern.match(line):
-        if line != lastmatchedline:
-            classifywarning(line)
-            lastmatchedline = line
+  for result in group_results:
+    for line, pattern_idx, project_idx in result:
+      pattern = warn_patterns[pattern_idx]
+      pattern['members'].append(line)
+      message_idx = len(warning_messages)
+      warning_messages.append(line)
+      warning_records.append([pattern_idx, project_idx, message_idx])
+      pname = '???' if project_idx < 0 else project_names[project_idx]
+      # Count warnings by project.
+      if pname in pattern['projects']:
+        pattern['projects'][pname] += 1
+      else:
+        pattern['projects'][pname] = 1
+
+
+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 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(infile):
+  """Parse input file, match warning lines."""
+  global platform_version
+  global target_product
+  global target_variant
+  line_counter = 0
+
+  # handle only warning messages with a file path
+  warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
+
+  # Collect all warnings into the warning_lines set.
+  warning_lines = set()
+  for line in infile:
+    if warning_pattern.match(line):
+      line = normalize_warning_line(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 warning_lines
+
+
+# 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:
-        # 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)
+      print '"",'  # no such warning
+  print '];'
+
+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>";
+
+    }
+    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
-dumphtmlprologue('Warnings for ' + platformversion + ' - ' + targetproduct + ' - ' + targetvariant)
-dumpstats()
-dumpseverity(severity.FIXMENOW)
-dumpseverity(severity.HIGH)
-dumpseverity(severity.MEDIUM)
-dumpseverity(severity.LOW)
-dumpseverity(severity.HARMLESS)
-dumpseverity(severity.UNKNOWN)
-dumpfixed()
+# 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 description_for_csv(category):
+  if not category['description']:
+    return '?'
+  return category['description']
+
+
+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 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')
+
+
+def main():
+  warning_lines = parse_input_file(open(args.buildlog, 'r'))
+  parallel_classify_warnings(warning_lines)
+  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/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index a2dfd02..d56ac29 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -19,8 +19,9 @@
  */
 #include "ZipFile.h"
 
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 using namespace android;
 
@@ -33,12 +34,12 @@
     fprintf(stderr, "Copyright (C) 2009 The Android Open Source Project\n\n");
     fprintf(stderr,
         "Usage: zipalign [-f] [-p] [-v] [-z] <align> infile.zip outfile.zip\n"
-        "       zipalign -c [-v] <align> infile.zip\n\n" );
+        "       zipalign -c [-p] [-v] <align> infile.zip\n\n" );
     fprintf(stderr,
         "  <align>: alignment in bytes, e.g. '4' provides 32-bit alignment\n");
     fprintf(stderr, "  -c: check alignment only (does not modify file)\n");
     fprintf(stderr, "  -f: overwrite existing outfile.zip\n");
-    fprintf(stderr, "  -p: page align stored shared object files\n");
+    fprintf(stderr, "  -p: memory page alignment for stored shared object files\n");
     fprintf(stderr, "  -v: verbose output\n");
     fprintf(stderr, "  -z: recompress using Zopfli\n");
 }
diff --git a/tools/zipalign/ZipEntry.cpp b/tools/zipalign/ZipEntry.cpp
index 2f33e23..63d75d1 100644
--- a/tools/zipalign/ZipEntry.cpp
+++ b/tools/zipalign/ZipEntry.cpp
@@ -23,10 +23,11 @@
 #include "ZipEntry.h"
 #include <utils/Log.h>
 
-#include <stdio.h>
-#include <string.h>
 #include <assert.h>
 #include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
 
 using namespace android;
 
@@ -130,6 +131,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/ZipEntry.h b/tools/zipalign/ZipEntry.h
index e06567d..247cf69 100644
--- a/tools/zipalign/ZipEntry.h
+++ b/tools/zipalign/ZipEntry.h
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <time.h>
 
 namespace android {
 
@@ -290,7 +291,7 @@
             mExtraField(NULL),
             mFileComment(NULL)
         {}
-        virtual ~CentralDirEntry(void) {
+        ~CentralDirEntry(void) {
             delete[] mFileName;
             delete[] mExtraField;
             delete[] mFileComment;
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 4edf0aa..1b39902 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -359,8 +359,7 @@
  * safely written.  Not really a concern for us.
  */
 status_t ZipFile::addCommon(const char* fileName, const void* data, size_t size,
-    const char* storageName, int sourceType, int compressionMethod,
-    ZipEntry** ppEntry)
+    const char* storageName, int compressionMethod, ZipEntry** ppEntry)
 {
     ZipEntry* pEntry = NULL;
     status_t result = NO_ERROR;
@@ -414,81 +413,51 @@
     /*
      * Copy the data in, possibly compressing it as we go.
      */
-    if (sourceType == ZipEntry::kCompressStored) {
-        if (compressionMethod == ZipEntry::kCompressDeflated) {
-            bool failed = false;
-            result = compressFpToFp(mZipFp, inputFp, data, size, &crc);
-            if (result != NO_ERROR) {
-                ALOGD("compression failed, storing\n");
-                failed = true;
-            } else {
-                /*
-                 * Make sure it has compressed "enough".  This probably ought
-                 * to be set through an API call, but I don't expect our
-                 * criteria to change over time.
-                 */
-                long src = inputFp ? ftell(inputFp) : size;
-                long dst = ftell(mZipFp) - startPosn;
-                if (dst + (dst / 10) > src) {
-                    ALOGD("insufficient compression (src=%ld dst=%ld), storing\n",
-                        src, dst);
-                    failed = true;
-                }
-            }
-
-            if (failed) {
-                compressionMethod = ZipEntry::kCompressStored;
-                if (inputFp) rewind(inputFp);
-                fseek(mZipFp, startPosn, SEEK_SET);
-                /* fall through to kCompressStored case */
-            }
-        }
-        /* handle "no compression" request, or failed compression from above */
-        if (compressionMethod == ZipEntry::kCompressStored) {
-            if (inputFp) {
-                result = copyFpToFp(mZipFp, inputFp, &crc);
-            } else {
-                result = copyDataToFp(mZipFp, data, size, &crc);
-            }
-            if (result != NO_ERROR) {
-                // don't need to truncate; happens in CDE rewrite
-                ALOGD("failed copying data in\n");
-                goto bail;
-            }
-        }
-
-        // currently seeked to end of file
-        uncompressedLen = inputFp ? ftell(inputFp) : size;
-    } else if (sourceType == ZipEntry::kCompressDeflated) {
-        /* we should support uncompressed-from-compressed, but it's not
-         * important right now */
-        assert(compressionMethod == ZipEntry::kCompressDeflated);
-
-        bool scanResult;
-        int method;
-        long compressedLen;
-        unsigned long longcrc;
-
-        scanResult = ZipUtils::examineGzip(inputFp, &method, &uncompressedLen,
-                        &compressedLen, &longcrc);
-        if (!scanResult || method != ZipEntry::kCompressDeflated) {
-            ALOGD("this isn't a deflated gzip file?");
-            result = UNKNOWN_ERROR;
-            goto bail;
-        }
-        crc = longcrc;
-
-        result = copyPartialFpToFp(mZipFp, inputFp, compressedLen, NULL);
+    if (compressionMethod == ZipEntry::kCompressDeflated) {
+        bool failed = false;
+        result = compressFpToFp(mZipFp, inputFp, data, size, &crc);
         if (result != NO_ERROR) {
-            ALOGD("failed copying gzip data in\n");
+            ALOGD("compression failed, storing\n");
+            failed = true;
+        } else {
+            /*
+             * Make sure it has compressed "enough".  This probably ought
+             * to be set through an API call, but I don't expect our
+             * criteria to change over time.
+             */
+            long src = inputFp ? ftell(inputFp) : size;
+            long dst = ftell(mZipFp) - startPosn;
+            if (dst + (dst / 10) > src) {
+                ALOGD("insufficient compression (src=%ld dst=%ld), storing\n",
+                    src, dst);
+                failed = true;
+            }
+        }
+
+        if (failed) {
+            compressionMethod = ZipEntry::kCompressStored;
+            if (inputFp) rewind(inputFp);
+            fseek(mZipFp, startPosn, SEEK_SET);
+            /* fall through to kCompressStored case */
+        }
+    }
+    /* handle "no compression" request, or failed compression from above */
+    if (compressionMethod == ZipEntry::kCompressStored) {
+        if (inputFp) {
+            result = copyFpToFp(mZipFp, inputFp, &crc);
+        } else {
+            result = copyDataToFp(mZipFp, data, size, &crc);
+        }
+        if (result != NO_ERROR) {
+            // don't need to truncate; happens in CDE rewrite
+            ALOGD("failed copying data in\n");
             goto bail;
         }
-    } else {
-        assert(false);
-        result = UNKNOWN_ERROR;
-        goto bail;
     }
 
+    // currently seeked to end of file
+    uncompressedLen = inputFp ? ftell(inputFp) : size;
+
     /*
      * We could write the "Data Descriptor", but there doesn't seem to
      * be any point since we're going to go back and write the LFH.
@@ -919,6 +888,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 +907,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;
     }
 
diff --git a/tools/zipalign/ZipFile.h b/tools/zipalign/ZipFile.h
index b0bafe9..d5ace7c 100644
--- a/tools/zipalign/ZipFile.h
+++ b/tools/zipalign/ZipFile.h
@@ -86,24 +86,10 @@
         int compressionMethod, ZipEntry** ppEntry)
     {
         return addCommon(fileName, NULL, 0, storageName,
-                         ZipEntry::kCompressStored,
                          compressionMethod, ppEntry);
     }
 
     /*
-     * Add a file that is already compressed with gzip.
-     *
-     * If "ppEntry" is non-NULL, a pointer to the new entry will be returned.
-     */
-    status_t addGzip(const char* fileName, const char* storageName,
-        ZipEntry** ppEntry)
-    {
-        return addCommon(fileName, NULL, 0, storageName,
-                         ZipEntry::kCompressDeflated,
-                         ZipEntry::kCompressDeflated, ppEntry);
-    }
-
-    /*
      * Add a file from an in-memory data buffer.
      *
      * If "ppEntry" is non-NULL, a pointer to the new entry will be returned.
@@ -112,7 +98,6 @@
         int compressionMethod, ZipEntry** ppEntry)
     {
         return addCommon(NULL, data, size, storageName,
-                         ZipEntry::kCompressStored,
                          compressionMethod, ppEntry);
     }
 
@@ -231,8 +216,7 @@
 
     /* common handler for all "add" functions */
     status_t addCommon(const char* fileName, const void* data, size_t size,
-        const char* storageName, int sourceType, int compressionMethod,
-        ZipEntry** ppEntry);
+        const char* storageName, int compressionMethod, ZipEntry** ppEntry);
 
     /* copy all of "srcFp" into "dstFp" */
     status_t copyFpToFp(FILE* dstFp, FILE* srcFp, uint32_t* pCRC32);
diff --git a/tools/ziptime/Android.bp b/tools/ziptime/Android.bp
new file mode 100644
index 0000000..874d346
--- /dev/null
+++ b/tools/ziptime/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright 2015 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.
+//
+
+//
+// Zip timestamp removal tool
+//
+
+cc_binary_host {
+
+    srcs: [
+        "ZipTime.cpp",
+        "ZipEntry.cpp",
+        "ZipFile.cpp",
+    ],
+
+    name: "ziptime",
+    target: {
+        windows: {
+            enabled: true,
+        },
+    },
+
+}
diff --git a/tools/ziptime/Android.mk b/tools/ziptime/Android.mk
deleted file mode 100644
index 3575229..0000000
--- a/tools/ziptime/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright 2015 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.
-#
-
-#
-# Zip timestamp removal tool
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	ZipTime.cpp \
-	ZipEntry.cpp \
-	ZipFile.cpp
-
-LOCAL_MODULE := ziptime
-LOCAL_MODULE_HOST_OS := darwin linux windows
-
-include $(BUILD_HOST_EXECUTABLE)