resolved conflicts for b161297d to lmp-mr1-ub-dev

Change-Id: I9bfac79b7d0cc7c6a3e501b15d5bd91781e6246e
diff --git a/CleanSpec.mk b/CleanSpec.mk
index e9d4455..897524b 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -284,6 +284,9 @@
 
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
 
+# Switch host builds to Clang by default
+$(call add-clean-step, rm -rf $(OUT_DIR)/host)
+
 # Adding dalvik.vm.dex2oat-filter
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
@@ -304,11 +307,48 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
 
+# Move to libc++ as the default STL.
+$(call add-clean-step, rm -rf $(OUT_DIR))
+
+# dex2oat instruction-set changes
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# Make GNU++11 the default standard version. This requires a cleanspec because
+# char16_t/char32_t will be real types now instead of typedefs, which means
+# an ABI change since the names will mangle differently.
+$(call add-clean-step, rm -rf $(OUT_DIR))
+
 # 5.1!
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
 
+# Remove ro.product.locale.language/country and add ro.product.locale
+# instead.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+
+# Adding dalvik.vm.usejit
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# Rename dalvik.vm.usejit to debug.dalvik.vm.usejit
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# Revert rename dalvik.vm.usejit to debug.dalvik.vm.usejit
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
+# Change from interpret-only to verify-at-runtime.
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
+
 # 5.1.1!
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
diff --git a/core/Makefile b/core/Makefile
index b23122e..4a11b0d 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -156,29 +156,12 @@
   BUILD_DISPLAY_ID := $(build_desc)
 endif
 
-# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
-product_property_override_locale_language := $(strip \
-    $(patsubst ro.product.locale.language=%,%,\
-    $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
-product_property_overrides_locale_region := $(strip \
-    $(patsubst ro.product.locale.region=%,%,\
-    $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
-
-# Selects the first locale in the list given as the argument,
-# and splits it into language and region, which each may be
-# empty.
-define default-locale
-$(subst _, , $(firstword $(1)))
-endef
-
-# Selects the first locale in the list given as the argument
-# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
-# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
-define default-locale-language
-$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
-endef
-define default-locale-region
-$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
+# Accepts a whitespace separated list of product locales such as
+# (en_US en_AU en_GB...) and returns the first locale in the list with
+# underscores replaced with hyphens. In the example above, this will
+# return "en-US".
+define get-default-product-locale
+$(strip $(subst _,-, $(firstword $(1))))
 endef
 
 BUILDINFO_SH := build/tools/buildinfo.sh
@@ -188,7 +171,7 @@
 else
 system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
 endif
-$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file)
+$(INSTALLED_BUILD_PROP_TARGET): $(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 > $@
@@ -204,8 +187,7 @@
 			TARGET_DEVICE="$(TARGET_DEVICE)" \
 			PRODUCT_NAME="$(TARGET_PRODUCT)" \
 			PRODUCT_BRAND="$(PRODUCT_BRAND)" \
-			PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \
-			PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \
+			PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \
 			PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \
 			PRODUCT_MODEL="$(PRODUCT_MODEL)" \
 			PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
@@ -246,6 +228,7 @@
 		        echo "#" >> $@; )
 	$(hide) $(foreach line,$(ADDITIONAL_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)
 
 build_desc :=
@@ -266,6 +249,21 @@
 	$(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT)">>$@
 endif
 
+# ----------------------------------------------------------------
+# boot.img build.prop
+# as with vendor build.prop above, for verifying that the bootimage
+# build is what we think it is
+
+INSTALLED_BOOTIMAGE_BUILD_PROP_TARGET := $(TARGET_ROOT_OUT)/build.prop
+ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BOOTIMAGE_BUILD_PROP_TARGET)
+$(INSTALLED_BOOTIMAGE_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
+	@echo Target bootimage buildinfo: $@
+	@mkdir -p $(dir $@)
+	$(hide) echo > $@
+	$(hide) echo ro.bootimage.build.date=`date`>>$@
+	$(hide) echo ro.bootimage.build.date.utc=`date +%s`>>$@
+	$(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT)">>$@
+
 # -----------------------------------------------------------------
 # sdk-build.prop
 #
@@ -491,23 +489,7 @@
 INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
 
 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
-tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg
-INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image)
-INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG)
-
-ifeq ($(TARGET_BOOTIMAGE_USE_EXTLINUX),true)
-INTERNAL_BOOTIMAGE_ARGS += --extlinuxconf $(TARGET_BOOTIMAGE_EXTLINUX_CONFIG)
-endif
-
-$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES)
-	$(call pretty,"Target boot image: $@")
-	$(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@
-
-.PHONY: bootimage-nodeps
-bootimage-nodeps: $(MKEXT2IMG)
-	@echo "make $@: ignoring dependencies"
-	$(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
-
+$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
 else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) # TARGET_BOOTIMAGE_USE_EXT2 != true
 
 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
@@ -699,8 +681,14 @@
 ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
 INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS)
 endif
-else
-INTERNAL_USERIMAGES_DEPS := $(MKYAFFS2)
+endif
+
+ifeq ($(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs)
+INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG)
+endif
+
+ifeq ($(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs)
+INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG)
 endif
 
 INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))
@@ -717,7 +705,10 @@
 define generate-userimage-prop-dictionary
 $(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))
 $(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
+$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
+$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(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_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
@@ -728,13 +719,19 @@
 $(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
 $(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
 $(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
-$(if $(mkyaffs2_extra_flags),$(hide) echo "mkyaffs2_extra_flags=$(mkyaffs2_extra_flags)" >> $(1))
 $(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1))
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1))
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(VERITY_SIGNER)" >> $(1))
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(FUTILITY)" >> $(1))
+$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
+$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
+    $(hide) echo "system_root_image=true" >> $(1);\
+    echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1))
 $(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);))
 endef
 
@@ -746,12 +743,14 @@
 
 INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
 
+INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
+    $(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_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system
 recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
 recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET)
-recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery
 recovery_resources_common := $(call include-path-for, recovery)/res
 
 # Set recovery_density to the density bucket of the device.
@@ -775,7 +774,7 @@
 # can be overridden for a particular device by putting a font.png in
 # its private recovery resources.
 
-ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
+ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density)))
 recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
 else
 recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
@@ -835,51 +834,62 @@
 	@mkdir -p $(dir $@)
 	java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@
 
+# $(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)/tmp
+  @echo Copying baseline ramdisk...
+  $(hide) rsync -a $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac.
+  @echo Modifying ramdisk contents...
+  $(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/*
+  $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
+  $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
+  $(hide) $(foreach item,$(recovery_resources_private), \
+    cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
+  $(hide) $(foreach item,$(recovery_fstab), \
+    cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
+  $(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) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
+  $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
+    $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \
+    $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1))
+  $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)),\
+    $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1))
+  $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
+    $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(1).keyblock $(1))
+  $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
+  @echo ----- Made recovery image: $(1) --------
+endef
+
 $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
 		$(INSTALLED_RAMDISK_TARGET) \
 		$(INSTALLED_BOOTIMAGE_TARGET) \
-		$(recovery_binary) \
+		$(INTERNAL_RECOVERYIMAGE_FILES) \
 		$(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \
 		$(INSTALLED_2NDBOOTLOADER_TARGET) \
 		$(recovery_build_prop) $(recovery_resource_deps) \
 		$(recovery_fstab) \
 		$(RECOVERY_INSTALL_OTA_KEYS)
-	@echo ----- Making recovery image ------
-	$(hide) rm -rf $(TARGET_RECOVERY_OUT)
-	$(hide) mkdir -p $(TARGET_RECOVERY_OUT)
-	$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/tmp
-	@echo Copying baseline ramdisk...
-	$(hide) cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
-	@echo Modifying ramdisk contents...
-	$(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)/
-	$(hide) cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/
-	$(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
-	$(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
-	$(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
-	$(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
-	$(hide) $(foreach item,$(recovery_resources_private), \
-	  cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
-	$(hide) $(foreach item,$(recovery_fstab), \
-	  cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
-	$(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) $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk)
-	$(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
-ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY))
-	$(BOOT_SIGNER) /recovery $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@
-endif
-	$(hide) $(call assert-max-image-size,$@,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))
-	@echo ----- Made recovery image: $@ --------
+		$(call build-recoveryimage-target, $@)
 
 $(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET)
 	$(hide) mkdir -p $(dir $@)
 	$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrj $@ -@
 
+.PHONY: recoveryimage-nodeps
+recoveryimage-nodeps:
+	@echo "make $@: ignoring dependencies"
+	$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET))
+
 else
 INSTALLED_RECOVERYIMAGE_TARGET :=
 RECOVERY_RESOURCE_ZIP :=
@@ -888,16 +898,11 @@
 .PHONY: recoveryimage
 recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
 
-ifneq ($(BOARD_NAND_PAGE_SIZE),)
-mkyaffs2_extra_flags := -c $(BOARD_NAND_PAGE_SIZE)
-else
-mkyaffs2_extra_flags :=
+ifeq ($(BOARD_NAND_PAGE_SIZE),)
 BOARD_NAND_PAGE_SIZE := 2048
 endif
 
-ifneq ($(BOARD_NAND_SPARE_SIZE),)
-mkyaffs2_extra_flags += -s $(BOARD_NAND_SPARE_SIZE)
-else
+ifeq ($(BOARD_NAND_SPARE_SIZE),)
 BOARD_NAND_SPARE_SIZE := 64
 endif
 
@@ -917,6 +922,7 @@
     $(PDK_FUSION_SYSIMG_FILES) \
     $(RECOVERY_RESOURCE_ZIP))
 
+
 FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
 # -----------------------------------------------------------------
 # installed file list
@@ -1253,49 +1259,50 @@
 # host tools needed to build dist and OTA packages
 
 DISTTOOLS :=  $(HOST_OUT_EXECUTABLES)/minigzip \
-	  $(HOST_OUT_EXECUTABLES)/mkbootfs \
-	  $(HOST_OUT_EXECUTABLES)/mkbootimg \
-	  $(HOST_OUT_EXECUTABLES)/fs_config \
-	  $(HOST_OUT_EXECUTABLES)/mkyaffs2image \
-	  $(HOST_OUT_EXECUTABLES)/zipalign \
-	  $(HOST_OUT_EXECUTABLES)/bsdiff \
-	  $(HOST_OUT_EXECUTABLES)/imgdiff \
-	  $(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)/simg2img \
-	  $(HOST_OUT_EXECUTABLES)/e2fsck \
-	  $(HOST_OUT_EXECUTABLES)/build_verity_tree \
-	  $(HOST_OUT_EXECUTABLES)/verity_signer \
-	  $(HOST_OUT_EXECUTABLES)/append2simg \
-	  $(HOST_OUT_EXECUTABLES)/boot_signer
+  $(HOST_OUT_EXECUTABLES)/mkbootfs \
+  $(HOST_OUT_EXECUTABLES)/mkbootimg \
+  $(HOST_OUT_EXECUTABLES)/fs_config \
+  $(HOST_OUT_EXECUTABLES)/zipalign \
+  $(HOST_OUT_EXECUTABLES)/bsdiff \
+  $(HOST_OUT_EXECUTABLES)/imgdiff \
+  $(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)/simg2img \
+  $(HOST_OUT_EXECUTABLES)/e2fsck \
+  $(HOST_OUT_EXECUTABLES)/build_verity_tree \
+  $(HOST_OUT_EXECUTABLES)/verity_signer \
+  $(HOST_OUT_EXECUTABLES)/append2simg \
+  $(HOST_OUT_EXECUTABLES)/boot_signer
+
+# Shared libraries.
+DISTTOOLS += \
+  $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX)
 
 OTATOOLS := $(DISTTOOLS) \
-	  $(HOST_OUT_EXECUTABLES)/aapt
+  $(HOST_OUT_EXECUTABLES)/aapt
 
 .PHONY: otatools
 otatools: $(OTATOOLS)
 
 BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
-$(BUILT_OTATOOLS_PACKAGE): \
-	intermediate := $(call intermediates-dir-for,PACKAGING,otatools)
-$(BUILT_OTATOOLS_PACKAGE): \
-	zip_root := $(intermediate)/otatools
+$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
 
-$(BUILT_OTATOOLS_PACKAGE): \
-		$(OTATOOLS)
+$(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
-	$(hide) $(ACP) -p $(OTATOOLS) $(zip_root)/bin
-	$(hide) mv $(zip_root)/bin/*.jar $(zip_root)/framework/
+	$(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
 	$(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools
 	$(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
-	$(hide) (cd $(zip_root) && zip -qry $(abspath $@) bin framework releasetools)
+	$(hide) (cd $(zip_root) && zip -qry $(abspath $@) *)
 	$(hide) zip -qry $(abspath $@) build/target/product/security/
-	$(hide) find device vendor -name \*.pk8 -o -name \*.x509.pem | xargs zip -qry $(abspath $@)>/dev/null || true
+	$(hide) find device vendor -name \*.pk8 -o -name \*.x509.pem -o -name oem.prop | xargs zip -qry $(abspath $@)>/dev/null || true
 
 .PHONY: otatools-package
 otatools-package: $(BUILT_OTATOOLS_PACKAGE)
@@ -1329,11 +1336,11 @@
 endef
 
 built_ota_tools := \
-	$(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \
-	$(call intermediates-dir-for,EXECUTABLES,applypatch_static)/applypatch_static \
-	$(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq \
-	$(call intermediates-dir-for,EXECUTABLES,sqlite3)/sqlite3 \
-	$(call intermediates-dir-for,EXECUTABLES,updater)/updater
+	$(call intermediates-dir-for,EXECUTABLES,applypatch,,,$(TARGET_PREFER_32_BIT))/applypatch \
+	$(call intermediates-dir-for,EXECUTABLES,applypatch_static,,,$(TARGET_PREFER_32_BIT))/applypatch_static \
+	$(call intermediates-dir-for,EXECUTABLES,check_prereq,,,$(TARGET_PREFER_32_BIT))/check_prereq \
+	$(call intermediates-dir-for,EXECUTABLES,sqlite3,,,$(TARGET_PREFER_32_BIT))/sqlite3 \
+	$(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater
 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools)
 
 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION)
@@ -1428,7 +1435,7 @@
 	$(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)	echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
+	$(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
 	$(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
@@ -1461,7 +1468,8 @@
 	$(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt
 endif
 	$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
-	$(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
+	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
+	    ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
 	@# Zip everything up, preserving symlinks
 	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
 	@# Run fs_config on all the system, vendor, boot ramdisk,
@@ -1471,7 +1479,8 @@
 	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
 	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
 	$(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
-	$(hide) ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
+	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
+	    ./build/tools/releasetools/add_img_to_target_files -p $(HOST_OUT) $@
 
 .PHONY: target-files-package
 target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
@@ -1500,7 +1509,7 @@
 
 $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
 	@echo "Package OTA: $@"
-	$(hide) MKBOOTIMG=$(MKBOOTIMG) \
+	$(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \
 	   ./build/tools/releasetools/ota_from_target_files -v \
 	   --block \
 	   -p $(HOST_OUT) \
@@ -1529,7 +1538,7 @@
 
 $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS)
 	@echo "Package: $@"
-	$(hide) MKBOOTIMG=$(MKBOOTIMG) \
+	$(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) $@
@@ -1604,10 +1613,10 @@
 		  unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \
 		  zip -q $@ $$dict_files $$unobfuscated_jars; \
 		else \
-		  touch $(dir $@)/dummy; \
-		  (cd $(dir $@) && zip -q $(notdir $@) dummy); \
-		  zip -qd $@ dummy; \
-		  rm $(dir $@)/dummy; \
+		  touch $(dir $@)/zipdummy; \
+		  (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \
+		  zip -qd $@ zipdummy; \
+		  rm $(dir $@)/zipdummy; \
 		fi
 
 endif # TARGET_BUILD_APPS
@@ -1777,7 +1786,7 @@
 MAIN_SDK_NAME := $(sdk_name)
 MAIN_SDK_DIR  := $(sdk_dir)
 MAIN_SDK_ZIP  := $(INTERNAL_SDK_TARGET)
-ifneq ($(filter win_sdk,$(MAKECMDGOALS)),)
+ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),)
 include $(TOPDIR)development/build/tools/windows_sdk.mk
 endif
 
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 1bd6c37..d4c9a06 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -221,7 +221,12 @@
 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: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
+$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \
+        $(TOPDIR)$(LOCAL_PATH)/%.aidl \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+        $(AIDL) \
+        $(aidl_preprocess_import)
 	$(transform-aidl-to-java)
 -include $(aidl_java_sources:%.java=%.P)
 
@@ -565,27 +570,27 @@
 ###########################################################
 ## CHECK_BUILD goals
 ###########################################################
-
-ifdef java_alternative_checked_module
-  LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
-endif
-
+my_checked_module :=
 # If nobody has defined a more specific module for the
 # checked modules, use LOCAL_BUILT_MODULE.
-ifndef LOCAL_CHECKED_MODULE
-  LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
+ifdef LOCAL_CHECKED_MODULE
+  my_checked_module := $(LOCAL_CHECKED_MODULE)
+else ifdef java_alternative_checked_module
+  my_checked_module := $(java_alternative_checked_module)
+else
+  my_checked_module := $(LOCAL_BUILT_MODULE)
 endif
 
 # If they request that this module not be checked, then don't.
 # PLEASE DON'T SET THIS.  ANY PLACES THAT SET THIS WITHOUT
 # GOOD REASON WILL HAVE IT REMOVED.
 ifdef LOCAL_DONT_CHECK_MODULE
-  LOCAL_CHECKED_MODULE :=
+  my_checked_module :=
 endif
 # Don't check build target module defined for the 2nd arch
 ifndef LOCAL_IS_HOST_MODULE
 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
-  LOCAL_CHECKED_MODULE :=
+  my_checked_module :=
 endif
 endif
 
@@ -604,7 +609,7 @@
 ALL_MODULES.$(my_register_name).TAGS := \
     $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
 ALL_MODULES.$(my_register_name).CHECKED := \
-    $(ALL_MODULES.$(my_register_name).CHECKED) $(LOCAL_CHECKED_MODULE)
+    $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module)
 ALL_MODULES.$(my_register_name).BUILT := \
     $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
@@ -685,9 +690,9 @@
 endif
 
 ifdef j_or_n
-$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
+$(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 : $(LOCAL_CHECKED_MODULE)
+$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module)
 endif
 endif
 
diff --git a/core/binary.mk b/core/binary.mk
index 1e313ff..d3d050e 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -9,73 +9,6 @@
 include $(BUILD_SYSTEM)/base_rules.mk
 #######################################
 
-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
-  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
-  ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
-    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
-  else
-    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
-  endif
-
-  # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
-  # 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 :=
-  LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
-  ifeq (,$(LOCAL_NDK_STL_VARIANT))
-    LOCAL_NDK_STL_VARIANT := system
-  endif
-  ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
-    $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
-  endif
-  ifeq (system,$(LOCAL_NDK_STL_VARIANT))
-    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
-    # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
-  else # LOCAL_NDK_STL_VARIANT is not system
-  ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
-    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
-    ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT))
-      my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_static.a
-    else
-      my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/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/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_static.a
-    else
-      my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libc++_shared.so
-      my_ndk_stl_shared_lib := -lc++_shared
-    endif
-    my_ndk_stl_cppflags := -std=c++11
-  else
-    # LOCAL_NDK_STL_VARIANT is gnustl_static
-    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/include \
-                               $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
-    my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libgnustl_static.a
-  endif
-  endif
-  endif
-endif
-
 ##################################################
 # Compute the dependency of the shared libraries
 ##################################################
@@ -105,18 +38,109 @@
 my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
 my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
 my_cflags := $(LOCAL_CFLAGS)
+my_conlyflags := $(LOCAL_CONLYFLAGS)
 my_cppflags := $(LOCAL_CPPFLAGS)
 my_ldflags := $(LOCAL_LDFLAGS)
+my_ldlibs := $(LOCAL_LDLIBS)
 my_asflags := $(LOCAL_ASFLAGS)
 my_cc := $(LOCAL_CC)
 my_cxx := $(LOCAL_CXX)
 my_c_includes := $(LOCAL_C_INCLUDES)
 my_generated_sources := $(LOCAL_GENERATED_SOURCES)
+my_native_coverage := $(LOCAL_NATIVE_COVERAGE)
+my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+
+ifdef LOCAL_IS_HOST_MODULE
+my_allow_undefined_symbols := true
+else
+my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
+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
+  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
+  ifeq (x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64
+  else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
+    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6
+  else
+    my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib
+  endif
+
+  # 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 and disabling packed relocations.
+  #ifeq ($(shell expr $(LOCAL_SDK_VERSION) >= FIRST_SUPPORTED_VERSION),0)
+    my_ldflags += -Wl,--hash-style=sysv
+    LOCAL_PACK_MODULE_RELOCATIONS := false
+  #endif
+
+  # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
+  # 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_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
+  ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT))
+    my_cpu_variant := mips32r6
+  endif
+  LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
+  ifeq (,$(LOCAL_NDK_STL_VARIANT))
+    LOCAL_NDK_STL_VARIANT := system
+  endif
+  ifneq (1,$(words $(filter system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT))))
+    $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
+  endif
+  ifeq (system,$(LOCAL_NDK_STL_VARIANT))
+    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
+    # for "system" variant, the shared library exists in the system library and -lstdc++ is added by default.
+  else # LOCAL_NDK_STL_VARIANT is not system
+  ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT)))
+    my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport
+    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
+    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
+    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
+    endif
+    my_ndk_stl_cppflags := -std=c++11
+  else
+    # LOCAL_NDK_STL_VARIANT is gnustl_static
+    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 \
+                               $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include
+    my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/libgnustl_static.a
+  endif
+  endif
+  endif
+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.
-ifeq ($(strip $(USE_MINGW)),)
+ifndef USE_MINGW
 ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
 my_cflags += -fpie
 else
@@ -133,12 +157,29 @@
 my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
 my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
 
-my_clang := $(LOCAL_CLANG)
+my_clang := $(strip $(LOCAL_CLANG))
 ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
-my_clang := $(LOCAL_CLANG_$(my_32_64_bit_suffix))
+my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
 endif
 ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
-my_clang := $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
+endif
+
+# clang is enabled by default for host builds
+# enable it unless we've specifically disabled clang above
+ifdef LOCAL_IS_HOST_MODULE
+    ifneq ($(HOST_OS),windows)
+    ifeq ($(my_clang),)
+        my_clang := true
+    endif
+    endif
+endif
+
+# Add option to make clang the default for device build
+ifeq ($(USE_CLANG_PLATFORM_BUILD),true)
+    ifeq ($(my_clang),)
+        my_clang := true
+    endif
 endif
 
 # arch-specific static libraries go first so that generic ones can depend on them
@@ -147,12 +188,7 @@
 
 my_cflags := $(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_UNSUPPORTED_CFLAGS),$(my_cflags))
 
-
-# Replace libstdc++ with libc++ if it's seen
-my_libcxx := $(filter libc++, $(my_shared_libraries))
-ifdef my_libcxx
-my_system_shared_libraries := $(filter-out libstdc++, $(my_system_shared_libraries))
-endif
+include $(BUILD_SYSTEM)/cxx_stl_setup.mk
 
 # Add static HAL libraries
 ifdef LOCAL_HAL_STATIC_LIBRARIES
@@ -163,36 +199,31 @@
 b_lib :=
 endif
 
-ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
-  my_clang := true
-  # Frame pointer based unwinder in ASan requires ARM frame setup.
-  LOCAL_ARM_MODE := arm
-  my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
-  my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
-  my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
-  my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
-endif
+include $(BUILD_SYSTEM)/config_sanitizers.mk
 
 ifeq ($(strip $($(LOCAL_2ND_ARCH_VAR_PREFIX)WITHOUT_$(my_prefix)CLANG)),true)
   my_clang :=
 endif
 
 # Add in libcompiler_rt for all regular device builds
-ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
+ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT))
   my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
 
-my_compiler_dependencies :=
-
-##################################################################
+####################################################
 ## Add FDO flags if FDO is turned on and supported
 ## Please note that we will do option filtering during FDO build.
 ## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
 ##################################################################
-ifeq ($(strip $(LOCAL_FDO_SUPPORT)), true)
-  ifeq ($(strip $(LOCAL_IS_HOST_MODULE)),)
-    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_CFLAGS)
-    my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LDFLAGS)
+my_fdo_build :=
+ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),)
+  ifeq ($(BUILD_FDO_INSTRUMENT),true)
+    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS)
+    my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS)
+    my_fdo_build := true
+  else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),)
+    my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS)
+    my_fdo_build := true
   endif
 endif
 
@@ -203,30 +234,6 @@
 my_asflags += -D__ASSEMBLY__
 
 
-##########################################################
-## Set up installed module dependency
-## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
-## they may cusomize their install path with LOCAL_MODULE_PATH
-##########################################################
-# Get the list of INSTALLED libraries as module names.
-ifdef LOCAL_SDK_VERSION
-  installed_shared_library_module_names := \
-      $(my_shared_libraries)
-else
-  installed_shared_library_module_names := \
-      $(my_system_shared_libraries) $(my_shared_libraries)
-endif
-installed_shared_library_module_names := $(sort $(installed_shared_library_module_names))
-
-# The real dependency will be added after all Android.mks are loaded and the install paths
-# of the shared libraries are determined.
-ifdef LOCAL_INSTALLED_MODULE
-ifdef installed_shared_library_module_names
-$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
-    $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
-endif
-endif
-
 ###########################################################
 ## Define PRIVATE_ variables from global vars
 ###########################################################
@@ -243,11 +250,12 @@
 
 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_c_includes += $(CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES)
 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)
 endif # my_clang
@@ -255,6 +263,7 @@
 $(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_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)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
 
@@ -262,11 +271,13 @@
 
 ifeq ($(my_clang),true)
 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CFLAGS)
+my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CONLYFLAGS)
 my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_CPPFLAGS)
 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_HOST_GLOBAL_LDFLAGS)
-my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES) $(CLANG_CONFIG_EXTRA_HOST_C_INCLUDES)
+my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
 else
 my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS)
+my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CONLYFLAGS)
 my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS)
 my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LDFLAGS)
 my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_C_INCLUDES)
@@ -274,10 +285,30 @@
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_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)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
 endif # LOCAL_IS_HOST_MODULE
 
+# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
+# build with NATIVE_COVERAGE=true in your enviornment. Note that the build
+# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a
+# clean build of your module after toggling it.
+ifeq ($(NATIVE_COVERAGE),true)
+    ifeq ($(my_native_coverage),true)
+        # Note that clang coverage doesn't play nicely with acov out of the box.
+        # Clang apparently generates .gcno files that aren't compatible with
+        # gcov-4.8.  This can be solved by installing gcc-4.6 and invoking lcov
+        # with `--gcov-tool /usr/bin/gcov-4.6`.
+        #
+        # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
+        my_cflags += --coverage -O0
+        my_ldflags += --coverage
+    endif
+else
+    my_native_coverage := false
+endif
+
 ###########################################################
 ## Define PRIVATE_ variables used by multiple module types
 ###########################################################
@@ -299,7 +330,7 @@
 endif
 
 ifeq ($(strip $(my_cc)),)
-  ifeq ($(strip $(my_clang)),true)
+  ifeq ($(my_clang),true)
     my_cc := $(CLANG)
   else
     my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
@@ -315,7 +346,7 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
 
 ifeq ($(strip $(my_cxx)),)
-  ifeq ($(strip $(my_clang)),true)
+  ifeq ($(my_clang),true)
     my_cxx := $(CLANG_CXX)
   else
     my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
@@ -341,7 +372,7 @@
 # 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 ($(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)),)
+ifeq ($(my_allow_undefined_symbols),)
   my_ldflags +=  $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS)
 endif
 endif
@@ -365,7 +396,7 @@
 # actually used (although they are usually empty).
 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 ($(strip $(my_clang)),true)
+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))
 endif
@@ -422,18 +453,20 @@
 renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
 endif
 
+bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
+    $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
+
 $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
 $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
 $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
 $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
 $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
+$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
 $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
 	$(transform-renderscripts-to-cpp-and-bc)
 
-# include the dependency files (.d) generated by llvm-rs-cc.
-renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate)/, \
-    $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
--include $(renderscript_generated_dep_files)
+# include the dependency files (.d/.P) generated by llvm-rs-cc.
+-include $(bc_dep_files:%.d=%.P)
 
 LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
 
@@ -509,9 +542,17 @@
 my_c_includes += external/protobuf/src $(proto_generated_cc_sources_dir)
 my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
-my_static_libraries += libprotobuf-cpp-2.3.0-full
+    ifdef LOCAL_SDK_VERSION
+        my_static_libraries += libprotobuf-cpp-full
+    else
+        my_shared_libraries += libprotobuf-cpp-full
+    endif
 else
-my_static_libraries += libprotobuf-cpp-2.3.0-lite
+    ifdef LOCAL_SDK_VERSION
+        my_static_libraries += libprotobuf-cpp-lite
+    else
+        my_shared_libraries += libprotobuf-cpp-lite
+    endif
 endif
 endif  # $(proto_sources) non-empty
 
@@ -535,7 +576,7 @@
 ifneq ($(strip $(y_yacc_cpps)),)
 $(y_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
     $(TOPDIR)$(LOCAL_PATH)/%.y \
-    $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+    $(lex_cpps) $(my_additional_dependencies)
 	$(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
 $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
 endif
@@ -543,7 +584,7 @@
 ifneq ($(strip $(yy_yacc_cpps)),)
 $(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
     $(TOPDIR)$(LOCAL_PATH)/%.yy \
-    $(lex_cpps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+    $(lex_cpps) $(my_additional_dependencies)
 	$(call transform-y-to-cpp,$(PRIVATE_CPP_EXTENSION))
 $(yacc_headers): $(intermediates)/%.h: $(intermediates)/%$(LOCAL_CPP_EXTENSION)
 endif
@@ -587,7 +628,7 @@
 $(lex_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
 $(lex_objects): $(intermediates)/%.o: \
     $(intermediates)/%$(LOCAL_CPP_EXTENSION) \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+    $(my_additional_dependencies) \
     $(yacc_headers)
 	$(transform-$(PRIVATE_HOST)cpp-to-o)
 endif
@@ -598,16 +639,33 @@
 
 # we also do this on host modules, even though
 # it's not really arm, because there are files that are shared.
-cpp_arm_sources    := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
-cpp_arm_objects    := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
+cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)))
+dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources))
+cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources))
+cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o))
 
-cpp_normal_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))
+# For source files starting with ../, we remove all the ../ in the object file path,
+# to avoid object file escaping the intermediate directory.
+dotdot_arm_objects :=
+$(foreach s,$(dotdot_arm_sources),\
+  $(eval $(call compile-dotdot-cpp-file,$(s),\
+  $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
+  dotdot_arm_objects)))
+
+dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
+dotdot_objects :=
+$(foreach s,$(dotdot_sources),\
+  $(eval $(call compile-dotdot-cpp-file,$(s),\
+    $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
+    dotdot_objects)))
+
+cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
 cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
 
-$(cpp_arm_objects):    PRIVATE_ARM_MODE := $(arm_objects_mode)
-$(cpp_arm_objects):    PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
-$(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
-$(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
+$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
+$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
 
 cpp_objects        := $(cpp_arm_objects) $(cpp_normal_objects)
 
@@ -615,12 +673,13 @@
 $(cpp_objects): $(intermediates)/%.o: \
     $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
     $(yacc_cpps) $(proto_generated_headers) \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)cpp-to-o)
 -include $(cpp_objects:%.o=%.P)
 endif
 
+cpp_objects += $(dotdot_arm_objects) $(dotdot_objects)
+
 ###########################################################
 ## C++: Compile generated .cpp files to .o.
 ###########################################################
@@ -636,8 +695,7 @@
 $(gen_cpp_objects): $(intermediates)/%.o: \
     $(intermediates)/%$(LOCAL_CPP_EXTENSION) $(yacc_cpps) \
     $(proto_generated_headers) \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)cpp-to-o)
 -include $(gen_cpp_objects:%.o=%.P)
 endif
@@ -651,8 +709,7 @@
 
 ifneq ($(strip $(gen_S_sources)),)
 $(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)s-to-o)
 -include $(gen_S_objects:%.o=%.P)
 endif
@@ -662,8 +719,7 @@
 
 ifneq ($(strip $(gen_s_objects)),)
 $(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
 -include $(gen_s_objects:%.o=%.P)
 endif
@@ -680,27 +736,45 @@
 ## C: Compile .c files to .o.
 ###########################################################
 
-c_arm_sources    := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
-c_arm_objects    := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
+c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files)))
+dotdot_arm_sources := $(filter ../%,$(c_arm_sources))
+c_arm_sources := $(filter-out ../%,$(c_arm_sources))
+c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o))
 
-c_normal_sources := $(filter %.c,$(my_src_files))
+# For source files starting with ../, we remove all the ../ in the object file path,
+# to avoid object file escaping the intermediate directory.
+dotdot_arm_objects :=
+$(foreach s,$(dotdot_arm_sources),\
+  $(eval $(call compile-dotdot-c-file,$(s),\
+    $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
+    dotdot_arm_objects)))
+
+dotdot_sources := $(filter ../%.c, $(my_src_files))
+dotdot_objects :=
+$(foreach s, $(dotdot_sources),\
+  $(eval $(call compile-dotdot-c-file,$(s),\
+    $(yacc_cpps) $(proto_generated_headers) $(my_additional_dependencies),\
+    dotdot_objects)))
+
+c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
 c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
 
-$(c_arm_objects):    PRIVATE_ARM_MODE := $(arm_objects_mode)
-$(c_arm_objects):    PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
-$(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
-$(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
+$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode)
+$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags)
+$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
+$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
 
 c_objects        := $(c_arm_objects) $(c_normal_objects)
 
 ifneq ($(strip $(c_objects)),)
 $(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c $(yacc_cpps) $(proto_generated_headers) \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)c-to-o)
 -include $(c_objects:%.o=%.P)
 endif
 
+c_objects += $(dotdot_arm_objects) $(dotdot_objects)
+
 ###########################################################
 ## C: Compile generated .c files to .o.
 ###########################################################
@@ -714,8 +788,7 @@
 $(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
 $(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
 $(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c $(yacc_cpps) $(proto_generated_headers) \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)c-to-o)
 -include $(gen_c_objects:%.o=%.P)
 endif
@@ -729,8 +802,7 @@
 
 ifneq ($(strip $(objc_objects)),)
 $(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m $(yacc_cpps) $(proto_generated_headers) \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)m-to-o)
 -include $(objc_objects:%.o=%.P)
 endif
@@ -740,43 +812,79 @@
 ###########################################################
 
 asm_sources_S := $(filter %.S,$(my_src_files))
+dotdot_sources := $(filter ../%,$(asm_sources_S))
+asm_sources_S := $(filter-out ../%,$(asm_sources_S))
 asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
 
+dotdot_objects_S :=
+$(foreach s,$(dotdot_sources),\
+  $(eval $(call compile-dotdot-s-file,$(s),\
+    $(my_additional_dependencies),\
+    dotdot_objects_S)))
+
 ifneq ($(strip $(asm_objects_S)),)
 $(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)s-to-o)
 -include $(asm_objects_S:%.o=%.P)
 endif
 
 asm_sources_s := $(filter %.s,$(my_src_files))
+dotdot_sources := $(filter ../%,$(asm_sources_s))
+asm_sources_s := $(filter-out ../%,$(asm_sources_s))
 asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
 
+dotdot_objects_s :=
+$(foreach s,$(dotdot_sources),\
+  $(eval $(call compile-dotdot-s-file-no-deps,$(s),\
+    $(my_additional_dependencies),\
+    dotdot_objects_s)))
+
 ifneq ($(strip $(asm_objects_s)),)
 $(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-    | $(my_compiler_dependencies)
+    $(my_additional_dependencies)
 	$(transform-$(PRIVATE_HOST)s-to-o-no-deps)
--include $(asm_objects_s:%.o=%.P)
 endif
 
-asm_objects := $(asm_objects_S) $(asm_objects_s)
+asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
 
 
-# .asm for x86 needs to be compiled with yasm.
-ifeq (x86,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+# .asm for x86/x86_64 needs to be compiled with yasm.
 asm_sources_asm := $(filter %.asm,$(my_src_files))
 ifneq ($(strip $(asm_sources_asm)),)
 asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
 $(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
-    $(LOCAL_ADDITIONAL_DEPENDENCIES)
+    $(my_additional_dependencies)
 	$(transform-asm-to-o)
 
 asm_objects += $(asm_objects_asm)
 endif
+
+
+##########################################################
+## Set up installed module dependency
+## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
+## they may cusomize their install path with LOCAL_MODULE_PATH
+##########################################################
+# Get the list of INSTALLED libraries as module names.
+ifdef LOCAL_SDK_VERSION
+  installed_shared_library_module_names := \
+      $(my_shared_libraries)
+else
+  installed_shared_library_module_names := \
+      $(my_shared_libraries) $(my_system_shared_libraries)
 endif
 
+# The real dependency will be added after all Android.mks are loaded and the install paths
+# of the shared libraries are determined.
+ifdef LOCAL_INSTALLED_MODULE
+ifdef installed_shared_library_module_names
+$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
+    $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names)))
+endif
+endif
+
+
 ####################################################
 ## Import includes
 ####################################################
@@ -786,11 +894,12 @@
       $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/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))/export_includes))
-$(import_includes) : $(import_includes_deps)
+$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
+$(import_includes) : $(LOCAL_MODULE_MAKEFILE) $(import_includes_deps)
 	@echo Import includes file: $@
 	$(hide) mkdir -p $(dir $@) && rm -f $@
 ifdef import_includes_deps
-	$(hide) for f in $^; do \
+	$(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \
 	  cat $$f >> $@; \
 	done
 else
@@ -919,30 +1028,31 @@
 ###########################################################
 
 ifeq ($(my_clang),true)
+my_cflags += $(LOCAL_CLANG_CFLAGS)
+my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
+my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
+my_asflags += $(LOCAL_CLANG_ASFLAGS)
+my_ldflags += $(LOCAL_CLANG_LDFLAGS)
+my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
+my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix))
+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))
 endif
 
-ifeq ($(LOCAL_FDO_SUPPORT), true)
-  build_with_fdo := false
-  ifeq ($(BUILD_FDO_INSTRUMENT), true)
-    build_with_fdo := true
-  endif
-  ifeq ($(BUILD_FDO_OPTIMIZE), true)
-    build_with_fdo := true
-  endif
-  ifeq ($(build_with_fdo), true)
-    my_cflags := $(patsubst -Os,-O2,$(my_cflags))
-    fdo_incompatible_flags=-fno-early-inlining -finline-limit=%
-    my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
-  endif
+ifeq ($(my_fdo_build), true)
+  my_cflags := $(patsubst -Os,-O2,$(my_cflags))
+  fdo_incompatible_flags := -fno-early-inlining -finline-limit=%
+  my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags))
 endif
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(LOCAL_CONLYFLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
@@ -950,9 +1060,8 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_CRT := $(strip $(LOCAL_NO_CRT) $(LOCAL_NO_CRT_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LIBCXX := $(my_libcxx)
 
 # this is really the way to get the files onto the command line instead
 # of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
diff --git a/core/build_id.mk b/core/build_id.mk
index f39329b..f94b224 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -18,4 +18,6 @@
 # (like "CRB01").  It must be a single word, and is
 # capitalized by convention.
 
-export BUILD_ID=LKY80
+BUILD_ID := AOSP
+
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/clang/HOST_x86.mk b/core/clang/HOST_x86.mk
index 510a74d..f14a9c3 100644
--- a/core/clang/HOST_x86.mk
+++ b/core/clang/HOST_x86.mk
@@ -11,6 +11,10 @@
 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
 ifeq ($(HOST_OS),windows)
 CLANG_CONFIG_x86_HOST_TRIPLE := i686-pc-mingw32
@@ -30,6 +34,12 @@
   $(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) \
@@ -55,6 +65,10 @@
   $(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)
@@ -62,3 +76,5 @@
 $(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 6b94525..1211e73 100644
--- a/core/clang/HOST_x86_64.mk
+++ b/core/clang/HOST_x86_64.mk
@@ -11,6 +11,10 @@
 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
 ifeq ($(HOST_OS),windows)
 CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-pc-mingw64
@@ -30,6 +34,12 @@
   $(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) \
@@ -55,6 +65,10 @@
   $(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)
@@ -62,3 +76,5 @@
 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
index 0241cb6..74b5a69 100644
--- a/core/clang/HOST_x86_common.mk
+++ b/core/clang/HOST_x86_common.mk
@@ -1,53 +1,51 @@
 # Shared by HOST_x86.mk and HOST_x86_64.mk.
 
 ifeq ($(HOST_OS),darwin)
-# nothing required here yet
+CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS := \
+  -integrated-as
+
+CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS := \
+  -integrated-as
 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 \
-  -no-integrated-as
+  --sysroot=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot
 
 CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS := \
-  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \
-  -no-integrated-as
+  --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)
 
 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.6 \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/x86_64-linux \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/backward \
-  -no-integrated-as
+  -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.6 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.6 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib64/ \
-  -no-integrated-as
+  -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.6 \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/x86_64-linux/32 \
-  -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.6/backward \
-  -no-integrated-as
+  -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.6/32 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.6/32 \
-  -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib32/ \
-  -no-integrated-as
+  -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 59ed41f..6f6d624 100644
--- a/core/clang/TARGET_arm.mk
+++ b/core/clang/TARGET_arm.mk
@@ -19,6 +19,11 @@
   -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) \
@@ -44,6 +49,10 @@
   $(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)
@@ -54,4 +63,6 @@
 
 $(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi
 $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS :=
-RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi
+$(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
diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk
index 6f9e540..b67d458 100644
--- a/core/clang/TARGET_arm64.mk
+++ b/core/clang/TARGET_arm64.mk
@@ -18,6 +18,11 @@
   $(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) \
@@ -42,6 +47,10 @@
   $(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)
@@ -53,3 +62,5 @@
 RS_TRIPLE := aarch64-linux-android
 RS_TRIPLE_CFLAGS :=
 RS_COMPAT_TRIPLE := aarch64-linux-android
+
+TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a
diff --git a/core/clang/TARGET_mips.mk b/core/clang/TARGET_mips.mk
index 91067f5..19bbaf2 100644
--- a/core/clang/TARGET_mips.mk
+++ b/core/clang/TARGET_mips.mk
@@ -9,6 +9,7 @@
   $(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)
 
@@ -18,6 +19,11 @@
   $(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) \
@@ -42,6 +48,10 @@
   $(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)
@@ -53,3 +63,5 @@
 $(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi
 $(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
diff --git a/core/clang/TARGET_mips64.mk b/core/clang/TARGET_mips64.mk
index ab69aed..104fb70 100644
--- a/core/clang/TARGET_mips64.mk
+++ b/core/clang/TARGET_mips64.mk
@@ -18,6 +18,11 @@
   $(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) \
@@ -42,6 +47,10 @@
   $(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)
@@ -53,3 +62,5 @@
 RS_TRIPLE := aarch64-linux-android
 RS_TRIPLE_CFLAGS :=
 RS_COMPAT_TRIPLE := mips64el-linux-android
+
+TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mips64el-android.a
diff --git a/core/clang/TARGET_x86.mk b/core/clang/TARGET_x86.mk
index 60ee06f..4e9e8be 100644
--- a/core/clang/TARGET_x86.mk
+++ b/core/clang/TARGET_x86.mk
@@ -18,7 +18,20 @@
   $(CLANG_CONFIG_EXTRA_CFLAGS) \
   $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \
   $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \
-  $(CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS)
+  $(CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS) \
+  -fno-optimize-sibling-calls \
+  -mstackrealign
+
+# http://llvm.org/bugs/show_bug.cgi?id=15086,
+# llvm tail call optimization is wrong for x86.
+# -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) \
@@ -44,6 +57,10 @@
   $(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)
@@ -54,4 +71,6 @@
 
 $(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi
 $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := -D__i386__
-RS_COMPAT_TRIPLE := i686-linux-android
+$(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
diff --git a/core/clang/TARGET_x86_64.mk b/core/clang/TARGET_x86_64.mk
index 5561e42..e44382d 100644
--- a/core/clang/TARGET_x86_64.mk
+++ b/core/clang/TARGET_x86_64.mk
@@ -18,6 +18,11 @@
   $(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) \
@@ -42,6 +47,10 @@
   $(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)
@@ -53,3 +62,5 @@
 RS_TRIPLE := aarch64-linux-android
 RS_TRIPLE_CFLAGS := -D__x86_64__
 RS_COMPAT_TRIPLE := x86_64-linux-android
+
+TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64-android.a
diff --git a/core/clang/arm.mk b/core/clang/arm.mk
index 22c7397..bf31f51 100644
--- a/core/clang/arm.mk
+++ b/core/clang/arm.mk
@@ -1,16 +1,23 @@
 # Clang flags for arm arch, target or host.
 
-CLANG_CONFIG_arm_EXTRA_ASFLAGS := \
-  -no-integrated-as
+CLANG_CONFIG_arm_EXTRA_ASFLAGS :=
 
-CLANG_CONFIG_arm_EXTRA_CFLAGS := \
-  -no-integrated-as
+CLANG_CONFIG_arm_EXTRA_CFLAGS :=
 
-CLANG_CONFIG_arm_EXTRA_CPPFLAGS := \
-  -no-integrated-as
+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
+endif
 
-CLANG_CONFIG_arm_EXTRA_LDFLAGS := \
-  -no-integrated-as
+ifeq ($(HOST_OS),darwin)
+  # Darwin is really bad at dealing with idiv/sdiv. Don't use krait on Darwin.
+  CLANG_CONFIG_arm_EXTRA_CFLAGS += -mcpu=cortex-a9
+endif
+
+CLANG_CONFIG_arm_EXTRA_CPPFLAGS :=
+
+CLANG_CONFIG_arm_EXTRA_LDFLAGS :=
 
 # Include common unknown flags
 CLANG_CONFIG_arm_UNKNOWN_CFLAGS := \
@@ -19,14 +26,19 @@
   -fgcse-after-reload \
   -frerun-cse-after-loop \
   -frename-registers \
-  -fno-builtin-sin \
-  -fno-strict-volatile-bitfields \
   -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 \
   -Wa,--noexecstack
 
 define subst-clang-incompatible-arm-flags
   $(subst -march=armv5te,-march=armv5t,\
   $(subst -march=armv5e,-march=armv5,\
-  $(subst -mcpu=cortex-a15,-march=armv7-a,\
-  $(1))))
+  $(1)))
 endef
diff --git a/core/clang/arm64.mk b/core/clang/arm64.mk
index 9fb3670..ab395b3 100644
--- a/core/clang/arm64.mk
+++ b/core/clang/arm64.mk
@@ -1,10 +1,8 @@
 # Clang flags for arm64 arch, target or host.
 
-CLANG_CONFIG_arm64_EXTRA_ASFLAGS := \
-  -no-integrated-as
+CLANG_CONFIG_arm64_EXTRA_ASFLAGS :=
 
-CLANG_CONFIG_arm64_EXTRA_CFLAGS := \
-  -no-integrated-as
+CLANG_CONFIG_arm64_EXTRA_CFLAGS :=
 
 CLANG_CONFIG_arm64_EXTRA_LDFLAGS :=
 
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 2a2ce94..24c06b6 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -6,8 +6,9 @@
 WITHOUT_HOST_CLANG := true
 endif
 
-LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/bin
-LLVM_PREBUILTS_HEADER_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/3.5/lib/clang/3.5/include/
+LLVM_PREBUILTS_VERSION := 3.6
+LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/$(LLVM_PREBUILTS_VERSION)/bin
+LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/
 
 CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX)
 CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX)
@@ -32,6 +33,7 @@
 # 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 :=
 
@@ -42,17 +44,47 @@
 CLANG_CONFIG_EXTRA_CFLAGS += \
   -Werror=int-conversion
 
+# Disable overly aggressive warning for macros defined with a leading underscore
+# This happens in AndroidConfig.h, which is included nearly everywhere.
+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
+
 CLANG_CONFIG_UNKNOWN_CFLAGS := \
-  -funswitch-loops \
-  -fno-tree-sra \
+  -finline-functions \
   -finline-limit=64 \
-  -Wno-psabi \
-  -Wno-unused-but-set-variable \
-  -Wno-unused-but-set-parameter \
+  -fno-canonical-system-headers \
+  -fno-tree-sra \
+  -fprefetch-loop-arrays \
+  -funswitch-loops \
   -Wmaybe-uninitialized \
-  -Wno-maybe-uninitialized \
   -Wno-error=maybe-uninitialized \
-  -fno-canonical-system-headers
+  -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
 
 # Clang flags for all host rules
 CLANG_CONFIG_HOST_EXTRA_ASFLAGS :=
@@ -66,6 +98,32 @@
 CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc
 CLANG_CONFIG_TARGET_EXTRA_LDFLAGS :=
 
+CLANG_DEFAULT_UB_CHECKS := \
+  bool \
+  integer-divide-by-zero \
+  return \
+  returns-nonnull-attribute \
+  shift-exponent \
+  unreachable \
+  vla-bound \
+
+# TODO(danalbert): The following checks currently have compiler performance
+# issues.
+# CLANG_DEFAULT_UB_CHECKS += alignment
+# CLANG_DEFAULT_UB_CHECKS += bounds
+# CLANG_DEFAULT_UB_CHECKS += enum
+# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
+# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
+# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
+# CLANG_DEFAULT_UB_CHECKS += null
+# CLANG_DEFAULT_UB_CHECKS += shift-base
+# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
+
+# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
+# https://llvm.org/PR19302
+# http://reviews.llvm.org/D6974
+# CLANG_DEFAULT_UB_CHECKS += object-size
+
 # HOST config
 clang_2nd_arch_prefix :=
 include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
@@ -86,15 +144,11 @@
 include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
 endif
 
-
-# Clang compiler-specific libc headers
-CLANG_CONFIG_EXTRA_HOST_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH)
-CLANG_CONFIG_EXTRA_TARGET_C_INCLUDES := $(LLVM_PREBUILTS_HEADER_PATH) $(TARGET_OUT_HEADERS)/clang
-
 # Address sanitizer clang config
 ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android
-ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer
+ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
 ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
+
 ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY)
 ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
 
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index d5a5f03..4f5ac28 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -20,6 +20,7 @@
 LOCAL_MODULE_CLASS:=
 LOCAL_MODULE_SUFFIX:=
 LOCAL_PACKAGE_NAME:=
+LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES:=
 LOCAL_OVERRIDES_PACKAGES:=
 LOCAL_EXPORT_PACKAGE_RESOURCES:=
 LOCAL_MANIFEST_PACKAGE_NAME:=
@@ -47,11 +48,16 @@
 LOCAL_ASFLAGS:=
 LOCAL_CFLAGS:=
 LOCAL_CPPFLAGS:=
+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:=
@@ -86,8 +92,8 @@
 LOCAL_COPY_HEADERS:=
 LOCAL_FORCE_STATIC_EXECUTABLE:=
 LOCAL_ADDITIONAL_DEPENDENCIES:=
-LOCAL_COMPRESS_MODULE_SYMBOLS:=
 LOCAL_STRIP_MODULE:=
+LOCAL_PACK_MODULE_RELOCATIONS:=
 LOCAL_JNI_SHARED_LIBRARIES:=
 LOCAL_JNI_SHARED_LIBRARIES_ABI:=
 LOCAL_PREBUILT_JNI_LIBS:=
@@ -145,8 +151,10 @@
 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_DIST_BUNDLED_BINARIES:=
 LOCAL_HAL_STATIC_LIBRARIES:=
@@ -160,17 +168,25 @@
 LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
 LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
 LOCAL_MODULE_HOST_ARCH:=
+LOCAL_NO_FPIE :=
+LOCAL_CXX_STL := default
+LOCAL_NATIVE_COVERAGE :=
 LOCAL_DPI_VARIANTS:=
 LOCAL_DPI_FILE_STEM:=
+LOCAL_SANITIZE:=
 
 # arch specific variables
 LOCAL_SRC_FILES_$(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_CLANG_ASFLAGS_$(TARGET_ARCH):=
 LOCAL_NO_CRT_$(TARGET_ARCH):=
 LOCAL_LDFLAGS_$(TARGET_ARCH):=
+LOCAL_CLANG_LDFLAGS_$(TARGET_ARCH):=
 LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):=
 LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):=
 LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_ARCH):=
@@ -181,11 +197,15 @@
 ifdef TARGET_2ND_ARCH
 LOCAL_SRC_FILES_$(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_CLANG_ASFLAGS_$(TARGET_2ND_ARCH):=
 LOCAL_NO_CRT_$(TARGET_2ND_ARCH):=
 LOCAL_LDFLAGS_$(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):=
@@ -196,11 +216,15 @@
 endif
 LOCAL_SRC_FILES_$(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_CLANG_ASFLAGS_$(HOST_ARCH):=
 LOCAL_NO_CRT_$(HOST_ARCH):=
 LOCAL_LDFLAGS_$(HOST_ARCH):=
+LOCAL_CLANG_LDFLAGS_$(HOST_ARCH):=
 LOCAL_SHARED_LIBRARIES_$(HOST_ARCH):=
 LOCAL_STATIC_LIBRARIES_$(HOST_ARCH):=
 LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_ARCH):=
@@ -210,11 +234,15 @@
 ifdef HOST_2ND_ARCH
 LOCAL_SRC_FILES_$(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_CLANG_ASFLAGS_$(HOST_2ND_ARCH):=
 LOCAL_NO_CRT_$(HOST_2ND_ARCH):=
 LOCAL_LDFLAGS_$(HOST_2ND_ARCH):=
+LOCAL_CLANG_LDFLAGS_$(HOST_2ND_ARCH):=
 LOCAL_SHARED_LIBRARIES_$(HOST_2ND_ARCH):=
 LOCAL_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
 LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
@@ -241,6 +269,14 @@
 LOCAL_LDFLAGS_64:=
 LOCAL_ASFLAGS_32:=
 LOCAL_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_MODULE_PATH_32:=
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index ec37993..8389bb8 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -33,19 +33,8 @@
 
 $(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)
-# Don't do anything if the toolchain is not there
-ifneq (,$(strip $(wildcard $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc)))
 $(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++
-ifneq ($(filter 10.8 10.9, $(mac_sdk_version)),)
-# Mac SDK 10.8+ no longer has stdarg.h, etc
-host_toolchain_header := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header)
-endif
-else
-$(combo_2nd_arch_prefix)HOST_CC := gcc
-$(combo_2nd_arch_prefix)HOST_CXX := g++
-endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists
 
 # gcc location for clang; to be updated when clang is updated
 # HOST_TOOLCHAIN_ROOT is a Darwin-specific define
@@ -54,6 +43,7 @@
 $(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
@@ -66,12 +56,6 @@
 $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += \
     -include $(call select-android-config-h,darwin-x86)
 
-ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
-       $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := false
-else
-       $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := true
-       PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
-endif
 $(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs
 
 ############################################################
@@ -101,7 +85,7 @@
 $(hide) $(PRIVATE_CXX) \
         -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
         -o $@ \
-        $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -Wl,-headerpad_max_install_names \
+        -Wl,-headerpad_max_install_names \
         $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
         $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
            $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
diff --git a/core/combo/HOST_darwin-x86_64.mk b/core/combo/HOST_darwin-x86_64.mk
index a776a69..0efa78f 100644
--- a/core/combo/HOST_darwin-x86_64.mk
+++ b/core/combo/HOST_darwin-x86_64.mk
@@ -33,19 +33,8 @@
 
 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)
-# Don't do anything if the toolchain is not there
-ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)-gcc)))
 HOST_CC  := $(HOST_TOOLCHAIN_PREFIX)-gcc
 HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++
-ifneq ($(filter 10.8 10.9, $(mac_sdk_version)),)
-# Mac SDK 10.8+ no longer has stdarg.h, etc
-host_toolchain_header := $(HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include
-HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header)
-endif
-else
-HOST_CC := gcc
-HOST_CXX := g++
-endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists
 
 # gcc location for clang; to be updated when clang is updated
 # HOST_TOOLCHAIN_ROOT is a Darwin-specific define
@@ -54,6 +43,7 @@
 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
@@ -65,11 +55,6 @@
 HOST_GLOBAL_CFLAGS += \
     -include $(call select-android-config-h,darwin-x86)
 
-ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
-       HOST_RUN_RANLIB_AFTER_COPYING := false
-else
-       HOST_RUN_RANLIB_AFTER_COPYING := true
-endif
 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 3ca7443..8eda6c0 100644
--- a/core/combo/HOST_linux-x86.mk
+++ b/core/combo/HOST_linux-x86.mk
@@ -18,21 +18,18 @@
 # 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.11-4.6/bin/x86_64-linux-
+$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
 endif
-# Don't do anything if the toolchain is not there
-ifneq (,$(strip $(wildcard $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc)))
 $(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
-endif # $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc exists
 
 # 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.11-4.6/
+$(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 += -mstackrealign -msse3 -mfpmath=sse -m32 -Wa,--noexecstack -march=prescott
-$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 -Wl,-z,noexecstack
+$(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
 
 ifneq ($(strip $(BUILD_HOST_static)),)
 # Statically-linked binaries are desirable for sandboxed environment
@@ -43,8 +40,8 @@
   -no-canonical-prefixes \
   -include $(call select-android-config-h,linux-x86)
 
-# Disable new longjmp in glibc 2.11 and later. See bug 2967937.
-$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+# TODO: Set _FORTIFY_SOURCE=2. Bug 20558757.
+$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fstack-protector
 
 # Workaround differences in inttypes.h between host and target.
 # See bug 12708004.
@@ -52,7 +49,6 @@
 
 $(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 53a3ae8..e268e41 100644
--- a/core/combo/HOST_linux-x86_64.mk
+++ b/core/combo/HOST_linux-x86_64.mk
@@ -18,20 +18,17 @@
 # Included by combo/select.mk
 
 ifeq ($(strip $(HOST_TOOLCHAIN_PREFIX)),)
-HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-
+HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
 endif
-# Don't do anything if the toolchain is not there
-ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)gcc)))
 HOST_CC  := $(HOST_TOOLCHAIN_PREFIX)gcc
 HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)g++
 HOST_AR  := $(HOST_TOOLCHAIN_PREFIX)ar
-endif # $(HOST_TOOLCHAIN_PREFIX)gcc exists
 
 # gcc location for clang; to be updated when clang is updated
-HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/
+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
+HOST_GLOBAL_LDFLAGS += -m64 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
 
 ifneq ($(strip $(BUILD_HOST_static)),)
 # Statically-linked binaries are desirable for sandboxed environment
@@ -43,8 +40,8 @@
   -no-canonical-prefixes \
   -include $(call select-android-config-h,linux-x86)
 
-# Disable new longjmp in glibc 2.11 and later. See bug 2967937.
-HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+# TODO: Set _FORTIFY_SOURCE=2. Bug 20558757.
+HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -fstack-protector
 
 # Workaround differences in inttypes.h between host and target.
 # See bug 12708004.
diff --git a/core/combo/HOST_windows-x86.mk b/core/combo/HOST_windows-x86.mk
index 00e1974..b71ac16 100644
--- a/core/combo/HOST_windows-x86.mk
+++ b/core/combo/HOST_windows-x86.mk
@@ -24,7 +24,7 @@
 
 # Settings to use MinGW has a cross-compiler under Linux
 ifneq ($(findstring Linux,$(UNAME)),)
-ifneq ($(strip $(USE_MINGW)),)
+ifdef USE_MINGW
 HOST_ACP_UNAVAILABLE := true
 TOOLS_EXE_SUFFIX :=
 $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN
diff --git a/core/combo/HOST_windows-x86_64.mk b/core/combo/HOST_windows-x86_64.mk
index c77d82c..bd392ea 100644
--- a/core/combo/HOST_windows-x86_64.mk
+++ b/core/combo/HOST_windows-x86_64.mk
@@ -24,7 +24,7 @@
 
 # Settings to use MinGW has a cross-compiler under Linux
 ifneq ($(findstring Linux,$(UNAME)),)
-ifneq ($(strip $(USE_MINGW)),)
+ifdef USE_MINGW
 HOST_ACP_UNAVAILABLE := true
 TOOLS_EXE_SUFFIX :=
 HOST_GLOBAL_CFLAGS += -DUSE_MINGW
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index df81cd5..3651c39 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -35,10 +35,10 @@
 endif
 
 # Decouple NDK library selection with platform compiler version
-$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8
+$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9
 
 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.8
+$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9
 else
 $(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
 endif
@@ -114,7 +114,7 @@
 # "-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, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
+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
@@ -133,9 +133,11 @@
 			-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 \
 			$(arch_variant_ldflags)
 
 $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork
@@ -153,7 +155,6 @@
 
 libc_root := bionic/libc
 libm_root := bionic/libm
-libstdc++_root := bionic/libstdc++
 
 
 ## on some hosts, the target cross-compiler is not available so do not run this command
@@ -165,6 +166,8 @@
         $($(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
@@ -174,7 +177,6 @@
 $(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
 	$(libc_root)/arch-arm/include \
 	$(libc_root)/include \
-	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
 	$(libm_root)/include/arm \
@@ -186,81 +188,8 @@
 $(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_STRIP_MODULE:=true
+$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
 
-$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
+$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
 
-$(combo_2nd_arch_prefix)TARGET_CUSTOM_LD_COMMAND := true
-
-define $(combo_2nd_arch_prefix)transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	-nostdlib -Wl,-soname,$(notdir $@) \
-	-Wl,--gc-sections \
-	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define $(combo_2nd_arch_prefix)transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \
-	-Wl,-dynamic-linker,/system/bin/linker \
-	-Wl,--gc-sections \
-	-Wl,-z,nocopyreloc \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define $(combo_2nd_arch_prefix)transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
-	-Wl,--gc-sections \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(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)) \
-	-Wl,--no-whole-archive \
-	$(call normalize-target-libraries,$(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))) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	-Wl,--end-group \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
-endef
+$(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 07d3984..0819d13 100644
--- a/core/combo/TARGET_linux-arm64.mk
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -91,6 +91,7 @@
 TARGET_GLOBAL_CFLAGS += \
     -Werror=pointer-to-int-cast \
     -Werror=int-to-pointer-cast \
+    -Werror=implicit-function-declaration \
 
 TARGET_GLOBAL_CFLAGS += -fno-strict-volatile-bitfields
 
@@ -108,11 +109,16 @@
 			-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 \
 			$(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
@@ -126,12 +132,13 @@
 
 libc_root := bionic/libc
 libm_root := bionic/libm
-libstdc++_root := bionic/libstdc++
 
 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_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
@@ -140,7 +147,6 @@
 TARGET_C_INCLUDES := \
 	$(libc_root)/arch-arm64/include \
 	$(libc_root)/include \
-	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
 	$(libm_root)/include/arm64 \
@@ -152,81 +158,8 @@
 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
 TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
 
-TARGET_STRIP_MODULE:=true
+TARGET_PACK_MODULE_RELOCATIONS := true
 
-TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
+TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
 
-TARGET_CUSTOM_LD_COMMAND := true
-
-define transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	-nostdlib -Wl,-soname,$(notdir $@) \
-	-Wl,--gc-sections \
-	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \
-	-Wl,-dynamic-linker,/system/bin/linker64 \
-	-Wl,--gc-sections \
-	-Wl,-z,nocopyreloc \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
-	-Wl,--gc-sections \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(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)) \
-	-Wl,--no-whole-archive \
-	$(call normalize-target-libraries,$(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))) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	-Wl,--end-group \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
-endef
+TARGET_LINKER := /system/bin/linker64
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index 995e63c..29e49fb 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -35,7 +35,7 @@
 endif
 
 # Decouple NDK library selection with platform compiler version
-$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.8
+$(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
@@ -104,10 +104,14 @@
 			-Wl,-z,noexecstack \
 			-Wl,-z,relro \
 			-Wl,-z,now \
+			-Wl,--build-id=md5 \
 			-Wl,--warn-shared-textrel \
 			-Wl,--fatal-warnings \
 			$(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
@@ -121,7 +125,6 @@
 
 libc_root := bionic/libc
 libm_root := bionic/libm
-libstdc++_root := bionic/libstdc++
 
 
 ## on some hosts, the target cross-compiler is not available so do not run this command
@@ -137,6 +140,8 @@
 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
@@ -146,7 +151,6 @@
 $(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
 	$(libc_root)/arch-mips/include \
 	$(libc_root)/include \
-	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
 	$(libm_root)/include/mips \
@@ -158,81 +162,8 @@
 $(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_STRIP_MODULE:=true
+$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
 
-$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
+$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
 
-$(combo_2nd_arch_prefix)TARGET_CUSTOM_LD_COMMAND := true
-
-define $(combo_2nd_arch_prefix)transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	-nostdlib -Wl,-soname,$(notdir $@) \
-	-Wl,--gc-sections \
-	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define $(combo_2nd_arch_prefix)transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \
-	-Wl,-dynamic-linker,/system/bin/linker \
-	-Wl,--gc-sections \
-	-Wl,-z,nocopyreloc \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define $(combo_2nd_arch_prefix)transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
-	-Wl,--gc-sections \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(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)) \
-	-Wl,--no-whole-archive \
-	$(call normalize-target-libraries,$(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))) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	-Wl,--end-group \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
-endef
+$(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 4511b47..b34b7a6 100644
--- a/core/combo/TARGET_linux-mips64.mk
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -18,7 +18,7 @@
 # Included by combo/select.mk
 
 # You can set TARGET_ARCH_VARIANT to use an arch version other
-# than mips64. Each value should correspond to a file named
+# than mips64r6. Each value should correspond to a file named
 # $(BUILD_COMBOS)/arch/<name>.mk which must contain
 # makefile variable definitions similar to the preprocessor
 # defines in build/core/combo/include/arch/<combo>/AndroidConfig.h. Their
@@ -35,7 +35,7 @@
 endif
 
 # Decouple NDK library selection with platform compiler version
-TARGET_NDK_GCC_VERSION := 4.8
+TARGET_NDK_GCC_VERSION := 4.9
 
 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
 TARGET_GCC_VERSION := 4.9
@@ -96,6 +96,12 @@
 			-include $(android_config_h) \
 			-I $(dir $(android_config_h))
 
+# 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
@@ -104,6 +110,7 @@
 			-Wl,-z,noexecstack \
 			-Wl,-z,relro \
 			-Wl,-z,now \
+			-Wl,--build-id=md5 \
 			-Wl,--warn-shared-textrel \
 			-Wl,--fatal-warnings \
 			$(arch_variant_ldflags)
@@ -121,7 +128,6 @@
 
 libc_root := bionic/libc
 libm_root := bionic/libm
-libstdc++_root := bionic/libstdc++
 libthread_db_root := bionic/libthread_db
 
 
@@ -138,6 +144,8 @@
 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
@@ -148,7 +156,6 @@
 TARGET_C_INCLUDES := \
 	$(libc_root)/arch-mips64/include \
 	$(libc_root)/include \
-	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
 	$(libm_root)/include/mips \
@@ -162,81 +169,8 @@
 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
 TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
 
-TARGET_STRIP_MODULE:=true
+TARGET_PACK_MODULE_RELOCATIONS := true
 
 TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
 
-TARGET_CUSTOM_LD_COMMAND := true
-
-define transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	-nostdlib -Wl,-soname,$(notdir $@) \
-	-Wl,--gc-sections \
-	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \
-	-Wl,-dynamic-linker,/system/bin/linker64 \
-	-Wl,--gc-sections \
-	-Wl,-z,nocopyreloc \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \
-	-Wl,--gc-sections \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(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)) \
-	-Wl,--no-whole-archive \
-	$(call normalize-target-libraries,$(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))) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	-Wl,--end-group \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
-endef
+TARGET_LINKER := /system/bin/linker64
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 0af3948..ed78372 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -62,13 +62,14 @@
 	$(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
-libstdc++_root := bionic/libstdc++
 
 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
 KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
@@ -121,14 +122,15 @@
 
 $(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_C_INCLUDES := \
 	$(libc_root)/arch-x86/include \
 	$(libc_root)/include \
-	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
 	$(libm_root)/include/i387 \
@@ -140,77 +142,10 @@
 $(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_STRIP_MODULE:=true
+$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
 
-$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
+$(combo_2nd_arch_prefix)TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
 
-$(combo_2nd_arch_prefix)TARGET_CUSTOM_LD_COMMAND := true
-define $(combo_2nd_arch_prefix)transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	 -nostdlib -Wl,-soname,$(notdir $@) \
-	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
-	$(PRIVATE_LDLIBS)
-endef
+$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
 
-define $(combo_2nd_arch_prefix)transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	-nostdlib -Bdynamic \
-	-Wl,-z,nocopyreloc \
-	-pie \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define $(combo_2nd_arch_prefix)transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	-nostdlib -Bstatic \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_STATIC_O)) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-	-Wl,--no-whole-archive \
-	-Wl,--start-group \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	-Wl,--end-group \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
-endef
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_YASM_FLAGS := -f elf32 -m x86
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
index 33d6a56..0b2905c 100644
--- a/core/combo/TARGET_linux-x86_64.mk
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -23,7 +23,7 @@
 endif
 
 # Decouple NDK library selection with platform compiler version
-TARGET_NDK_GCC_VERSION := 4.8
+TARGET_NDK_GCC_VERSION := 4.9
 
 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
 TARGET_GCC_VERSION := 4.8
@@ -62,13 +62,14 @@
 	$(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
-libstdc++_root := bionic/libstdc++
 
 KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
 KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
@@ -96,6 +97,7 @@
 TARGET_GLOBAL_CFLAGS += \
     -Werror=pointer-to-int-cast \
     -Werror=int-to-pointer-cast \
+    -Werror=implicit-function-declaration \
 
 android_config_h := $(call select-android-config-h,target_linux-x86)
 TARGET_ANDROID_CONFIG_CFLAGS := -include $(android_config_h) -I $(dir $(android_config_h))
@@ -115,6 +117,9 @@
 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
@@ -126,14 +131,15 @@
 
 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_C_INCLUDES := \
 	$(libc_root)/arch-x86_64/include \
 	$(libc_root)/include \
-	$(libstdc++_root)/include \
 	$(KERNEL_HEADERS) \
 	$(libm_root)/include \
 	$(libm_root)/include/amd64 \
@@ -145,77 +151,8 @@
 TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
 TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
 
-TARGET_STRIP_MODULE:=true
+TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libm
 
-TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libm
+TARGET_LINKER := /system/bin/linker64
 
-TARGET_CUSTOM_LD_COMMAND := true
-define transform-o-to-shared-lib-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	 -nostdlib -Wl,-soname,$(notdir $@) \
-	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl,-shared) \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O))
-endef
-
-define transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	-nostdlib -Bdynamic \
-	-Wl,-z,nocopyreloc \
-	-pie \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-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)) \
-	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
-	$(if $(TARGET_BUILD_APPS),$(PRIVATE_TARGET_LIBGCC)) \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
-	-o $@ \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
-
-define transform-o-to-static-executable-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	-nostdlib -Bstatic \
-	-o $@ \
-	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_STATIC_O)) \
-	$(PRIVATE_LDFLAGS) \
-	$(PRIVATE_ALL_OBJECTS) \
-	-Wl,--whole-archive \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-	-Wl,--no-whole-archive \
-	-Wl,--start-group \
-	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
-	$(PRIVATE_TARGET_LIBATOMIC) \
-	$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-	-Wl,--end-group \
-	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
-	$(PRIVATE_LDLIBS)
-endef
+TARGET_GLOBAL_YASM_FLAGS := -f elf64 -m amd64
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index c6603db..99f17aa 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -7,15 +7,32 @@
 ARCH_ARM_HAVE_NEON              := true
 
 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
+
+	# Fake an ARM compiler flag as these processors support LPAE which GCC/clang
+	# don't advertise.
+	arch_variant_cflags += -D__ARM_FEATURE_LPAE=1
+	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
 ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a7)
 	arch_variant_cflags := -mcpu=cortex-a7
+	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
@@ -23,6 +40,3 @@
 arch_variant_cflags += \
     -mfloat-abi=softfp \
     -mfpu=neon
-
-arch_variant_ldflags := \
-	-Wl,--fix-cortex-a8
diff --git a/core/combo/arch/x86/x86-atom.mk b/core/combo/arch/x86/atom.mk
similarity index 95%
rename from core/combo/arch/x86/x86-atom.mk
rename to core/combo/arch/x86/atom.mk
index 508a0af..3800350 100644
--- a/core/combo/arch/x86/x86-atom.mk
+++ b/core/combo/arch/x86/atom.mk
@@ -11,6 +11,5 @@
 # CFLAGS for this arch
 arch_variant_cflags := \
 	-march=atom \
-	-mstackrealign \
 	-mfpmath=sse \
 
diff --git a/core/combo/arch/x86/haswell.mk b/core/combo/arch/x86/haswell.mk
index a00e0a6..b3922c0 100644
--- a/core/combo/arch/x86/haswell.mk
+++ b/core/combo/arch/x86/haswell.mk
@@ -7,10 +7,11 @@
 ARCH_X86_HAVE_SSE4_2 := true
 ARCH_X86_HAVE_AES_NI := true
 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 \
-	-mstackrealign \
 	-mfpmath=sse \
 
diff --git a/core/combo/arch/x86/ivybridge.mk b/core/combo/arch/x86/ivybridge.mk
index 02dc1e0..c9fc33b 100644
--- a/core/combo/arch/x86/ivybridge.mk
+++ b/core/combo/arch/x86/ivybridge.mk
@@ -7,10 +7,11 @@
 ARCH_X86_HAVE_SSE4_2 := true
 ARCH_X86_HAVE_AES_NI := true
 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 \
-	-mstackrealign \
 	-mfpmath=sse \
 
diff --git a/core/combo/arch/x86/sandybridge.mk b/core/combo/arch/x86/sandybridge.mk
index dfa540c..bca5953 100644
--- a/core/combo/arch/x86/sandybridge.mk
+++ b/core/combo/arch/x86/sandybridge.mk
@@ -2,13 +2,16 @@
 # Generating binaries for SandyBridge processors.
 #
 ARCH_X86_HAVE_SSSE3  := true
+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_POPCNT := true
+ARCH_X86_HAVE_MOVBE  := false
 
 # CFLAGS for this arch
 arch_variant_cflags := \
 	-march=corei7-avx \
-	-mstackrealign \
 	-mfpmath=sse \
 
diff --git a/core/combo/arch/x86/silvermont.mk b/core/combo/arch/x86/silvermont.mk
index 3a8718d..d064b1d 100644
--- a/core/combo/arch/x86/silvermont.mk
+++ b/core/combo/arch/x86/silvermont.mk
@@ -15,6 +15,5 @@
 # CFLAGS for this arch
 arch_variant_cflags := \
 	-march=slm \
-	-mstackrealign \
 	-mfpmath=sse \
 
diff --git a/core/combo/arch/x86/x86.mk b/core/combo/arch/x86/x86.mk
index 73706c4..f070426 100644
--- a/core/combo/arch/x86/x86.mk
+++ b/core/combo/arch/x86/x86.mk
@@ -13,11 +13,7 @@
 ARCH_X86_HAVE_POPCNT := false
 
 
-# XXX: This flag is probably redundant, because it should be set by default
-# by our toolchain binaries. However, there have been reports that this may
-# not always work as intended, so keep it unless we have the time to check
-# everything properly.
-
+# Some intrinsic functions used by libcxx only exist for prescott or newer CPUs.
 arch_variant_cflags := \
-    -march=i686 \
+    -march=prescott \
 
diff --git a/core/combo/arch/x86_64/haswell.mk b/core/combo/arch/x86_64/haswell.mk
index 9cf95b3..6067eee 100644
--- a/core/combo/arch/x86_64/haswell.mk
+++ b/core/combo/arch/x86_64/haswell.mk
@@ -7,6 +7,8 @@
 ARCH_X86_HAVE_SSE4_2 := true
 ARCH_X86_HAVE_AES_NI := true
 ARCH_X86_HAVE_AVX    := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE  := true
 
 # CFLAGS for this arch
 arch_variant_cflags := \
diff --git a/core/combo/arch/x86_64/ivybridge.mk b/core/combo/arch/x86_64/ivybridge.mk
index 7b95190..90e23a9 100644
--- a/core/combo/arch/x86_64/ivybridge.mk
+++ b/core/combo/arch/x86_64/ivybridge.mk
@@ -7,6 +7,8 @@
 ARCH_X86_HAVE_SSE4_2 := true
 ARCH_X86_HAVE_AES_NI := true
 ARCH_X86_HAVE_AVX    := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE  := false
 
 # CFLAGS for this arch
 arch_variant_cflags := \
diff --git a/core/combo/arch/x86_64/sandybridge.mk b/core/combo/arch/x86_64/sandybridge.mk
index a443b6b..865548c 100644
--- a/core/combo/arch/x86_64/sandybridge.mk
+++ b/core/combo/arch/x86_64/sandybridge.mk
@@ -2,9 +2,13 @@
 # Generating binaries for SandyBridge processors.
 #
 ARCH_X86_HAVE_SSSE3  := true
+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_POPCNT := true
+ARCH_X86_HAVE_MOVBE  := false
 
 # CFLAGS for this arch
 arch_variant_cflags := \
diff --git a/core/combo/arch/x86_64/x86_64-atom.mk b/core/combo/arch/x86_64/x86_64-atom.mk
deleted file mode 100755
index 64b07a0..0000000
--- a/core/combo/arch/x86_64/x86_64-atom.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-# This file contains feature macro definitions specific to the
-# 'x86_64-atom' arch variant. This is an extension of the 'x86_64' base variant
-# that adds Atom-specific features.
-#
-# See build/core/combo/arch/x86_64/x86_64.mk for differences.
-#
-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
diff --git a/core/combo/arch/x86_64/x86_64.mk b/core/combo/arch/x86_64/x86_64.mk
index 9d2b620..08dd9cd 100755
--- a/core/combo/arch/x86_64/x86_64.mk
+++ b/core/combo/arch/x86_64/x86_64.mk
@@ -8,6 +8,9 @@
 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
 
 
 # CFLAGS for this arch
diff --git a/core/combo/fdo.mk b/core/combo/fdo.mk
index 9e331b6..8fb8fd3 100644
--- a/core/combo/fdo.mk
+++ b/core/combo/fdo.mk
@@ -18,22 +18,16 @@
 
 $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:=
 
-ifeq ($(strip $(BUILD_FDO_INSTRUMENT)), true)
-  # Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
-  # The profile will be generated on /sdcard/fdo_profile on the device.
-  $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
-  $(combo_2nd_arch_prefix)TARGET_FDO_LDFLAGS := -lgcov -lgcc
-else
-  ifeq ($(strip $(BUILD_FDO_OPTIMIZE)), true)
-    # Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
-    ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
-      $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := vendor/google_data/fdo_profile
-    endif
+# Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
+# The profile will be generated on /sdcard/fdo_profile on the device.
+$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
+$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_LDFLAGS := -lgcov -lgcc
 
-    ifneq ($(strip $(wildcard $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)/$(PRODUCT_OUT))),)
-      $(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS := -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
-    else
-      $(warning Profile directory $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)/$(PRODUCT_OUT) does not exist. Turn off FDO.)
-    endif
-  endif
+# Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
+ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
+  $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := vendor/google_data/fdo_profile
 endif
+
+$(combo_2nd_arch_prefix)TARGET_FDO_OPTIMIZE_CFLAGS := \
+    -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) \
+    -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
diff --git a/core/combo/include/arch/darwin-x86/AndroidConfig.h b/core/combo/include/arch/darwin-x86/AndroidConfig.h
index 54f3750..c28a7f8 100644
--- a/core/combo/include/arch/darwin-x86/AndroidConfig.h
+++ b/core/combo/include/arch/darwin-x86/AndroidConfig.h
@@ -33,190 +33,9 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have the futex syscall?
- */
-
-/* #define HAVE_FUTEX */
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_MACOSX_IPC
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-/* #define  HAVE_SYS_SENDFILE_H 1 */
-
-/*
- * Define this if you build against MSVCRT.DLL
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS
-
-/*
- * Define this if we have localtime_r().
- */
-#define HAVE_LOCALTIME_R 1
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-/* #define HAVE_IOCTL */
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-/* #define HAVE_POSIX_CLOCKS */
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#if (defined(__ppc__) || defined(__ppc64__))
-#   define HAVE_BIG_ENDIAN
-#elif (defined(__i386__) || defined(__x86_64__))
-#   define HAVE_LITTLE_ENDIAN
-#endif
-
-/*
- * We need to choose between 32-bit and 64-bit off_t.  All of our code should
- * agree on the same size.  For desktop systems, use 64-bit values,
- * because some of our libraries (e.g. wxWidgets) expect to be built that way.
- */
-#define _FILE_OFFSET_BITS 64
-#define _LARGEFILE_SOURCE 1
-
-/*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-/* #define HAVE_OFF64_T */
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-/* #define HAVE_GETTID */
-
-
-/*
- * Add any extra platform-specific defines here.
- */
-#define _THREAD_SAFE
-
-/*
  * Define if we have <malloc.h> header
  */
-/* #define HAVE_MALLOC_H */
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if we include <sys/mount.h> for statfs()
- */
-#define INCLUDE_SYS_MOUNT_FOR_STATFS 1
-
-/*
- * What CPU architecture does this platform use?
- */
-#if (defined(__ppc__) || defined(__ppc64__))
-#   define ARCH_PPC
-#elif (defined(__i386__) || defined(__x86_64__))
-#   define ARCH_X86
-#endif
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.dylib"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE char *
+/* #define HAVE_MALLOC_H 1 */
 
 /*
  * The default path separator for the platform
@@ -224,75 +43,8 @@
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- *
- * For tools apps, we'll treat is as not case sensitive.
- */
-/* #define OS_CASE_SENSITIVE */
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-#define HAVE_STRLCPY 1
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-#define HAVE_FUNOPEN 1
-
-/*
- * Define if writev() exists
- */
-#define HAVE_WRITEV 1
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/core/combo/include/arch/linux-arm/AndroidConfig.h b/core/combo/include/arch/linux-arm/AndroidConfig.h
index c06c8bc..e819535 100644
--- a/core/combo/include/arch/linux-arm/AndroidConfig.h
+++ b/core/combo/include/arch/linux-arm/AndroidConfig.h
@@ -33,306 +33,23 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_ANDROID_IPC
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H 1
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
- * Define this if you build against MSVCRT.DLL
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H 1
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS
-
-/*
- * Define this if we have localtime_r().
- */
-/* #define HAVE_LOCALTIME_R 1 */
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-#define HAVE_POSIX_CLOCKS
-
-/*
- * Define this if we have linux style epoll()
- */
-#define HAVE_EPOLL
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#define HAVE_ENDIAN_H
-#define HAVE_LITTLE_ENDIAN
-
-/*
- * We need to choose between 32-bit and 64-bit off_t.  All of our code should
- * agree on the same size.  For desktop systems, use 64-bit values,
- * because some of our libraries (e.g. wxWidgets) expect to be built that way.
- */
-/* #define _FILE_OFFSET_BITS 64 */
-/* #define _LARGEFILE_SOURCE 1 */
-
-/*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/* 
- * Defined if we have the sched_setscheduler() call
- */
-#define HAVE_SCHED_SETSCHEDULER
-
-/*
- * Add any extra platform-specific defines here.
- */
-#ifndef __linux__
-#define __linux__
-#endif
-
-/*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
-/* 
+/*
  * Define if we're running on *our* linux on device or emulator.
  */
 #define HAVE_ANDROID_OS 1
 
 /*
- * Define if we have Linux-style non-filesystem Unix Domain Sockets
- */
-#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1
-
-/*
- * Define if we have Linux's inotify in <sys/inotify.h>.
- */
-#define HAVE_INOTIFY 1
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-#define HAVE_LIBC_SYSTEM_PROPERTIES 1
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-/* #define HAVE_SYSTEM_PROPERTY_SERVER */
-
-/*
- * What CPU architecture does this platform use?
- */
-#define ARCH_ARM
-
-/*
- * Define if the size of enums is as short as possible,
- */
-/* #define HAVE_SHORT_ENUMS */
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- */
-#define OS_CASE_SENSITIVE
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-#define HAVE_STRLCPY 1
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-#define HAVE_FUNOPEN 1
-
-/*
- * Define if prctl() exists
- */
-#define HAVE_PRCTL 1
-
-/*
- * Define if writev() exists
- */
-#define HAVE_WRITEV 1
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/core/combo/include/arch/linux-arm64/AndroidConfig.h b/core/combo/include/arch/linux-arm64/AndroidConfig.h
index bcbda8f..cee484d 100644
--- a/core/combo/include/arch/linux-arm64/AndroidConfig.h
+++ b/core/combo/include/arch/linux-arm64/AndroidConfig.h
@@ -33,168 +33,9 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * Process out-of-memory adjustment.  Set if running on Linux,
- * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory
- * badness adjustment.
- */
-#define HAVE_OOM_ADJ
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_ANDROID_IPC
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H 1
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
- * Define this if you build against MSVCRT.DLL
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H 1
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS
-
-/*
- * Define this if we have localtime_r().
- */
-/* #define HAVE_LOCALTIME_R 1 */
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-#define HAVE_POSIX_CLOCKS
-
-/*
- * Define this if we have linux style epoll()
- */
-#define HAVE_EPOLL
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#define HAVE_ENDIAN_H
-#define HAVE_LITTLE_ENDIAN
-
-#define _FILE_OFFSET_BITS 64
-/* #define _LARGEFILE_SOURCE 1 */
-
-/*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/*
- * Defined if we have the sched_setscheduler() call
- */
-#define HAVE_SCHED_SETSCHEDULER
-
-/*
- * Add any extra platform-specific defines here.
- */
-#ifndef __linux__
-#define __linux__
-#endif
-
-/*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
@@ -202,139 +43,13 @@
 #define HAVE_ANDROID_OS 1
 
 /*
- * Define if we have Linux-style non-filesystem Unix Domain Sockets
- */
-#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1
-
-/*
- * Define if we have Linux's inotify in <sys/inotify.h>.
- */
-#define HAVE_INOTIFY 1
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-#define HAVE_LIBC_SYSTEM_PROPERTIES 1
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-/* #define HAVE_SYSTEM_PROPERTY_SERVER */
-
-/*
- * What CPU architecture does this platform use?
- */
-#define ARCH_AARCH64
-
-/*
- * Define if the size of enums is as short as possible,
- */
-/* #define HAVE_SHORT_ENUMS */
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- */
-#define OS_CASE_SENSITIVE
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-#define HAVE_STRLCPY 1
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-#define HAVE_FUNOPEN 1
-
-/*
- * Define if prctl() exists
- */
-#define HAVE_PRCTL 1
-
-/*
- * Define if writev() exists
- */
-#define HAVE_WRITEV 1
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/core/combo/include/arch/linux-mips/AndroidConfig.h b/core/combo/include/arch/linux-mips/AndroidConfig.h
index bb3dc95..a5dcef1 100644
--- a/core/combo/include/arch/linux-mips/AndroidConfig.h
+++ b/core/combo/include/arch/linux-mips/AndroidConfig.h
@@ -33,183 +33,9 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_ANDROID_IPC
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H 1
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
- * Define this if you build against MSVCRT.DLL
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H 1
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS
-
-/*
- * Define this if we have localtime_r().
- */
-/* #define HAVE_LOCALTIME_R */
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-#define HAVE_POSIX_CLOCKS
-
-/*
- * Define this if we have linux style epoll()
- */
-#define HAVE_EPOLL
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#define HAVE_ENDIAN_H
-#if defined(__MIPSEB__)
-#define HAVE_BIG_ENDIAN
-#endif
-#if defined(__MIPSEL__)
-#define HAVE_LITTLE_ENDIAN
-#endif
-
-/*
- * We need to choose between 32-bit and 64-bit off_t.  All of our code should
- * agree on the same size.  For desktop systems, use 64-bit values,
- * because some of our libraries (e.g. wxWidgets) expect to be built that way.
- */
-/* #define _FILE_OFFSET_BITS 64 */
-/* #define _LARGEFILE_SOURCE 1 */
-
-/*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/*
- * Defined if we have the sched_setscheduler() call
- */
-#define HAVE_SCHED_SETSCHEDULER
-
-/*
- * Add any extra platform-specific defines here.
- */
-#ifndef __linux__
-#define __linux__ 1
-#endif
-
-#ifndef __linux
-#define __linux 1
-#endif
-
-#ifdef __unix__
-#undef __unix__
-#endif
-
-#ifdef __unix
-#undef __unix
-#endif
-
-/*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
@@ -217,134 +43,13 @@
 #define HAVE_ANDROID_OS 1
 
 /*
- * Define if we have Linux-style non-filesystem Unix Domain Sockets
- */
-#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1
-
-/*
- * Define if we have Linux's inotify in <sys/inotify.h>.
- */
-#define HAVE_INOTIFY 1
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-#define HAVE_LIBC_SYSTEM_PROPERTIES 1
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-/* #define HAVE_SYSTEM_PROPERTY_SERVER */
-
-/*
- * What CPU architecture does this platform use?
- */
-#define ARCH_MIPS 1
-
-/*
- * Define if the size of enums is as short as possible,
- */
-/* #define HAVE_SHORT_ENUMS */
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- */
-#define OS_CASE_SENSITIVE
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-#define HAVE_STRLCPY 1
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-#define HAVE_FUNOPEN 1
-
-/*
- * Define if prctl() exists
- */
-#define HAVE_PRCTL 1
-
-/*
- * Define if writev() exists
- */
-#define HAVE_WRITEV 1
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Whether or not _Unwind_Context is defined as a struct.
- */
-#define HAVE_UNWIND_CONTEXT_STRUCT 1
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/core/combo/include/arch/linux-mips64/AndroidConfig.h b/core/combo/include/arch/linux-mips64/AndroidConfig.h
index 7ded3ce..62d569e 100644
--- a/core/combo/include/arch/linux-mips64/AndroidConfig.h
+++ b/core/combo/include/arch/linux-mips64/AndroidConfig.h
@@ -33,180 +33,9 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * Process out-of-memory adjustment.  Set if running on Linux,
- * where we can write to /proc/<pid>/oom_adj to modify the out-of-memory
- * badness adjustment.
- */
-#define HAVE_OOM_ADJ
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_ANDROID_IPC
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H 1
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
- * Define this if you build against MSVCRT.DLL
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H 1
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS
-
-/*
- * Define this if we have localtime_r().
- */
-/* #define HAVE_LOCALTIME_R */
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-#define HAVE_POSIX_CLOCKS
-
-/*
- * Define this if we have linux style epoll()
- */
-#define HAVE_EPOLL
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#define HAVE_ENDIAN_H
-#define HAVE_LITTLE_ENDIAN
-
-#define _FILE_OFFSET_BITS 64
-/* #define _LARGEFILE_SOURCE 1 */
-
-/*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/*
- * Defined if we have the sched_setscheduler() call
- */
-#define HAVE_SCHED_SETSCHEDULER
-
-/*
- * Add any extra platform-specific defines here.
- */
-#ifndef __linux__
-#define __linux__ 1
-#endif
-
-#ifndef __linux
-#define __linux 1
-#endif
-
-#ifdef __unix__
-#undef __unix__
-#endif
-
-#ifdef __unix
-#undef __unix
-#endif
-
-/*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
@@ -214,134 +43,13 @@
 #define HAVE_ANDROID_OS 1
 
 /*
- * Define if we have Linux-style non-filesystem Unix Domain Sockets
- */
-#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1
-
-/*
- * Define if we have Linux's inotify in <sys/inotify.h>.
- */
-#define HAVE_INOTIFY 1
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-#define HAVE_LIBC_SYSTEM_PROPERTIES 1
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-/* #define HAVE_SYSTEM_PROPERTY_SERVER */
-
-/*
- * What CPU architecture does this platform use?
- */
-#define ARCH_MIPS64 1
-
-/*
- * Define if the size of enums is as short as possible,
- */
-/* #define HAVE_SHORT_ENUMS */
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- */
-#define OS_CASE_SENSITIVE
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-#define HAVE_STRLCPY 1
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-#define HAVE_FUNOPEN 1
-
-/*
- * Define if prctl() exists
- */
-#define HAVE_PRCTL 1
-
-/*
- * Define if writev() exists
- */
-#define HAVE_WRITEV 1
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Whether or not _Unwind_Context is defined as a struct.
- */
-#define HAVE_UNWIND_CONTEXT_STRUCT 1
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/core/combo/include/arch/linux-x86/AndroidConfig.h b/core/combo/include/arch/linux-x86/AndroidConfig.h
index 5523e49..89b29fe 100644
--- a/core/combo/include/arch/linux-x86/AndroidConfig.h
+++ b/core/combo/include/arch/linux-x86/AndroidConfig.h
@@ -33,113 +33,6 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have the futex syscall?
- */
-
-#define HAVE_FUTEX
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_SYSV_IPC
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H 1
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
- * Define this if you build against MSVCRT.DLL
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H 1
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS
-
-/*
- * Define this if we have localtime_r().
- */
-#define HAVE_LOCALTIME_R 1
-
-/*
- * Define this if we have gethostbyname_r().
- */
-#define HAVE_GETHOSTBYNAME_R
-
-/*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-#define HAVE_POSIX_CLOCKS
-
-/*
- * Define this if we have linux style epoll()
- */
-#define HAVE_EPOLL
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#define HAVE_ENDIAN_H
-#define HAVE_LITTLE_ENDIAN
-
-/*
  * We need to choose between 32-bit and 64-bit off_t.  All of our code should
  * agree on the same size.  For desktop systems, use 64-bit values,
  * because some of our libraries (e.g. wxWidgets) expect to be built that way.
@@ -148,92 +41,9 @@
 #define _LARGEFILE_SOURCE 1
 
 /*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 1
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-/* #define HAVE_GETTID */
-
-/* 
- * Defined if we have the sched_setscheduler() call
- */
-#define HAVE_SCHED_SETSCHEDULER
-
-/*
- * Add any extra platform-specific defines here.
- */
-
-/*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
-
-/*
- * Define if we have Linux-style non-filesystem Unix Domain Sockets
- */
-
-/*
- * What CPU architecture does this platform use?
- */
-#define ARCH_X86
-
-
-/*
- * Define if we have Linux's inotify in <sys/inotify.h>.
- */
-/*#define HAVE_INOTIFY 1*/
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-/* #define HAVE_LIBC_SYSTEM_PROPERTIES */
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-#define HAVE_SYSTEM_PROPERTY_SERVER
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
+#define HAVE_MALLOC_H 1
 
 /*
  * The default path separator for the platform
@@ -241,82 +51,8 @@
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- */
-#define OS_CASE_SENSITIVE
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-/* #define HAVE_STRLCPY 1 */
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-#define HAVE_OPEN_MEMSTREAM 1
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-/* #define HAVE_FUNOPEN 1 */
-
-/*
- * Define if prctl() exists
- */
-#define HAVE_PRCTL 1
-
-/*
- * Define if writev() exists
- */
-#define HAVE_WRITEV 1
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
-#define HAVE_GNU_QSORT_R 1
-#else
-#define HAVE_GNU_QSORT_R 0
-#endif
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/core/combo/include/arch/target_linux-x86/AndroidConfig.h b/core/combo/include/arch/target_linux-x86/AndroidConfig.h
index c267b2b..41e4df9 100644
--- a/core/combo/include/arch/target_linux-x86/AndroidConfig.h
+++ b/core/combo/include/arch/target_linux-x86/AndroidConfig.h
@@ -19,309 +19,23 @@
  */
 
 /*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- *  -- combine HAVE_CREATETHREAD, HAVE_CREATEMUTEX, and HAVE__BEGINTHREADEX
- */
-#define HAVE_PTHREADS
-
-/*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#define HAVE_FORKEXEC
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
-#define HAVE_ANDROID_IPC 1
-
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
-#define  HAVE_POSIX_FILEMAP 1
-
-/*
- * Define this if you have <termio.h>
- */
-#define  HAVE_TERMIO_H 1
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
- * Define this if you build against have Microsoft C runtime (MSVCRT.DLL)
- */
-/* #define HAVE_MS_C_RUNTIME */
-
-/*
- * Define this if you have sys/uio.h
- */
-#define  HAVE_SYS_UIO_H 1
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-#define HAVE_SYMLINKS 1
-
-/*
- * Define this if we have localtime_r().
- */
-/* #define HAVE_LOCALTIME_R 1 */
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
- * Define this if we want to use WinSock.
- */
-/* #define HAVE_WINSOCK */
-
-/*
- * Define this if have clock_gettime() and friends
- *
- */
-#define HAVE_POSIX_CLOCKS
-
-/*
- * Define this if we have linux style epoll()
- */
-#define HAVE_EPOLL
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#define HAVE_ENDIAN_H
-#define HAVE_LITTLE_ENDIAN
-
-/*
- * We need to choose between 32-bit and 64-bit off_t.  All of our code should
- * agree on the same size.  For desktop systems, use 64-bit values,
- * because some of our libraries (e.g. wxWidgets) expect to be built that way.
- */
-#if __LP64__
-#define _FILE_OFFSET_BITS 64
-#endif
-/* #define _LARGEFILE_SOURCE 1 */
-
-/*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/* 
- * Defined if we have the sched_setscheduler() call
- */
-#define HAVE_SCHED_SETSCHEDULER
-
-/*
- * Add any extra platform-specific defines here.
- */
-#ifndef __linux__
-#define __linux__
-#endif
-
-/*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
-/* 
+/*
  * Define if we're running on *our* linux on device or emulator.
  */
 #define HAVE_ANDROID_OS 1
 
 /*
- * Define if we have Linux-style non-filesystem Unix Domain Sockets
- */
-#define HAVE_LINUX_LOCAL_SOCKET_NAMESPACE 1
-
-/*
- * Define if we have Linux's inotify in <sys/inotify.h>.
- */
-#define HAVE_INOTIFY 1
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-#define HAVE_MADVISE 1
-
-/*
- * Define if we have Linux's dbus 
- */
-/* #define HAVE_DBUS 1 */
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-#define HAVE_TM_GMTOFF 1
-
-/*
- * Define if dirent struct has d_type field
- */
-#define HAVE_DIRENT_D_TYPE 1
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-#define HAVE_LIBC_SYSTEM_PROPERTIES 1
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-/* #define HAVE_SYSTEM_PROPERTY_SERVER */
-
-/*
- * What CPU architecture does this platform use?
- */
-#define ARCH_X86
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
 
 /*
- * Is the filesystem case sensitive?
- */
-#define OS_CASE_SENSITIVE
-
-/*
- * Define if <sys/socket.h> exists.
- */
-#define HAVE_SYS_SOCKET_H 1
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-#define HAVE_STRLCPY 1
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-#define HAVE_FUNOPEN 1
-
-/*
- * Define if prctl() exists
- */
-#define HAVE_PRCTL 1
-
-/*
- * Whether or not _Unwind_Context is defined as a struct.
- */
-#define HAVE_UNWIND_CONTEXT_STRUCT
-
-/*
  * Define if <stdint.h> exists.
  */
 #define HAVE_STDINT_H 1
 
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H 1
-
-/*
- * Define if <sched.h> exists.
- */
-#define HAVE_SCHED_H 1
-
-/*
- * Define if pread() exists
- */
-#define HAVE_PREAD 1
-
-/*
- * Define if we have st_mtim in struct stat
- */
-#define HAVE_STAT_ST_MTIM 1
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-#define HAVE_PRINTF_ZD 1
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /* _ANDROID_CONFIG_H */
diff --git a/core/combo/include/arch/windows/AndroidConfig.h b/core/combo/include/arch/windows/AndroidConfig.h
index 204740d..e7eb837 100644
--- a/core/combo/include/arch/windows/AndroidConfig.h
+++ b/core/combo/include/arch/windows/AndroidConfig.h
@@ -55,129 +55,22 @@
 #  endif
 #endif
 
-/*
- * Threading model.  Choose one:
- *
- * HAVE_PTHREADS - use the pthreads library.
- * HAVE_WIN32_THREADS - use Win32 thread primitives.
- */
-#define HAVE_WIN32_THREADS
-
-/*
- * Do we have the futex syscall?
- */
-
-/* #define HAVE_FUTEX */
-
-
-/*
- * Process creation model.  Choose one:
- *
- * HAVE_FORKEXEC - use fork() and exec()
- * HAVE_WIN32_PROC - use CreateProcess()
- */
-#ifdef __CYGWIN__
-#  define HAVE_FORKEXEC
-#else
-#  define HAVE_WIN32_PROC
-#endif
-
-/*
- * IPC model.  Choose one:
- *
- * HAVE_SYSV_IPC - use the classic SysV IPC mechanisms (semget, shmget).
- * HAVE_MACOSX_IPC - use Macintosh IPC mechanisms (sem_open, mmap).
- * HAVE_WIN32_IPC - use Win32 IPC (CreateSemaphore, CreateFileMapping).
- * HAVE_ANDROID_IPC - use Android versions (?, mmap).
- */
+/* TODO: replace references to this. */
 #define HAVE_WIN32_IPC
 
-/*
- * Memory-mapping model. Choose one:
- *
- * HAVE_POSIX_FILEMAP - use the Posix sys/mmap.h
- * HAVE_WIN32_FILEMAP - use Win32 filemaps
- */
 #ifdef __CYGWIN__
-#define  HAVE_POSIX_FILEMAP
-#else
-#define  HAVE_WIN32_FILEMAP
-#endif
-
-/*
- * Define this if you have <termio.h>
- */
-#ifdef __CYGWIN__
-#  define  HAVE_TERMIO_H
-#endif
-
-/*
- * Define this if you have <sys/sendfile.h>
- */
-#ifdef __CYGWIN__
-#  define  HAVE_SYS_SENDFILE_H 1
+#error "CYGWIN is unsupported for platform builds"
 #endif
 
 /*
  * Define this if you build against MSVCRT.DLL
  */
-#ifndef __CYGWIN__
-#  define HAVE_MS_C_RUNTIME
-#endif
-
-/*
- * Define this if you have sys/uio.h
- */
-#ifdef __CYGWIN__
-#define  HAVE_SYS_UIO_H
-#endif
-
-
-/*
- * Define this if we have localtime_r().
- */
-/* #define HAVE_LOCALTIME_R 1 */
-
-/*
- * Define this if we have gethostbyname_r().
- */
-/* #define HAVE_GETHOSTBYNAME_R */
-
-/*
- * Define this if we have ioctl().
- */
-/* #define HAVE_IOCTL */
+#define HAVE_MS_C_RUNTIME
 
 /*
  * Define this if we want to use WinSock.
  */
-#ifndef __CYGWIN__
 #define HAVE_WINSOCK
-#endif
-
-/*
- * Define this if your platforms implements symbolic links
- * in its filesystems
- */
-/* #define HAVE_SYMLINKS */
-
-/*
- * Define this if have clock_gettime() and friends
- */
-/* #define HAVE_POSIX_CLOCKS */
-
-/*
- * Endianness of the target machine.  Choose one:
- *
- * HAVE_ENDIAN_H -- have endian.h header we can include.
- * HAVE_LITTLE_ENDIAN -- we are little endian.
- * HAVE_BIG_ENDIAN -- we are big endian.
- */
-#ifdef __CYGWIN__
-#define HAVE_ENDIAN_H
-#endif
-
-#define HAVE_LITTLE_ENDIAN
 
 /*
  * We need to choose between 32-bit and 64-bit off_t.  All of our code should
@@ -188,50 +81,6 @@
 #define _LARGEFILE_SOURCE 1
 
 /*
- * Define if platform has off64_t (and lseek64 and other xxx64 functions)
- */
-#define HAVE_OFF64_T
-
-/*
- * Defined if we have the backtrace() call for retrieving a stack trace.
- * Needed for CallStack to operate; if not defined, CallStack is
- * non-functional.
- */
-#define HAVE_BACKTRACE 0
-
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Define if tm struct has tm_gmtoff field
- */
-/* #define HAVE_TM_GMTOFF 1 */
-
-/*
- * Define if dirent struct has d_type field
- */
-/* #define HAVE_DIRENT_D_TYPE 1 */
-
-/*
- * Define if libc includes Android system properties implementation.
- */
-/* #define HAVE_LIBC_SYSTEM_PROPERTIES */
-
-/*
- * Define if system provides a system property server (should be
- * mutually exclusive with HAVE_LIBC_SYSTEM_PROPERTIES).
- */
-/* #define HAVE_SYSTEM_PROPERTY_SERVER */
-
-/*
- * Define if we have madvise() in <sys/mman.h>
- */
-/*#define HAVE_MADVISE 1*/
-
-/*
  * Add any extra platform-specific defines here.
  */
 #define WIN32 1                 /* stock Cygwin doesn't define these */
@@ -241,115 +90,15 @@
 #define HAVE_WINDOWS_PATHS      /* needed by simulator */
 
 /*
- * What CPU architecture does this platform use?
- */
-#define ARCH_X86
-
-/*
- * sprintf() format string for shared library naming.
- */
-#define OS_SHARED_LIB_FORMAT_STR    "lib%s.dll"
-
-/*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '\\'
 
 /*
- * Is the filesystem case sensitive?
- */
-/* #define OS_CASE_SENSITIVE */
-
-/*
- * Define if <sys/socket.h> exists.
- * Cygwin has it, but not MinGW.
- */
-#ifdef USE_MINGW
-/* #define HAVE_SYS_SOCKET_H */
-#else
-#define HAVE_SYS_SOCKET_H 1
-#endif
-
-/*
- * Define if the strlcpy() function exists on the system.
- */
-/* #define HAVE_STRLCPY 1 */
-
-/*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
- * Define if the BSD funopen() function exists on the system.
- */
-/* #define HAVE_FUNOPEN 1 */
-
-/*
- * Define if <winsock2.h> exists.
- * Only MinGW has it.
- */
-#ifdef USE_MINGW
-#define HAVE_WINSOCK2_H 1
-#else
-/* #define HAVE_WINSOCK2_H */
-#endif
-
-/*
  * Various definitions missing in MinGW
  */
 #ifdef USE_MINGW
 #define S_IRGRP 0
 #endif
 
-/*
- * Define if writev() exists.
- */
-/* #define HAVE_WRITEV */
-
-/*
- * Define if <stdint.h> exists.
- */
-/* #define HAVE_STDINT_H */
-
-/*
- * Define if <stdbool.h> exists.
- */
-#define HAVE_STDBOOL_H
-
-/*
- * Define if <sched.h> exists.
- */
-/* #define HAVE_SCHED_H */
-
-/*
- * Define if pread() exists
- */
-/* #define HAVE_PREAD 1 */
-
-/*
- * Define if we have st_mtim in struct stat
- */
-/* #define HAVE_STAT_ST_MTIM 1 */
-
-/*
- * Define if printf() supports %zd for size_t arguments
- */
-/* #define HAVE_PRINTF_ZD 1 */
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a BSD style function prototype.
- */
-#define HAVE_BSD_QSORT_R 0
-
-/*
- * Define to 1 if <stdlib.h> provides qsort_r() with a GNU style function prototype.
- */
-#define HAVE_GNU_QSORT_R 0
-
 #endif /*_ANDROID_CONFIG_H*/
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index 7f91aa9..fb43ea4 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -9,11 +9,7 @@
 #   COMMON_JAVAC -- Java compiler command with common arguments
 #
 
-ifneq ($(LEGACY_USE_JAVA6),)
-common_jdk_flags := -target 1.5 -Xmaxerrs 9999999
-else
 common_jdk_flags := -source 1.7 -target 1.7 -Xmaxerrs 9999999
-endif
 
 # Use the indexer wrapper to index the codebase instead of the javac compiler
 ifeq ($(ALTERNATE_JAVAC),)
diff --git a/core/combo/select.mk b/core/combo/select.mk
index d495c6f..01f9322 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -33,22 +33,6 @@
 $(combo_var_prefix)AR := $(AR)
 $(combo_var_prefix)STRIP := $(STRIP)
 
-$(combo_var_prefix)BINDER_MINI := 0
-
-$(combo_var_prefix)HAVE_EXCEPTIONS := 0
-$(combo_var_prefix)HAVE_UNIX_FILE_PATH := 1
-$(combo_var_prefix)HAVE_WINDOWS_FILE_PATH := 0
-$(combo_var_prefix)HAVE_RTTI := 1
-$(combo_var_prefix)HAVE_CALL_STACKS := 1
-$(combo_var_prefix)HAVE_64BIT_IO := 1
-$(combo_var_prefix)HAVE_CLOCK_TIMERS := 1
-$(combo_var_prefix)HAVE_PTHREAD_RWLOCK := 1
-$(combo_var_prefix)HAVE_STRNLEN := 1
-$(combo_var_prefix)HAVE_STRERROR_R_STRRET := 1
-$(combo_var_prefix)HAVE_STRLCPY := 0
-$(combo_var_prefix)HAVE_STRLCAT := 0
-$(combo_var_prefix)HAVE_KERNEL_MODULES := 0
-
 $(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
 $(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
 $(combo_var_prefix)GLOBAL_CPPFLAGS :=
@@ -106,6 +90,11 @@
   endif
 endif
 
+# Stash the original values of CC and CXX so we can still use the non-wrapped
+# values later.
+$(combo_2nd_arch_prefix)CC_BARE := $($(combo_var_prefix)CC)
+$(combo_2nd_arch_prefix)CXX_BARE := $($(combo_var_prefix)CXX)
+
 # The C/C++ compiler can be wrapped by setting the CC/CXX_WRAPPER vars.
 ifdef CC_WRAPPER
   ifneq ($(CC_WRAPPER),$(firstword $($(combo_var_prefix)CC)))
diff --git a/core/config.mk b/core/config.mk
index e6a6812..aa7e318 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -69,10 +69,8 @@
 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_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk
 BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
 BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
-BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
 BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
 BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
 BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
@@ -85,6 +83,7 @@
 BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
 BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
 BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
+BUILD_NATIVE_BENCHMARK := $(BUILD_SYSTEM)/native_benchmark.mk
 BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
 
 BUILD_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/shared_test_lib.mk
@@ -97,8 +96,6 @@
 BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
 
 
--include cts/build/config.mk
-
 # ###############################################################
 # Parse out any modifier targets.
 # ###############################################################
@@ -117,9 +114,15 @@
 COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
 COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
 
-COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo
+COMMON_GLOBAL_CPPFLAGS:= $(COMMON_GLOBAL_CFLAGS) -Wsign-promo -std=gnu++11
 COMMON_RELEASE_CPPFLAGS:= $(COMMON_RELEASE_CFLAGS)
 
+GLOBAL_CFLAGS_NO_OVERRIDE :=  \
+    -Werror=int-to-pointer-cast \
+    -Werror=pointer-to-int-cast \
+
+GLOBAL_CPPFLAGS_NO_OVERRIDE :=
+
 # Set the extensions used for various packages
 COMMON_PACKAGE_SUFFIX := .zip
 COMMON_JAVA_PACKAGE_SUFFIX := .jar
@@ -128,9 +131,6 @@
 # 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
 
-# TODO: do symbol compression
-TARGET_COMPRESS_MODULE_SYMBOLS := false
-
 # ###############################################################
 # Include sub-configuration files
 # ###############################################################
@@ -393,16 +393,21 @@
 else
 MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
 endif
-MKYAFFS2 := $(HOST_OUT_EXECUTABLES)/mkyaffs2image$(HOST_EXECUTABLE_SUFFIX)
 APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
 FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
-MKEXT2IMG := $(HOST_OUT_EXECUTABLES)/genext2fs$(HOST_EXECUTABLE_SUFFIX)
 MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
 MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
+ifeq ($(HOST_OS),linux)
+MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX)
+MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
+else
+MAKE_SQUASHFS :=
+MKSQUASHFSUSERIMG :=
+endif
 MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX)
 MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
-MKEXT2BOOTIMG := external/genext2fs/mkbootimg_ext2.sh
 SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
+IMG2SIMG := $(HOST_OUT_EXECUTABLES)/img2simg$(HOST_EXECUTABLE_SUFFIX)
 E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
 MKTARBALL := build/tools/mktarball.sh
 TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
@@ -425,6 +430,10 @@
 # dx is java behind a shell script; no .exe necessary.
 DX := $(HOST_OUT_EXECUTABLES)/dx
 ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
+
+# relocation packer
+RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
+
 FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
 FINDBUGS := $(FINDBUGS_DIR)/findbugs
 EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
@@ -441,17 +450,7 @@
 COLUMN:= column
 endif
 
-ifeq ($(HOST_OS),darwin)
-ifeq ($(LEGACY_USE_JAVA6),)
 HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
-else
-# Deliberately set to blank for Java 6 installations on MacOS. These
-# versions allegedly use a non-standard directory structure.
-HOST_JDK_TOOLS_JAR :=
-endif
-else
-HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
-endif
 
 ifneq ($(HOST_JDK_TOOLS_JAR),)
 ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
@@ -549,23 +548,23 @@
   TARGET_DEFAULT_JAVA_LIBRARIES := core-libart core-junit ext framework
 endif
 
-TARGET_CPU_SMP ?= true
-
 # Flags for DEX2OAT
 DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
-DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_CPU_VARIANT)
-DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
-ifneq (,$(filter $(DEX2OAT_TARGET_CPU_VARIANT),cortex-a7 cortex-a15 krait denver))
-  DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div
+ifeq ($(TARGET_CPU_VARIANT),)
+ifeq ($(TARGET_ARCH_VARIANT),)
+DEX2OAT_TARGET_CPU_VARIANT := default
+else
+DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_ARCH_VARIANT)
 endif
+else
+DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_CPU_VARIANT)
+endif
+DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
 
 ifdef TARGET_2ND_ARCH
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_2ND_CPU_VARIANT)
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
-ifneq (,$(filter $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT),cortex-a7 cortex-a15 krait denver))
-  $(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div
-endif
 endif
 
 # define clang/llvm tools and global flags
@@ -620,4 +619,8 @@
 RS_PREBUILT_LIBPATH := -L prebuilts/ndk/8/platforms/android-9/arch-$(TARGET_ARCH)/usr/lib
 RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
 
+# API Level lists for Renderscript Compat lib.
+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
+
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
new file mode 100644
index 0000000..210d442
--- /dev/null
+++ b/core/config_sanitizers.mk
@@ -0,0 +1,94 @@
+##############################################
+## Perform configuration steps for sanitizers.
+##############################################
+
+my_sanitize := $(strip $(LOCAL_SANITIZE))
+
+# Keep compatibility for LOCAL_ADDRESS_SANITIZER until all targets have moved to
+# `LOCAL_SANITIZE := address`.
+ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
+  my_sanitize += address
+endif
+
+# And `LOCAL_SANITIZE := never`.
+ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),false)
+  my_sanitize := never
+endif
+
+# Don't apply sanitizers to NDK code.
+ifdef LOCAL_SDK_VERSION
+  my_sanitize := never
+endif
+
+# Configure SANITIZE_HOST.
+ifdef LOCAL_IS_HOST_MODULE
+  ifeq ($(my_sanitize),)
+    my_sanitize := $(strip $(SANITIZE_HOST))
+
+    # SANTIZIZE_HOST=true is a deprecated way to say SANITIZE_HOST=address.
+    ifeq ($(my_sanitize),true)
+      my_sanitize := address
+    endif
+
+    # 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
+    # have set `LOCAL_CLANG := true`.
+    ifneq ($(my_clang),true)
+      my_sanitize :=
+    endif
+  endif
+endif
+
+ifeq ($(my_sanitize),never)
+  my_sanitize :=
+endif
+
+# Sanitizers can only be used with clang.
+ifneq ($(my_clang),true)
+  ifneq ($(my_sanitize),)
+    $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of sanitizers requires LOCAL_CLANG := true)
+  endif
+endif
+
+ifneq ($(filter default-ub,$(my_sanitize)),)
+  my_sanitize := $(CLANG_DEFAULT_UB_CHECKS)
+  my_ldlibs += -ldl
+
+  ifdef LOCAL_IS_HOST_MODULE
+    my_cflags += -fno-sanitize-recover=all
+  else
+    my_cflags += -fsanitize-undefined-trap-on-error
+  endif
+endif
+
+ifneq ($(my_sanitize),)
+  fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize)),
+  my_cflags += -fsanitize=$(fsanitize_arg)
+
+  ifdef LOCAL_IS_HOST_MODULE
+    my_ldflags += -fsanitize=$(fsanitize_arg)
+  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)
+  my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
+  ifdef LOCAL_IS_HOST_MODULE
+    # -nodefaultlibs (provided with libc++) prevents the driver from linking
+    # libraries needed with -fsanitize=address. http://b/18650275 (WAI)
+    my_ldlibs += -ldl -lpthread
+  else
+    my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
+    my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+  endif
+endif
+
+ifneq ($(filter undefined,$(my_sanitize)),)
+  ifdef LOCAL_IS_HOST_MODULE
+    my_ldlibs += -ldl
+  else
+    $(error ubsan is not yet supported on the target)
+  endif
+endif
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
new file mode 100644
index 0000000..da84bdd
--- /dev/null
+++ b/core/cxx_stl_setup.mk
@@ -0,0 +1,110 @@
+#############################################################
+## Set up flags based on LOCAL_CXX_STL.
+## Input variables: LOCAL_CXX_STL
+## Output variables: My_cflags, my_c_includes, my_shared_libraries, etc.
+#############################################################
+
+# Select the appropriate C++ STL
+ifeq ($(strip $(LOCAL_CXX_STL)),default)
+    ifndef LOCAL_SDK_VERSION
+        # Platform code. Select the appropriate STL.
+        ifndef USE_MINGW
+            my_cxx_stl := libc++
+            ifdef LOCAL_IS_HOST_MODULE
+                ifneq (,$(BUILD_HOST_static))
+                    my_cxx_stl := libc++_static
+                endif
+            endif
+        else
+            # libc++ is not supported on mingw.
+            my_cxx_stl := libstdc++
+        endif
+    else
+        my_cxx_stl := ndk
+    endif
+else
+    my_cxx_stl := $(strip $(LOCAL_CXX_STL))
+endif
+
+# Yes, this is actually what the clang driver does.
+HOST_linux_dynamic_gcclibs := -lgcc_s -lgcc -lc -lgcc_s -lgcc
+HOST_linux_static_gcclibs := -Wl,--start-group -lgcc -lgcc_eh -lc -Wl,--end-group
+HOST_darwin_dynamic_gcclibs := -lc -lSystem
+HOST_darwin_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_DARWIN
+
+my_link_type := dynamic
+ifdef LOCAL_IS_HOST_MODULE
+    ifneq (,$(BUILD_HOST_static))
+        my_link_type := static
+    endif
+    ifeq (-static,$(filter -static,$(my_ldflags)))
+        my_link_type := static
+    endif
+else
+    ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
+        my_link_type := static
+    endif
+endif
+
+ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
+    my_cflags += -D_USING_LIBCXX
+    my_c_includes += external/libcxx/include
+    ifeq ($(my_cxx_stl),libc++)
+        my_shared_libraries += libc++
+    else
+        my_static_libraries += libc++_static
+        ifndef LOCAL_IS_HOST_MODULE
+            ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+                my_static_libraries += libm libc libdl
+            endif
+        endif
+    endif
+
+    ifdef LOCAL_IS_HOST_MODULE
+        my_cppflags += -nostdinc++
+        my_ldflags += -nodefaultlibs
+        my_ldlibs += -lpthread -lm
+        my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs)
+    else
+        ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+            my_static_libraries += libunwind_llvm
+        endif
+
+        ifeq ($(my_link_type),static)
+            my_static_libraries += libdl
+        else
+            my_shared_libraries += libdl
+        endif
+    endif
+else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),)
+    ifndef LOCAL_IS_HOST_MODULE
+        my_c_includes += external/stlport/stlport bionic/libstdc++/include \
+                         bionic
+        ifeq ($(my_cxx_stl),stlport)
+            my_shared_libraries += libstdc++ libstlport
+        else
+            my_static_libraries += libstdc++ libstlport_static
+        endif
+    endif
+else ifeq ($(my_cxx_stl),ndk)
+    # Using an NDK STL. Handled farther up in this file.
+    ifndef LOCAL_IS_HOST_MODULE
+        my_system_shared_libraries += libstdc++
+    endif
+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++
+    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)$(HOST_OS)_$(my_link_type)_gcclibs)
+    endif
+else
+    $(error $(my_cxx_stl) is not a supported STL.)
+endif
diff --git a/core/definitions.mk b/core/definitions.mk
index 946a2a9..d90376e 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -871,6 +871,8 @@
   $(PRIVATE_RS_FLAGS) \
   $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
   $(PRIVATE_RS_SOURCE_FILES)
+  $(foreach d,$(PRIVATE_DEP_FILES),\
+    $(call transform-d-to-p-args,$(d),$(d:%.d=%.P))$(newline))
 $(hide) mkdir -p $(dir $@)
 $(hide) touch $@
 endef
@@ -884,8 +886,8 @@
 	-Wl,-rpath,\$$ORIGIN/../lib \
 	$(dir $@)/$(notdir $(<:.bc=.o)) \
 	$(RS_PREBUILT_COMPILER_RT) \
-	-o $@ $(TARGET_GLOBAL_LDFLAGS) -L prebuilts/gcc/ \
-	-L $(TARGET_OUT_INTERMEDIATE_LIBRARIES) $(RS_PREBUILT_LIBPATH) \
+	-o $@ $(TARGET_GLOBAL_LDFLAGS) -Wl,--hash-style=sysv -L prebuilts/gcc/ \
+	$(RS_PREBUILT_LIBPATH) -L $(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
 	-lRSSupport -lm -lc
 endef
 
@@ -905,6 +907,8 @@
   $(PRIVATE_RS_FLAGS) \
   $(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
   $(PRIVATE_RS_SOURCE_FILES)
+  $(foreach d,$(PRIVATE_DEP_FILES),\
+    $(call transform-d-to-p-args,$(d),$(d:%.d=%.P))$(newline))
 $(hide) mkdir -p $(dir $@)
 $(hide) touch $@
 endef
@@ -990,6 +994,8 @@
 	$(PRIVATE_CFLAGS) \
 	$(PRIVATE_CPPFLAGS) \
 	$(PRIVATE_DEBUG_CFLAGS) \
+	$(GLOBAL_CFLAGS_NO_OVERRIDE) \
+	$(GLOBAL_CPPFLAGS_NO_OVERRIDE) \
 	-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
 $(transform-d-to-p)
 endef
@@ -1013,6 +1019,7 @@
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
+	    $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
 	    $(PRIVATE_ARM_CFLAGS) \
 	 ) \
 	 $(1) \
@@ -1021,7 +1028,11 @@
 
 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))
+$(call transform-c-or-s-to-o-no-deps, \
+    $(PRIVATE_CFLAGS) \
+    $(PRIVATE_CONLYFLAGS) \
+    $(PRIVATE_DEBUG_CFLAGS) \
+    $(GLOBAL_CFLAGS_NO_OVERRIDE))
 endef
 
 define transform-s-to-o-no-deps
@@ -1044,7 +1055,7 @@
 @mkdir -p $(dir $@)
 $(hide) $(YASM) \
     $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
-    -f elf32 -m x86 \
+    $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_YASM_FLAGS) \
     $(PRIVATE_ASFLAGS) \
     -o $@ $<
 endef
@@ -1111,6 +1122,7 @@
 	-c \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 	    $(PRIVATE_HOST_GLOBAL_CFLAGS) \
+	    $(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \
 	 ) \
 	$(1) \
 	-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
@@ -1150,6 +1162,64 @@
 $(transform-d-to-p)
 endef
 
+
+###########################################################
+## Rules to compile a single C/C++ source with ../ in the path
+###########################################################
+# Replace "../" in object paths with $(DOTDOT_REPLACEMENT).
+DOTDOT_REPLACEMENT := dotdot/
+
+## Rule to compile a C++ source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the C++ source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-cpp-file
+o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+	$$(transform-$$(PRIVATE_HOST)cpp-to-o)
+-include $$(o:%.o=%.P)
+$(3) += $$(o)
+endef
+
+## Rule to compile a C source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the C source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-c-file
+o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+	$$(transform-$$(PRIVATE_HOST)c-to-o)
+-include $$(o:%.o=%.P)
+$(3) += $$(o)
+endef
+
+## Rule to compile a .S source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the .S source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-s-file
+o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+	$$(transform-$$(PRIVATE_HOST)s-to-o)
+-include $$(o:%.o=%.P)
+$(3) += $$(o)
+endef
+
+## Rule to compile a .s source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the .s source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+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)
+$(3) += $$(o)
+endef
+
 ###########################################################
 ## Commands for running ar
 ###########################################################
@@ -1176,22 +1246,41 @@
 
 # $(1): the full path of the source static library.
 define _extract-and-include-single-target-whole-static-lib
-@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(strip $(1))]"
 $(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_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \
-        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $(1) $$f > $$ldir/$$f; \
-        filelist="$$filelist $$ldir/$$f"; \
+        if [ -e $$ldir/$$f ]; then \
+            mkdir $$ldir/$$subdir; \
+            ext=$$subdir/; \
+            subdir=$$((subdir+1)); \
+            $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) m $$lib_to_include $$f; \
+        else \
+            ext=; \
+        fi; \
+        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
+        filelist="$$filelist $$ldir/$$ext$$f"; \
     done ; \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
         $(PRIVATE_ARFLAGS) $@ $$filelist
 
 endef
 
+# $(1): the full path of the source static library.
+define extract-and-include-whole-static-libs-first
+$(if $(strip $(1)),
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(strip $(1))]"
+$(hide) cp $(1) $@)
+endef
+
 define extract-and-include-target-whole-static-libs
-$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
     $(call _extract-and-include-single-target-whole-static-lib, $(lib)))
 endef
 
@@ -1204,7 +1293,7 @@
 @echo "target StaticLib: $(PRIVATE_MODULE) ($@)"
 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
-    $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^))
+    $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
 endef
 
 ###########################################################
@@ -1213,14 +1302,25 @@
 
 # $(1): the full path of the source static library.
 define _extract-and-include-single-host-whole-static-lib
-@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(strip $(1))]"
 $(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_2ND_ARCH_VAR_PREFIX)HOST_AR) t $(1) | \grep '\.o$$'`; do \
-        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) p $(1) $$f > $$ldir/$$f; \
-        filelist="$$filelist $$ldir/$$f"; \
+        if [ -e $$ldir/$$f ]; then \
+           mkdir $$ldir/$$subdir; \
+           ext=$$subdir/; \
+           subdir=$$((subdir+1)); \
+           $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) m $$lib_to_include $$f; \
+        else \
+           ext=; \
+        fi; \
+        $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
+        filelist="$$filelist $$ldir/$$ext$$f"; \
     done ; \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_ARFLAGS) \
         $(PRIVATE_ARFLAGS) $@ $$filelist
@@ -1228,7 +1328,8 @@
 endef
 
 define extract-and-include-host-whole-static-libs
-$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
     $(call _extract-and-include-single-host-whole-static-lib, $(lib)))
 endef
 
@@ -1241,7 +1342,7 @@
 @echo "host StaticLib: $(PRIVATE_MODULE) ($@)"
 $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_AR) \
     $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_ARFLAGS) \
-    $(PRIVATE_ARFLAGS) $@,$(filter %.o, $^))
+    $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
 endef
 
 
@@ -1269,6 +1370,8 @@
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-host-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)) \
 	-o $@ \
 	$(PRIVATE_LDLIBS)
@@ -1292,26 +1395,13 @@
 ## Commands for running gcc to link a shared library or package
 ###########################################################
 
-#echo >$@.vers "{"; \
-#echo >>$@.vers " global:"; \
-#$(BUILD_SYSTEM)/filter_symbols.sh $(TARGET_NM) "  " ";" $(filter %.o,$^) | sort -u >>$@.vers; \
-#echo >>$@.vers " local:"; \
-#echo >>$@.vers "  *;"; \
-#echo >>$@.vers "};"; \
-
-#	-Wl,--version-script=$@.vers \
-
-# ld just seems to be so finicky with command order that we allow
-# it to be overriden en-masse see combo/linux-arm.make for an example.
-ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-shared-lib-inner
 $(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
-	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	-Wl,-rpath,\$$ORIGIN/../lib \
-	-Wl,-shared -Wl,-soname,$(notdir $@) \
-	$(PRIVATE_LDFLAGS) \
+	-nostdlib -Wl,-soname,$(notdir $@) \
+	-Wl,--gc-sections \
+	$(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl$(comma)-shared) \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_SO_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
@@ -1319,16 +1409,22 @@
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \
+	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBPROFILE_RT)) \
+	$(PRIVATE_TARGET_LIBATOMIC) \
+	$(PRIVATE_TARGET_LIBGCC) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
+	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+	$(PRIVATE_LDFLAGS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
 	$(PRIVATE_LDLIBS)
 endef
-endif
 
 define transform-o-to-shared-lib
 @mkdir -p $(dir $@)
 @echo "target SharedLib: $(PRIVATE_MODULE) ($@)"
-$($(PRIVATE_2ND_ARCH_VAR_PREFIX)transform-o-to-shared-lib-inner)
+$(transform-o-to-shared-lib-inner)
 endef
 
 
@@ -1344,7 +1440,8 @@
 define transform-to-stripped
 @mkdir -p $(dir $@)
 @echo "target Strip: $(PRIVATE_MODULE) ($@)"
-$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ $(TARGET_STRIP_EXTRA)
+$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \
+  $(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA))
 endef
 
 define transform-to-stripped-keep-symbols
@@ -1355,19 +1452,29 @@
     $(TARGET_STRIP_KEEP_SYMBOLS_EXTRA) $< $@
 endef
 
+###########################################################
+## Commands for packing a target executable or library
+###########################################################
+
+define pack-elf-relocations
+$(copy-file-to-target)
+@echo "target Pack Relocations: $(PRIVATE_MODULE) ($@)"
+$(hide) $(RELOCATION_PACKER) $@
+endef
 
 ###########################################################
 ## Commands for running gcc to link an executable
 ###########################################################
 
-ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-executable-inner
-$(hide) $(PRIVATE_CXX) \
-	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+$(hide) $(PRIVATE_CXX) -pie \
+	-nostdlib -Bdynamic \
+	-Wl,-dynamic-linker,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_LINKER) \
+	-Wl,--gc-sections \
+	-Wl,-z,nocopyreloc \
 	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
 	-Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
-	-Wl,-rpath,\$$ORIGIN/../lib \
-	$(PRIVATE_LDFLAGS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O)) \
 	$(PRIVATE_ALL_OBJECTS) \
 	-Wl,--whole-archive \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
@@ -1375,35 +1482,66 @@
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \
+	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBPROFILE_RT)) \
+	$(PRIVATE_TARGET_LIBATOMIC) \
+	$(PRIVATE_TARGET_LIBGCC) \
 	$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
 	-o $@ \
+	$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+	$(PRIVATE_LDFLAGS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
 	$(PRIVATE_LDLIBS)
 endef
-endif
 
 define transform-o-to-executable
 @mkdir -p $(dir $@)
 @echo "target Executable: $(PRIVATE_MODULE) ($@)"
-$($(PRIVATE_2ND_ARCH_VAR_PREFIX)transform-o-to-executable-inner)
+$(transform-o-to-executable-inner)
 endef
 
 
 ###########################################################
-## Commands for running gcc to link a statically linked
-## executable.  In practice, we only use this on arm, so
-## the other platforms don't have the
-## transform-o-to-static-executable defined
+## Commands for linking a static executable. In practice,
+## we only use this on arm, so the other platforms don't
+## have transform-o-to-static-executable defined.
+## Clang driver needs -static to create static executable.
+## However, bionic/linker uses -shared to overwrite.
+## Linker for x86 targets does not allow coexistance of -static and -shared,
+## so we add -static only if -shared is not used.
 ###########################################################
 
-ifneq ($(TARGET_CUSTOM_LD_COMMAND),true)
 define transform-o-to-static-executable-inner
+$(hide) $(PRIVATE_CXX) \
+	-nostdlib -Bstatic \
+	$(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
+	-Wl,--gc-sections \
+	-o $@ \
+	$(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(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)) \
+	-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))))) \
+	-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))) \
+	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \
+	$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBPROFILE_RT)) \
+	$(PRIVATE_TARGET_LIBATOMIC) \
+	$(call normalize-target-libraries,$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+	$(PRIVATE_TARGET_LIBGCC) \
+	-Wl,--end-group \
+	$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))
 endef
-endif
 
 define transform-o-to-static-executable
 @mkdir -p $(dir $@)
 @echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)"
-$($(PRIVATE_2ND_ARCH_VAR_PREFIX)transform-o-to-static-executable-inner)
+$(transform-o-to-static-executable-inner)
 endef
 
 
@@ -1430,13 +1568,14 @@
 	$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
 	$(call normalize-host-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)) \
 	-Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) \
 	-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
 	$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
 	$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
 		$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
-		$(HOST_FPIE_FLAGS) \
 	) \
 	$(PRIVATE_LDFLAGS) \
 	-o $@ \
@@ -1612,6 +1751,7 @@
         jar -cfm $@ $(dir $@)/manifest.mf \
             -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \
     $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .)
+$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
 endef
 
 define transform-java-to-classes.jar
@@ -1672,6 +1812,7 @@
         jar -cfm $@ $(dir $@)/manifest.mf \
             -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \
     $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .)
+$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
 $(hide) mv $(PRIVATE_CLASS_INTERMEDIATES_DIR)/newstamp $(PRIVATE_CLASS_INTERMEDIATES_DIR)/stamp
 endef
 
@@ -1713,10 +1854,21 @@
 # so we need to give it something.
 define create-empty-package
 @mkdir -p $(dir $@)
-$(hide) touch $(dir $@)dummy
-$(hide) (cd $(dir $@) && jar cf $(notdir $@) dummy)
-$(hide) zip -qd $@ dummy
-$(hide) rm $(dir $@)dummy
+$(hide) touch $(dir $@)zipdummy
+$(hide) (cd $(dir $@) && jar cf $(notdir $@) zipdummy)
+$(hide) zip -qd $@ zipdummy
+$(hide) rm $(dir $@)zipdummy
+endef
+
+# Copy an arhchive file and delete any class files and empty folders inside.
+# $(1): the source archive file.
+# $(2): the destination archive file.
+define initialize-package-file
+@mkdir -p $(dir $(2))
+$(hide) cp -f $(1) $(2)
+$(hide) zip -qd $(2) "*.class" \
+    $(if $(strip $(PRIVATE_DONT_DELETE_JAR_DIRS)),,"*/") \
+    || true # Ignore the error when nothing to delete.
 endef
 
 #TODO: we kinda want to build different asset packages for
@@ -1760,7 +1912,8 @@
 $(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
   $(call _add-jni-shared-libs-to-package-per-abi,$(abi),\
     $(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
-$(hide) (cd $(dir $@) && zip -r $(notdir $@) lib)
+$(hide) (cd $(dir $@) && zip -r \
+    $(if $(filter true, $(PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES)),-0,) $(notdir $@) lib)
 $(hide) rm -rf $(dir $@)lib
 endef
 
@@ -1770,24 +1923,12 @@
 endef
 
 # Add java resources added by the current module.
+# $(1) destination package
 #
-define add-java-resources-to-package
-$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(dir $@)jar-arg-list)
-$(hide) jar uf $@ @$(dir $@)jar-arg-list
-@rm -f $(dir $@)jar-arg-list
-endef
-
-# Add java resources carried by static Java libraries.
-#
-define add-carried-java-resources
-$(hide) if [ -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) ] ; then \
-    java_res_jar_flags=$$(find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -type f -a -not -name "*.class" \
-        | sed -e "s?^$(PRIVATE_CLASS_INTERMEDIATES_DIR)/? -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ?"); \
-    if [ -n "$$java_res_jar_flags" ] ; then \
-        echo $$java_res_jar_flags >$(dir $@)java_res_jar_flags; \
-        jar uf $@ $$java_res_jar_flags; \
-    fi; \
-fi
+define add-java-resources-to
+$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list)
+$(hide) jar uf $(1) @$(1).jar-arg-list
+@rm -f $(1).jar-arg-list
 endef
 
 # Sign a package using the specified key/cert.
@@ -1800,15 +1941,28 @@
 $(hide) mv $@.signed $@
 endef
 
-# Align STORED entries of a package on 4-byte boundaries
-# to make them easier to mmap.
+# Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
 #
 define align-package
 $(hide) mv $@ $@.unaligned
-$(hide) $(ZIPALIGN) -f 4 $@.unaligned $@.aligned
+$(hide) $(ZIPALIGN) \
+    -f \
+    $(if $(filter true, $(PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES)),-p,) \
+    4 \
+    $@.unaligned $@.aligned
 $(hide) mv $@.aligned $@
 endef
 
+define uncompress-shared-libs
+$(hide) rm -rf $(dir $@)/tmpworkdir
+$(hide) mv $@ $@.compressed
+$(hide) mkdir $(dir $@)/tmpworkdir
+$(hide) unzip $@.compressed 'lib/*.so' -d $(dir $@)/tmpworkdir
+$(hide) ( cd $(dir $@)/tmpworkdir && zip -D -r -0 ../$(notdir $@).compressed lib )
+$(hide) mv $@.compressed $@
+$(hide) rm -rf $(dir $@)/tmpworkdir
+endef
+
 define install-dex-debug
 $(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \
 	    mkdir -p $(TOP)/dalvik/DEBUG-FILES; \
@@ -1831,7 +1985,6 @@
 define transform-host-java-to-package
 @echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
 $(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH))
-$(if $(PRIVATE_EXTRA_JAR_ARGS), $(call add-java-resources-to-package))
 endef
 
 ###########################################################
@@ -1947,31 +2100,16 @@
 $(copy-file-to-target-strip-comments)
 endef
 
-###########################################################
-## On some platforms (MacOS), after copying a static
-## library, ranlib must be run to update an internal
-## timestamp!?!?!
-###########################################################
-
-ifeq ($(HOST_RUN_RANLIB_AFTER_COPYING),true)
-define transform-host-ranlib-copy-hack
-    $(hide) ranlib $@ || true
+# Copy a list of files/directories to target location, with sub dir structure preserved.
+# For example $(HOST_OUT_EXECUTABLES)/aapt -> $(staging)/bin/aapt .
+# $(1): the source list of files/directories.
+# $(2): the path prefix to strip. In the above example it would be $(HOST_OUT).
+# $(3): the target location.
+define copy-files-with-structure
+$(foreach t,$(1),\
+  $(eval s := $(patsubst $(2)%,%,$(t)))\
+  $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
 endef
-else
-define transform-host-ranlib-copy-hack
-@true
-endef
-endif
-
-ifeq ($(TARGET_RUN_RANLIB_AFTER_COPYING),true)
-define transform-ranlib-copy-hack
-    $(hide) ranlib $@
-endef
-else
-define transform-ranlib-copy-hack
-@true
-endef
-endif
 
 
 ###########################################################
@@ -2211,6 +2349,7 @@
 
 # Include any vendor specific definitions.mk file
 -include $(TOPDIR)vendor/*/build/core/definitions.mk
+-include $(TOPDIR)device/*/build/core/definitions.mk
 
 # broken:
 #	$(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file)))
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 8a19b66..8b555e0 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -3,8 +3,6 @@
 #
 ####################################
 
-ifneq ($(DALVIK_VM_LIB),)
-
 # list of boot classpath jars for dexpreopt
 DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
 DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
@@ -18,6 +16,9 @@
 DEXPREOPT_BOOT_JAR_DIR := system/framework
 DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
 
+# The default value for LOCAL_DEX_PREOPT
+DEX_PREOPT_DEFAULT ?= true
+
 # $(1): the .jar or .apk to remove classes.dex
 define dexpreopt-remove-classes.dex
 $(hide) zip --quiet --delete $(1) classes.dex; \
@@ -46,36 +47,17 @@
 
 $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
 
-# Conditionally include Dalvik support.
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-include $(BUILD_SYSTEM)/dex_preopt_libdvm.mk
-endif
-
-# Unconditionally include ART support because its used run dex2oat on the host for tests.
 include $(BUILD_SYSTEM)/dex_preopt_libart.mk
 
 # Define dexpreopt-one-file based on current default runtime.
 # $(1): the input .jar or .apk file
 # $(2): the output .odex file
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-define dexpreopt-one-file
-$(call dexopt-one-file,$(1),$(2))
-endef
-
-DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEXOPT_DEPENDENCY)
-DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEXPREOPT_BOOT_ODEXS)
-else
 define dexpreopt-one-file
 $(call dex2oat-one-file,$(1),$(2))
 endef
 
-DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OATD_DEPENDENCY)
+DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
 DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
 ifdef TARGET_2ND_ARCH
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
 endif  # TARGET_2ND_ARCH
-endif  # DALVIK_VM_LIB
-else
-$(warning No DALVIK_VM_LIB, disable dexpreopt.)
-WITH_DEXPREOPT := false
-endif  # DALVIK_VM_LIB is defined.
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index cfbf221..6f598be 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -24,6 +24,13 @@
 COMPILED_CLASSES := $(call word-colon,1,$(firstword \
     $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
 
+# Default to debug version to help find bugs.
+# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
+ifneq ($(USE_DEX2OAT_DEBUG), false)
+DEX2OAT = $(DEX2OATD)
+DEX2OAT_DEPENDENCY = $(DEX2OATD_DEPENDENCY)
+endif
+
 # start of image reserved address space
 LIBART_IMG_HOST_BASE_ADDRESS   := 0x60000000
 LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
@@ -37,7 +44,7 @@
 DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
 DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
 
-ifeq ($(TARGET_ARCH),mips)
+ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
 # MIPS specific overrides.
 # For MIPS the ART image is loaded at a lower address. This causes issues
 # with the image overlapping with memory on the host cross-compiling and
@@ -55,7 +62,7 @@
 # $(1): the arch name.
 # $(2): the full path (including file name) of the corresponding .jar or .apk.
 define get-odex-file-path
-$(dir $(2))$(1)/$(basename $(notdir $(2))).odex
+$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
 endef
 
 # Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
@@ -88,7 +95,7 @@
 define dex2oat-one-file
 $(hide) rm -f $(2)
 $(hide) mkdir -p $(dir $(2))
-$(hide) $(DEX2OATD) \
+$(hide) $(DEX2OAT) \
 	--runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
 	--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
 	--dex-file=$(1) \
@@ -96,7 +103,9 @@
 	--oat-file=$(2) \
 	--android-root=$(PRODUCT_OUT)/system \
 	--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-include-debug-symbols \
+	--include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols --no-include-cfi \
+	--abort-on-hard-verifier-error \
 	$(PRIVATE_DEX_PREOPT_FLAGS)
 endef
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 6c6e0ad..cfc7653 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -27,10 +27,7 @@
 # The .oat with symbols
 $(my_2nd_arch_prefix)LIBART_TARGET_BOOT_OAT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)$(patsubst %.art,%.oat,$($(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME))
 
-$(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE :=
-ifneq ($(PRODUCT_DEX_PREOPT_IMAGE_IN_DATA),true)
 $(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$($(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME)
-endif
 
 # Compile boot.oat as position-independent code if WITH_DEXPREOPT_PIC=true
 ifeq (true,$(WITH_DEXPREOPT_PIC))
@@ -50,11 +47,11 @@
 
 $($(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) $(DEX2OATD_DEPENDENCY)
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(DEX2OAT_DEPENDENCY)
 	@echo "target dex2oat: $@ ($?)"
 	@mkdir -p $(dir $@)
 	@mkdir -p $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
-	$(hide) $(DEX2OATD) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
+	$(hide) $(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
 		--image-classes=$(PRELOADED_CLASSES) \
 		$(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
 		$(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
@@ -63,6 +60,7 @@
 		--oat-location=$(patsubst %.art,%.oat,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_BOOT_IMAGE_FILENAME)) \
 		--image=$@ --base=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
 		--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-include-debug-symbols \
+		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols --no-include-cfi \
 		$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(COMPILED_CLASSES_FLAGS)
diff --git a/core/dex_preopt_libdvm.mk b/core/dex_preopt_libdvm.mk
deleted file mode 100644
index 23a54e1..0000000
--- a/core/dex_preopt_libdvm.mk
+++ /dev/null
@@ -1,76 +0,0 @@
-####################################
-# dexpreopt support for Dalvik
-#
-####################################
-
-DEXOPT := $(HOST_OUT_EXECUTABLES)/dexopt$(HOST_EXECUTABLE_SUFFIX)
-DEXPREOPT := dalvik/tools/dex-preopt
-
-DEXPREOPT_DEXOPT := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXOPT))
-
-DEXPREOPT_BOOT_ODEXS := $(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),\
-    $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(b).odex)
-
-# If the target is a uniprocessor, then explicitly tell the preoptimizer
-# that fact. (By default, it always optimizes for an SMP target.)
-ifeq ($(TARGET_CPU_SMP),true)
-    DEXPREOPT_UNIPROCESSOR :=
-else
-    DEXPREOPT_UNIPROCESSOR := --uniprocessor
-endif
-
-# By default, do not run rerun dexopt if the tool changes.
-# Comment out the | to force dex2oat to rerun on after all changes.
-DEXOPT_DEPENDENCY := |
-DEXOPT_DEPENDENCY += $(DEXPREOPT) $(DEXOPT)
-
-# $(1): the input .jar or .apk file
-# $(2): the output .odex file
-define dexopt-one-file
-$(hide) rm -f $(2)
-$(hide) mkdir -p $(dir $(2))
-$(hide) $(DEXPREOPT) \
-        --dexopt=$(DEXPREOPT_DEXOPT) \
-        --build-dir=$(DEXPREOPT_BUILD_DIR) \
-        --product-dir=$(DEXPREOPT_PRODUCT_DIR) \
-        --boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \
-        --boot-jars=$(DEXPREOPT_BOOT_JARS) \
-        $(DEXPREOPT_UNIPROCESSOR) \
-        $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \
-        $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2))
-endef
-
-# Special rules for building odex files for boot jars that override java_library.mk rules
-
-# $(1): boot jar module name
-define _dexpreopt-boot-odex
-_dbj_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).jar
-_dbj_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1).odex
-_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
-$$(_dbj_odex): PRIVATE_DBJ_JAR := $$(_dbj_jar)
-$$(_dbj_odex) : $$(_dbj_src_jar) | $(ACP) $(DEXPREOPT) $(DEXOPT)
-	@echo "Dexpreopt Boot Jar: $$@"
-	$(hide) mkdir -p $$(dir $$(PRIVATE_DBJ_JAR)) && $(ACP) -fp $$< $$(PRIVATE_DBJ_JAR)
-	$$(call dexopt-one-file,$$(PRIVATE_DBJ_JAR),$$@)
-
-_dbj_jar :=
-_dbj_odex :=
-_dbj_src_jar :=
-endef
-
-$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-odex,$(b))))
-
-# $(1): the rest list of boot jars
-define _build-dexpreopt-boot-jar-dependency-pair
-$(if $(filter 1,$(words $(1)))$(filter 0,$(words $(1))),,\
-	$(eval _bdbjdp_target := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 2,$(1)).odex) \
-	$(eval _bdbjdp_dep := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(word 1,$(1)).odex) \
-	$(eval $(call add-dependency,$(_bdbjdp_target),$(_bdbjdp_dep))) \
-	$(eval $(call _build-dexpreopt-boot-jar-dependency-pair,$(wordlist 2,999,$(1)))))
-endef
-
-define _build-dexpreopt-boot-jar-dependency
-$(call _build-dexpreopt-boot-jar-dependency-pair,$(DEXPREOPT_BOOT_JARS_MODULES))
-endef
-
-$(eval $(call _build-dexpreopt-boot-jar-dependency))
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index cb38261..73c8146 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -33,10 +33,6 @@
 ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code
 LOCAL_DEX_PREOPT :=
 endif
-# if module oat file requested in data, disable LOCAL_DEX_PREOPT, will default location to dalvik-cache
-ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA)))
-LOCAL_DEX_PREOPT :=
-endif
 # if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip
 ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY))
 ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
@@ -50,28 +46,21 @@
 ifdef LOCAL_DEX_PREOPT
 dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
 ifdef dexpreopt_boot_jar_module
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
-installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
-built_installed_odex := $(built_odex):$(installed_odex)
-else # libdvm.so
 # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
 # We use this installed_odex trick to get boot.art installed.
 installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
 # Append the odex for the 2nd arch if we have one.
 installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
-endif # libdvm.so
 else  # boot jar
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
-installed_odex := $(basename $(LOCAL_INSTALLED_MODULE)).odex
-built_installed_odex := $(built_odex):$(installed_odex)
-
-$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
-                $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-else # libart
 ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
-# For a Java library, we build odex for both 1st arch and 2nd arch, if we have one.
+# For a Java library, by default we build odex for both 1st arch and 2nd arch.
+# But it can be overridden with "LOCAL_MULTILIB := first".
+ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
+# For system server jars, we build for only "first".
+my_module_multilib := first
+else
+my_module_multilib := $(LOCAL_MULTILIB)
+endif
 # #################################################
 # Odex for the 1st arch
 my_2nd_arch_prefix :=
@@ -79,8 +68,10 @@
 # #################################################
 # Odex for the 2nd arch
 ifdef TARGET_2ND_ARCH
+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_2ND_ARCH
 # #################################################
 else  # must be APPS
@@ -95,7 +86,6 @@
 endif  # LOCAL_MULTILIB is both
 endif  # TARGET_2ND_ARCH
 endif  # LOCAL_MODULE_CLASS
-endif  # libart
 endif  # boot jar
 
 ifdef built_odex
diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk
index 0e8cbdf..06e498d 100644
--- a/core/dpi_specific_apk.mk
+++ b/core/dpi_specific_apk.mk
@@ -47,7 +47,10 @@
 ifneq ($(jni_shared_libraries),)
 	$(add-jni-shared-libs-to-package)
 endif
-ifneq ($(full_classes_jar),)
+ifeq ($(full_classes_jar),)
+# We don't build jar, need to add the Java resources here.
+	$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
+else
 	$(add-dex-to-package)
 endif
 	$(add-carried-java-resources)
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index d3e61d5..41f135c 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -154,7 +154,14 @@
 # TODO: not clear if this is used any more
 $(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
 
-$(full_target): $(full_src_files) $(droiddoc_templates) $(droiddoc) $(html_dir_files) $(full_java_lib_deps) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(full_target): \
+        $(full_src_files) \
+        $(droiddoc_templates) \
+        $(droiddoc) \
+        $(html_dir_files) \
+        $(full_java_lib_deps) \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	@echo Docs droiddoc: $(PRIVATE_OUT_DIR)
 	$(hide) mkdir -p $(dir $@)
 	$(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
index 08fb176..fe498ed 100644
--- a/core/dynamic_binary.mk
+++ b/core/dynamic_binary.mk
@@ -39,30 +39,6 @@
 ###################################
 
 ###########################################################
-## Compress
-###########################################################
-compress_input := $(linked_module)
-
-ifeq ($(strip $(LOCAL_COMPRESS_MODULE_SYMBOLS)),)
-  LOCAL_COMPRESS_MODULE_SYMBOLS := $(strip $(TARGET_COMPRESS_MODULE_SYMBOLS))
-endif
-
-ifeq ($(LOCAL_COMPRESS_MODULE_SYMBOLS),true)
-$(error Symbol compression not yet supported.)
-compress_output := $(intermediates)/COMPRESSED-$(my_built_module_stem)
-
-#TODO: write the real $(STRIPPER) rule.
-#TODO: define a rule to build TARGET_SYMBOL_FILTER_FILE, and
-#      make it depend on ALL_ORIGINAL_DYNAMIC_BINARIES.
-$(compress_output): $(compress_input) $(TARGET_SYMBOL_FILTER_FILE) | $(ACP)
-	@echo "target Compress Symbols: $(PRIVATE_MODULE) ($@)"
-	$(copy-file-to-target)
-else
-# Skip this step.
-compress_output := $(compress_input)
-endif
-
-###########################################################
 ## Store a copy with symbols for symbolic debugging
 ###########################################################
 ifeq ($(LOCAL_UNSTRIPPED_PATH),)
@@ -70,7 +46,7 @@
 else
 my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
 endif
-symbolic_input := $(compress_output)
+symbolic_input := $(linked_module)
 symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
 $(symbolic_output) : $(symbolic_input) | $(ACP)
 	@echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
@@ -81,25 +57,28 @@
 ## Strip
 ###########################################################
 strip_input := $(symbolic_output)
-strip_output := $(LOCAL_BUILT_MODULE)
+strip_output := $(intermediates)/STRIPPED/$(my_built_module_stem)
 
 my_strip_module := $(LOCAL_STRIP_MODULE)
 ifeq ($(my_strip_module),)
-  my_strip_module := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP_MODULE)
+  my_strip_module := true
 endif
 
-ifeq ($(my_strip_module),true)
-# Strip the binary
-$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
-$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
-$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
-	$(transform-to-stripped)
-else
-ifeq ($(my_strip_module),keep_symbols)
-# Strip only the debug frames, but leave the symbol table.
 $(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_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
+ifeq ($(my_strip_module),no_debuglink)
+$(strip_output): PRIVATE_NO_DEBUGLINK := true
+else
+$(strip_output): PRIVATE_NO_DEBUGLINK :=
+endif
+
+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)
+else ifeq ($(my_strip_module),keep_symbols)
+# Strip only the debug frames, but leave the symbol table.
 $(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
 	$(transform-to-stripped-keep-symbols)
 
@@ -126,11 +105,41 @@
 	@echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target-with-cp)
 endif
-endif
 endif # my_strip_module
 
+###########################################################
+## Pack relocation tables
+###########################################################
+relocation_packer_input := $(strip_output)
+relocation_packer_output := $(LOCAL_BUILT_MODULE)
+
+my_pack_module_relocations := $(LOCAL_PACK_MODULE_RELOCATIONS)
+
+ifeq ($(my_pack_module_relocations),)
+  my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
+endif
+
+# Do not pack relocations for static executables.
+ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+  my_pack_module_relocations := false
+endif
+
+# TODO (dimitry): Relocation packer is not yet available for darwin
+ifneq ($(HOST_OS),linux)
+  my_pack_module_relocations := false
+endif
+
+ifeq (true,$(my_pack_module_relocations))
+# Pack relocations
+$(relocation_packer_output): $(relocation_packer_input) | $(ACP)
+	$(pack-elf-relocations)
+else
+$(relocation_packer_output): $(relocation_packer_input) | $(ACP)
+	@echo "target Unpacked: $(PRIVATE_MODULE) ($@)"
+	$(copy-file-to-target)
+endif
 
 $(cleantarget): PRIVATE_CLEAN_FILES += \
     $(linked_module) \
     $(symbolic_output) \
-    $(compress_output)
+    $(strip_output)
diff --git a/core/envsetup.mk b/core/envsetup.mk
index ba67737..bf04455 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -63,7 +63,7 @@
 # Under Linux, if USE_MINGW is set, we change HOST_OS to Windows to build the
 # Windows SDK. Only a subset of tools and SDK will manage to build properly.
 ifeq ($(HOST_OS),linux)
-ifneq ($(USE_MINGW),)
+ifdef USE_MINGW
   HOST_OS := windows
 endif
 endif
@@ -72,24 +72,15 @@
 $(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
 endif
 
-# TODO: Replace BUILD_HOST_64bit with a flag that forces 32-bit build,
-# after we default to 64-bit host build.
-ifeq (,$(BUILD_HOST_64bit))
-# Default to 32-bit-by-default multilib host build.
-HOST_PREFER_32_BIT := true
-endif
-
 # HOST_ARCH
 ifneq (,$(findstring x86_64,$(UNAME)))
   HOST_ARCH := x86_64
   HOST_2ND_ARCH := x86
   HOST_IS_64_BIT := true
-endif
-
-ifeq ($(HOST_PREFER_32_BIT),true)
-SDK_HOST_ARCH := x86
 else
-SDK_HOST_ARCH := $(HOST_ARCH)
+ifneq (,$(findstring x86,$(UNAME)))
+$(error Building on a 32-bit x86 host is not supported: $(UNAME)!)
+endif
 endif
 
 BUILD_ARCH := $(HOST_ARCH)
@@ -149,6 +140,17 @@
 $(error must be empty or one of: eng user userdebug)
 endif
 
+# Build host as 32-bit for SDK build.
+ifneq ($(filter $(MAKECMDGOALS),win_sdk sdk),)
+HOST_PREFER_32_BIT := true
+endif
+ifdef USE_MINGW
+# We only build sdk host tools in the MinGW windows build.
+# Build it as 32-bit as well.
+HOST_PREFER_32_BIT := true
+endif
+SDK_HOST_ARCH := x86
+
 # Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
 # or under vendor/*/$(TARGET_DEVICE).  Search in both places, but
 # make sure only one exists.
@@ -403,8 +405,6 @@
 TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
 TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
 
-TARGET_FACTORY_RAMDISK_OUT := $(PRODUCT_OUT)/factory_ramdisk
-
 COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
 
 ifeq (,$(strip $(DIST_DIR)))
diff --git a/core/executable_internal.mk b/core/executable_internal.mk
index 9325287..2684d51 100644
--- a/core/executable_internal.mk
+++ b/core/executable_internal.mk
@@ -35,6 +35,8 @@
 
 # Define PRIVATE_ variables from global vars
 my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS)
+my_target_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT)
+my_target_libgcov := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV)
 my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC)
 my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC)
 my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_DYNAMIC_O)
@@ -54,6 +56,8 @@
 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_LIBPROFILE_RT := $(my_target_libprofile_rt)
+$(linked_module): PRIVATE_TARGET_LIBGCOV := $(my_target_libgcov)
 $(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)
@@ -62,8 +66,10 @@
 $(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
 
 ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
 $(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
 	$(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)
 	$(transform-o-to-executable)
diff --git a/core/find-jdk-tools-jar.sh b/core/find-jdk-tools-jar.sh
index f150a9a..0224829 100755
--- a/core/find-jdk-tools-jar.sh
+++ b/core/find-jdk-tools-jar.sh
@@ -2,7 +2,13 @@
 if [ "x$ANDROID_JAVA_HOME" != x ] && [ -e "$ANDROID_JAVA_HOME/lib/tools.jar" ] ; then
     echo $ANDROID_JAVA_HOME/lib/tools.jar
 else
-    JAVAC=$(which javac)
+    JAVAC=$(realpath $(which javac) 2>/dev/null)
+    if [ -z "$JAVAC" ]; then
+        JAVAC=$(readlink -f $(which javac) 2>/dev/null)
+    fi
+    if [ -z "$JAVAC" ]; then
+        JAVAC=$(which javac)
+    fi
     if [ -z "$JAVAC" ] ; then
         exit 1
     fi
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
index 61eb3ff..f8264ee 100644
--- a/core/host_dalvik_java_library.mk
+++ b/core/host_dalvik_java_library.mk
@@ -20,6 +20,7 @@
 # They will be compiled against libcore and not the host JRE.
 #
 
+ifeq ($(HOST_OS),linux)
 USE_CORE_LIB_BOOTCLASSPATH := true
 
 #######################################
@@ -69,8 +70,14 @@
 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
 $(full_classes_compiled_jar): PRIVATE_RMTYPEDEFS :=
-$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
-        $(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(full_classes_compiled_jar): \
+        $(java_sources) \
+        $(java_resource_sources) \
+        $(full_java_lib_deps) \
+        $(jar_manifest_file) \
+        $(proto_java_sources_file_stamp) \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
 
 # Run jarjar if necessary, otherwise just copy the file.
@@ -95,13 +102,13 @@
 	$(transform-classes.jar-to-dex)
 
 $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
 $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
 	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
-	$(create-empty-package)
+	$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
 	$(add-dex-to-package)
-	$(add-carried-java-resources)
-ifneq ($(extra_jar_args),)
-	$(add-java-resources-to-package)
-endif
 
 USE_CORE_LIB_BOOTCLASSPATH :=
+
+endif
diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk
index 3ae74e4..9e5aaa3 100644
--- a/core/host_dalvik_static_java_library.mk
+++ b/core/host_dalvik_static_java_library.mk
@@ -19,6 +19,7 @@
 # These libraries will be compiled against libcore and not the host
 # JRE.
 #
+ifeq ($(HOST_OS),linux)
 
 USE_CORE_LIB_BOOTCLASSPATH := true
 LOCAL_JAVA_LIBRARIES += core-libart-hostdex
@@ -26,3 +27,5 @@
 include $(BUILD_SYSTEM)/host_java_library.mk
 
 USE_CORE_LIB_BOOTCLASSPATH :=
+
+endif
diff --git a/core/host_executable.mk b/core/host_executable.mk
index bf3cde1..0091f3f 100644
--- a/core/host_executable.mk
+++ b/core/host_executable.mk
@@ -13,6 +13,10 @@
 endif
 endif
 
+ifeq ($(LOCAL_NO_FPIE),)
+LOCAL_LDFLAGS += $(HOST_FPIE_FLAGS)
+endif
+
 ifeq ($(my_module_multilib),both)
 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))
diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk
index ffb35d2..0c0ac3d 100644
--- a/core/host_executable_internal.mk
+++ b/core/host_executable_internal.mk
@@ -27,6 +27,9 @@
 
 include $(BUILD_SYSTEM)/binary.mk
 
+my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_LIBPROFILE_RT)
+$(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
+
 $(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
 	$(transform-host-o-to-executable)
 
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 7e0e437..b751c5f 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -79,6 +79,12 @@
 $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
 $(full_classes_compiled_jar): PRIVATE_RMTYPEDEFS :=
-$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
-		$(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(full_classes_compiled_jar): \
+        $(java_sources) \
+        $(java_resource_sources) \
+        $(full_java_lib_deps) \
+        $(jar_manifest_file) \
+        $(proto_java_sources_file_stamp) \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
diff --git a/core/host_java_library_common.mk b/core/host_java_library_common.mk
index 973afa0..cd9e679 100644
--- a/core/host_java_library_common.mk
+++ b/core/host_java_library_common.mk
@@ -29,12 +29,12 @@
 proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
 ifneq ($(proto_sources),)
 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
-    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-micro
+    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-micro
 else
   ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
-    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-nano
+    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-nano
   else
-    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-lite
+    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-lite
   endif
 endif
 endif
diff --git a/core/host_shared_library.mk b/core/host_shared_library.mk
index 438a9ce..e840780 100644
--- a/core/host_shared_library.mk
+++ b/core/host_shared_library.mk
@@ -6,8 +6,8 @@
 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
+# libraries default to building for both architecturess
+my_module_multilib := both
 endif
 endif
 endif
diff --git a/core/host_shared_library_internal.mk b/core/host_shared_library_internal.mk
index d9769d3..645098a 100644
--- a/core/host_shared_library_internal.mk
+++ b/core/host_shared_library_internal.mk
@@ -40,7 +40,14 @@
 
 include $(BUILD_SYSTEM)/binary.mk
 
-$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_LIBPROFILE_RT)
+$(LOCAL_BUILD_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
+
+$(LOCAL_BUILT_MODULE): \
+        $(all_objects) \
+        $(all_libraries) \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-o-to-shared-lib)
 
 endif  # skip_build_from_source
diff --git a/core/host_static_library.mk b/core/host_static_library.mk
index 74ac2ea..52c42ef 100644
--- a/core/host_static_library.mk
+++ b/core/host_static_library.mk
@@ -6,8 +6,8 @@
 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
+# libraries default to building for both architecturess
+my_module_multilib := both
 endif
 endif
 endif
diff --git a/core/host_test_internal.mk b/core/host_test_internal.mk
index 691468d..e0070c1 100644
--- a/core/host_test_internal.mk
+++ b/core/host_test_internal.mk
@@ -12,10 +12,4 @@
 LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g
 LOCAL_C_INCLUDES +=  external/gtest/include
 
-ifneq ($(filter libc++,$(LOCAL_SHARED_LIBRARIES)),)
-LOCAL_STATIC_LIBRARIES += libgtest_libc++_host libgtest_main_libc++_host
-else
 LOCAL_STATIC_LIBRARIES += libgtest_host libgtest_main_host
-LOCAL_SHARED_LIBRARIES +=
-endif
-
diff --git a/core/java.mk b/core/java.mk
index a969254..fc4703c 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -42,12 +42,12 @@
 proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
 ifneq ($(proto_sources),)
 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
-    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-micro
+    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-micro
 else
   ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
-    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-nano
+    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano
   else
-    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-lite
+    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite
   endif
 endif
 endif
@@ -180,6 +180,9 @@
 LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
 endif
 
+bc_files := $(patsubst %.fs,%.bc, $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources))))
+bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files)))
+
 $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES)
 $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
 $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
@@ -188,18 +191,38 @@
 # automatically found by the java compiling function transform-java-to-classes.jar.
 $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON)
 $(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api)
+$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
 $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
 	$(transform-renderscripts-to-java-and-bc)
 
+# include the dependency files (.d/.P) generated by llvm-rs-cc.
+-include $(bc_dep_files:%.d=%.P)
+
 ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),)
-bc_files := $(patsubst %.fs,%.bc, $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources))))
+
+
+ifeq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),)
+ifeq ($(TARGET_IS_64_BIT),true)
+renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc64/
+else
+renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc32/
+endif
+else
+renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/
+endif
+
 rs_generated_bc := $(addprefix \
-    $(renderscript_intermediate.COMMON)/res/raw/, $(bc_files))
+    $(renderscript_intermediate.bc_folder), $(bc_files))
 
 renderscript_intermediate := $(intermediates)/renderscript
 
 # We don't need the .so files in bundled branches
 # Prevent these from showing up on the device
+# One exception is librsjni.so, which is needed for
+# both native path and compat path.
+rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so
+LOCAL_JNI_SHARED_LIBRARIES += librsjni
+
 ifneq (,$(TARGET_BUILD_APPS)$(FORCE_BUILD_RS_COMPAT))
 
 rs_compatibility_jni_libs := $(addprefix \
@@ -209,28 +232,28 @@
 $(rs_generated_bc) : $(RenderScript_file_stamp)
 
 rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so
-rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so
-LOCAL_JNI_SHARED_LIBRARIES += libRSSupport librsjni
+LOCAL_JNI_SHARED_LIBRARIES += libRSSupport
 
+rs_support_io_lib :=
+# check if the target api level support USAGE_IO
+ifeq ($(filter $(RSCOMPAT_NO_USAGEIO_API_LEVELS),$(renderscript_target_api)),)
+rs_support_io_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupportIO.so
+LOCAL_JNI_SHARED_LIBRARIES += libRSSupportIO
+endif
 
 
 $(rs_compatibility_jni_libs): $(RenderScript_file_stamp) $(RS_PREBUILT_CLCORE) \
-    $(rs_support_lib) $(rs_jni_lib) $(rs_compiler_rt)
+    $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt)
 $(rs_compatibility_jni_libs): $(BCC_COMPAT)
 $(rs_compatibility_jni_libs): PRIVATE_CXX := $(TARGET_CXX)
 $(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \
-    $(renderscript_intermediate.COMMON)/res/raw/%.bc
+    $(renderscript_intermediate.bc_folder)%.bc
 	$(transform-bc-to-so)
 
 endif
 
 endif
 
-# include the dependency files (.d) generated by llvm-rs-cc.
-renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/, \
-    $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources)))))
--include $(renderscript_generated_dep_files)
-
 LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
 # Make sure the generated resource will be added to the apk.
 LOCAL_RESOURCE_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript/res $(LOCAL_RESOURCE_DIR)
@@ -340,9 +363,16 @@
 $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
 $(full_classes_compiled_jar): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
 $(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
-$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
-        $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) \
-        $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(full_classes_compiled_jar): \
+        $(java_sources) \
+        $(java_resource_sources) \
+        $(full_java_lib_deps) \
+        $(jar_manifest_file) \
+        $(layers_file) \
+        $(RenderScript_file_stamp) \
+        $(proto_java_sources_file_stamp) \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-java-to-classes.jar)
 
 $(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g
diff --git a/core/java_library.mk b/core/java_library.mk
index dffc7d9..b4e3eaa 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -58,9 +58,6 @@
 endif
 	@echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-target)
-ifneq ($(extra_jar_args),)
-	$(add-java-resources-to-package)
-endif
 
 $(LOCAL_BUILT_MODULE): $(common_javalib.jar)
 	$(copy-file-to-target)
@@ -68,14 +65,12 @@
 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_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
 $(common_javalib.jar) : $(built_dex) $(java_resource_sources)
 	@echo "target Jar: $(PRIVATE_MODULE) ($@)"
-	$(create-empty-package)
+	$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
 	$(add-dex-to-package)
-	$(add-carried-java-resources)
-ifneq ($(extra_jar_args),)
-	$(add-java-resources-to-package)
-endif
 
 ifdef LOCAL_DEX_PREOPT
 ifneq ($(dexpreopt_boot_jar_module),) # boot jar
@@ -85,12 +80,6 @@
 	$(call copy-file-to-target)
 
 # For libart boot jars, we don't have .odex files.
-ifeq ($(DALVIK_VM_LIB),libdvm.so)
-dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex
-$(built_odex) : $(dexpreopted_boot_odex) | $(ACP)
-	$(call copy-file-to-target)
-endif
-
 else # ! boot jar
 $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
 # Use pattern rule - we may have multiple built odex files.
diff --git a/core/main.mk b/core/main.mk
index 0f6315f..8ae3f5f 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -29,7 +29,7 @@
 # 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 probles when make strips off the
+# pattern matching problems when make strips off the
 # trailing "./" from paths in various places.
 #ifeq ($(TOP),.)
 #TOPDIR :=
@@ -79,7 +79,8 @@
     cacheimage-nodeps \
     vendorimage-nodeps \
     ramdisk-nodeps \
-    bootimage-nodeps
+    bootimage-nodeps \
+    recoveryimage-nodeps
 
 ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
 dont_bother := true
@@ -92,6 +93,9 @@
 # and host information.
 include $(BUILD_SYSTEM)/config.mk
 
+# CTS-specific config.
+-include cts/build/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
 # file does the rm -rf inline so the deps which are all done below will
@@ -140,18 +144,18 @@
 javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
 
 # Check for the correct version of java, should be 1.7 by
-# default, and 1.6 if LEGACY_USE_JAVA6 is set.
-ifeq ($(LEGACY_USE_JAVA6),)
+# default, and 1.8 if EXPERIMENTAL_USE_JAVA8 is set
+ifneq ($(EXPERIMENTAL_USE_JAVA8),)
+required_version := "1.8.x"
+required_javac_version := "1.8"
+java_version := $(shell echo '$(java_version_str)' | grep 'openjdk .*[ "]1\.8[\. "$$]')
+javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.8[\. "$$]')
+else # default
 required_version := "1.7.x"
 required_javac_version := "1.7"
 java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
 javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
-else # if LEGACY_USE_JAVA6
-required_version := "1.6.x"
-required_javac_version := "1.6"
-java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.6[\. "$$]')
-javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.6[\. "$$]')
-endif # if LEGACY_USE_JAVA6
+endif # if EXPERIMENTAL_USE_JAVA8
 
 ifeq ($(strip $(java_version)),)
 $(info ************************************************************)
@@ -170,13 +174,10 @@
 # Check for the current JDK.
 #
 # For Java 1.7, we require OpenJDK on linux and Oracle JDK on Mac OS.
-# For Java 1.6, we require Oracle for all host OSes.
 requires_openjdk := false
-ifeq ($(LEGACY_USE_JAVA6),)
 ifeq ($(HOST_OS), linux)
 requires_openjdk := true
 endif
-endif
 
 
 # Check for the current jdk
@@ -277,8 +278,8 @@
 ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
 $(info ***************************************************************)
 $(info ***************************************************************)
-$(info Invalid variant: $(TARGET_BUILD_VARIANT)
-$(info Valid values are: $(INTERNAL_VALID_VARIANTS)
+$(info Invalid variant: $(TARGET_BUILD_VARIANT))
+$(info Valid values are: $(INTERNAL_VALID_VARIANTS))
 $(info ***************************************************************)
 $(info ***************************************************************)
 $(error stopping)
@@ -308,9 +309,19 @@
 is_sdk_build := true
 endif
 
-ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+# Add build properties for ART. These define system properties used by installd
+# to pass flags to dex2oat.
+ADDITIONAL_BUILD_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart
+ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT)
+ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
+  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+endif
+
 ifdef TARGET_2ND_ARCH
-ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).variant=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)
+  ifneq ($($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
+    ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+  endif
 endif
 
 ## user/userdebug ##
@@ -325,23 +336,19 @@
   ifeq ($(user_variant),userdebug)
     # Pick up some extra useful tools
     tags_to_install += debug
-
-    # Enable Dalvik lock contention logging for userdebug builds.
-    ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
   else
     # Disable debugging in plain user builds.
     enable_target_debugging :=
   endif
 
-  # Turn on Dalvik preoptimization for libdvm.so user builds, but only if not
+  # Turn on Dalvik preoptimization for user builds, but only if not
   # explicitly disabled and the build is running on Linux (since host
   # Dalvik isn't built for non-Linux hosts).
   ifeq (,$(WITH_DEXPREOPT))
-    ifeq ($(DALVIK_VM_LIB),libdvm.so)
-      ifeq ($(user_variant),user)
-        ifeq ($(HOST_OS),linux)
-          WITH_DEXPREOPT := true
-        endif
+    ifeq ($(user_variant),user)
+      ifeq ($(HOST_OS),linux)
+        # TODO: turn on WITH_DEXPREOPT for libart user builds.
+        # WITH_DEXPREOPT := true
       endif
     endif
   endif
@@ -361,6 +368,8 @@
 ifeq (true,$(strip $(enable_target_debugging)))
   # Target is more debuggable and adbd is on by default
   ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
+  # Enable Dalvik lock contention logging.
+  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
   # Include the debugging/testing OTA keys in this build.
   INCLUDE_TEST_OTA_KEYS := true
 else # !enable_target_debugging
@@ -379,11 +388,12 @@
           ro.setupwizard.mode=OPTIONAL
 endif
 ifndef is_sdk_build
-  # Don't even verify the image on eng builds to speed startup
-  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.image-dex2oat-filter=verify-none
-  # Don't compile apps on eng builds to speed startup
-  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dex2oat-filter=interpret-only
+  # Don't verify or compile the image on eng builds to speed startup.
+  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.image-dex2oat-filter=verify-at-runtime
+  # Don't verify or compile apps on eng builds to speed startup.
+  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dex2oat-filter=verify-at-runtime
 endif
+  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.usejit=true
 endif
 
 ## sdk ##
@@ -408,16 +418,6 @@
 
 BUILD_WITHOUT_PV := true
 
-## precise GC ##
-
-ifneq ($(filter dalvik.gc.type-precise,$(PRODUCT_TAGS)),)
-  # Enabling type-precise GC results in larger optimized DEX files.  The
-  # additional storage requirements for ".odex" files can cause /system
-  # to overflow on some devices, so this is configured separately for
-  # each product.
-  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
-endif
-
 ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
 
 # enable vm tracing in files for now to help track
@@ -771,10 +771,6 @@
   $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
     $(if $(strip $(ALL_MODULES.$(m).INSTALLED) $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).INSTALLED)),,\
       $(eval dangling_modules += $(m))))
-  ifneq ($(TARGET_IS_64_BIT),true)
-    # We know those 64-bit modules don't exist in the 32-bit SDK build.
-    dangling_modules := $(filter-out %64,$(dangling_modules))
-  endif
   ifneq ($(dangling_modules),)
     $(warning: Modules '$(dangling_modules)' in PRODUCT_PACKAGES have nothing to install!)
   endif
@@ -848,12 +844,6 @@
 .PHONY: ramdisk
 ramdisk: $(INSTALLED_RAMDISK_TARGET)
 
-.PHONY: factory_ramdisk
-factory_ramdisk: $(INSTALLED_FACTORY_RAMDISK_TARGET)
-
-.PHONY: factory_bundle
-factory_bundle: $(INSTALLED_FACTORY_BUNDLE_TARGET)
-
 .PHONY: systemtarball
 systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
 
@@ -964,8 +954,6 @@
     $(BUILT_TARGET_FILES_PACKAGE) \
     $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
     $(INSTALLED_RAMDISK_TARGET) \
-    $(INSTALLED_FACTORY_RAMDISK_TARGET) \
-    $(INSTALLED_FACTORY_BUNDLE_TARGET) \
    )
 
   # Put a copy of the radio/bootloader files in the dist dir.
diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk
index bc85cea..ed2fed6 100644
--- a/core/multi_prebuilt.mk
+++ b/core/multi_prebuilt.mk
@@ -76,8 +76,7 @@
      ) \
    ) \
   $(eval LOCAL_MODULE_SUFFIX := $(suffix $(LOCAL_SRC_FILES))) \
-  $(if $(filter user,$(TARGET_BUILD_VARIANT)), \
-    $(eval LOCAL_STRIP_MODULE := $(8))) \
+  $(eval LOCAL_STRIP_MODULE := $(8)) \
   $(eval include $(BUILD_PREBUILT)) \
  )
 endef
diff --git a/core/native_benchmark.mk b/core/native_benchmark.mk
new file mode 100644
index 0000000..431e40a
--- /dev/null
+++ b/core/native_benchmark.mk
@@ -0,0 +1,12 @@
+###########################################
+## A thin wrapper around BUILD_EXECUTABLE
+## Common flags for native benchmarks are added.
+###########################################
+
+LOCAL_STATIC_LIBRARIES += libbenchmark
+
+ifndef LOCAL_MODULE_PATH
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/core/package_internal.mk b/core/package_internal.mk
index a6ad354..d52997b 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -320,7 +320,12 @@
 
 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): $(built_dex)
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE :=
 endif # full_classes_jar
 
 include $(BUILD_SYSTEM)/install_jni_libs.mk
@@ -364,6 +369,7 @@
 $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
 # PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names.
 $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
+$(LOCAL_BUILT_MODULE): PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES := $(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES)
 ifneq ($(TARGET_BUILD_APPS),)
     # Include all resources for unbundled apps.
     LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
@@ -379,26 +385,28 @@
     $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
 endif
 endif
+$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
 $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
 	@echo "target Package: $(PRIVATE_MODULE) ($@)"
-	$(create-empty-package)
+	$(if $(PRIVATE_SOURCE_ARCHIVE),\
+	  $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
+	  $(create-empty-package))
 	$(add-assets-to-package)
 ifneq ($(jni_shared_libraries),)
 	$(add-jni-shared-libs-to-package)
 endif
-ifneq ($(full_classes_jar),)
+ifeq ($(full_classes_jar),)
+# We don't build jar, need to add the Java resources here.
+	$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
+else
 	$(add-dex-to-package)
 endif
-	$(add-carried-java-resources)
-ifneq ($(extra_jar_args),)
-	$(add-java-resources-to-package)
-endif
-	$(sign-package)
 ifdef LOCAL_DEX_PREOPT
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
 endif
+	$(sign-package)
 	@# Alignment must happen after all other zip operations.
 	$(align-package)
 
@@ -487,7 +495,7 @@
 	@rm -rf $(dir $@) && mkdir -p $(dir $@)
 	$(hide) cp $< $@
 	$(hide) zip -d $@ $(foreach f,$(PRIVATE_JNI_SHARED_LIBRARIES),\*/$(f))
-	$(call align-package)
+	$(align-package)
 
 $(call dist-for-goals, apps_only, $(apk_jni_stripped):$(dist_subdir)/$(LOCAL_PACKAGE_NAME).apk)
 
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 0820885..2914576 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -27,7 +27,6 @@
 # A mapping from shorthand names to include directories.
 #
 pathmap_INCL := \
-    bootloader:bootable/bootloader/legacy/include \
     camera:system/media/camera/include \
     frameworks-base:frameworks/base/include \
     frameworks-native:frameworks/native/include \
@@ -87,7 +86,6 @@
 	    sax \
 	    telecomm \
 	    telephony \
-	    phone \
 	    wifi \
 	    keystore \
 	    rs \
@@ -113,10 +111,11 @@
         v7/cardview \
         v7/mediarouter \
         v7/palette \
-        v7/recyclerview \
         v8/renderscript \
         v13 \
-        v17/leanback
+        v17/leanback \
+        design \
+        percent
 
 #
 # A list of all source roots under frameworks/multidex.
@@ -131,13 +130,15 @@
 #
 FRAMEWORKS_SUPPORT_JAVA_SRC_DIRS := \
 	$(addprefix frameworks/support/,$(FRAMEWORKS_SUPPORT_SUBDIRS)) \
-	$(addprefix frameworks/,$(FRAMEWORKS_MULTIDEX_SUBDIRS))
+	$(addprefix frameworks/,$(FRAMEWORKS_MULTIDEX_SUBDIRS)) \
+	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-v7-recyclerview \
     android-support-multidex \
     android-support-multidex-instrumentation
 
diff --git a/core/phony_package.mk b/core/phony_package.mk
index b534335..30e198c 100644
--- a/core/phony_package.mk
+++ b/core/phony_package.mk
@@ -7,7 +7,7 @@
 
 include $(BUILD_SYSTEM)/base_rules.mk
 
-$(LOCAL_BUILT_MODULE): $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(LOCAL_BUILT_MODULE): $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(hide) echo "Fake: $@"
 	$(hide) mkdir -p $(dir $@)
 	$(hide) touch $@
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
index ba0e757..d3f9d1a 100644
--- a/core/prebuilt.mk
+++ b/core/prebuilt.mk
@@ -25,6 +25,10 @@
 ifneq ($(my_module_multilib),both)
 my_skip_non_preferred_arch := true
 endif # $(my_module_multilib)
+# For apps, we don't want to set up the prebuilt apk rule twice even if "LOCAL_MULTILIB := both".
+ifeq (APPS,$(LOCAL_MODULE_CLASS))
+my_skip_non_preferred_arch := true
+endif
 endif # $(my_module_arch_supported)
 
 ifndef my_skip_non_preferred_arch
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index bc6088f..f85b0b8 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -39,6 +39,15 @@
   # 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)
+  ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_STRIP_MODULE),)
+    # Strip but not try to add debuglink
+    LOCAL_STRIP_MODULE := no_debuglink
+  endif
+
+  ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_PACK_MODULE_RELOCATIONS),)
+    # Do not pack relocations by default
+    LOCAL_PACK_MODULE_RELOCATIONS := false
+  endif
 endif
 
 ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
@@ -59,19 +68,20 @@
 LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
 endif
 
-ifeq ($(LOCAL_STRIP_MODULE),true)
+ifneq ($(filter true no_debuglink,$(LOCAL_STRIP_MODULE) $(LOCAL_PACK_MODULE_RELOCATIONS)),)
   ifdef LOCAL_IS_HOST_MODULE
-    $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH))
+    $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH))
   endif
   ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
-    $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
+    $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
   endif
   ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
-    $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH))
+    $(error Cannot strip/pack scripts LOCAL_PATH=$(LOCAL_PATH))
   endif
   include $(BUILD_SYSTEM)/dynamic_binary.mk
   built_module := $(linked_module)
-else  # LOCAL_STRIP_MODULE not true
+
+else  # LOCAL_STRIP_MODULE and LOCAL_PACK_MODULE_RELOCATIONS not true
   include $(BUILD_SYSTEM)/base_rules.mk
   built_module := $(LOCAL_BUILT_MODULE)
 
@@ -96,19 +106,24 @@
 # of the shared libraries are determined.
 ifdef LOCAL_INSTALLED_MODULE
 ifdef LOCAL_SHARED_LIBRARIES
+my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
+# Extra shared libraries introduced by LOCAL_CXX_STL.
+include $(BUILD_SYSTEM)/cxx_stl_setup.mk
 $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
-  $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES))
+  $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
 
 # We also need the LOCAL_BUILT_MODULE dependency,
 # since we use -rpath-link which points to the built module's path.
-built_shared_libraries := \
+my_built_shared_libraries := \
     $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
     $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
-        $(LOCAL_SHARED_LIBRARIES)))
-$(LOCAL_BUILT_MODULE) : $(built_shared_libraries)
+        $(my_shared_libraries)))
+$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries)
 endif
 endif
 
+# We need to enclose the above export_includes and built_shared_libraries in
+# "LOCAL_STRIP_MODULE not true" because otherwise the rules are defined in dynamic_binary.mk.
 endif  # LOCAL_STRIP_MODULE not true
 
 ifeq ($(LOCAL_MODULE_CLASS),APPS)
@@ -180,19 +195,24 @@
 include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
 #######################################
 # Sign and align non-presigned .apks.
+$(built_module) : PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES := $(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES)
 $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
 	$(transform-prebuilt-to-target)
+ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
+	@# Only strip out files if we can re-sign the package.
 ifdef extracted_jni_libs
 	$(hide) zip -d $@ 'lib/*.so'  # strip embedded JNI libraries.
 endif
-ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
-	$(sign-package)
-endif
 ifdef LOCAL_DEX_PREOPT
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
 endif
+	$(sign-package)
+endif
+ifeq ($(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES),true)
+	$(uncompress-shared-libs)
+endif
 	$(align-package)
 
 ###############################
@@ -245,13 +265,6 @@
 else
 $(built_module) : $(my_prebuilt_src_file) | $(ACP)
 	$(transform-prebuilt-to-target)
-ifneq ($(prebuilt_module_is_a_library),)
-  ifneq ($(LOCAL_IS_HOST_MODULE),)
-	$(transform-host-ranlib-copy-hack)
-  else
-	$(transform-ranlib-copy-hack)
-  endif
-endif
 endif
 endif # LOCAL_MODULE_CLASS != APPS
 
@@ -289,6 +302,6 @@
 $(built_module) : $(common_javalib_jar)
 endif # TARGET JAVA_LIBRARIES
 
-$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
+$(built_module) : $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 
 my_prebuilt_src_file :=
diff --git a/core/product.mk b/core/product.mk
index f0fc921..46fad89 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -86,7 +86,6 @@
     PRODUCT_EXTRA_RECOVERY_KEYS \
     PRODUCT_PACKAGE_OVERLAYS \
     DEVICE_PACKAGE_OVERLAYS \
-    PRODUCT_TAGS \
     PRODUCT_SDK_ATREE_FILES \
     PRODUCT_SDK_ADDON_NAME \
     PRODUCT_SDK_ADDON_COPY_FILES \
@@ -97,9 +96,6 @@
     PRODUCT_DEFAULT_DEV_CERTIFICATE \
     PRODUCT_RESTRICT_VENDOR_FILES \
     PRODUCT_VENDOR_KERNEL_HEADERS \
-    PRODUCT_FACTORY_RAMDISK_MODULES \
-    PRODUCT_FACTORY_BUNDLE_MODULES \
-    PRODUCT_RUNTIMES \
     PRODUCT_BOOT_JARS \
     PRODUCT_SUPPORTS_VERITY \
     PRODUCT_OEM_PROPERTIES \
@@ -108,7 +104,6 @@
     PRODUCT_VERITY_SIGNING_KEY \
     PRODUCT_SYSTEM_VERITY_PARTITION \
     PRODUCT_VENDOR_VERITY_PARTITION \
-    PRODUCT_DEX_PREOPT_IMAGE_IN_DATA \
     PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
     PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
     PRODUCT_DEX_PREOPT_BOOT_FLAGS \
@@ -234,7 +229,6 @@
 	TARGET_DEVICE_KERNEL_HEADERS \
 	TARGET_PRODUCT_KERNEL_HEADERS \
 	TARGET_BOOTLOADER_BOARD_NAME \
-	TARGET_COMPRESS_MODULE_SYMBOLS \
 	TARGET_NO_BOOTLOADER \
 	TARGET_NO_KERNEL \
 	TARGET_NO_RECOVERY \
@@ -243,7 +237,6 @@
 	TARGET_PROVIDES_INIT_RC \
 	TARGET_CPU_ABI \
 	TARGET_CPU_ABI2 \
-	TARGET_CPU_SMP \
 
 
 _product_stash_var_list += \
@@ -258,6 +251,7 @@
 	BOARD_BOOTIMAGE_PARTITION_SIZE \
 	BOARD_RECOVERYIMAGE_PARTITION_SIZE \
 	BOARD_SYSTEMIMAGE_PARTITION_SIZE \
+	BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
 	BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
 	BOARD_USERDATAIMAGE_PARTITION_SIZE \
 	BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
@@ -273,6 +267,10 @@
 	WITH_DEXPREOPT \
 	WITH_DEXPREOPT_BOOT_IMG_ONLY
 
+_product_stash_var_list += \
+	GLOBAL_CFLAGS_NO_OVERRIDE \
+	GLOBAL_CPPFLAGS_NO_OVERRIDE \
+
 #
 # Stash values of the variables in _product_stash_var_list.
 # $(1): Renamed prefix
diff --git a/core/product_config.mk b/core/product_config.mk
index e7fa75e..5240ae7 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -248,36 +248,6 @@
 
 
 #############################################################################
-# TODO: Remove this hack once only 1 runtime is left.
-# Include the runtime product makefile based on the product's PRODUCT_RUNTIMES
-$(call clear-var-list, $(_product_var_list))
-
-# Set PRODUCT_RUNTIMES, allowing buildspec to override using OVERRIDE_RUNTIMES
-product_runtimes := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RUNTIMES))
-ifneq ($(OVERRIDE_RUNTIMES),)
-  $(info Overriding PRODUCT_RUNTIMES=$(product_runtimes) with $(OVERRIDE_RUNTIMES))
-  product_runtimes := $(OVERRIDE_RUNTIMES)
-endif
-$(foreach runtime, $(product_runtimes), $(eval include $(SRC_TARGET_DIR)/product/$(runtime).mk))
-$(foreach v, $(_product_var_list), $(if $($(v)),\
-    $(eval PRODUCTS.$(INTERNAL_PRODUCT).$(v) += $(sort $($(v))))))
-
-$(call clear-var-list, $(_product_var_list))
-# Now we can assign to PRODUCT_RUNTIMES
-PRODUCT_RUNTIMES := $(product_runtimes)
-product_runtimes :=
-
-PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES += persist.sys.dalvik.vm.lib.2=$(DALVIK_VM_LIB)
-
-ifeq ($(words $(PRODUCT_RUNTIMES)),1)
-  # If we only have one runtime, we can strip classes.dex by default during dex_preopt
-  DEX_PREOPT_DEFAULT := true
-else
-  # If we have more than one, we leave the classes.dex alone for post-boot analysis
-  DEX_PREOPT_DEFAULT := nostripping
-endif
-
-#############################################################################
 
 # A list of module names of BOOTCLASSPATH (jar files)
 PRODUCT_BOOT_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BOOT_JARS))
@@ -379,9 +349,6 @@
 DEVICE_PACKAGE_OVERLAYS := \
         $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))
 
-# An list of whitespace-separated words.
-PRODUCT_TAGS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_TAGS))
-
 # The list of product-specific kernel header dirs
 PRODUCT_VENDOR_KERNEL_HEADERS := \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_KERNEL_HEADERS)
@@ -401,10 +368,6 @@
 PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
     $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
 
-# If there is no room in /system for the image, place it in /data
-PRODUCT_DEX_PREOPT_IMAGE_IN_DATA := \
-    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_IMAGE_IN_DATA))
-
 PRODUCT_DEX_PREOPT_DEFAULT_FLAGS := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_DEFAULT_FLAGS))
 PRODUCT_DEX_PREOPT_BOOT_FLAGS := \
diff --git a/core/raw_executable.mk b/core/raw_executable.mk
deleted file mode 100644
index b64173a..0000000
--- a/core/raw_executable.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE_SUFFIX := 
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-
-include $(BUILD_SYSTEM)/binary.mk
-
-$(LOCAL_BUILT_MODULE) : PRIVATE_ELF_FILE := $(intermediates)/$(PRIVATE_MODULE).elf
-$(LOCAL_BUILT_MODULE) : PRIVATE_LIBS := `$(TARGET_CC) -mthumb-interwork -print-libgcc-file-name`
-
-$(all_objects) : PRIVATE_TARGET_PROJECT_INCLUDES :=
-$(all_objects) : PRIVATE_TARGET_C_INCLUDES :=
-$(all_objects) : PRIVATE_TARGET_GLOBAL_CFLAGS :=
-$(all_objects) : PRIVATE_TARGET_GLOBAL_CPPFLAGS :=
-
-$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
-	@$(mkdir -p $(dir $@)
-	@echo "target Linking: $(PRIVATE_MODULE)"
-	$(hide) $(TARGET_LD) \
-		$(addprefix --script ,$(PRIVATE_LINK_SCRIPT)) \
-		$(PRIVATE_RAW_EXECUTABLE_LDFLAGS) \
-		-o $(PRIVATE_ELF_FILE) \
-		$(PRIVATE_ALL_OBJECTS) \
-		--start-group $(PRIVATE_ALL_STATIC_LIBRARIES) --end-group \
-		$(PRIVATE_LIBS)
-	$(hide) $(TARGET_OBJCOPY) -O binary $(PRIVATE_ELF_FILE) $@
diff --git a/core/raw_static_library.mk b/core/raw_static_library.mk
deleted file mode 100644
index 14a404d..0000000
--- a/core/raw_static_library.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-
-LOCAL_RAW_STATIC_LIBRARY:=true
-
-include $(BUILD_SYSTEM)/static_library_internal.mk
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
index c01be37..2487fbb0 100644
--- a/core/shared_library_internal.mk
+++ b/core/shared_library_internal.mk
@@ -40,6 +40,8 @@
 
 # Define PRIVATE_ variables from global vars
 my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS)
+my_target_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT)
+my_target_libgcov := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV)
 my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC)
 my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC)
 my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_SO_O)
@@ -57,14 +59,20 @@
 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_LIBPROFILE_RT := $(my_target_libprofile_rt)
+$(linked_module): PRIVATE_TARGET_LIBGCOV := $(my_target_libgcov)
 $(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)
 $(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
 
-$(linked_module): $(all_objects) $(all_libraries) \
-                  $(LOCAL_ADDITIONAL_DEPENDENCIES) \
-                  $(my_target_crtbegin_so_o) $(my_target_crtend_so_o)
+$(linked_module): \
+        $(all_objects) \
+        $(all_libraries) \
+        $(my_target_crtbegin_so_o) \
+        $(my_target_crtend_so_o) \
+        $(LOCAL_MODULE_MAKEFILE) \
+        $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-o-to-shared-lib)
 
 endif  # skip_build_from_source
diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk
index 95d4159..f8a9f04 100644
--- a/core/target_test_internal.mk
+++ b/core/target_test_internal.mk
@@ -5,18 +5,11 @@
 LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING
 
 LOCAL_C_INCLUDES += external/gtest/include
-ifneq ($(filter libc++,$(LOCAL_SHARED_LIBRARIES)),)
-LOCAL_STATIC_LIBRARIES += libgtest_libc++ libgtest_main_libc++
-else
-LOCAL_STATIC_LIBRARIES += libgtest libgtest_main
 
 ifndef LOCAL_SDK_VERSION
-LOCAL_C_INCLUDES += bionic \
-                    bionic/libstdc++/include \
-                    external/stlport/stlport
-LOCAL_SHARED_LIBRARIES += libstlport
-LOCAL_STATIC_LIBRARIES += libstdc++
-endif
+LOCAL_STATIC_LIBRARIES += libgtest libgtest_main
+else
+LOCAL_STATIC_LIBRARIES += libgtest_ndk libgtest_main_ndk
 endif
 
 ifdef LOCAL_MODULE_PATH
diff --git a/core/tasks/check_boot_jars/check_boot_jars.py b/core/tasks/check_boot_jars/check_boot_jars.py
index 89d9ee8..5a0ec40 100755
--- a/core/tasks/check_boot_jars/check_boot_jars.py
+++ b/core/tasks/check_boot_jars/check_boot_jars.py
@@ -64,10 +64,10 @@
 def main(argv):
   if len(argv) < 2:
     print __doc__
-    sys.exit(1)
+    return 1
 
   if not LoadWhitelist(argv[0]):
-    sys.exit(1)
+    return 1
 
   passed = True
   for jar in argv[1:]:
@@ -80,4 +80,4 @@
 
 
 if __name__ == '__main__':
-  main(sys.argv[1:])
+  sys.exit(main(sys.argv[1:]))
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 2ce5dbc..23648f8 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -50,6 +50,10 @@
 	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 += \
@@ -61,7 +65,7 @@
 
 CTS_TEST_JAR_LIST := \
         cts-junit \
-	CtsJdwp
+        CtsJdwp
 
 # Depend on the full package paths rather than the phony targets to avoid
 # rebuilding the packages every time.
@@ -82,8 +86,11 @@
     $(eval $(call copy-one-file, $(built), $(installed)))\
     $(eval CTS_CASE_LIST_APKS += $(installed))))
 
+CTS_SHARED_LIBS := \
+	$(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX)
+
 DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
-$(cts_dir)/all_cts_files_stamp: $(CTS_CORE_CASES) $(CTS_TEST_CASES) $(CTS_CASE_LIST_APKS) $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(ACP) $(CTS_TEST_JAR_FILES)
+$(cts_dir)/all_cts_files_stamp: $(CTS_CORE_CASES) $(CTS_TEST_CASES) $(CTS_CASE_LIST_APKS) $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(ACP) $(CTS_TEST_JAR_FILES) $(CTS_SHARED_LIBS)
 # Make necessary directory for CTS
 	$(hide) mkdir -p $(TMP_DIR)
 	$(hide) mkdir -p $(PRIVATE_DIR)/docs
@@ -93,6 +100,7 @@
 # Copy executable and JARs to CTS directory
 	$(hide) $(ACP) -fp $(VMTESTSTF_JAR) $(PRIVATE_DIR)/repository/testcases
 	$(hide) $(ACP) -fp $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(PRIVATE_DIR)/tools
+	$(hide) $(call copy-files-with-structure, $(CTS_SHARED_LIBS),$(HOST_OUT)/,$(PRIVATE_DIR))
 # Change mode of the executables
 	$(foreach jar,$(CTS_TEST_JAR_LIST),$(call copy-testcase-jar,$(jar)))
 	$(foreach testcase,$(CTS_TEST_CASES),$(call copy-testcase,$(testcase)))
@@ -128,8 +136,10 @@
 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 := $(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
+GEN_CLASSPATH := \
+    $(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 \
@@ -154,6 +164,7 @@
 	$(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
@@ -161,7 +172,7 @@
 # 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 build/core/tasks/cts.mk | $(ACP)
+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)
@@ -317,6 +328,13 @@
 		$(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
diff --git a/core/tasks/factory_bundle.mk b/core/tasks/factory_bundle.mk
deleted file mode 100644
index 51531cb..0000000
--- a/core/tasks/factory_bundle.mk
+++ /dev/null
@@ -1,84 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-ifeq (,$(ONE_SHOT_MAKEFILE))
-ifneq ($(TARGET_BUILD_PDK),true)
-  TARGET_BUILD_FACTORY=true
-endif
-ifeq ($(TARGET_BUILD_FACTORY),true)
-
-# PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
-# <install_path> is relative to the staging directory for the bundle.
-# 
-# Only host modules can be installed here. 
-# (It's possible to relax this, but it's not needed and kind of tricky.  We'll need to add
-# a better way of specifying the class. Really the answer is to stop having modules with
-# duplicate names)
-#
-# You can also add files with PRODUCT_COPY_FILES if necessary.
-#
-# For example:
-# PRODUCT_FACTORY_BUNDLE_MODULES := \
-#     adb:adb fastboot:fastboot
-requested_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_BUNDLE_MODULES))
-
-root_dir := $(PRODUCT_OUT)/factory_bundle
-leaf := $(strip $(TARGET_PRODUCT))-factory_bundle-$(FILE_NAME_TAG)
-named_dir := $(PRODUCT_OUT)/$(leaf)
-tarball := $(PRODUCT_OUT)/$(leaf).tgz
-
-copied_files := \
-  $(foreach _fb_m, $(requested_modules), $(strip \
-    $(eval _fb_m_tuple := $(subst :, ,$(_fb_m))) \
-    $(eval _fb_m_name := $(word 1,$(_fb_m_tuple))) \
-    $(eval _fb_dests := $(wordlist 2,999,$(_fb_m_tuple))) \
-    $(eval _fb_m_built := $(filter $(HOST_OUT)/%, $(ALL_MODULES.$(_fb_m_name).BUILT))) \
-    $(if $(_fb_m_built),,$(warning no built file in requested_modules for '$(_fb_m_built)'))\
-    $(foreach _fb_f,$(_fb_dests),$(eval $(call copy-one-file,$(_fb_m_built),$(root_dir)/$(_fb_f))))\
-    $(addprefix $(root_dir)/,$(_fb_dests)) \
-    )) \
-  $(filter $(root_dir)/%, $(ALL_DEFAULT_INSTALLED_MODULES))
-
-ifneq (,$(strip $(copied_files)))
-
-#
-# These files are made by magic so we need to explicitly include them
-#
-$(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(root_dir)/build.prop))
-copied_files += $(root_dir)/build.prop
-
-$(eval $(call copy-one-file,$(PRODUCT_OUT)/factory_ramdisk.img,$(root_dir)/factory_ramdisk.img))
-copied_files += $(root_dir)/factory_ramdisk.img
-#
-# End magic
-#
-
-$(tarball): PRIVATE_ROOT_DIR := $(root_dir)
-$(tarball): PRIVATE_NAMED_DIR := $(named_dir)
-
-$(tarball): $(copied_files)
-	@echo "Tarball: $@"
-	$(hide) rm -rf $(PRIVATE_NAMED_DIR)
-	$(hide) ( cp -r $(PRIVATE_ROOT_DIR) $(PRIVATE_NAMED_DIR) \
-			&& tar cfz $@ -C $(dir $(PRIVATE_NAMED_DIR)) $(notdir $(PRIVATE_NAMED_DIR)) \
-			) && rm -rf $(PRIVATE_NAMED_DIR)
-
-INSTALLED_FACTORY_BUNDLE_TARGET := $(tarball)
-
-endif
-
-endif # TARGET_BUILD_PDK
-endif # ONE_SHOT_MAKEFILE
diff --git a/core/tasks/factory_ramdisk.mk b/core/tasks/factory_ramdisk.mk
deleted file mode 100644
index d65d931..0000000
--- a/core/tasks/factory_ramdisk.mk
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-ifeq (,$(ONE_SHOT_MAKEFILE))
-ifneq ($(TARGET_BUILD_PDK),true)
-  TARGET_BUILD_FACTORY=true
-endif
-ifeq ($(TARGET_BUILD_FACTORY),true)
-
-# PRODUCT_FACTORY_RAMDISK_MODULES consists of "<module_name>:<install_path>[:<install_path>...]" tuples.
-# <install_path> is relative to TARGET_FACTORY_RAMDISK_OUT.
-# We can have multiple <install_path>s because multiple modules may have the same name.
-# For example:
-# PRODUCT_FACTORY_RAMDISK_MODULES := \
-#     toolbox:system/bin/toolbox adbd:sbin/adbd adb:system/bin/adb
-factory_ramdisk_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FACTORY_RAMDISK_MODULES))
-ifneq (,$(factory_ramdisk_modules))
-
-# A module name may end up in multiple modules (so multiple built files)
-# with the same name.
-# This function selects the module built file based on the install path.
-# $(1): the dest install path
-# $(2): the module built files
-define install-one-factory-ramdisk-module
-$(eval _iofrm_suffix := $(suffix $(1))) \
-$(if $(_iofrm_suffix), \
-    $(eval _iofrm_pattern := %$(_iofrm_suffix)), \
-    $(eval _iofrm_pattern := %$(notdir $(1)))) \
-$(eval _iofrm_src := $(filter $(_iofrm_pattern),$(2))) \
-$(if $(filter 1,$(words $(_iofrm_src))), \
-    $(eval _fulldest := $(TARGET_FACTORY_RAMDISK_OUT)/$(1)) \
-    $(eval $(call copy-one-file,$(_iofrm_src),$(_fulldest))) \
-    $(eval INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES += $(_fulldest)), \
-    $(warning Warning: Cannot find built file in "$(2)" for "$(1)") \
-    )
-endef
-
-INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES :=
-$(foreach m, $(factory_ramdisk_modules), \
-    $(eval _fr_m_tuple := $(subst :, ,$(m))) \
-    $(eval _fr_m_name := $(word 1,$(_fr_m_tuple))) \
-    $(eval _fr_dests := $(wordlist 2,999,$(_fr_m_tuple))) \
-    $(eval _fr_m_built := $(filter $(PRODUCT_OUT)/%, $(ALL_MODULES.$(_fr_m_name).BUILT))) \
-    $(foreach d,$(_fr_dests),$(call install-one-factory-ramdisk-module,$(d),$(_fr_m_built))) \
-    )
-endif
-
-# Files may also be installed via PRODUCT_COPY_FILES, PRODUCT_PACKAGES etc.
-INTERNAL_FACTORY_RAMDISK_FILES := $(filter $(TARGET_FACTORY_RAMDISK_OUT)/%, \
-    $(ALL_DEFAULT_INSTALLED_MODULES))
-
-ifneq (,$(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES)$(INTERNAL_FACTORY_RAMDISK_FILES))
-
-# These files are made by magic in build/core/Makefile so we need to explicitly include them
-$(eval $(call copy-one-file,$(TARGET_OUT)/build.prop,$(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop))
-INTERNAL_FACTORY_RAMDISK_FILES += $(TARGET_FACTORY_RAMDISK_OUT)/system/build.prop
-
-BUILT_FACTORY_RAMDISK_FS := $(PRODUCT_OUT)/factory_ramdisk.gz
-BUILT_FACTORY_RAMDISK_TARGET := $(PRODUCT_OUT)/factory_ramdisk.img
-
-INSTALLED_FACTORY_RAMDISK_FS := $(BUILT_FACTORY_RAMDISK_FS)
-$(INSTALLED_FACTORY_RAMDISK_FS) : $(MKBOOTFS) \
-    $(INTERNAL_FACTORY_RAMDISK_EXTRA_MODULES_FILES) $(INTERNAL_FACTORY_RAMDISK_FILES) | $(MINIGZIP)
-	$(call pretty,"Target factory ram disk file system: $@")
-	$(hide) $(MKBOOTFS) $(TARGET_FACTORY_RAMDISK_OUT) | $(MINIGZIP) > $@
-
-TARGET_RAMDISK_KERNEL := $(INSTALLED_KERNEL_TARGET)
-INSTALLED_FACTORY_RAMDISK_TARGET := $(BUILT_FACTORY_RAMDISK_TARGET)
-ifneq (,$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT))
-  RAMDISK_CMDLINE := --cmdline "$(BOARD_KERNEL_CMDLINE_FACTORY_BOOT)"
-else
-  RAMDISK_CMDLINE :=
-endif
-$(INSTALLED_FACTORY_RAMDISK_TARGET) : $(MKBOOTIMG) $(TARGET_RAMDISK_KERNEL) $(INSTALLED_FACTORY_RAMDISK_FS)
-	$(call pretty,"Target factory ram disk img format: $@")
-	$(MKBOOTIMG) --kernel $(TARGET_RAMDISK_KERNEL) --ramdisk $(INSTALLED_FACTORY_RAMDISK_FS) \
-            --base $(BOARD_KERNEL_BASE) $(BOARD_MKBOOTIMG_ARGS) $(RAMDISK_CMDLINE) --output $@
-
-endif
-
-endif # TARGET_BUILD_PDK
-endif # ONE_SHOT_MAKEFILE
diff --git a/core/tasks/product-graph.mk b/core/tasks/product-graph.mk
index fcec277..db2cf71 100644
--- a/core/tasks/product-graph.mk
+++ b/core/tasks/product-graph.mk
@@ -61,7 +61,7 @@
 $(hide) echo \"$(1)\" [ \
 label=\"$(dir $(1))\\n$(notdir $(1))\\n\\n$(subst $(close_parenthesis),,$(subst $(open_parethesis),,$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)))\\n$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)\" \
 $(if $(filter $(1),$(PRIVATE_PRODUCTS_FILTER)), style=\"filled\" fillcolor=\"#FFFDB0\",) \
-fontcolor=\"darkblue\" href=\"products/$(1).html\" \
+colorscheme=\"svg\" fontcolor=\"darkblue\" href=\"products/$(1).html\" \
 ] >> $(2)
 
 endef
@@ -109,7 +109,6 @@
 	$(hide) echo 'PRODUCT_EXTRA_RECOVERY_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_EXTRA_RECOVERY_KEYS)' >> $$@
 	$(hide) echo 'PRODUCT_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGE_OVERLAYS)' >> $$@
 	$(hide) echo 'DEVICE_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).DEVICE_PACKAGE_OVERLAYS)' >> $$@
-	$(hide) echo 'PRODUCT_TAGS=$$(PRODUCTS.$(strip $(1)).PRODUCT_TAGS)' >> $$@
 	$(hide) echo 'PRODUCT_SDK_ADDON_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_NAME)' >> $$@
 	$(hide) echo 'PRODUCT_SDK_ADDON_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_FILES)' >> $$@
 	$(hide) echo 'PRODUCT_SDK_ADDON_COPY_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_MODULES)' >> $$@
@@ -117,7 +116,6 @@
 	$(hide) echo 'PRODUCT_DEFAULT_WIFI_CHANNELS=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_WIFI_CHANNELS)' >> $$@
 	$(hide) echo 'PRODUCT_DEFAULT_DEV_CERTIFICATE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_DEV_CERTIFICATE)' >> $$@
 	$(hide) echo 'PRODUCT_RESTRICT_VENDOR_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_RESTRICT_VENDOR_FILES)' >> $$@
-	$(hide) echo 'PRODUCT_FACTORY_RAMDISK_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_FACTORY_RAMDISK_MODULES)' >> $$@
 	$(hide) echo 'PRODUCT_VENDOR_KERNEL_HEADERS=$$(PRODUCTS.$(strip $(1)).PRODUCT_VENDOR_KERNEL_HEADERS)' >> $$@
 
 $(call product-debug-filename, $(p)): \
diff --git a/envsetup.sh b/envsetup.sh
index d80e95c..bec6993 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -14,9 +14,16 @@
 - ggrep:   Greps on all local Gradle files.
 - jgrep:   Greps on all local Java files.
 - resgrep: Greps on all local res/*.xml files.
+- mangrep: Greps on all local AndroidManifest.xml files.
+- sepgrep: Greps on all local sepolicy files.
 - sgrep:   Greps on all local source files.
 - godir:   Go to the directory containing a file.
 
+Environemnt options:
+- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that
+                 ASAN_OPTIONS=detect_leaks=0 will be set by default until the
+                 build is leak-check clean.
+
 Look at the source to view more functions. The complete list is:
 EOF
     T=$(gettop)
@@ -231,6 +238,7 @@
     export ANDROID_BUILD_TOP=$(gettop)
     # With this environment variable new GCC can apply colors to warnings/errors
     export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+    export ASAN_OPTIONS=detect_leaks=0
 }
 
 function set_sequence_number()
@@ -664,6 +672,7 @@
         $DRV make -C $T -f build/core/main.mk $@
     else
         echo "Couldn't locate the top of the tree.  Try setting TOP."
+        return 1
     fi
 }
 
@@ -702,8 +711,10 @@
         local M=`echo $M|sed 's:'$T'/::'`
         if [ ! "$T" ]; then
             echo "Couldn't locate the top of the tree.  Try setting TOP."
+            return 1
         elif [ ! "$M" ]; then
             echo "Couldn't locate a makefile from the current directory."
+            return 1
         else
             for ARG in $@; do
                 case $ARG in
@@ -766,6 +777,7 @@
         ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
     else
         echo "Couldn't locate the top of the tree.  Try setting TOP."
+        return 1
     fi
 }
 
@@ -778,6 +790,7 @@
   else
     if [ ! "$T" ]; then
       echo "Couldn't locate the top of the tree.  Try setting TOP."
+      return 1
     fi
     local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
     $DRV make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD"
@@ -817,6 +830,7 @@
     $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS"
   else
     echo "Couldn't locate the top of the tree.  Try setting TOP."
+    return 1
   fi
 }
 
@@ -1027,18 +1041,6 @@
     fi
 }
 
-function gdbwrapper()
-{
-    local GDB_CMD="$1"
-    shift 1
-    $GDB_CMD -x "$@"
-}
-
-function get_symbols_directory()
-{
-    echo $(get_abs_build_var TARGET_OUT_UNSTRIPPED)
-}
-
 # Read the ELF header from /proc/$PID/exe to determine if the process is
 # 64-bit.
 function is64bit()
@@ -1055,251 +1057,6 @@
     fi
 }
 
-function adb_get_product_device() {
-  echo `adb shell getprop ro.product.device | sed s/.$//`
-}
-
-# returns 0 when process is not traced
-function adb_get_traced_by() {
-  echo `adb shell cat /proc/$1/status | grep -e "^TracerPid:" | sed "s/^TracerPid:\t//" | sed s/.$//`
-}
-
-function gdbclient() {
-  # TODO:
-  # 1. Check for ANDROID_SERIAL/multiple devices
-  local PROCESS_NAME="n/a"
-  local PID=$1
-  local PORT=5039
-  if [ -z "$PID" ]; then
-    echo "Usage: gdbclient <pid|processname> [port number]"
-    return -1
-  fi
-  local DEVICE=$(adb_get_product_device)
-
-  if [ -z "$DEVICE" ]; then
-    echo "Error: Unable to get device name. Please check if device is connected and ANDROID_SERIAL is set."
-    return -2
-  fi
-
-  if [ -n "$2" ]; then
-    PORT=$2
-  fi
-
-  local ROOT=$(gettop)
-  if [ -z "$ROOT" ]; then
-    # This is for the situation with downloaded symbols (from the build server)
-    # we check if they are available.
-    ROOT=`realpath .`
-  fi
-
-  local OUT_ROOT="$ROOT/out/target/product/$DEVICE"
-  local SYMBOLS_DIR="$OUT_ROOT/symbols"
-
-  if [ ! -d $SYMBOLS_DIR ]; then
-    echo "Error: couldn't find symbols: $SYMBOLS_DIR does not exist or is not a directory."
-    return -3
-  fi
-
-  # let's figure out which executable we are about to debug
-
-  # check if user specified a name -> resolve to pid
-  if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
-    PROCESS_NAME=$PID
-    PID=$(pid --exact $PROCESS_NAME)
-    if [ -z "$PID" ]; then
-      echo "Error: couldn't resolve pid by process name: $PROCESS_NAME"
-      return -4
-    fi
-  fi
-
-  local EXE=`adb shell readlink /proc/$PID/exe | sed s/.$//`
-  # TODO: print error in case there is no such pid
-  local LOCAL_EXE_PATH=$SYMBOLS_DIR$EXE
-
-  if [ ! -f $LOCAL_EXE_PATH ]; then
-    echo "Error: unable to find symbols for executable $EXE: file $LOCAL_EXE_PATH does not exist"
-    return -5
-  fi
-
-  local USE64BIT=""
-
-  if [[ "$(file $LOCAL_EXE_PATH)" =~ 64-bit ]]; then
-    USE64BIT="64"
-  fi
-
-  local GDB=
-  local GDB64=
-  local CPU_ABI=`adb shell getprop ro.product.cpu.abilist | sed s/.$//`
-  # TODO: we assume these are available via $PATH
-  if [[ $CPU_ABI =~ (^|,)arm64 ]]; then
-    GDB=arm-linux-androideabi-gdb
-    GDB64=aarch64-linux-android-gdb
-  elif [[ $CPU_ABI =~ (^|,)arm ]]; then
-    GDB=arm-linux-androideabi-gdb
-  elif [[ $CPU_ABI =~ (^|,)x86_64 ]]; then
-    GDB=x86_64-linux-androideabi-gdb
-  elif [[ $CPU_ABI =~ (^|,)x86 ]]; then
-    GDB=x86_64-linux-androideabi-gdb
-  elif [[ $CPU_ABI =~ (^|,)mips64 ]]; then
-    GDB=mipsel-linux-android-gdb
-    GDB64=mips64el-linux-android-gdb
-  elif [[ $CPU_ABI =~ (^|,)mips ]]; then
-    GDB=mipsel-linux-android-gdb
-  else
-    echo "Error: unrecognized cpu.abilist: $CPU_ABI"
-    return -6
-  fi
-
-  # TODO: check if tracing process is gdbserver and not some random strace...
-  if [ $(adb_get_traced_by $PID) -eq 0 ]; then
-    # start gdbserver
-    echo "Starting gdbserver..."
-    # TODO: check if adb is already listening $PORT
-    # to avoid unnecessary calls
-    echo ". adb forward for port=$PORT..."
-    adb forward tcp:$PORT tcp:$PORT
-    echo ". starting gdbserver to attach to pid=$PID..."
-    adb shell gdbserver$USE64BIT :$PORT --attach $PID &
-    echo ". give it couple of seconds to start..."
-    sleep 2
-    echo ". done"
-  else
-    echo "It looks like gdbserver is already attached to $PID (process is traced), trying to connect to it using local port=$PORT"
-  fi
-
-  local OUT_SO_SYMBOLS=$SYMBOLS_DIR/system/lib$USE64BIT
-  local OUT_VENDOR_SO_SYMBOLS=$SYMBOLS_DIR/vendor/lib$USE64BIT
-  local ART_CMD=""
-
-  echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $SYMBOLS_DIR"
-  echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl"
-  local DALVIK_GDB_SCRIPT=$ROOT/development/scripts/gdb/dalvik.gdb
-  if [ -f $DALVIK_GDB_SCRIPT ]; then
-    echo >>"$OUT_ROOT/gdbclient.cmds" "source $DALVIK_GDB_SCRIPT"
-    ART_CMD="art-on"
-  else
-    echo "Warning: couldn't find $DALVIK_GDB_SCRIPT - ART debugging options will not be available"
-  fi
-  echo >>"$OUT_ROOT/gdbclient.cmds" "target remote :$PORT"
-  if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$ ]]; then
-    echo >> "$OUT_ROOT/gdbclient.cmds" $ART_CMD
-  fi
-
-  echo >>"$OUT_ROOT/gdbclient.cmds" ""
-
-  local WHICH_GDB=$GDB
-
-  if [ -n "$USE64BIT" -a -n "$GDB64" ]; then
-    WHICH_GDB=$GDB64
-  fi
-
-  gdbwrapper $WHICH_GDB "$OUT_ROOT/gdbclient.cmds" "$LOCAL_EXE_PATH"
-}
-
-# gdbclient now determines whether the user wants to debug a 32-bit or 64-bit
-# executable, set up the approriate gdbserver, then invokes the proper host
-# gdb.
-function gdbclient_old()
-{
-   local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
-   local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
-   local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
-   local OUT_VENDOR_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED)
-   local OUT_EXE_SYMBOLS=$(get_symbols_directory)
-   local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
-   local ARCH=$(get_build_var TARGET_ARCH)
-   local GDB
-   case "$ARCH" in
-       arm) GDB=arm-linux-androideabi-gdb;;
-       arm64) GDB=arm-linux-androideabi-gdb; GDB64=aarch64-linux-android-gdb;;
-       mips|mips64) GDB=mips64el-linux-android-gdb;;
-       x86) GDB=x86_64-linux-android-gdb;;
-       x86_64) GDB=x86_64-linux-android-gdb;;
-       *) echo "Unknown arch $ARCH"; return 1;;
-   esac
-
-   if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
-       local EXE="$1"
-       if [ "$EXE" ] ; then
-           EXE=$1
-           if [[ $EXE =~ ^[^/].* ]] ; then
-               EXE="system/bin/"$EXE
-           fi
-       else
-           EXE="app_process"
-       fi
-
-       local PORT="$2"
-       if [ "$PORT" ] ; then
-           PORT=$2
-       else
-           PORT=":5039"
-       fi
-
-       local PID="$3"
-       if [ "$PID" ] ; then
-           if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
-               PID=`pid $3`
-               if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
-                   # that likely didn't work because of returning multiple processes
-                   # try again, filtering by root processes (don't contain colon)
-                   PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'`
-                   if [[ ! "$PID" =~ ^[0-9]+$ ]]
-                   then
-                       echo "Couldn't resolve '$3' to single PID"
-                       return 1
-                   else
-                       echo ""
-                       echo "WARNING: multiple processes matching '$3' observed, using root process"
-                       echo ""
-                   fi
-               fi
-           fi
-           adb forward "tcp$PORT" "tcp$PORT"
-           local USE64BIT="$(is64bit $PID)"
-           adb shell gdbserver$USE64BIT $PORT --attach $PID &
-           sleep 2
-       else
-               echo ""
-               echo "If you haven't done so already, do this first on the device:"
-               echo "    gdbserver $PORT /system/bin/$EXE"
-                   echo " or"
-               echo "    gdbserver $PORT --attach <PID>"
-               echo ""
-       fi
-
-       OUT_SO_SYMBOLS=$OUT_SO_SYMBOLS$USE64BIT
-       OUT_VENDOR_SO_SYMBOLS=$OUT_VENDOR_SO_SYMBOLS$USE64BIT
-
-       echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
-       echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl"
-       echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb"
-       echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
-       # Enable special debugging for ART processes.
-       if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$ ]]; then
-          echo >> "$OUT_ROOT/gdbclient.cmds" "art-on"
-       fi
-       echo >>"$OUT_ROOT/gdbclient.cmds" ""
-
-       local WHICH_GDB=
-       # 64-bit exe found
-       if [ "$USE64BIT" != "" ] ; then
-           WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB64
-       # 32-bit exe / 32-bit platform
-       elif [ "$(get_build_var TARGET_2ND_ARCH)" = "" ]; then
-           WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB
-       # 32-bit exe / 64-bit platform
-       else
-           WHICH_GDB=$ANDROID_TOOLCHAIN_2ND_ARCH/$GDB
-       fi
-
-       gdbwrapper $WHICH_GDB "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
-  else
-       echo "Unable to determine build system output dir."
-   fi
-
-}
-
 case `uname -s` in
     Darwin)
         function sgrep()
@@ -1333,7 +1090,7 @@
 
 function cgrep()
 {
-    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep --color -n "$@"
+    find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | xargs -0 grep --color -n "$@"
 }
 
 function resgrep()
@@ -1631,7 +1388,7 @@
     \cd $T/$pathname
 }
 
-# Force JAVA_HOME to point to java 1.7 or java 1.6  if it isn't already set.
+# Force JAVA_HOME to point to java 1.7 if it isn't already set.
 #
 # Note that the MacOS path for java 1.7 includes a minor revision number (sigh).
 # For some reason, installing the JDK doesn't make it show up in the
@@ -1648,25 +1405,14 @@
     fi
 
     if [ ! "$JAVA_HOME" ]; then
-      if [ -n "$LEGACY_USE_JAVA6" ]; then
-        case `uname -s` in
-            Darwin)
-                export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
-                ;;
-            *)
-                export JAVA_HOME=/usr/lib/jvm/java-6-sun
-                ;;
-        esac
-      else
-        case `uname -s` in
-            Darwin)
-                export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
-                ;;
-            *)
-                export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
-                ;;
-        esac
-      fi
+      case `uname -s` in
+          Darwin)
+              export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
+              ;;
+          *)
+              export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
+              ;;
+      esac
 
       # Keep track of the fact that we set JAVA_HOME ourselves, so that
       # we can change it on the next envsetup.sh, if required.
@@ -1702,11 +1448,21 @@
     local hours=$(($tdiff / 3600 ))
     local mins=$((($tdiff % 3600) / 60))
     local secs=$(($tdiff % 60))
+    local ncolors=$(tput colors 2>/dev/null)
+    if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
+        color_failed="\e[0;31m"
+        color_success="\e[0;32m"
+        color_reset="\e[00m"
+    else
+        color_failed=""
+        color_success=""
+        color_reset=""
+    fi
     echo
     if [ $ret -eq 0 ] ; then
-        echo -n -e "#### make completed successfully "
+        echo -n -e "${color_success}#### make completed successfully "
     else
-        echo -n -e "#### make failed to build some targets "
+        echo -n -e "${color_failed}#### make failed to build some targets "
     fi
     if [ $hours -gt 0 ] ; then
         printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
@@ -1715,13 +1471,11 @@
     elif [ $secs -gt 0 ] ; then
         printf "(%s seconds)" $secs
     fi
-    echo -e " ####"
+    echo -e " ####${color_reset}"
     echo
     return $ret
 }
 
-
-
 if [ "x$SHELL" != "x/bin/bash" ]; then
     case `ps -o command -p $$` in
         *bash*)
@@ -1733,8 +1487,8 @@
 fi
 
 # Execute the contents of any vendorsetup.sh files we can find.
-for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
-         `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
+for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
+         `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
 do
     echo "including $f"
     . $f
diff --git a/libs/host/Android.mk b/libs/host/Android.mk
index c67afbb..cab878b 100644
--- a/libs/host/Android.mk
+++ b/libs/host/Android.mk
@@ -1,5 +1,6 @@
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_SRC_FILES:= \
     CopyFile.c
@@ -20,6 +21,8 @@
 # acp to install libhost.
 LOCAL_ACP_UNAVAILABLE:= true
 
+LOCAL_ADDRESS_SANITIZER := false
+
 include $(BUILD_HOST_STATIC_LIBRARY)
 
 # Include toolchain prebuilt modules if they exist.
diff --git a/libs/host/CopyFile.c b/libs/host/CopyFile.c
index ca52565..855a565 100644
--- a/libs/host/CopyFile.c
+++ b/libs/host/CopyFile.c
@@ -28,8 +28,9 @@
 #  define  mkdir(path,mode)   _mkdir(path)
 #endif
 
-#ifndef HAVE_SYMLINKS
-#  define  lstat              stat
+#if defined(_WIN32)
+#  define S_ISLNK(s) 0
+#  define lstat stat
 #  ifndef EACCESS   /* seems to be missing from the Mingw headers */
 #    define  EACCESS            13
 #  endif
@@ -68,15 +69,13 @@
  */
 static bool isHiresMtime(const struct stat* pSrcStat)
 {
-#if HAVE_STAT_ST_MTIM
-#if defined(MACOSX_RSRC)
+#if defined(__CYGWIN__) || defined(__MINGW32__)
+  return 0;
+#elif defined(MACOSX_RSRC)
     return pSrcStat->st_mtimespec.tv_nsec > 0;
 #else
     return pSrcStat->st_mtim.tv_nsec > 0;
 #endif
-#else
-    return 0;
-#endif
 }
 
 /*
@@ -339,7 +338,6 @@
 }
 
 
-#ifdef HAVE_SYMLINKS
 /*
  * Copy a symlink.  This only happens if we're in "no derefence" mode,
  * in which we copy the links rather than the files that are pointed at.
@@ -348,6 +346,9 @@
  * we want to throw it out and replace it.  If it's not a symlink, we
  * need to trash it so we can create one.
  */
+#if defined(_WIN32)
+extern int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options) __attribute__((error("no symlinks on Windows")));
+#else
 static int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options)
 {
     struct stat dstStat;
@@ -422,7 +423,7 @@
 
     return 0;
 }
-#endif /* HAVE_SYMLINKS */
+#endif
 
 /*
  * Copy the contents of one directory to another.  Both "src" and "dst"
@@ -618,10 +619,8 @@
         } else {
             retVal = copyDirectory(src, dst, &srcStat, options);
         }
-#ifdef HAVE_SYMLINKS
     } else if (S_ISLNK(srcStat.st_mode)) {
         retVal = copySymlink(src, dst, &srcStat, options);
-#endif		
     } else if (S_ISREG(srcStat.st_mode)) {
         retVal = copyRegular(src, dst, &srcStat, options);
     } else {
diff --git a/libs/host/list.java b/libs/host/list.java
deleted file mode 100644
index 30546e3..0000000
--- a/libs/host/list.java
+++ /dev/null
@@ -1,35 +0,0 @@
-import java.io.*;
-
-public class list {
-    private static char nibble(int c) {
-        return (char)(c < 10 ? ('0' + c) : ('a' + (c-10)));
-    }
-    public static void main(String[] argv)
-    {
-        ByteArrayOutputStream stream = new ByteArrayOutputStream(100);
-        OutputStreamWriter writer = null;
-        try {
-            writer = new OutputStreamWriter(stream, "utf-8");
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace(System.err);
-        }
-
-        int n = Integer.parseInt(argv[1], 16);
-        try {
-            writer.write(n);
-            writer.close();
-        } catch (IOException e) {
-            e.printStackTrace(System.err);
-        }
-
-        byte[] array = stream.toByteArray();
-
-        System.out.print("        case '" + argv[0] + "':   return \"");
-        for (int i=0; i<array.length; i++) {
-            int b = array[i];
-            System.out.print("\\x" + nibble((b >> 4) & 0x0f) + nibble(b & 0xf));
-        }
-        System.out.println("\";");
-    }
-}
-
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index 656b643..4e5504e 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -76,17 +76,6 @@
 TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
 
 BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
-BOARD_SEPOLICY_UNION += \
-        bootanim.te \
-        device.te \
-        domain.te \
-        file.te \
-        file_contexts \
-        qemud.te \
-        rild.te \
-        shell.te \
-        surfaceflinger.te \
-        system_server.te
 
 ifeq ($(TARGET_PRODUCT),sdk)
   # include an expanded selection of fonts for the SDK.
diff --git a/target/board/generic/device.mk b/target/board/generic/device.mk
index 06a7d8a..e56a4d1 100644
--- a/target/board/generic/device.mk
+++ b/target/board/generic/device.mk
@@ -30,8 +30,3 @@
     frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
     device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
     hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
-
-PRODUCT_PACKAGES := \
-    audio.primary.goldfish \
-    power.goldfish \
-    vibrator.goldfish
diff --git a/target/board/generic/sepolicy/device.te b/target/board/generic/sepolicy/device.te
index e4af13c..d129441 100644
--- a/target/board/generic/sepolicy/device.te
+++ b/target/board/generic/sepolicy/device.te
@@ -1 +1 @@
-type qemu_device, dev_type;
+type qemu_device, dev_type, mlstrustedobject;
diff --git a/target/board/generic/sepolicy/file_contexts b/target/board/generic/sepolicy/file_contexts
index f204cde..444a47f 100644
--- a/target/board/generic/sepolicy/file_contexts
+++ b/target/board/generic/sepolicy/file_contexts
@@ -1,4 +1,9 @@
+/dev/block/mtdblock0       u:object_r:system_block_device:s0
+/dev/block/mtdblock1       u:object_r:userdata_block_device:s0
+/dev/block/mtdblock2       u:object_r:cache_block_device:s0
 /dev/qemu_.*		u:object_r:qemu_device:s0
 /dev/socket/qemud	u:object_r:qemud_socket:s0
 /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/bin/qemu-props	     u:object_r:qemu_props_exec:s0
diff --git a/target/board/generic/sepolicy/goldfish_logcat.te b/target/board/generic/sepolicy/goldfish_logcat.te
new file mode 100644
index 0000000..a785355
--- /dev/null
+++ b/target/board/generic/sepolicy/goldfish_logcat.te
@@ -0,0 +1,10 @@
+# goldfish-logcat service:  runs logcat -Q
+type goldfish_logcat, domain;
+
+domain_auto_trans(init, logcat_exec, goldfish_logcat)
+
+# Read from logd.
+read_logd(goldfish_logcat)
+
+# Write to /dev/ttyS2
+allow goldfish_logcat serial_device:chr_file { write open };
diff --git a/target/board/generic/sepolicy/goldfish_setup.te b/target/board/generic/sepolicy/goldfish_setup.te
new file mode 100644
index 0000000..584731e
--- /dev/null
+++ b/target/board/generic/sepolicy/goldfish_setup.te
@@ -0,0 +1,18 @@
+# goldfish-setup service: runs init.goldfish.sh script
+type goldfish_setup, domain;
+type goldfish_setup_exec, exec_type, file_type;
+
+init_daemon_domain(goldfish_setup)
+
+# Inherit open file to shell (interpreter) for script.
+allow goldfish_setup shell_exec:file read;
+
+# Run ifconfig, route commands to configure interfaces and routes.
+allow goldfish_setup system_file:file execute_no_trans;
+allow goldfish_setup self:capability { net_admin net_raw };
+allow goldfish_setup self:udp_socket create_socket_perms;
+
+# Set net.eth0.dns*, debug.sf.nobootanimation
+unix_socket_connect(goldfish_setup, property, init)
+allow goldfish_setup system_prop:property_service set;
+allow goldfish_setup debug_prop:property_service set;
diff --git a/target/board/generic/sepolicy/property.te b/target/board/generic/sepolicy/property.te
new file mode 100644
index 0000000..b3d15f8
--- /dev/null
+++ b/target/board/generic/sepolicy/property.te
@@ -0,0 +1 @@
+type qemu_prop, property_type;
diff --git a/target/board/generic/sepolicy/property_contexts b/target/board/generic/sepolicy/property_contexts
new file mode 100644
index 0000000..5f741f8
--- /dev/null
+++ b/target/board/generic/sepolicy/property_contexts
@@ -0,0 +1 @@
+qemu.                   u:object_r:qemu_prop:s0
diff --git a/target/board/generic/sepolicy/qemu_props.te b/target/board/generic/sepolicy/qemu_props.te
new file mode 100644
index 0000000..05c7461
--- /dev/null
+++ b/target/board/generic/sepolicy/qemu_props.te
@@ -0,0 +1,9 @@
+# qemu-props service:  Sets system properties on boot.
+type qemu_props, domain;
+type qemu_props_exec, exec_type, file_type;
+
+init_daemon_domain(qemu_props)
+
+# Set properties.
+unix_socket_connect(qemu_props, property, init)
+allow qemu_props { qemu_prop dalvik_prop config_prop }:property_service set;
diff --git a/target/board/generic/sepolicy/qemud.te b/target/board/generic/sepolicy/qemud.te
index 4ff02ec..41f2065 100644
--- a/target/board/generic/sepolicy/qemud.te
+++ b/target/board/generic/sepolicy/qemud.te
@@ -3,4 +3,6 @@
 type qemud_exec, exec_type, file_type;
 
 init_daemon_domain(qemud)
-unconfined_domain(qemud)
+
+# Access /dev/ttyS1.
+allow qemud serial_device:chr_file rw_file_perms;
diff --git a/target/board/generic_arm64/device.mk b/target/board/generic_arm64/device.mk
index 11a6a31..9647a4e 100644
--- a/target/board/generic_arm64/device.mk
+++ b/target/board/generic_arm64/device.mk
@@ -30,6 +30,6 @@
     frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
     device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml
 
-PRODUCT_PACKAGES := \
-    audio.primary.goldfish \
-    vibrator.goldfish
+# Adjust the Dalvik heap to be appropriate for a tablet.
+$(call inherit-product-if-exists, frameworks/base/build/tablet-dalvik-heap.mk)
+$(call inherit-product-if-exists, frameworks/native/build/tablet-dalvik-heap.mk)
diff --git a/target/board/generic_armv5/BoardConfig.mk b/target/board/generic_armv5/BoardConfig.mk
index 95fb559..016937a 100644
--- a/target/board/generic_armv5/BoardConfig.mk
+++ b/target/board/generic_armv5/BoardConfig.mk
@@ -19,6 +19,5 @@
 TARGET_ARCH_VARIANT := armv5te
 TARGET_CPU_ABI := armeabi
 TARGET_CPU_ABI2 :=
-ARCH_ARM_HAVE_TLS_REGISTER := false
 
 WITH_DEXPREOPT := false
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
index 0431c09..33443ed 100644
--- a/target/board/generic_mips/BoardConfig.mk
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -28,6 +28,9 @@
 endif
 TARGET_CPU_ABI  := mips
 
+# Make TARGET_CPU_VARIANT the same as TARGET_ARCH_VARIANT
+TARGET_CPU_VARIANT := $(TARGET_ARCH_VARIANT)
+
 HAVE_HTC_AUDIO_DRIVER := true
 BOARD_USES_GENERIC_AUDIO := true
 
@@ -58,14 +61,3 @@
 TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
 
 BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
-BOARD_SEPOLICY_UNION += \
-        bootanim.te \
-        device.te \
-        domain.te \
-        file.te \
-        file_contexts \
-        qemud.te \
-        rild.te \
-        shell.te \
-        surfaceflinger.te \
-        system_server.te
diff --git a/target/board/generic_mips/device.mk b/target/board/generic_mips/device.mk
index 590f422..06a7d8a 100644
--- a/target/board/generic_mips/device.mk
+++ b/target/board/generic_mips/device.mk
@@ -34,5 +34,4 @@
 PRODUCT_PACKAGES := \
     audio.primary.goldfish \
     power.goldfish \
-    vibrator.goldfish \
-    libffi
+    vibrator.goldfish
diff --git a/target/board/generic_mips64/BoardConfig.mk b/target/board/generic_mips64/BoardConfig.mk
index 602e22c..7fe6cd3 100644
--- a/target/board/generic_mips64/BoardConfig.mk
+++ b/target/board/generic_mips64/BoardConfig.mk
@@ -38,6 +38,10 @@
 endif
 TARGET_2ND_CPU_ABI  := mips
 
+# Make TARGET_XXX_CPU_VARIANT the same as TARGET_XXX_ARCH_VARIANT
+TARGET_CPU_VARIANT := $(TARGET_ARCH_VARIANT)
+TARGET_2ND_CPU_VARIANT := $(TARGET_2ND_ARCH_VARIANT)
+
 # The emulator (qemu) uses the Goldfish devices
 HAVE_HTC_AUDIO_DRIVER := true
 BOARD_USES_GENERIC_AUDIO := true
@@ -62,7 +66,7 @@
 
 TARGET_USERIMAGES_USE_EXT4 := true
 BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1342177280  # 1.25 GB swag, 20% more than before
-BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 734003200
 BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
 BOARD_FLASH_BLOCK_SIZE := 512
diff --git a/target/board/generic_mips64/device.mk b/target/board/generic_mips64/device.mk
index 015686e..66ec9db 100644
--- a/target/board/generic_mips64/device.mk
+++ b/target/board/generic_mips64/device.mk
@@ -33,5 +33,4 @@
 
 PRODUCT_PACKAGES := \
     audio.primary.goldfish \
-    power.goldfish \
-    libffi
+    power.goldfish
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index 34b5bac..0b8e1cd 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -45,16 +45,3 @@
 BOARD_SEPOLICY_DIRS += \
         build/target/board/generic/sepolicy \
         build/target/board/generic_x86/sepolicy
-
-BOARD_SEPOLICY_UNION += \
-        device.te \
-        domain.te \
-        file.te \
-        file_contexts \
-        healthd.te \
-        installd.te \
-        qemud.te \
-        rild.te \
-        shell.te \
-        system_server.te \
-        zygote.te
diff --git a/target/product/aosp_arm64.mk b/target/product/aosp_arm64.mk
index e119466..ea8ec06 100644
--- a/target/product/aosp_arm64.mk
+++ b/target/product/aosp_arm64.mk
@@ -23,8 +23,6 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_arm64/device.mk)
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 include $(SRC_TARGET_DIR)/product/emulator.mk
 PRODUCT_NAME := aosp_arm64
 PRODUCT_DEVICE := generic_arm64
diff --git a/target/product/base.mk b/target/product/base.mk
index 0d052b5..85c01a2 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -95,7 +95,6 @@
     monkey \
     mtpd \
     ndc \
-    netcfg \
     netd \
     ping \
     ping6 \
diff --git a/target/product/core_base.mk b/target/product/core_base.mk
index 6c29482..03d33e1 100644
--- a/target/product/core_base.mk
+++ b/target/product/core_base.mk
@@ -41,13 +41,14 @@
     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_h264dec \
-    libstagefright_soft_h264enc \
     libstagefright_soft_hevcdec \
     libstagefright_soft_mp3dec \
+    libstagefright_soft_mpeg2dec \
     libstagefright_soft_mpeg4dec \
     libstagefright_soft_mpeg4enc \
     libstagefright_soft_opusdec \
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index 4c08cb0..33b49a6 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -51,6 +51,7 @@
     iptables \
     keystore \
     keystore.default \
+    ld.mc \
     libbcc \
     libOpenMAXAL \
     libOpenSLES \
@@ -100,11 +101,10 @@
     ethernet-service \
     wifi-service
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     ro.zygote=zygote32
 PRODUCT_COPY_FILES += \
     system/core/rootdir/init.zygote32.rc:root/init.zygote32.rc
 
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index 9637e34..39789d9 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -101,8 +101,6 @@
     services \
     wifi-service
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     ro.zygote=zygote32
 PRODUCT_COPY_FILES += \
@@ -111,6 +109,7 @@
 PRODUCT_PROPERTY_OVERRIDES += \
     ro.carrier=unknown
 
+$(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 b60c948..a408860 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -23,10 +23,11 @@
     atrace \
     bootanimation \
     debuggerd \
-    debuggerd64 \
     dumpstate \
     dumpsys \
+    fastboot \
     gralloc.default \
+    grep \
     gzip \
     healthd \
     init \
@@ -49,6 +50,7 @@
     libm \
     libpixelflinger \
     libpower \
+    libsigchain \
     libstdc++ \
     libstlport \
     libsurfaceflinger \
@@ -57,18 +59,18 @@
     libui \
     libutils \
     linker \
-    linker64 \
     lmkd \
     logcat \
     logwrapper \
     mkshrc \
     reboot \
+    recovery \
     service \
     servicemanager \
     sh \
     surfaceflinger \
     toolbox \
-    libsigchain
+    toybox \
 
 # SELinux packages
 PRODUCT_PACKAGES += \
@@ -80,6 +82,10 @@
     selinux_version \
     service_contexts
 
+# Ensure that this property is always defined so that bionic_systrace.cpp
+# can rely on it being initially set by init.
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+    debug.atrace.tags.enableflags=0
 
 PRODUCT_COPY_FILES += \
     system/core/rootdir/init.usb.rc:root/init.usb.rc \
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index 62099df..3a8a4aa 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -41,11 +41,18 @@
     lights.goldfish \
     gps.goldfish \
     sensors.goldfish \
-    e2fsck
+    e2fsck \
+    audio.primary.goldfish \
+    vibrator.goldfish \
+    power.goldfish \
+    sensors.ranchu
 
 
 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/ueventd.goldfish.rc:root/ueventd.goldfish.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
diff --git a/target/product/full_base.mk b/target/product/full_base.mk
index caace76..d8dad79 100644
--- a/target/product/full_base.mk
+++ b/target/product/full_base.mk
@@ -40,7 +40,6 @@
 
 # Additional settings used in all AOSP builds
 PRODUCT_PROPERTY_OVERRIDES := \
-    ro.com.android.dateformat=MM-dd-yyyy \
     ro.config.ringtone=Ring_Synth_04.ogg \
     ro.config.notification_sound=pixiedust.ogg
 
diff --git a/target/product/full_base_telephony.mk b/target/product/full_base_telephony.mk
index 2fd2ce8..9a2c63a 100644
--- a/target/product/full_base_telephony.mk
+++ b/target/product/full_base_telephony.mk
@@ -19,9 +19,6 @@
 # build quite specifically for the emulator, and might not be
 # entirely appropriate to inherit from for on-device configurations.
 
-PRODUCT_PACKAGES := \
-    VoiceDialer
-
 PRODUCT_PROPERTY_OVERRIDES := \
     keyguard.no_require_sim=true \
     ro.com.android.dataroaming=true
diff --git a/target/product/full_mips64.mk b/target/product/full_mips64.mk
index 408e81c..e813e41 100644
--- a/target/product/full_mips64.mk
+++ b/target/product/full_mips64.mk
@@ -23,8 +23,6 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_mips64/device.mk)
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 include $(SRC_TARGET_DIR)/product/emulator.mk
 
 # Overrides
diff --git a/target/product/full_x86_64.mk b/target/product/full_x86_64.mk
index d9c0c1e..051a86e 100755
--- a/target/product/full_x86_64.mk
+++ b/target/product/full_x86_64.mk
@@ -27,8 +27,6 @@
 $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86_64/device.mk)
 
-PRODUCT_RUNTIMES := runtime_libart_default
-
 include $(SRC_TARGET_DIR)/product/emulator.mk
 
 ifdef NET_ETH0_STARTONBOOT
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
index 7af62ce..dd18fab 100644
--- a/target/product/generic_no_telephony.mk
+++ b/target/product/generic_no_telephony.mk
@@ -49,9 +49,6 @@
     vibrator.default \
     power.default
 
-PRODUCT_PACKAGES += \
-    local_time.default
-
 PRODUCT_COPY_FILES := \
         frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf
 
diff --git a/target/product/runtime_common.mk b/target/product/runtime_common.mk
deleted file mode 100644
index 9ae182a..0000000
--- a/target/product/runtime_common.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (C) 2013 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 runtime modules for both Dalvik and ART
-
-PRODUCT_PACKAGES += \
-    apache-xml \
-    bouncycastle \
-    cacerts \
-    conscrypt \
-    core-junit \
-    dalvikvm \
-    dexdeps \
-    dexdump \
-    dexlist \
-    dmtracedump \
-    dx \
-    ext \
-    hprof-conv \
-    libcrypto \
-    libexpat \
-    libicui18n \
-    libicuuc \
-    libjavacore \
-    libnativehelper \
-    libssl \
-    libz \
-    okhttp
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index e4200b3..a35122b 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -17,11 +17,33 @@
 # Provides a functioning ART environment without Android frameworks
 
 PRODUCT_PACKAGES += \
-        core-libart \
-        libart \
-        dex2oat \
-        oatdump \
-        patchoat
+    apache-xml \
+    bouncycastle \
+    cacerts \
+    conscrypt \
+    core-junit \
+    core-libart \
+    dalvikvm \
+    dex2oat \
+    dexdeps \
+    dexdump \
+    dexlist \
+    dmtracedump \
+    dx \
+    ext \
+    hprof-conv \
+    libart \
+    libcrypto \
+    libexpat \
+    libicui18n \
+    libicuuc \
+    libjavacore \
+    libnativehelper \
+    libssl \
+    libz \
+    oatdump \
+    okhttp \
+    patchoat
 
 PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
     dalvik.vm.image-dex2oat-Xms=64m \
@@ -29,5 +51,3 @@
     dalvik.vm.dex2oat-Xms=64m \
     dalvik.vm.dex2oat-Xmx=512m \
     ro.dalvik.vm.native.bridge=0 \
-
-include $(SRC_TARGET_DIR)/product/runtime_common.mk
diff --git a/target/product/runtime_libart_default.mk b/target/product/runtime_libart_default.mk
deleted file mode 100644
index 2d4c793..0000000
--- a/target/product/runtime_libart_default.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-# Set ART as the default runtime environment
-
-DALVIK_VM_LIB := libart.so
-
-include $(SRC_TARGET_DIR)/product/runtime_libart.mk
diff --git a/target/product/runtime_libdvm.mk b/target/product/runtime_libdvm.mk
deleted file mode 100644
index 638d7d7..0000000
--- a/target/product/runtime_libdvm.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-# Provides a functioning Dalvik environment without Android frameworks
-
-PRODUCT_PACKAGES += \
-    core \
-    libdvm \
-    dexopt
-
-include $(SRC_TARGET_DIR)/product/runtime_common.mk
diff --git a/target/product/runtime_libdvm_default.mk b/target/product/runtime_libdvm_default.mk
deleted file mode 100644
index b581ce5..0000000
--- a/target/product/runtime_libdvm_default.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-# Set Dalvik as the default runtime environment
-
-DALVIK_VM_LIB := libdvm.so
-
-include $(SRC_TARGET_DIR)/product/runtime_libdvm.mk
diff --git a/target/product/sdk_phone_arm64.mk b/target/product/sdk_phone_arm64.mk
index c501f14..a0cf6c1 100644
--- a/target/product/sdk_phone_arm64.mk
+++ b/target/product/sdk_phone_arm64.mk
@@ -21,6 +21,7 @@
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
 $(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_arm64/device.mk)
 
 # Overrides
 PRODUCT_BRAND := generic_arm64
diff --git a/tools/acp/Android.mk b/tools/acp/Android.mk
index 33c5567..2b41bc1 100644
--- a/tools/acp/Android.mk
+++ b/tools/acp/Android.mk
@@ -4,6 +4,7 @@
 
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_SRC_FILES := \
     acp.c
@@ -21,5 +22,7 @@
 LOCAL_C_INCLUDES := build/libs/host/include
 LOCAL_MODULE := acp
 LOCAL_ACP_UNAVAILABLE := true
+LOCAL_CXX_STL := none
+LOCAL_ADDRESS_SANITIZER := false
 
 include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/atree/files.cpp b/tools/atree/files.cpp
index df3e987..d945f58 100644
--- a/tools/atree/files.cpp
+++ b/tools/atree/files.cpp
@@ -447,14 +447,7 @@
             continue;
         }
         string entry = path_append(path, ent->d_name);
-#ifdef HAVE_DIRENT_D_TYPE
-		bool is_directory = (ent->d_type == DT_DIR);
-#else
-	    // If dirent.d_type is missing, then use stat instead
-		struct stat stat_buf;
-		stat(entry.c_str(), &stat_buf);
-		bool is_directory = S_ISDIR(stat_buf.st_mode);
-#endif
+        bool is_directory = (ent->d_type == DT_DIR);
         add_more(entry, is_directory, rec, more);
         if (is_directory) {
             dirs.push_back(entry);
diff --git a/tools/atree/fs.cpp b/tools/atree/fs.cpp
index 9468cfd..6cd080e 100644
--- a/tools/atree/fs.cpp
+++ b/tools/atree/fs.cpp
@@ -63,14 +63,7 @@
             string full = path;
             full += '/';
             full += ent->d_name;
-#ifdef HAVE_DIRENT_D_TYPE
             bool is_directory = (ent->d_type == DT_DIR);
-#else
-            // If dirent.d_type is missing, then use stat instead
-            struct stat stat_buf;
-            stat(full.c_str(), &stat_buf);
-            bool is_directory = S_ISDIR(stat_buf.st_mode);
-#endif
             if (is_directory) {
                 dirs.push_back(full);
             } else {
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index d89b934..bbd3f16 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -38,11 +38,8 @@
 echo "ro.product.cpu.abilist64=$TARGET_CPU_ABI_LIST_64_BIT"
 
 echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER"
-if [ -n "$PRODUCT_DEFAULT_LANGUAGE" ] ; then
-  echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"
-fi
-if [ -n "$PRODUCT_DEFAULT_REGION" ] ; then
-  echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION"
+if [ -n "$PRODUCT_DEFAULT_LOCALE" ] ; then
+  echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
 fi
 echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"
 echo "ro.board.platform=$TARGET_BOARD_PLATFORM"
diff --git a/tools/droiddoc/templates-sac/head_tag.cs b/tools/droiddoc/templates-sac/head_tag.cs
index 9fca488..5cee68c 100644
--- a/tools/droiddoc/templates-sac/head_tag.cs
+++ b/tools/droiddoc/templates-sac/head_tag.cs
@@ -7,7 +7,7 @@
 <title><?cs 
   if:page.title ?><?cs 
     var:page.title ?> | <?cs
-  /if ?>Android Developers</title>
+  /if ?>Android Open Source Project</title>
 
 <!-- STYLESHEETS -->
 <link rel="stylesheet"
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/GPL-LICENSE.txt b/tools/droiddoc/templates-sdk-dev/assets/GPL-LICENSE.txt
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/GPL-LICENSE.txt
rename to tools/droiddoc/templates-sdk-dev/assets/GPL-LICENSE.txt
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/LICENSE.txt b/tools/droiddoc/templates-sdk-dev/assets/LICENSE.txt
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/LICENSE.txt
rename to tools/droiddoc/templates-sdk-dev/assets/LICENSE.txt
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/android-developer-docs.css b/tools/droiddoc/templates-sdk-dev/assets/android-developer-docs.css
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/android-developer-docs.css
rename to tools/droiddoc/templates-sdk-dev/assets/android-developer-docs.css
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/css/default.css b/tools/droiddoc/templates-sdk-dev/assets/css/default.css
similarity index 84%
rename from tools/droiddoc/templates-sdk-dyn/assets/css/default.css
rename to tools/droiddoc/templates-sdk-dev/assets/css/default.css
index e26aec6..cc4dce7 100644
--- a/tools/droiddoc/templates-sdk-dyn/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk-dev/assets/css/default.css
@@ -158,12 +158,6 @@
 .layout-content-row {
   display: inline-block;
   margin-bottom: 10px; }
-  .layout-content-row:after {
-    content: ".";
-    display: block;
-    height: 0;
-    clear: both;
-    visibility: hidden; }
   * html .layout-content-row {
     height: 1px; }
 
@@ -430,20 +424,19 @@
 /* content header */
 .content-header {
   height: 30px;
-  margin:20px 0 25px;
-  padding:0 0 10px;}
+  margin:36px 0 23px;  /* same as h1 */
+  padding:0 0 10px;}  /* same as h1 */
 .content-header.just-links {
   margin-bottom:0;
   padding-bottom:0;}
 
 .content-header h1 {
-  color:#000;
   margin:0;
-  border-bottom:0;
   padding:0;
+  width: 700px;
 }
 .content-header > div:first-child {
-  height:55px; /* set fixed height for the header div to ensure the
+  height:1px; /* set fixed height for the header div to ensure the
                   next/prev links align with toc on training classes */
 }
 
@@ -451,7 +444,7 @@
   border-top: 1px solid #ccc;
   margin-top: 10px;
   padding-top:10px;
-  height: 30px; }
+  width:100%; }
 
 .content-footer .col-9 {
   margin-left:0;
@@ -462,20 +455,33 @@
 .content-footer.wrap {
   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 {
+  margin-top:-25px;
+}
 .paging-links {
-  position: relative; }
+  position: relative;
+  height:30px; }
   .paging-links a {
     position: absolute; }
   .paging-links a,
   .training-nav-top a {
-    font-size: 14px;
-    line-height: 30px;
     color: #555555;
     text-decoration: none;
     text-transform: uppercase; }
     .paging-links .prev-page-link:before,
-    .training-nav-top .prev-page-link:before {
+    .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;
@@ -489,7 +495,7 @@
     .paging-links .prev-page-link {
       left: -15px; }
     .paging-links .next-page-link {
-      right: 0px; }
+      right: 0; }
     .next-page-link:after,
     .start-class-link:after,
     .start-course-link:after,
@@ -506,6 +512,9 @@
     .next-page-link.inline:after {
       content: none; }
 
+  .content-footer .paging-links .next-page-link {
+    left:0;
+  }
 
   .training-nav-top a {
     display:block;
@@ -544,7 +553,6 @@
 
   .paging-links a.start-class-link {
     width:100%;
-    text-align:right;
   }
 
   /* list of classes on course landing page */
@@ -623,19 +631,6 @@
     display:none !important;
   }
 
-  .content-footer.next-class {
-    display:block;
-    border:0;
-    margin-top:0;
-    padding-top:0;
-  }
-
-  .content-footer.next-class a.next-class-link {
-    display:block;
-    float:right;
-    text-transform:uppercase;
-  }
-
 
 
   /* inner-doc tabs w/ title */
@@ -713,6 +708,7 @@
     color: #33b5e5;
     border-bottom-color: #33b5e5; } }
 
+h1:target,
 h2:target,
 h3:target {
     -webkit-animation-name: glowheader;
@@ -894,7 +890,7 @@
   .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;
@@ -929,6 +925,47 @@
   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;
+}
+
+#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;
@@ -1102,12 +1139,13 @@
 }
 h1 {
     color:#333;
-    font-size: 22px;
-    margin: 20px 0 20px;
+    font-size: 34px;
+    margin: 36px 0 27px;
     padding:0 0 10px;
+    font-weight:300;
 }
 h1, h2 {
-    line-height: 32px;
+    line-height: 30px;
 }
 h1.short {
   margin-right:320px;
@@ -1120,21 +1158,24 @@
 }
 h2 {
     color:#333;
-    font-size: 20px;
-    margin: 20px 0 20px;
+    font-size: 26px;
+    margin: 32px 0 20px;
     padding:0;
+    font-weight:300;
 }
 h3 {
     color:#333;
-    font-size: 18px;
+    font-size: 21px;
+    font-weight:400;
+    margin:21px 0 14px 0;
 }
 h3, h4 {
-    color:#333;
-    line-height: 20px;
-    margin: 10px 0;
+    line-height: 21px;
 }
 h4 {
-  font-size: 16px;
+  font-size: 18px;
+  margin: 12px 0;
+  font-weight:500;
 }
 h5 {
   font-size: 14px;
@@ -1147,7 +1188,7 @@
 }
 hr { /* applied to the bottom of h2 elements */
   height: 1px;
-  margin: 5px 0 20px;
+  margin: 3px 0 12px;
   border: 0;
   background: #ccc;
 }
@@ -1208,7 +1249,7 @@
 legend {
     display: none;
 }
-a:link, a:visited {
+a:link, a:visited, .link-color {
   color: #258aaf;
   text-decoration: none;
 }
@@ -1216,6 +1257,13 @@
   color: #33B5E5;
   text-decoration: none;
 }
+a.white {
+  color: #fff;
+  text-decoration:underline;
+}
+a.white:hover, a.white:active {
+  color: #ccc !important;
+}
 strong, b {
   font-weight:bold;
   color: #222;
@@ -1249,6 +1297,7 @@
 tr:first-of-type th:first-of-type:empty {
     visibility: hidden;
 }
+
 /* --------------------------------------------------------------------------
 Footer
 */
@@ -1523,6 +1572,9 @@
     color: #333;
     font-size: 16px;
 }
+.about a.selected {
+    color: #9933CC;
+}
 .design a.selected {
     color: #33b5e5;
 }
@@ -1834,6 +1886,11 @@
   margin:0 0 0 20px;
 }
 
+.training-nav-top {
+  position:relative;
+  top:73px;
+}
+
 .training-nav-bottom {
   padding:0 0 20px;
 }
@@ -1842,12 +1899,12 @@
 #qv-wrapper {
   float:right;
   clear:right;
-  margin:0 0 0 30px; /* negative top-margin to counter the content-header bottom margin */
+  margin:6px 0 0 30px; /* negative top-margin to counter the content-header bottom margin */
   padding:0 0 30px;
 }
 
 #tb-wrapper {
-  margin:-29px 0 0 20px; /* negative top-margin to counter the content-header bottom margin */
+  margin:51px 0 0 20px; /* negative top-margin to counter the content-header bottom margin */
 }
 
 #tb,
@@ -1931,6 +1988,10 @@
   margin:0 15px 10px 35px;
 }
 
+#tb p {
+  margin:0 15px 10px;
+}
+
 #qv ol {
   list-style:none;
   margin:0 15px 15px;
@@ -1959,28 +2020,12 @@
 
 /* related resources blocks in checklists */
 
-.rel-resources {
-  margin:10px 0px;
-  border:1px solid #ccc;
-  background-color:rgba(0, 0, 0, 0.027451);
-  border:1px solid #ccc;
-  font-size:13px;
-  color:#6f6f6f;
-}
+/* related resources sections that have dynamic content */
 
-.rel-resources ul {
-padding: .5em 1em 0 1em;
-}
 
-.rel-resources a {
-font-weight:500;
-}
 
-.rel-resources h3 {
-  margin:4px 15px 0px 15px;
-  font-size:13px;
-  font-weight:600;
-  text-transform:uppercase;
+h3.rel-resources {
+margin:1.25em auto;
 }
 
 /* --------------------------------------------------------------------------
@@ -2360,6 +2405,13 @@
 #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
 }
@@ -2725,19 +2777,22 @@
   width:100%;
 }
 #butterbar {
-  width:940px;
+  width:100%;
   margin:0 auto;
 }
 #butterbar-message {
-  background-color:#f80;
-  float:right;
-  font-size:12px;
-  font-weight:bold;
-  padding:0 10px;
-  border-radius: 0 0 5px 5px;
+  background-color:rgba(255, 187, 51, .4);
+  font-size:13px;
+  padding: 5px 0;
+  text-align:center;
 }
-#butterbar-message a {color:#fff !important}
-#butterbar-message a:hover {text-decoration:underline;}
+a#butterbar-message {
+  cursor:pointer;
+  display:block;
+}
+a#butterbar-message:hover {
+  text-decoration:underline;
+}
 
 /* --------------------------------------------------------------------------
 Misc
@@ -2761,7 +2816,7 @@
 .caption {
   margin: 0.5em 0 2em 0;
   color: #000;
-  font-size: 11.5px; 
+  font-size: 11.5px;
 }
 
 .nolist, .nolist ul, .nolist ol {
@@ -2910,7 +2965,8 @@
 a.notice-developers-video,
 a.notice-developers,
 a.notice-designers-video,
-a.notice-designers {
+a.notice-designers,
+a.notice-designers-material {
   float:right;
   clear:right;
   width:238px;
@@ -2921,13 +2977,15 @@
 a.notice-developers-video.wide,
 a.notice-developers.wide,
 a.notice-designers-video.wide,
-a.notice-designers.wide {
+a.notice-designers.wide,
+a.notice-designers-material.wide {
   width:278px;
 }
 a.notice-developers-video div,
 a.notice-developers div,
 a.notice-designers-video div,
-a.notice-designers div {
+a.notice-designers div,
+a.notice-designers-material div {
   min-height:40px;
   background:url('../images/styles/notice-developers@2x.png') no-repeat 10px 10px;
   background-size:40px 40px;
@@ -2945,16 +3003,22 @@
   background:url('../images/styles/notice-developers-video@2x.png') no-repeat 10px 10px;
   background-size:40px 40px;
 }
+a.notice-designers-material div {
+  background:url('../images/styles/notice-designers-material@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 {
+a.notice-designers:hover,
+a.notice-designers-material:hover {
   background:#eee;
 }
 a.notice-developers-video h3,
 a.notice-developers h3,
 a.notice-designers-video h3,
-a.notice-designers h3 {
+a.notice-designers h3,
+a.notice-designers-material h3 {
   font-size:13px;
   line-height:18px;
   font-weight:bold;
@@ -2965,14 +3029,16 @@
 a.notice-developers-video p,
 a.notice-developers p,
 a.notice-designers-video p,
-a.notice-designers p {
+a.notice-designers p,
+a.notice-designers-material p {
   margin:0;
   line-height:14px;
 }
 a.notice-developers-video.left,
 a.notice-developers.left,
 a.notice-designers-video.left,
-a.notice-designers.left {
+a.notice-designers.left,
+a.notice-designers-material.left {
   margin-left:0;
   float:left;
 }
@@ -2994,6 +3060,34 @@
 }
 
 
+/* 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
 */
@@ -3072,6 +3166,7 @@
   -webkit-box-shadow:-5px 5px 10px #ccc;
 }
 
+div#langMessage,
 div#naMessage {
   display:none;
   width:555px;
@@ -3079,6 +3174,8 @@
   margin:0 auto;
 }
 
+
+div#langMessage>div,
 div#naMessage div {
   z-index:99;
   width:450px;
@@ -3092,12 +3189,16 @@
   -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
@@ -3346,28 +3447,37 @@
 }
 
 #jd-header {
-  padding: 0 0 5px;
-  margin: 20px 0 10px;
-  font-size:13px;
+  padding: 0 0 12px;
+  margin: 20px 0 12px;
+  font-size:12px;
+  padding-bottom:12px;
   border-bottom:solid 1px #ccc;
 }
 
 #jd-header h1 {
   margin:0;
-  padding:0;
+  padding:0 0 6px 0;
 }
 
+/* not sure if this is needed in the ref docs, disabling for now
+.jd-descr h2 {
+  margin:16px 0;
+}
+*/
+
 /* page-top-right container for reference pages (holds
 links to summary tables) */
 #api-info-block {
-  font-size:13px;
+  font-size:12px;
   margin:20px 0 0;
   padding:0 10px 6px;
   font-weight:normal;
   float:right;
   text-align:right;
   color:#999;
-  max-width:70%;
+  max-width:80%;
+  font-size: 12px;
+  line-height:14px;
 }
 
 #api-info-block div.api-level {
@@ -3384,7 +3494,8 @@
   border-spacing:0;
   margin:0;
   padding:0;
-  font-size:13px;
+  font-size:12px;
+  line-height:14px;
   background-color:transparent;
 }
 .jd-inheritance-table tr td {
@@ -3966,7 +4077,7 @@
   height: 38px;
 }
 #header-wrapper #nav-x ul.nav-x li {
-  margin-right: 36px !important;
+  margin-right: 31px !important;
   margin-top: 5px;
   margin-bottom: 0px;
   height: 30px;
@@ -4093,6 +4204,7 @@
   width: 26px;
   height: 25px;
   background: url(../images/dac_logo.png);
+  background-image: -webkit-image-set(url(../images/dac_logo.png) 1x, url(../images/dac_logo@2x.png) 2x);
   z-index: 52;
   position: relative;
 }
@@ -4115,6 +4227,15 @@
   z-index: 52;
 }
 
+/* offset the <a name=""> tags to account for sticky nav */
+body.reference a[name],
+div.renderscript a[name] {
+  visibility: hidden;
+  display: block;
+  position: relative;
+  top: -56px;
+}
+
 
 }
 
@@ -4168,13 +4289,13 @@
 }
 
 
-#header-wrap .logo.wear-logo {
+#header-wrap .logo.landing-logo {
   width:220px;
   margin:0;
   padding:0;
   margin-bottom:22px;
 }
-#header-wrap .logo.wear-logo img {
+#header-wrap .logo.landing-logo img {
   padding:0 0 0 10px;
 }
 
@@ -4246,7 +4367,7 @@
 #quicknav {
  float:none;
  clear:both;
- margin-left:180px;
+ margin-left:0;
  margin-top:-30px;
  display:none;
  overflow:hidden;
@@ -4261,6 +4382,10 @@
   padding:0;
 }
 
+#quicknav ul li.about {
+  border-top:1px solid #9933CC;
+}
+
 #quicknav ul li.design {
   border-top:1px solid #33b5e5;
 }
@@ -4311,7 +4436,7 @@
 }
 
 #header-wrap.quicknav {
-  height:196px;
+  height:216px;
 
 }
 
@@ -4590,7 +4715,9 @@
 }
 
 
-
+#landing h1 {
+  margin:17px 0 20px 0 !important;
+}
 
 a.download-sdk {
     float:right;
@@ -4761,14 +4888,14 @@
 
 /* Slideshow */
 .slideshow-develop {
-  height: 300px;
+  height: 316px;
   width: 940px;
   position: relative;
   overflow:hidden;
 }
 .slideshow-develop .frame {
   width: 940px;
-  height: 300px;
+  height: 316px;
 }
 .slideshow-develop img.play {
   max-width:350px;
@@ -4800,6 +4927,7 @@
   padding:0;
   margin-bottom:10px;
   border:none;
+  font-size:24px;
 }
 .slideshow-develop .item {
   height: 300px;
@@ -4972,7 +5100,8 @@
   margin-bottom:0;
 }
 .landing-banner h1 {
-  margin-top:0;
+  margin-top:16px;
+  padding-bottom:24px;
 }
 .landing-docs,
 .landing-banner {
@@ -5127,22 +5256,6 @@
 
 /************ DISTRIBUTE PAGES ******************/
 
-/* Article page header line fix */
-.headerLine {
-  overflow: hidden;
-}
-.headerLine h1 {
-  float: left;
-  padding-right: 20px;
-  margin-bottom: 0px;
-  font-size: 20px;
-  color: #363636;
-}
-.headerLine hr {
-  overflow: hidden;
-  margin: 42px 0 0 0;
-}
-
 .article-detail #body-content {
   padding-top: 10px;
 }
@@ -5155,7 +5268,7 @@
   text-transform:uppercase;
   border-bottom:1px solid #CCC;
   padding:8px 0 0 1px;
-  margin-bottom:10px;
+  margin-bottom:14px;
   clear:both;
 }
 
@@ -5191,7 +5304,7 @@
 /* Basic card-styling with shadow */
 .resource-card {
   border-radius: 1px;
-  box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.14);
+  box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.12);
   background: #fefefe;
 }
 
@@ -5220,6 +5333,9 @@
   -o-transition: opacity 0.5s;
   transition: opacity 0.5s;
 }
+.static .card-bg:after {
+  display:none;
+}
 .card-bg .card-section-icon {
   position: absolute;
   top: 50%;
@@ -5366,18 +5482,21 @@
   content: ".";
   display: block;
   height: 0;
+  position:relative;
   clear: both;
   visibility: hidden;
 }
-
 .resource-card:hover {
   cursor: pointer;
 }
+.static .resource-card:hover {
+  cursor: auto;
+}
 .resource-card:hover .card-bg:after {
   opacity: 0;
 }
 /* disabled to make way for fade/ellipsis truncation,
-   and the plusone moves up. 
+   and the plusone moves up.
 .resource-card:hover .card-info .description .text {
   padding-right: 70px;
 } */
@@ -6289,6 +6408,17 @@
   display: none;
 }
 
+
+/* 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 > .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;
@@ -6383,4 +6513,940 @@
 div.jd-descr > .resource-widget[data-section=distribute\/tools]
 .section-card-menu .card-info ul li {
   border-top-color: #7e3794 !important;
-}
\ No newline at end of file
+}
+
+
+
+/**
+ * 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 {
+  font-weight: 100;
+  font-size: 60px;
+  line-height: 78px;
+  text-align: center;
+  letter-spacing: -1px;
+}
+
+.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;
+}
+
+.landing-h2 {
+  font-weight: 300;
+  font-size: 42px;
+  line-height: 64px;
+  text-align: center;
+}
+
+.landing-subhead {
+  color: #999999;
+  font-size: 20px;
+  line-height: 28px;
+  font-weight:300;
+  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
+ */
+
+#body-content,
+.fullpage,
+#jd-content,
+.jd-descr,
+.landing-body-content {
+  height: 100%;
+}
+
+.landing-section {
+  padding: 80px 10px 80px;
+  width: 100%;
+  margin-left: -10px;
+  text-rendering: optimizeLegibility;
+}
+
+#extending-android-to-wearables {
+  padding-top: 30px;
+}
+
+.landing-short-section {
+  padding: 40px 10px 28px;
+}
+
+.landing-gray-background {
+  background-color: #e9e9e9;
+}
+
+.landing-white-background {
+  background-color: white;
+}
+
+.landing-red-background {
+  color: white;
+  background-color: hsl(8, 70%, 54%);
+}
+
+.landing-subhead-red {
+  color: hsl(8, 71%, 84%);
+  text-align: left;
+}
+
+.landing-subhead-red p {
+  margin-top: 20px;
+}
+
+.landing-hero-container {
+  height: 100%;
+}
+
+
+.preview-hero {
+  height: calc(100% - 110px);
+  min-height: 504px;
+  margin-top: -5px;
+  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(100% - 110px);
+  min-height: 504px;
+  margin-top: -5px;
+  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(100% - 110px);
+  min-height: 504px;
+  margin-top: -5px;
+  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(100% - 110px);
+  min-height: 504px;
+  margin-top: -5px;
+  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;
+  opacity: .2;
+  position: absolute;
+  width: 100%;
+  height: 100%;
+  margin-left: -10px;
+}
+
+.landing-hero-wrap {
+  margin: 0 auto;
+  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-button {
+  white-space: nowrap;
+  display: inline-block;
+  padding: 16px 32px;
+  font-size: 18px;
+  font-weight: 500;
+  line-height: 24px;
+  cursor: pointer;
+  color: white;
+  -webkit-user-select: none;
+     -moz-user-select: none;
+       -o-user-select: none;
+  user-select: none;
+  -webkit-transition: .2s background-color ease-in-out;
+     -moz-transition: .2s background-color ease-in-out;
+       -o-transition: .2s background-color ease-in-out;
+  transition: .2s background-color ease-in-out;
+}
+
+.landing-primary {
+  background-color: hsl(8, 70%, 44%);
+  color: #f8f8f8;
+}
+
+.landing-button.landing-primary:hover {
+  background-color: hsl(8, 70%, 36%);
+}
+
+.landing-button.landing-primary:active {
+  background-color: hsl(8, 70%, 30%);
+}
+
+.landing-button.landing-secondary {
+  background-color: #2faddb;
+}
+
+.landing-button.landing-secondary:hover {
+  background-color: #09c;
+}
+
+.landing-button.landing-secondary:active {
+  background-color: #3990ab;
+}
+
+a.landing-button,
+a.landing-button:hover,
+a.landing-button:visited {
+  color: white !important;
+}
+
+.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;
+}
+
+.col-3-wide {
+  display: inline;
+  float: left;
+  margin-left: 10px;
+  margin-right: 10px;
+}
+
+.col-3-wide {
+  width: 302px;
+}
+
+/**
+ * ANIMATION
+ */
+
+@-webkit-keyframes pulse-opacity {
+  0% {
+    opacity: .5;
+  }
+  20% {
+    opacity: .5;
+  }
+  40% {
+    opacity: 1;
+  }
+  60% {
+    opacity: .5;
+  }
+  80% {
+    opacity: 1;
+  }
+  100% {
+    opacity: .5;
+  }
+}
+
+
+
+/**
+ * VIDEO
+ */
+
+#video-container {
+  display:none;
+  position:fixed;
+  top:0;
+  left:0;
+  width:100%;
+  height:100%;
+  background-color:rgba(0,0,0,0.8);
+  z-index:9999;
+}
+
+#video-frame {
+  width:940px;
+  height:100%;
+  margin:72px auto;
+  display:none;
+  position:relative;
+}
+
+.video-close {
+  cursor: pointer;
+  position: absolute;
+  right: -49px;
+  top: -49px;
+  pointer-events: all;
+}
+
+#icon-video-close {
+  background-image: url("../images/close-white.png");
+  background-image: -webkit-image-set(url(../images/close-white.png) 1x, url(../images/close-white_2x.png) 2x);
+  background-repeat: no-repeat;
+  background-position: 0 0;
+  background-size: 36px 36px;
+  height: 36px;
+  width: 36px;
+  display:block;
+}
+
+#icon-video-close:hover {
+  background-image: url("../images/close-grey.png");
+  background-image: -webkit-image-set(url(../images/close-grey.png) 1x, url(../images/close-grey_2x.png) 2x);
+}
+
+/* Preload the hover images */
+a.video-shadowbox-button.white:after {
+  display:none;
+  content:url("../images/close-grey.png") url("../images/close-grey_2x.png");
+}
+
+a.video-shadowbox-button.white {
+  background-image: url("../images/play-circle-white.png");
+  background-image: -webkit-image-set(url(../images/play-circle-white.png) 1x, url(../images/play-circle-white_2x.png) 2x);
+  background-size: 36px 36px;
+  background-repeat: no-repeat;
+  background-position: right;
+  padding: 16px 42px 16px 8px;
+  font-size: 18px;
+  font-weight: 500;
+  line-height: 24px;
+  color: #fff;
+  text-decoration:none;
+}
+
+a.video-shadowbox-button.white:hover {
+  color:#bababa !important;
+  background-image: url("../images/play-circle-grey.png");
+  background-image: -webkit-image-set(url(../images/play-circle-grey.png) 1x, url(../images/play-circle-grey_2x.png) 2x);
+}
+
+/* Preload the hover images */
+a.video-shadowbox-button.white:after {
+  display:none;
+  content:url("../images/play-circle-grey.png") url("../images/play-circle-grey_2x.png");
+}
+
+/******************
+Styles for d.a.c/index:
+*******************/
+
+
+
+/* Generic full screen carousel styling to be used across pages. */
+.fullscreen-carousel {
+  margin: 0 -10px;
+  width: 100%;
+  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;
+  margin-top: 0;
+}
+
+.fullscreen-carousel .hero p {
+  font-weight: 300;
+  font-size: 18px;
+  line-height: 24px;
+  -webkit-font-smoothing: antialiased;
+}
+
+.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;
+}
+
+
+
+
+
+/*
+   Styles for the entity link used in the actions bar and in the cta of
+   the resources that appear in the tab carousel.
+*/
+.actions-bar a:after,
+.resource .cta:after {
+  content: '›';
+  font-weight: 400;
+  font-size: 22px;
+  left: 5px;
+  line-height: 1;
+  position: relative;
+  top: 1px;
+  transition: left 190ms ease-out;
+}
+
+.actions-bar a:hover:after,
+.resource .cta:hover:after {
+  left: 10px;
+}
+
+
+
+
+/*
+  Styles for the actions bar.
+*/
+.actions-bar {
+  background: #9acd00;
+  margin: 0 -10px;
+  text-align: center;
+}
+
+.actions-bar .actions {
+  padding: 30px 0 30px;
+  text-align: justify;
+  font-size: 0.1px;
+  line-height: 0.1px;
+  margin: 0 10px 0 0;
+}
+
+.actions-bar .actions:after {
+  content: '';
+  width: 100%;
+  display: inline-block;
+}
+
+.actions-bar .actions > div {
+  display: inline-block;
+}
+
+.actions-bar a {
+  font-size: 21px;
+  line-height: 27px;
+  color: #fff;
+  font-weight: 300;
+  -webkit-font-smoothing: antialiased;
+}
+
+.actions-bar a:after {
+  top: 0px;
+  font-size: 22px;
+}
+
+.actions-bar a:hover {
+  color: #fff !important;
+}
+
+
+
+
+
+/*
+  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;
+}
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/css/fullscreen.css b/tools/droiddoc/templates-sdk-dev/assets/css/fullscreen.css
similarity index 99%
rename from tools/droiddoc/templates-sdk-dyn/assets/css/fullscreen.css
rename to tools/droiddoc/templates-sdk-dev/assets/css/fullscreen.css
index 53d9a64..7912e34 100644
--- a/tools/droiddoc/templates-sdk-dyn/assets/css/fullscreen.css
+++ b/tools/droiddoc/templates-sdk-dev/assets/css/fullscreen.css
@@ -197,9 +197,6 @@
   left:-20px;
 }
 
-
-}
-
 .col-right {
   margin-right:0px;
 }
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/design/default.js b/tools/droiddoc/templates-sdk-dev/assets/design/default.js
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/design/default.js
rename to tools/droiddoc/templates-sdk-dev/assets/design/default.js
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/android-developers-logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/android-developers-logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/android-developers-logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/android-developers-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/android.png b/tools/droiddoc/templates-sdk-dev/assets/images/android.png
new file mode 100644
index 0000000..4040f3f
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/android_wrench.png b/tools/droiddoc/templates-sdk-dev/assets/images/android_wrench.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/android_wrench.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/android_wrench.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow-left-develop.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrow-left-develop.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow-left-develop.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow-left-develop.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow-left.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrow-left.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow-left.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow-left.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow-right-develop.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrow-right-develop.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow-right-develop.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow-right-develop.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow-right.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrow-right.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow-right.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow-right.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow_bluelink_down.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrow_bluelink_down.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow_bluelink_down.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow_bluelink_down.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow_bluelink_up.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrow_bluelink_up.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow_bluelink_up.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow_bluelink_up.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow_left_off.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/arrow_left_off.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow_left_off.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow_left_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow_left_on.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/arrow_left_on.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow_left_on.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow_left_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow_right_off.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/arrow_right_off.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow_right_off.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow_right_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrow_right_on.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/arrow_right_on.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrow_right_on.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrow_right_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/arrows-up-down.png b/tools/droiddoc/templates-sdk-dev/assets/images/arrows-up-down.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/arrows-up-down.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/arrows-up-down.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/bg_community_leftDiv.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/bg_community_leftDiv.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/bg_community_leftDiv.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/bg_community_leftDiv.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/bg_fade.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/bg_fade.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/bg_fade.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/bg_fade.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/bg_gradient.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/bg_gradient.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/bg_gradient.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/bg_gradient.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/bg_images_sprite.png b/tools/droiddoc/templates-sdk-dev/assets/images/bg_images_sprite.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/bg_images_sprite.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/bg_images_sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/bg_logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/bg_logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/bg_logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/bg_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/blog-default.png b/tools/droiddoc/templates-sdk-dev/assets/images/blog-default.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/blog-default.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/blog-default.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/body-gradient-tab.png b/tools/droiddoc/templates-sdk-dev/assets/images/body-gradient-tab.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/body-gradient-tab.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/body-gradient-tab.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/body-gradient.png b/tools/droiddoc/templates-sdk-dev/assets/images/body-gradient.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/body-gradient.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/body-gradient.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/breadcrumb.png b/tools/droiddoc/templates-sdk-dev/assets/images/breadcrumb.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/breadcrumb.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/breadcrumb.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/close-grey.png b/tools/droiddoc/templates-sdk-dev/assets/images/close-grey.png
new file mode 100644
index 0000000..1b0d7f1
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/close-grey.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/close-grey_2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/close-grey_2x.png
new file mode 100644
index 0000000..1355507
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/close-grey_2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/close-white.png b/tools/droiddoc/templates-sdk-dev/assets/images/close-white.png
new file mode 100644
index 0000000..ef02018
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/close-white.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/close-white_2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/close-white_2x.png
new file mode 100644
index 0000000..9b9c41d
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/close-white_2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/close.png b/tools/droiddoc/templates-sdk-dev/assets/images/close.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/close.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/close.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/dac_logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/dac_logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/dac_logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/dac_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/dac_logo@2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/dac_logo@2x.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/dac_logo@2x.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/dac_logo@2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/developers-logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/developers-logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/developers-logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/developers-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/file-generic.png b/tools/droiddoc/templates-sdk-dev/assets/images/file-generic.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/file-generic.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/file-generic.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/file-image.png b/tools/droiddoc/templates-sdk-dev/assets/images/file-image.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/file-image.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/file-image.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/file-java.png b/tools/droiddoc/templates-sdk-dev/assets/images/file-java.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/file-java.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/file-java.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/file-manifest.png b/tools/droiddoc/templates-sdk-dev/assets/images/file-manifest.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/file-manifest.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/file-manifest.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/file-xml.png b/tools/droiddoc/templates-sdk-dev/assets/images/file-xml.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/file-xml.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/file-xml.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/folder.png b/tools/droiddoc/templates-sdk-dev/assets/images/folder.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/folder.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/folder.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/fullscreen.png b/tools/droiddoc/templates-sdk-dev/assets/images/fullscreen.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/fullscreen.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/fullscreen.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/grad-rule-qv.png b/tools/droiddoc/templates-sdk-dev/assets/images/grad-rule-qv.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/grad-rule-qv.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/grad-rule-qv.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/Android_Dev_Lab_l.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/Android_Dev_Lab_l.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/Android_Dev_Lab_l.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/Android_Dev_Lab_l.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/GDC2011.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/GDC2011.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/GDC2011.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/GDC2011.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/GTV_icon_large.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/GTV_icon_large.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/GTV_icon_large.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/GTV_icon_large.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/GTV_icon_small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/GTV_icon_small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/GTV_icon_small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/GTV_icon_small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/IO-logo-2011.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/IO-logo-2011.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/IO-logo-2011.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/IO-logo-2011.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/IO-logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/IO-logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/IO-logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/IO-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/adc2_l.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/adc2_l.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/adc2_l.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/adc2_l.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/adc2_s.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/adc2_s.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/adc2_s.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/adc2_s.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/android_adc.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/android_adc.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/android_adc.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/android_adc.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_announcement.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_announcement.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_announcement.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_announcement.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_bottom.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_bottom.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_bottom.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_bottom.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_carousel.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_carousel.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_carousel.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_carousel.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_carousel_board.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_carousel_board.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_carousel_board.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_carousel_board.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_carousel_wheel.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_carousel_wheel.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/bg_home_carousel_wheel.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/bg_home_carousel_wheel.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/carousel_buttons_sprite.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/carousel_buttons_sprite.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/carousel_buttons_sprite.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/carousel_buttons_sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/devphone-large.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/devphone-large.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/devphone-large.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/devphone-large.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/devphone-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/devphone-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/devphone-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/devphone-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/donut-android.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/donut-android.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/donut-android.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/donut-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/eclair-android.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/eclair-android.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/eclair-android.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/eclair-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/froyo-android.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/froyo-android.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/froyo-android.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/froyo-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/gdc-logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/gdc-logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/gdc-logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/gdc-logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/gingerdroid.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/gingerdroid.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/gingerdroid.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/gingerdroid.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/google-plus-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/google-plus-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/google-plus-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/google-plus-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/google-plus.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/google-plus.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/google-plus.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/google-plus.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/honeycomb-android.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/honeycomb-android.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/honeycomb-android.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/honeycomb-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-about.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/icon-about.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-about.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/icon-about.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-design.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/icon-design.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-design.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/icon-design.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-develop.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/icon-develop.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-develop.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/icon-develop.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-distribute.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/icon-distribute.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/icon-distribute.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/icon-distribute.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/ics-android.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/ics-android.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/ics-android.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/ics-android.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/io-large.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/io-large.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/io-large.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/io-large.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/io-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/io-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/io-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/io-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/maps-large.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/maps-large.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/maps-large.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/maps-large.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/maps-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/maps-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/maps-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/maps-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/market-large.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/market-large.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/market-large.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/market-large.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/market-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/market-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/market-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/market-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/sdk-large.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/sdk-large.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/sdk-large.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/sdk-large.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/home/sdk-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/home/sdk-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/home/sdk-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/home/sdk-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/hr_gray_main.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/hr_gray_main.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/hr_gray_main.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/hr_gray_main.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/hr_gray_side.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/hr_gray_side.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/hr_gray_side.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/hr_gray_side.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_contribute.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/icon_contribute.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_contribute.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_contribute.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_design.png b/tools/droiddoc/templates-sdk-dev/assets/images/icon_design.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_design.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_design.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_download.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/icon_download.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_download.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_download.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_download2.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/icon_download2.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_download2.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_download2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_guidelines_logo.png b/tools/droiddoc/templates-sdk-dev/assets/images/icon_guidelines_logo.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_guidelines_logo.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_guidelines_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_market.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/icon_market.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_market.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_market.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_more.png b/tools/droiddoc/templates-sdk-dev/assets/images/icon_more.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_more.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_more.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_play.png b/tools/droiddoc/templates-sdk-dev/assets/images/icon_play.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_play.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_play.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_robot.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/icon_robot.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_robot.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_robot.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_search.png b/tools/droiddoc/templates-sdk-dev/assets/images/icon_search.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_search.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_search.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/icon_world.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/icon_world.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/icon_world.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/icon_world.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/left_off.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/left_off.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/left_off.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/left_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/left_on.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/left_on.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/left_on.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/left_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/link-out.png b/tools/droiddoc/templates-sdk-dev/assets/images/link-out.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/link-out.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/link-out.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/locale.png b/tools/droiddoc/templates-sdk-dev/assets/images/locale.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/locale.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/locale.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/logo_breadcrumbz.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/logo_breadcrumbz.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/logo_breadcrumbz.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/logo_breadcrumbz.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/more_bottom.png b/tools/droiddoc/templates-sdk-dev/assets/images/more_bottom.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/more_bottom.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/more_bottom.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/more_check.png b/tools/droiddoc/templates-sdk-dev/assets/images/more_check.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/more_check.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/more_check.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/more_mid.png b/tools/droiddoc/templates-sdk-dev/assets/images/more_mid.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/more_mid.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/more_mid.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/more_top.png b/tools/droiddoc/templates-sdk-dev/assets/images/more_top.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/more_top.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/more_top.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/open_source.png b/tools/droiddoc/templates-sdk-dev/assets/images/open_source.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/open_source.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/open_source.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-grey.png b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-grey.png
new file mode 100644
index 0000000..5e7e7ba
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-grey.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-grey_2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-grey_2x.png
new file mode 100644
index 0000000..3e01635
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-grey_2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-white.png b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-white.png
new file mode 100644
index 0000000..017d846
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-white.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-white_2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-white_2x.png
new file mode 100644
index 0000000..e48c1fd
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/play-circle-white_2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/preliminary.png b/tools/droiddoc/templates-sdk-dev/assets/images/preliminary.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/preliminary.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/preliminary.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/preview.png b/tools/droiddoc/templates-sdk-dev/assets/images/preview.png
new file mode 100644
index 0000000..e5856db
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/preview.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/quicknav_arrow.png b/tools/droiddoc/templates-sdk-dev/assets/images/quicknav_arrow.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/quicknav_arrow.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/quicknav_arrow.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/quicknav_btn_bg.png b/tools/droiddoc/templates-sdk-dev/assets/images/quicknav_btn_bg.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/quicknav_btn_bg.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/quicknav_btn_bg.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-e.gif b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-e.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-e.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-e.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-e2.gif b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-e2.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-e2.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-e2.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-eg.gif b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-eg.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-eg.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-eg.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-s.gif b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-s.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-s.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-s.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-s2.gif b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-s2.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-s2.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-s2.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-s2.png b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-s2.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-s2.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-s2.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resizable-sg.gif b/tools/droiddoc/templates-sdk-dev/assets/images/resizable-sg.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resizable-sg.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/resizable-sg.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-article.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-article.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-article.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-article.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-article.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-big-article.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-article.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-big-article.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-sample.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-big-sample.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-sample.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-big-sample.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-tutorial.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-big-tutorial.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-tutorial.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-big-tutorial.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-video.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-big-video.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-big-video.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-big-video.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-card-default-android.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/resource-card-default-android.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-card-default-android.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-card-default-android.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-sample.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-sample.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-sample.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-sample.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-tutorial.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-tutorial.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-tutorial.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-tutorial.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/resource-video.png b/tools/droiddoc/templates-sdk-dev/assets/images/resource-video.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/resource-video.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/resource-video.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/right_off.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/right_off.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/right_off.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/right_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/right_on.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/right_on.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/right_on.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/right_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/sidenav-rule.png b/tools/droiddoc/templates-sdk-dev/assets/images/sidenav-rule.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/sidenav-rule.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/sidenav-rule.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_1.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_1.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_1.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_1.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_2.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_2.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_2.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_3.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_3.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_3.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_3.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_large_1.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_large_1.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_large_1.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_large_1.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_large_2.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_large_2.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_large_2.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_large_2.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_large_3.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_large_3.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_large_3.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_large_3.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_off.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_off.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_off.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_off.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/slide_on.jpg b/tools/droiddoc/templates-sdk-dev/assets/images/slide_on.jpg
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/slide_on.jpg
rename to tools/droiddoc/templates-sdk-dev/assets/images/slide_on.jpg
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/spacer.gif b/tools/droiddoc/templates-sdk-dev/assets/images/spacer.gif
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/spacer.gif
rename to tools/droiddoc/templates-sdk-dev/assets/images/spacer.gif
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/stack-arrow-right.png b/tools/droiddoc/templates-sdk-dev/assets/images/stack-arrow-right.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/stack-arrow-right.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/stack-arrow-right.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/callout.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/callout.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/callout.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/callout.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_land_span13.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_land_span13.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_land_span13.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_land_span13.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_land_span8.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_land_span8.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_land_span8.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_land_span8.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_port_span5.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_port_span5.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_port_span5.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_port_span5.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_port_span9.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_port_span9.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_galaxynexus_blank_port_span9.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_galaxynexus_blank_port_span9.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_nexus4_blank_port_432.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_nexus4_blank_port_432.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_nexus4_blank_port_432.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_nexus4_blank_port_432.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_nexus5_blank_land_span13.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_nexus5_blank_land_span13.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_nexus5_blank_land_span13.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_nexus5_blank_land_span13.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_nexus5_blank_port_span5.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_nexus5_blank_port_span5.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/device_nexus5_blank_port_span5.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/device_nexus5_blank_port_span5.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_wear_square.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_wear_square.png
new file mode 100644
index 0000000..077a7e6
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_wear_square.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_wear_square_small.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_wear_square_small.png
new file mode 100644
index 0000000..e7e1540
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/styles/device_wear_square_small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_down.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_down.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_down.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_down.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_left.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_left.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_left.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_left.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_right.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_right.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_right.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_right.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_up.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_up.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/disclosure_up.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/disclosure_up.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/gototop.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/gototop.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/gototop.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/gototop.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/styles/helpouts-logo-35.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/helpouts-logo-35.png
new file mode 100644
index 0000000..3c2dc1a
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/styles/helpouts-logo-35.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dev/assets/images/styles/helpouts-logo-35_2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/helpouts-logo-35_2x.png
new file mode 100644
index 0000000..e34be2e
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/assets/images/styles/helpouts-logo-35_2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_action.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_action.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_action.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_action.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_good.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_good.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_good.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_good.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_movie_inline.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_movie_inline.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_movie_inline.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_movie_inline.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_phone_tablet.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_phone_tablet.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_phone_tablet.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_phone_tablet.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_use.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_use.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_use.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_use.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_web.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_web.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_web.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_web.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_wrong.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_wrong.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/ico_wrong.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/ico_wrong.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-material.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-material.png
similarity index 100%
rename from tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-material.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-material.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-material@2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-material@2x.png
similarity index 100%
rename from tools/droiddoc/templates-sdk/assets/images/styles/notice-designers-material@2x.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-material@2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers-video.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-video.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers-video.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-video.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers-video@2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-video@2x.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers-video@2x.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers-video@2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers@2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers@2x.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-designers@2x.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-designers@2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers-video.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers-video.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers-video.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers-video.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers-video@2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers-video@2x.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers-video@2x.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers-video@2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers@2x.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers@2x.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/notice-developers@2x.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/notice-developers@2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/styles/open_new_page.png b/tools/droiddoc/templates-sdk-dev/assets/images/styles/open_new_page.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/styles/open_new_page.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/styles/open_new_page.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/triangle-closed-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/triangle-closed-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/triangle-closed-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/triangle-closed-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/triangle-closed.png b/tools/droiddoc/templates-sdk-dev/assets/images/triangle-closed.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/triangle-closed.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/triangle-closed.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/triangle-opened-small.png b/tools/droiddoc/templates-sdk-dev/assets/images/triangle-opened-small.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/triangle-opened-small.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/triangle-opened-small.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/triangle-opened.png b/tools/droiddoc/templates-sdk-dev/assets/images/triangle-opened.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/triangle-opened.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/triangle-opened.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/uiguidelines1.png b/tools/droiddoc/templates-sdk-dev/assets/images/uiguidelines1.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/uiguidelines1.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/uiguidelines1.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/images/video-droid.png b/tools/droiddoc/templates-sdk-dev/assets/images/video-droid.png
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/images/video-droid.png
rename to tools/droiddoc/templates-sdk-dev/assets/images/video-droid.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/js/android_3p-bundle.js b/tools/droiddoc/templates-sdk-dev/assets/js/android_3p-bundle.js
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/js/android_3p-bundle.js
rename to tools/droiddoc/templates-sdk-dev/assets/js/android_3p-bundle.js
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/js/docs.js b/tools/droiddoc/templates-sdk-dev/assets/js/docs.js
similarity index 83%
rename from tools/droiddoc/templates-sdk-dyn/assets/js/docs.js
rename to tools/droiddoc/templates-sdk-dev/assets/js/docs.js
index e6befe3..7f4be4e 100644
--- a/tools/droiddoc/templates-sdk-dyn/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk-dev/assets/js/docs.js
@@ -19,9 +19,19 @@
 
 /******  ON LOAD SET UP STUFF *********/
 
-var navBarIsFixed = false;
 $(document).ready(function() {
 
+  // show lang dialog if the URL includes /intl/
+  //if (location.pathname.substring(0,6) == "/intl/") {
+  //  var lang = location.pathname.split('/')[2];
+   // if (lang != getLangPref()) {
+   //   $("#langMessage a.yes").attr("onclick","changeLangPref('" + lang
+   //       + "', true); $('#langMessage').hide(); return false;");
+  //    $("#langMessage .lang." + lang).show();
+   //   $("#langMessage").show();
+   // }
+  //}
+
   // load json file for JD doc search suggestions
   $.getScript(toRoot + 'jd_lists_unified.js');
   // load json file for Android API search suggestions
@@ -64,7 +74,12 @@
   $('.scroll-pane').jScrollPane( {verticalGutter:0} );
 
   // add HRs below all H2s (except for a few other h2 variants)
-  $('h2').not('#qv h2').not('#tb h2').not('.sidebox h2').not('#devdoc-nav h2').not('h2.norule').css({marginBottom:0}).after('<hr/>');
+  $('h2').not('#qv h2')
+         .not('#tb h2')
+         .not('.sidebox h2')
+         .not('#devdoc-nav h2')
+         .not('h2.norule').css({marginBottom:0})
+         .after('<hr/>');
 
   // set up the search close button
   $('.search .close').click(function() {
@@ -169,6 +184,18 @@
     $("#header li.design a").addClass("selected");
     $("#sticky-header").addClass("design");
 
+  // highlight About tabs
+  } else if ($("body").hasClass("about")) {
+    var rootDir = pagePathOriginal.substring(1,pagePathOriginal.indexOf('/', 1));
+    if (rootDir == "about") {
+      $("#nav-x li.about a").addClass("selected");
+    } else if (rootDir == "wear") {
+      $("#nav-x li.wear a").addClass("selected");
+    } else if (rootDir == "tv") {
+      $("#nav-x li.tv a").addClass("selected");
+    } else if (rootDir == "auto") {
+      $("#nav-x li.auto a").addClass("selected");
+    }
   // highlight Develop tab
   } else if ($("body").hasClass("develop") || $("body").hasClass("google")) {
     $("#header li.develop a").addClass("selected");
@@ -207,6 +234,8 @@
       $("#nav-x li.engage a").addClass("selected");
     } else if (secondFrag == "monetize") {
       $("#nav-x li.monetize a").addClass("selected");
+    } else if (secondFrag == "analyze") {
+      $("#nav-x li.analyze a").addClass("selected");
     } else if (secondFrag == "tools") {
       $("#nav-x li.disttools a").addClass("selected");
     } else if (secondFrag == "stories") {
@@ -218,7 +247,7 @@
     }
   } else if ($("body").hasClass("about")) {
     $("#sticky-header").addClass("about");
-  } 
+  }
 
   // set global variable so we can highlight the sidenav a bit later (such as for google reference)
   // and highlight the sidenav
@@ -239,7 +268,7 @@
     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')) {
+      if ($prevListItem.hasClass('nav-section') || crossBoundaries) {
         // jump to last topic of previous section
         $prevLink = $prevListItem.find('a:last');
       } else if (!$selListItem.hasClass('nav-section')) {
@@ -262,7 +291,6 @@
     // set up next links
     var $nextLink = [];
     var startClass = false;
-    var training = $(".next-class-link").length; // decides whether to provide "next class" link
     var isCrossingBoundary = false;
 
     if ($selListItem.hasClass('nav-section') && $selListItem.children('div.empty').length == 0) {
@@ -289,13 +317,15 @@
       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.nav-section').find('a:eq(0)');
+        $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();
           }
         }
       }
@@ -314,13 +344,19 @@
       $('.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();
       if ($nextLink.length) {
         $('.next-class-link').attr('href',$nextLink.attr('href'))
-                             .removeClass("hide").append($nextLink.html());
+                             .removeClass("hide")
+                             .append(": " + $nextLink.html());
         $('.next-class-link').find('.new').empty();
       }
     } else {
-      $('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide");
+      $('.next-page-link').attr('href', $nextLink.attr('href'))
+                          .removeClass("hide");
+      // for the footer link, also add the next page title
+      $('.content-footer .next-page-link').append(": " + $nextLink.html());
     }
 
     if (!startClass && $prevLink.length) {
@@ -332,14 +368,6 @@
       }
     }
 
-    // If this is a training 'article', there should be no prev/next nav
-    // ... if the grandparent is the "nav" ... and it has no child list items...
-    if (training && $selListItem.parents('ul').eq(1).is('[id="nav"]') &&
-        !$selListItem.find('li').length) {
-      $('.next-page-link,.prev-page-link').attr('href','').addClass("disabled")
-                          .click(function() { return false; });
-    }
-
   }
 
 
@@ -347,7 +375,20 @@
   // 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');
-    var $classDescriptions = $classLinks.attr('description');
+
+    // 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;
@@ -359,7 +400,7 @@
     $classLinks.each(function(index) {
       $liClass  = $('<li></li>');
       $h2Title  = $('<a class="title" href="'+$(this).attr('href')+'"><h2>' + $(this).html()+'</h2><span></span></a>');
-      $pSummary = $('<p class="description">' + $(this).attr('description') + '</p>');
+      $pSummary = $('<p class="description">' + $classDescriptions[index] + '</p>');
 
       $olLessons  = $('<ol class="lesson-list"></ol>');
 
@@ -398,7 +439,7 @@
     var stylesheet = $('link[rel="stylesheet"][class="fullscreen"]');
     setNavBarLeftPos(); // do this even if sidenav isn't fixed because it could become fixed
     // make sidenav behave when resizing the window and side-scolling is a concern
-    if (navBarIsFixed) {
+    if (sticky) {
       if ((stylesheet.attr("disabled") == "disabled") || stylesheet.length == 0) {
         updateSideNavPosition();
       } else {
@@ -482,7 +523,11 @@
     }
   }
 
+  // Resize once loading is finished
   resizeNav();
+  // Check if there's an anchor that we need to scroll into view.
+  // A delay is needed, because some browsers do not immediately scroll down to the anchor
+  window.setTimeout(offsetScrollForSticky, 100);
 
   /* init the language selector based on user cookie for lang */
   loadLangPref();
@@ -515,10 +560,147 @@
     cookiePath = "distribute_";
   }
 
+
+  /* setup shadowbox for any videos that want it */
+  var $videoLinks = $("a.video-shadowbox-button, a.notice-developers-video");
+  if ($videoLinks.length) {
+    // if there's at least one, add the shadowbox HTML to the body
+    $('body').prepend(
+'<div id="video-container">'+
+  '<div id="video-frame">'+
+    '<div class="video-close">'+
+      '<span id="icon-video-close" onclick="closeVideo()">&nbsp;</span>'+
+    '</div>'+
+    '<div id="youTubePlayer"></div>'+
+  '</div>'+
+'</div>');
+
+    // loads the IFrame Player API code asynchronously.
+    $.getScript("https://www.youtube.com/iframe_api");
+
+    $videoLinks.each(function() {
+      var videoId = $(this).attr('href').split('?v=')[1];
+      $(this).click(function(event) {
+        event.preventDefault();
+        startYouTubePlayer(videoId);
+      });
+    });
+  }
 });
 // END of the onload event
 
 
+var youTubePlayer;
+function onYouTubeIframeAPIReady() {
+}
+
+/* Returns the height the shadowbox video should be. It's based on the current
+   height of the "video-frame" element, which is 100% height for the window.
+   Then minus the margin so the video isn't actually the full window height. */
+function getVideoHeight() {
+  var frameHeight = $("#video-frame").height();
+  var marginTop = $("#video-frame").css('margin-top').split('px')[0];
+  return frameHeight - (marginTop * 2);
+}
+
+var mPlayerPaused = false;
+
+function startYouTubePlayer(videoId) {
+  $("#video-container").show();
+  $("#video-frame").show();
+  mPlayerPaused = false;
+
+  // compute the size of the player so it's centered in window
+  var maxWidth = 940;  // the width of the web site content
+  var videoAspect = .5625; // based on 1280x720 resolution
+  var maxHeight = maxWidth * videoAspect;
+  var videoHeight = getVideoHeight();
+  var videoWidth = videoHeight / videoAspect;
+  if (videoWidth > maxWidth) {
+    videoWidth = maxWidth;
+    videoHeight = maxHeight;
+  }
+  $("#video-frame").css('width', videoWidth);
+
+  // check if we've already created this player
+  if (youTubePlayer == null) {
+    // 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;
+
+    youTubePlayer = new YT.Player('youTubePlayer', {
+      height: videoHeight,
+      width: videoWidth,
+      videoId: idAndHash[0],
+      playerVars: {start: startTime, hl: lang, cc_load_policy: captionsOn},
+      events: {
+        'onReady': onPlayerReady,
+        'onStateChange': onPlayerStateChange
+      }
+    });
+  } else {
+    // reset the size in case the user adjusted the window since last play
+    youTubePlayer.setSize(videoWidth, videoHeight);
+    // if a video different from the one already playing was requested, cue it up
+    if (videoId != youTubePlayer.getVideoUrl().split('?v=')[1].split('&')[0].split('%')[0]) {
+      youTubePlayer.cueVideoById(videoId);
+    }
+    youTubePlayer.playVideo();
+  }
+}
+
+function onPlayerReady(event) {
+  event.target.playVideo();
+  mPlayerPaused = false;
+}
+
+function closeVideo() {
+  try {
+    youTubePlayer.pauseVideo();
+  } catch(e) {
+  }
+  $("#video-container").fadeOut(200);
+}
+
+/* Track youtube playback for analytics */
+function onPlayerStateChange(event) {
+    // Video starts, send the video ID
+    if (event.data == YT.PlayerState.PLAYING) {
+      if (mPlayerPaused) {
+        ga('send', 'event', 'Videos', 'Resume',
+            youTubePlayer.getVideoUrl().split('?v=')[1].split('&')[0].split('%')[0]);
+      } else {
+        // track the start playing event so we know from which page the video was selected
+        ga('send', 'event', 'Videos', 'Start: ' +
+            youTubePlayer.getVideoUrl().split('?v=')[1].split('&')[0].split('%')[0],
+            'on: ' + document.location.href);
+      }
+      mPlayerPaused = false;
+    }
+    // Video paused, send video ID and video elapsed time
+    if (event.data == YT.PlayerState.PAUSED) {
+      ga('send', 'event', 'Videos', 'Paused',
+            youTubePlayer.getVideoUrl().split('?v=')[1].split('&')[0].split('%')[0],
+            youTubePlayer.getCurrentTime());
+      mPlayerPaused = true;
+    }
+    // Video finished, send video ID and video elapsed time
+    if (event.data == YT.PlayerState.ENDED) {
+      ga('send', 'event', 'Videos', 'Finished',
+            youTubePlayer.getVideoUrl().split('?v=')[1].split('&')[0].split('%')[0],
+            youTubePlayer.getCurrentTime());
+      mPlayerPaused = true;
+    }
+}
+
+
+
 function initExpandableNavItems(rootTag) {
   $(rootTag + ' li.nav-section .nav-section-header').click(function() {
     var section = $(this).closest('li.nav-section');
@@ -626,7 +808,7 @@
     setTimeout(updateSidenavFixedWidth,delay); // need to wait a moment for css to switch
     enabled = false;
   }
-  writeCookie("fullscreen", enabled, null, null);
+  writeCookie("fullscreen", enabled, null);
   setNavBarLeftPos();
   resizeNav(delay);
   updateSideNavPosition();
@@ -787,7 +969,7 @@
 function saveNavPanels() {
   var basePath = getBaseUri(location.pathname);
   var section = basePath.substring(1,basePath.indexOf("/",1));
-  writeCookie("height", resizePackagesNav.css("height"), section, null);
+  writeCookie("height", resizePackagesNav.css("height"), section);
 }
 
 
@@ -868,119 +1050,111 @@
   return 0;
 }
 
-function writeCookie(cookie, val, section, expiration) {
+function writeCookie(cookie, val, section) {
   if (val==undefined) return;
   section = section == null ? "_" : "_"+section+"_";
-  if (expiration == null) {
-    var date = new Date();
-    date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
-    expiration = date.toGMTString();
-  }
+  var age = 2*365*24*60*60; // set max-age to 2 years
   var cookieValue = cookie_namespace + section + cookie + "=" + val
-                    + "; expires=" + expiration+"; path=/";
+                    + "; max-age=" + age +"; path=/";
   document.cookie = cookieValue;
 }
 
 /* #########     END COOKIES!     ########## */
 
 
-
-
+var sticky = false;
 var stickyTop;
+var prevScrollLeft = 0; // used to compare current position to previous position of horiz scroll
 /* Sets the vertical scoll position at which the sticky bar should appear.
    This method is called to reset the position when search results appear or hide */
 function setStickyTop() {
   stickyTop = $('#header-wrapper').outerHeight() - $('#sticky-header').outerHeight();
 }
 
+/*
+ * Displays sticky nav bar on pages when dac header scrolls out of view
+ */
+$(window).scroll(function(event) {
 
-/* 
- * Displays sticky nav bar on pages when dac header scrolls out of view 
+  setStickyTop();
+  var hiding = false;
+  var $stickyEl = $('#sticky-header');
+  var $menuEl = $('.menu-container');
+  // Exit if there's no sidenav
+  if ($('#side-nav').length == 0) return;
+  // Exit if the mouse target is a DIV, because that means the event is coming
+  // from a scrollable div and so there's no need to make adjustments to our layout
+  if ($(event.target).nodeName == "DIV") {
+    return;
+  }
+
+  var top = $(window).scrollTop();
+  // we set the navbar fixed when the scroll position is beyond the height of the site header...
+  var shouldBeSticky = top >= stickyTop;
+  // ... except if the document content is shorter than the sidenav height.
+  // (this is necessary to avoid crazy behavior on OSX Lion due to overscroll bouncing)
+  if ($("#doc-col").height() < $("#side-nav").height()) {
+    shouldBeSticky = false;
+  }
+  // Account for horizontal scroll
+  var scrollLeft = $(window).scrollLeft();
+  // When the sidenav is fixed and user scrolls horizontally, reposition the sidenav to match
+  if (sticky && (scrollLeft != prevScrollLeft)) {
+    updateSideNavPosition();
+    prevScrollLeft = scrollLeft;
+  }
+
+  // Don't continue if the header is sufficently far away
+  // (to avoid intensive resizing that slows scrolling)
+  if (sticky == shouldBeSticky) {
+    return;
+  }
+
+  // If sticky header visible and position is now near top, hide sticky
+  if (sticky && !shouldBeSticky) {
+    sticky = false;
+    hiding = true;
+    // make the sidenav static again
+    $('#devdoc-nav')
+        .removeClass('fixed')
+        .css({'width':'auto','margin':''})
+        .prependTo('#side-nav');
+    // delay hide the sticky
+    $menuEl.removeClass('sticky-menu');
+    $stickyEl.fadeOut(250);
+    hiding = false;
+
+    // update the sidenaav position for side scrolling
+    updateSideNavPosition();
+  } else if (!sticky && shouldBeSticky) {
+    sticky = true;
+    $stickyEl.fadeIn(10);
+    $menuEl.addClass('sticky-menu');
+
+    // make the sidenav fixed
+    var width = $('#devdoc-nav').width();
+    $('#devdoc-nav')
+        .addClass('fixed')
+        .css({'width':width+'px'})
+        .prependTo('#body-content');
+
+    // update the sidenaav position for side scrolling
+    updateSideNavPosition();
+
+  } else if (hiding && top < 15) {
+    $menuEl.removeClass('sticky-menu');
+    $stickyEl.hide();
+    hiding = false;
+  }
+  resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance
+});
+
+/*
+ * Manages secion card states and nav resize to conclude loading
  */
 (function() {
   $(document).ready(function() {
 
-    setStickyTop();
-    var sticky = false;
-    var hiding = false;
-    var $stickyEl = $('#sticky-header');
-    var $menuEl = $('.menu-container');
-
-    var prevScrollLeft = 0; // used to compare current position to previous position of horiz scroll
-
-    $(window).scroll(function() {
-      // Exit if there's no sidenav
-      if ($('#side-nav').length == 0) return;
-      // Exit if the mouse target is a DIV, because that means the event is coming
-      // from a scrollable div and so there's no need to make adjustments to our layout
-      if (event.target.nodeName == "DIV") {
-        return;
-      }
-
-
-      var top = $(window).scrollTop();
-      // we set the navbar fixed when the scroll position is beyond the height of the site header...
-      var shouldBeSticky = top >= stickyTop;
-      // ... except if the document content is shorter than the sidenav height.
-      // (this is necessary to avoid crazy behavior on OSX Lion due to overscroll bouncing)
-      if ($("#doc-col").height() < $("#side-nav").height()) {
-        shouldBeSticky = false;
-      }
-
-      // Don't continue if the header is sufficently far away
-      // (to avoid intensive resizing that slows scrolling)
-      if (sticky && shouldBeSticky) {
-        return;
-      }
-
-      // Account for horizontal scroll
-      var scrollLeft = $(window).scrollLeft();
-      // When the sidenav is fixed and user scrolls horizontally, reposition the sidenav to match
-      if (navBarIsFixed && (scrollLeft != prevScrollLeft)) {
-        updateSideNavPosition();
-        prevScrollLeft = scrollLeft;
-      }
-
-      // If sticky header visible and position is now near top, hide sticky
-      if (sticky && !shouldBeSticky) {
-        sticky = false;
-        hiding = true;
-        // make the sidenav static again
-        $('#devdoc-nav')
-            .removeClass('fixed')
-            .css({'width':'auto','margin':''})
-            .prependTo('#side-nav');
-        // delay hide the sticky
-        $menuEl.removeClass('sticky-menu');
-        $stickyEl.fadeOut(250);
-        hiding = false;
-
-        // update the sidenaav position for side scrolling
-        updateSideNavPosition();
-      } else if (!sticky && shouldBeSticky) {
-        sticky = true;
-        $stickyEl.fadeIn(10);
-        $menuEl.addClass('sticky-menu');
-
-        // make the sidenav fixed
-        var width = $('#devdoc-nav').width();
-        $('#devdoc-nav')
-            .addClass('fixed')
-            .css({'width':width+'px'})
-            .prependTo('#body-content');
-
-        // update the sidenaav position for side scrolling
-        updateSideNavPosition();
-
-      } else if (hiding && top < 15) {
-        $menuEl.removeClass('sticky-menu');
-        $stickyEl.hide();
-        hiding = false;
-      }
-
-      resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance
-    });
-
     // Stack hover states
     $('.section-card-menu').each(function(index, el) {
       var height = $(el).height();
@@ -990,7 +1164,6 @@
       $cardInfo.css({position: 'absolute', bottom:'0px', left:'0px', right:'0px', overflow:'visible'});
     });
 
-    resizeNav();  // must resize once loading is finished
   });
 
 })();
@@ -1060,8 +1233,16 @@
 }
 
 
+/* 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);
+  });
+}
 
 
 
@@ -1114,9 +1295,7 @@
     nav_pref = NAV_PREF_TREE;
     init_default_navtree(toRoot);
   }
-  var date = new Date();
-  date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years
-  writeCookie("nav", nav_pref, "reference", date.toGMTString());
+  writeCookie("nav", nav_pref, "reference");
 
   $("#nav-panels").toggle();
   $("#panel-link").toggle();
@@ -1184,11 +1363,7 @@
 }
 
 function changeLangPref(lang, submit) {
-  var date = new Date();
-  expires = date.toGMTString(date.setTime(date.getTime()+(10*365*24*60*60*1000)));
-  // keep this for 50 years
-  //alert("expires: " + expires)
-  writeCookie("pref_lang", lang, null, expires);
+  writeCookie("pref_lang", lang, null);
 
   //  #######  TODO:  Remove this condition once we're stable on devsite #######
   //  This condition is only needed if we still need to support legacy GAE server
@@ -1607,8 +1782,8 @@
 
 function onSuggestionClick(link) {
   // When user clicks a suggested document, track it
-  _gaq.push(['_trackEvent', 'Suggestion Click', 'clicked: ' + $(link).text(),
-            'from: ' + $("#search_autocomplete").val()]);
+  ga('send', 'event', 'Suggestion Click', 'clicked: ' + $(link).attr('href'),
+                'query: ' + $("#search_autocomplete").val().toLowerCase());
 }
 
 function set_item_selected($li, selected)
@@ -1825,8 +2000,12 @@
             return false;
         }
     }
-    // Stop here if Google results are showing
+    // If Google results are showing, return true to allow ajax search to execute
     else if ($("#searchResults").is(":visible")) {
+        // Also, if search_results is scrolled out of view, scroll to top to make results visible
+        if ((sticky ) && (search.value != "")) {
+          $('body,html').animate({scrollTop:0}, '500', 'swing');
+        }
         return true;
     }
     // 38 UP ARROW
@@ -1949,7 +2128,7 @@
 
 
         // Search for matching JD docs
-        if (text.length >= 3) {
+        if (text.length >= 2) {
           // Regex to match only the beginning of a word
           var textRegex = new RegExp("\\b" + text.toLowerCase(), "g");
 
@@ -2496,8 +2675,29 @@
   }
 }, true);
 
+/* Adjust the scroll position to account for sticky header, only if the hash matches an id.
+   This does not handle <a name=""> tags. Some CSS fixes those, but only for reference docs. */
+function offsetScrollForSticky() {
+  // Ignore if there's no search bar (some special pages have no header)
+  if ($("#search-container").length < 1) return;
+
+  var hash = escape(location.hash.substr(1));
+  var $matchingElement = $("#"+hash);
+  // Sanity check that there's an element with that ID on the page
+  if ($matchingElement.length) {
+    // If the position of the target element is near the top of the page (<20px, where we expect it
+    // to be because we need to move it down 60px to become in view), then move it down 60px
+    if (Math.abs($matchingElement.offset().top - $(window).scrollTop()) < 20) {
+      $(window).scrollTop($(window).scrollTop() - 60);
+    }
+  }
+}
+
 // when an event on the browser history occurs (back, forward, load) requery hash and do search
 $(window).hashchange( function(){
+  // Ignore if there's no search bar (some special pages have no header)
+  if ($("#search-container").length < 1) return;
+
   // If the hash isn't a search query or there's an error in the query,
   // then adjust the scroll position to account for sticky header, then exit.
   if ((location.hash.indexOf("q=") == -1) || (query == "undefined")) {
@@ -2505,8 +2705,7 @@
     if (!$("#searchResults").is(":hidden")) {
       hideResults();
     }
-    // Adjust the scroll position to account for sticky header
-    $(window).scrollTop($(window).scrollTop() - 60);
+    offsetScrollForSticky();
     return;
   }
 
@@ -2557,8 +2756,8 @@
   $("#searchResults a.gs-title").each(function(index, link) {
     // When user clicks enter for Google search results, track it
     $(link).click(function() {
-      _gaq.push(['_trackEvent', 'Google Click', 'clicked: ' + $(this).text(),
-                'from: ' + $("#search_autocomplete").val()]);
+      ga('send', 'event', 'Google Click', 'clicked: ' + $(this).attr('href'),
+                'query: ' + $("#search_autocomplete").val().toLowerCase());
     });
   });
 }
@@ -2621,7 +2820,7 @@
   }
 
 function updateSidenavFixedWidth() {
-  if (!navBarIsFixed) return;
+  if (!sticky) return;
   $('#devdoc-nav').css({
     'width' : $('#side-nav').css('width'),
     'margin' : $('#side-nav').css('margin')
@@ -2632,7 +2831,7 @@
 }
 
 function updateSidenavFullscreenWidth() {
-  if (!navBarIsFixed) return;
+  if (!sticky) return;
   $('#devdoc-nav').css({
     'width' : $('#side-nav').css('width'),
     'margin' : $('#side-nav').css('margin')
@@ -2673,10 +2872,7 @@
   selectedLevel = parseInt($("#apiLevelSelector option:selected").val());
   toggleVisisbleApis(selectedLevel, "body");
 
-  var date = new Date();
-  date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years
-  var expiration = date.toGMTString();
-  writeCookie(API_LEVEL_COOKIE, selectedLevel, null, expiration);
+  writeCookie(API_LEVEL_COOKIE, selectedLevel, null);
 
   if (selectedLevel < minLevel) {
     var thing = ($("#jd-header").html().indexOf("package") != -1) ? "package" : "class";
@@ -3349,7 +3545,7 @@
     showing lines that are cut off. This works with the css ellipsis
     classes to fade last text line and apply an ellipsis char. */
 
-    //card text currently uses 15px line height. 
+    //card text currently uses 15px line height.
     var lineHeight = 15;
     $('.card-info .text').ellipsisfade(lineHeight);
   });
@@ -3380,7 +3576,10 @@
       sortOrder: $widget.data('sortorder'),
       query: $widget.data('query'),
       section: $widget.data('section'),
-      sizeCols: sizeCols
+      sizeCols: sizeCols,
+      /* Added by LFL 6/6/14 */
+      resourceStyle: $widget.data('resourcestyle') || 'card',
+      stackSort: $widget.data('stacksort') || 'true'
     };
 
     // run the search for the set of resources to show
@@ -3392,9 +3591,13 @@
     } else if (isCarousel) {
       drawResourcesCarouselWidget($widget, opts, resources);
     } else if (isStack) {
-      var sections = buildSectionList(opts);
+      /* Looks like this got removed and is not used, so repurposing for the
+          homepage style layout.
+          Modified by LFL 6/6/14
+      */
+      //var sections = buildSectionList(opts);
       opts['numStacks'] = $widget.data('numstacks');
-      drawResourcesStackWidget($widget, opts, resources, sections);
+      drawResourcesStackWidget($widget, opts, resources/*, sections*/);
     }
   }
 
@@ -3413,10 +3616,8 @@
     var $ul = $('<ul>');
 
     for (var i = 0; i < resources.length; ++i) {
-      //keep url clean for matching and offline mode handling
-      var urlPrefix = resources[i].url.indexOf("//") > -1 ? "" : toRoot;
       var $card = $('<a>')
-        .attr('href', urlPrefix + resources[i].url)
+        .attr('href', cleanUrl(resources[i].url))
         .decorateResourceCard(resources[i],plusone);
 
       $('<li>').css(css)
@@ -3435,7 +3636,9 @@
     });
   };
 
-  /* Initializes a Resource Card Stack Widget (column-based layout) */
+  /* 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
@@ -3453,60 +3656,88 @@
     var sectionResources = [];
 
     // Extract any subsections that are actually resource cards
-    for (var i = 0; i < sections.length; ++i) {
-      if (!sections[i].sections || !sections[i].sections.length) {
-        //keep url clean for matching and offline mode handling
-        urlPrefix = sections[i].url.indexOf("//") > -1 ? "" : toRoot;
-        // Render it as a resource card
+    if (sections) {
+      for (var 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]
+          );
 
-        sectionResources.push(
-          $('<a>')
-            .addClass('resource-card section-card')
-            .attr('href', urlPrefix + 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]
-        );
+        } else {
+          cards.push(
+            $('<div>')
+              .addClass('resource-card section-card-menu')
+              .decorateResourceSection(sections[i],plusone)[0]
+          );
+        }
       }
     }
 
     cards = cards.concat(sectionResources);
 
     for (var i = 0; i < resources.length; ++i) {
-      //keep url clean for matching and offline mode handling
-      urlPrefix = resources[i].url.indexOf("//") > -1 ? "" : toRoot;
-      var $card = $('<a>')
-          .addClass('resource-card related-card')
-          .attr('href', urlPrefix + resources[i].url)
-          .decorateResourceCard(resources[i],plusone);
+      var $card = createResourceElement(resources[i], opts);
+
+      if (opts.resourceStyle.indexOf('related') > -1) {
+        $card.addClass('related-card');
+      }
 
       cards.push($card[0]);
     }
 
-    for (var 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;
+    if (opts.stackSort != 'false') {
+      for (var 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;
+        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]));
+        $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;
+  }
+
   /* Initializes a flow widget, see distribute.scss for generating accompanying css */
   function drawResourcesFlowWidget($widget, opts, resources) {
     $widget.empty();
@@ -3517,7 +3748,6 @@
     while (i < resources.length) {
       var cardSize = cardSizes[j++ % cardSizes.length];
       cardSize = cardSize.replace(/^\s+|\s+$/,'');
-      console.log("cardsize is " + cardSize);
       // Some card sizes do not get a plusone button, such as where space is constrained
       // or for cards commonly embedded in docs (to improve overall page speed).
       plusone = !((cardSize == "6x2") || (cardSize == "6x3") ||
@@ -3539,11 +3769,11 @@
       // Build each stack item or just a single item
       do {
         var resource = resources[i];
-        //keep url clean for matching and offline mode handling
-        urlPrefix = resource.url.indexOf("//") > -1 ? "" : toRoot;
-        var $card = $('<a>')
-            .addClass('resource-card resource-card-' + cardSize + ' resource-card-' + resource.type)
-            .attr('href', urlPrefix + resource.url);
+
+        var $card = createResourceElement(resources[i], opts, plusone);
+
+        $card.addClass('resource-card-' + cardSize +
+          ' resource-card-' + resource.type);
 
         if (isStack) {
           $card.addClass('resource-card-' + isStack[1] + 'x' + isStack[2]);
@@ -3555,8 +3785,7 @@
           stackCount = 0;
         }
 
-        $card.decorateResourceCard(resource,plusone)
-          .appendTo($stackDiv || $widget);
+        $card.appendTo($stackDiv || $widget);
 
       } while (++i < resources.length && stackCount > 0);
     }
@@ -3696,6 +3925,15 @@
     return true;
   }
 
+  function cleanUrl(url)
+  {
+    if (url && url.indexOf('//') === -1) {
+      url = toRoot + url;
+    }
+
+    return url;
+  }
+
 
   function parseResourceQuery(query) {
     // Parse query into array of expressions (expression e.g. 'tag:foo + type:video')
@@ -3743,41 +3981,55 @@
 })();
 
 (function($) {
+
+  /*
+    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.group || resource.type;
-    var imgUrl;
-    if (resource.image) {
-      //keep url clean for matching and offline mode handling
-      var urlPrefix = resource.image.indexOf("//") > -1 ? "" : toRoot;
-      imgUrl = urlPrefix + resource.image;
+    var imgUrl = resource.image ||
+      'assets/images/resource-card-default-android.jpg';
+
+    if (imgUrl.indexOf('//') === -1) {
+      imgUrl = toRoot + imgUrl;
     }
-    //add linkout logic here. check url or type, assign a class, map to css :after
-    $('<div>')
-        .addClass('card-bg')
-        .css('background-image', 'url(' + (imgUrl || toRoot + 'assets/images/resource-card-default-android.jpg') + ')')
+
+    $('<div>').addClass('card-bg')
+      .css('background-image', 'url(' + (imgUrl || toRoot +
+        'assets/images/resource-card-default-android.jpg') + ')')
       .appendTo(this);
-    if (!plusone) {
-      $('<div>').addClass('card-info' + (!resource.summary ? ' empty-desc' : ''))
-        .append($('<div>').addClass('section').text(section))
-        .append($('<div>').addClass('title').html(resource.title))
-        .append($('<div>').addClass('description ellipsis')
-            .append($('<div>').addClass('text').html(resource.summary))
-          .append($('<div>').addClass('util')))
-          .appendTo(this);
-    } else {
-      $('<div>').addClass('card-info' + (!resource.summary ? ' empty-desc' : ''))
-        .append($('<div>').addClass('section').text(section))
-        .append($('<div>').addClass('title').html(resource.title))
-        .append($('<div>').addClass('description ellipsis')
-            .append($('<div>').addClass('text').html(resource.summary))
-          .append($('<div>').addClass('util')
-            .append($('<div>').addClass('g-plusone')
-              .attr('data-size', 'small')
-              .attr('data-align', 'right')
-              .attr('data-href', resource.url))))
-            .appendTo(this);
-    }
+
+    $('<div>').addClass('card-info' + (!resource.summary ? ' empty-desc' : ''))
+      .append($('<div>').addClass('section').text(section))
+      .append($('<div>').addClass('title').html(resource.title))
+      .append(buildResourceCardDescription(resource, plusone))
+      .appendTo(this);
 
     return this;
   };
@@ -3860,7 +4112,39 @@
 
     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),
+        $('<p>').addClass('summary').html(resource.summary),
+        $('<a>').attr('href', linkUrl).addClass('cta').html('Learn More')
+      )
+    );
+
+    return this;
+  };
 })(jQuery);
+
+
 /* Calculate the vertical area remaining */
 (function($) {
     $.fn.ellipsisfade= function(lineHeight) {
@@ -3870,8 +4154,10 @@
             var remainingHeight = $this.parent().parent().height();
             $this.parent().siblings().each(function ()
             {
-              var h = $(this).height();
-              remainingHeight = remainingHeight - h;
+              if ($(this).is(":visible")) {
+                var h = $(this).height();
+                remainingHeight = remainingHeight - h;
+              }
             });
 
             adjustedRemainingHeight = ((remainingHeight)/lineHeight>>0)*lineHeight
@@ -3882,3 +4168,189 @@
         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;
+      }
+    }
+  }
+})();
diff --git a/tools/droiddoc/templates-sdk-dyn/assets/js/prettify.js b/tools/droiddoc/templates-sdk-dev/assets/js/prettify.js
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/assets/js/prettify.js
rename to tools/droiddoc/templates-sdk-dev/assets/js/prettify.js
diff --git a/tools/droiddoc/templates-sdk-dyn/class.cs b/tools/droiddoc/templates-sdk-dev/class.cs
similarity index 93%
rename from tools/droiddoc/templates-sdk-dyn/class.cs
rename to tools/droiddoc/templates-sdk-dev/class.cs
index 0461af6..693eaed 100644
--- a/tools/droiddoc/templates-sdk-dyn/class.cs
+++ b/tools/droiddoc/templates-sdk-dev/class.cs
@@ -1,9 +1,12 @@
 <?cs include:"doctype.cs" ?>
 <?cs include:"macros.cs" ?>
+<?cs include:"macros_override.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs include:"head_tag.cs" ?>
 <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<?cs
+    /if ?><?cs
   elif:design ?>design<?cs
   elif:distribute ?>distribute<?cs
   /if ?>" itemscope itemtype="http://schema.org/Article">
@@ -123,6 +126,7 @@
   <?cs /if ?>
   <?cs set:colspan = colspan-1 ?>
 <?cs /each ?>
+<?cs call:show_annotations_list(class) ?>
 
 </div><!-- end header -->
 
@@ -165,13 +169,15 @@
 
 <div class="jd-descr">
 <?cs call:deprecated_warning(class) ?>
-<?cs if:subcount(class.descr) ?>
+<?cs if:subcount(class.descr) || subcount(class.annotationdocumentation) ?>
 <h2>Class Overview</h2>
-<p itemprop="articleBody"><?cs call:tag_list(class.descr) ?></p>
+<?cs if:subcount(class.descr) ?><p itemprop="articleBody"><?cs call:tag_list(class.descr) ?></p><?cs /if ?>
+<?cs if:subcount(class.annotationdocumentation) ?><?cs each:annodoc = class.annotationdocumentation?>
+<p><?cs var:annodoc.text ?></p>
+<?cs /each?><?cs /if?>
 <?cs /if ?>
 
 <?cs call:see_also_tags(class.seeAlso) ?>
-
 </div><!-- jd-descr -->
 
 
@@ -192,9 +198,12 @@
         </td>
         <td class="jd-linkcol" width="100%"><nobr>
         <span class="sympad"><?cs call:cond_link(method.name, toroot, method.href, included) ?></span>(<?cs call:parameter_list(method.params) ?>)</nobr>
-        <?cs if:subcount(method.shortDescr) || subcount(method.deprecated) ?>
-        <div class="jd-descrdiv"><?cs call:short_descr(method) ?></div>
-  <?cs /if ?>
+        <?cs if:subcount(method.shortDescr) || subcount(method.deprecated) || subcount(method.showAnnotations) ?>
+          <div class="jd-descrdiv">
+            <?cs if:subcount(method.shortDescr) || subcount(method.annotationdocumentation) ?><?cs call:short_descr(method)?><?cs /if?>
+            <?cs call:show_annotations_list(method) ?>
+          </div>
+        <?cs /if ?>
   </td></tr>
 <?cs set:count = count + #1 ?>
 <?cs /each ?>
@@ -210,7 +219,10 @@
           <?cs var:field.final ?>
           <?cs call:type_link(field.type) ?></nobr></td>
           <td class="jd-linkcol"><?cs call:cond_link(field.name, toroot, field.href, included) ?></td>
-          <td class="jd-descrcol" width="100%"><?cs call:short_descr(field) ?></td>
+          <td class="jd-descrcol" width="100%">
+            <?cs call:short_descr(field) ?>
+            <?cs call:show_annotations_list(field) ?>
+          </td>
       </tr>
       <?cs set:count = count + #1 ?>
     <?cs /each ?>
@@ -222,7 +234,10 @@
     <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:field.since ?>" >
         <td class="jd-typecol"><?cs call:type_link(field.type) ?></td>
         <td class="jd-linkcol"><?cs call:cond_link(field.name, toroot, field.href, included) ?></td>
-        <td class="jd-descrcol" width="100%"><?cs call:short_descr(field) ?></td>
+        <td class="jd-descrcol" width="100%">
+          <?cs call:short_descr(field) ?>
+          <?cs call:show_annotations_list(field) ?>
+        </td>
     </tr>
     <?cs set:count = count + #1 ?>
     <?cs /each ?>
@@ -242,7 +257,10 @@
             <?cs call:cond_link(m.name, toroot, m.href, included) ?>
             <?cs /each ?>
         </td>
-        <td class="jd-descrcol" width="100%"><?cs call:short_descr(attr) ?>&nbsp;</td>
+        <td class="jd-descrcol" width="100%">
+          <?cs call:short_descr(attr) ?>&nbsp;
+          <?cs call:show_annotations_list(attr) ?>
+        </td>
     </tr>
     <?cs set:count = count + #1 ?>
     <?cs /each ?>
@@ -259,7 +277,10 @@
         <?cs var:cl.abstract ?>
         <?cs var:cl.kind ?></nobr></td>
       <td class="jd-linkcol"><?cs call:type_link(cl.type) ?></td>
-      <td class="jd-descrcol" width="100%"><?cs call:short_descr(cl) ?>&nbsp;</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 ?>
@@ -335,7 +356,10 @@
     <tr class="<?cs if:count % #2 ?>alt-color<?cs /if ?> api apilevel-<?cs var:field.since ?>" >
         <td class="jd-descrcol"><?cs call:type_link(field.type) ?>&nbsp;</td>
         <td class="jd-linkcol"><?cs call:cond_link(field.name, toroot, field.href, cl.included) ?>&nbsp;</td>
-        <td class="jd-descrcol" width="100%"><?cs call:short_descr(field) ?>&nbsp;</td>
+        <td class="jd-descrcol" width="100%">
+          <?cs call:short_descr(field) ?>&nbsp;
+          <?cs call:show_annotations_list(field) ?>
+        </td>
     </tr>
     <?cs set:count = count + #1 ?>
     <?cs /each ?>
@@ -504,6 +528,7 @@
         <?cs call:federated_refs(field) ?>
       </div>
     <div class="jd-details-descr">
+      <?cs call:show_annotations_list(field) ?>
       <?cs call:description(field) ?>
     <?cs if:subcount(field.constantValue) ?>
         <div class="jd-tagdata">
@@ -546,6 +571,7 @@
         <?cs call:federated_refs(method) ?>
       </div>
     <div class="jd-details-descr">
+      <?cs call:show_annotations_list(method) ?>
       <?cs call:description(method) ?>
     </div>
 </div>
@@ -560,6 +586,7 @@
     <h4 class="jd-details-title"><?cs var:attr.name ?>
     </h4>
     <div class="jd-details-descr">
+        <?cs call:show_annotations_list(attr) ?>
         <?cs call:description(attr) ?>
 
         <div class="jd-tagdata">
diff --git a/tools/droiddoc/templates-sdk-dyn/classes.cs b/tools/droiddoc/templates-sdk-dev/classes.cs
similarity index 84%
rename from tools/droiddoc/templates-sdk-dyn/classes.cs
rename to tools/droiddoc/templates-sdk-dev/classes.cs
index 6769f47..405892d 100644
--- a/tools/droiddoc/templates-sdk-dyn/classes.cs
+++ b/tools/droiddoc/templates-sdk-dev/classes.cs
@@ -1,9 +1,12 @@
 <?cs include:"doctype.cs" ?>
 <?cs include:"macros.cs" ?>
+<?cs include:"macros_override.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs include:"head_tag.cs" ?>
 <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<?cs
+    /if ?><?cs
   elif:design ?>design<?cs
   elif:distribute ?>distribute<?cs
   /if ?>" itemscope itemtype="http://schema.org/Article">
@@ -30,7 +33,10 @@
     <?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;</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 ?>
diff --git a/tools/droiddoc/templates-sdk-dyn/components/masthead.cs b/tools/droiddoc/templates-sdk-dev/components/masthead.cs
similarity index 67%
rename from tools/droiddoc/templates-sdk-dyn/components/masthead.cs
rename to tools/droiddoc/templates-sdk-dev/components/masthead.cs
index d0ff64d..d48ea29 100644
--- a/tools/droiddoc/templates-sdk-dyn/components/masthead.cs
+++ b/tools/droiddoc/templates-sdk-dev/components/masthead.cs
@@ -1,12 +1,58 @@
 <?cs def:custom_masthead() ?>
-<?cs if:wear ?>
-  <?cs call:wear_masthead() ?>
+<?cs if:preview ?>
+  <?cs call:preview_masthead() ?>
 <?cs else ?>
 <a name="top"></a>
+
+<!-- dialog to prompt lang pref change when loaded from hardcoded URL
+<div id="langMessage" style="display:none">
+  <div>
+    <div class="lang en">
+      <p>You requested a page in English, would you like to proceed with this language setting?</p>
+    </div>
+    <div class="lang es">
+      <p>You requested a page in Spanish (Español), would you like to proceed with this language setting?</p>
+    </div>
+    <div class="lang ja">
+      <p>You requested a page in Japanese (日本語), would you like to proceed with this language setting?</p>
+    </div>
+    <div class="lang ko">
+      <p>You requested a page in Korean (한국어), would you like to proceed with this language setting?</p>
+    </div>
+    <div class="lang ru">
+      <p>You requested a page in Russian (Русский), would you like to proceed with this language setting?</p>
+    </div>
+    <div class="lang zh-cn">
+      <p>You requested a page in Simplified Chinese (简体中文), would you like to proceed with this language setting?</p>
+    </div>
+    <div class="lang zh-tw">
+      <p>You requested a page in Traditional Chinese (繁體中文), would you like to proceed with this language setting?</p>
+    </div>
+    <a href="#" class="button yes" onclick="return false;">
+      <span class="lang en">Yes</span>
+      <span class="lang es">Sí</span>
+      <span class="lang ja">Yes</span>
+      <span class="lang ko">Yes</span>
+      <span class="lang ru">Yes</span>
+      <span class="lang zh-cn">是的</span>
+      <span class="lang zh-tw">没有</span>
+    </a>
+    <a href="#" class="button" onclick="$('#langMessage').hide();return false;">
+      <span class="lang en">No</span>
+      <span class="lang es">No</span>
+      <span class="lang ja">No</span>
+      <span class="lang ko">No</span>
+      <span class="lang ru">No</span>
+      <span class="lang zh-cn">没有</span>
+      <span class="lang zh-tw">没有</span>
+    </a>
+  </div>
+</div> -->
+
 <?cs if:!devsite ?><?cs # leave out the global header for devsite; it is in devsite template ?>
   <!-- Header -->
   <div id="header-wrapper">
-    <div id="header">
+    <div id="header"><?cs call:butter_bar() ?>
       <div class="wrap" id="header-wrap">
         <div class="col-3 logo">
           <a href="<?cs var:toroot ?>index.html">
@@ -54,11 +100,20 @@
 
 
         <!-- Expanded quicknav -->
-        <div id="quicknav" class="col-9">
+        <div id="quicknav" class="col-13">
           <ul>
+            <li class="about">
+              <ul>
+                <li><a href="<?cs var:toroot ?>about/index.html">About</a></li>
+                <li><a href="<?cs var:toroot ?>wear/index.html">Wear</a></li>
+                <li><a href="<?cs var:toroot ?>tv/index.html">TV</a></li>
+                <li><a href="<?cs var:toroot ?>auto/index.html">Auto</a></li>
+              </ul>
+            </li>
             <li class="design">
               <ul>
                 <li><a href="<?cs var:toroot ?>design/index.html">Get Started</a></li>
+                <li><a href="<?cs var:toroot ?>design/devices.html">Devices</a></li>
                 <li><a href="<?cs var:toroot ?>design/style/index.html">Style</a></li>
                 <li><a href="<?cs var:toroot ?>design/patterns/index.html">Patterns</a></li>
                 <li><a href="<?cs var:toroot ?>design/building-blocks/index.html">Building Blocks</a></li>
@@ -92,7 +147,7 @@
                   ja-lang="リファレンス"
                   es-lang="Referencia"
                   >Reference</a></li>
-                <li><a href="<?cs var:toroot ?>tools/index.html"
+                <li><a href="<?cs var:toroot ?>sdk/index.html"
                   zh-tw-lang="相關工具"
                   zh-cn-lang="工具"
                   ru-lang="Инструменты"
@@ -100,7 +155,6 @@
                   ja-lang="ツール"
                   es-lang="Herramientas"
                   >Tools</a>
-                  <ul><li><a href="<?cs var:toroot ?>sdk/index.html">Get the SDK</a></li></ul>
                 </li>
                 <li><a href="<?cs var:toroot ?>google/index.html">Google Services</a>
                 </li>
@@ -117,6 +171,7 @@
                 <li><a href="<?cs var:toroot ?>distribute/users/index.html">Get Users</a></li>
                 <li><a href="<?cs var:toroot ?>distribute/engage/index.html">Engage &amp; Retain</a></li>
                 <li><a href="<?cs var:toroot ?>distribute/monetize/index.html">Monetize</a></li>
+                <li><a href="<?cs var:toroot ?>distribute/analyze/index.html">Analyze</a></li>
                 <li><a href="<?cs var:toroot ?>distribute/tools/index.html">Tools &amp; Reference</a></li>
                 <li><a href="<?cs var:toroot ?>distribute/stories/index.html">Developer Stories</a></li>
               </ul>
@@ -126,10 +181,35 @@
       </div><!-- end header-wrap.wrap -->
     </div><!-- end header -->
 
-  <?cs if:training || guide || reference || tools || develop || google || samples ?>
+  <?cs if:about || wear || tv || auto ?>
     <!-- Secondary x-nav -->
     <div id="nav-x">
         <div class="wrap">
+            <ul class="nav-x col-9 about" style="width:100%">
+                <li class="about"><a href="<?cs var:toroot ?>about/index.html"
+                  >About</a></li>
+                <li class="wear"><a href="<?cs var:toroot ?>wear/index.html"
+                  >Wear</a></li>
+                <li class="tv"><a href="<?cs var:toroot ?>tv/index.html"
+                  >TV</a></li>
+                <li class="auto"><a href="<?cs var:toroot ?>auto/index.html"
+                  >Auto</a></li>
+            </ul>
+        </div>
+    </div>
+    <!-- /Sendondary x-nav ABOUT -->
+
+
+
+  <?cs elif:training || guide || reference || tools || develop || google || samples ?>
+    <!-- Secondary x-nav -->
+    <div id="nav-x">
+        <div class="wrap" style="position:relative;z-index:1">
+
+        <?cs if:reference ?>
+
+        <?cs /if ?>
+
             <ul class="nav-x col-9 develop" style="width:100%">
                 <li class="training"><a href="<?cs var:toroot ?>training/index.html"
                   zh-tw-lang="訓練課程"
@@ -155,7 +235,7 @@
                   ja-lang="リファレンス"
                   es-lang="Referencia"
                   >Reference</a></li>
-                <li class="tools"><a href="<?cs var:toroot ?>tools/index.html"
+                <li class="tools"><a href="<?cs var:toroot ?>sdk/index.html"
                   zh-tw-lang="相關工具"
                   zh-cn-lang="工具"
                   ru-lang="Инструменты"
@@ -174,9 +254,9 @@
             </ul>
         </div>
     </div>
-    <!-- /Sendondary x-nav -->
+    <!-- /Sendondary x-nav DEVELOP -->
 
-  <?cs elif:distribute || googleplay || essentials || users || engage || monetize || disttools || stories ?>
+  <?cs elif:distribute || googleplay || essentials || users || engage || monetize || analyze ||  disttools || stories ?>
     <!-- Secondary distribute x-nav -->
     <div id="nav-x">
         <div class="wrap">
@@ -192,6 +272,9 @@
                 <li class="monetize"><a href="<?cs var:toroot ?>distribute/monetize/index.html"
                   >Monetize</a>
                 </li>
+                <li class="analyze"><a href="<?cs var:toroot ?>distribute/analyze/index.html"
+                  >Analyze</a>
+                </li>
                 <li class="disttools"><a href="<?cs var:toroot ?>distribute/tools/index.html"
                   >Tools</a>
                 </li>
@@ -202,6 +285,7 @@
             <a href="https://play.google.com/apps/publish/" class="developer-console-btn">Developer Console</a>
         </div> <!-- /Secondary distribute x-nav -->
     </div>
+    <!-- /Sendondary x-nav DISTRIBUTE -->
   <?cs /if ?>
 
     <div id="searchResults" class="wrap" style="display:none;">
@@ -223,23 +307,25 @@
   </div>
 
 <?cs /if ?><?cs # end if/else !devsite ?>
-<?cs /if ?><?cs # end if/else wear ?><?cs
+<?cs /if ?><?cs # end if/else preview ?><?cs
 /def ?>
 
-<?cs def:wear_masthead() ?>
+<?cs def:preview_masthead() ?>
 <a name="top"></a>
 
+
 <!-- Header -->
 <div id="header-wrapper">
-  <div id="header">
+  <div id="header"><?cs call:butter_bar() ?>
     <div class="wrap" id="header-wrap">
-      <div class="col_3 logo wear-logo">
-        <a href="<?cs var:toroot ?>wear/index.html">
-          <img src="<?cs var:toroot ?>wear/images/android-wear.png" height="16" alt="Android Wear" />
+      <div class="col_3 logo landing-logo" style="width:240px">
+        <a href="<?cs var:toroot ?>preview/index.html">
+          <img src="<?cs var:toroot ?>assets/images/android.png" height="25" alt="Android"
+            style="margin:-3px 0 0" />
         </a>
       </div>
-      <div class="col-8" style="margin:0"><h1 style="margin:1px 0 0 20px;padding:0;line-height:16px;
-color:#666;font-weight:100;font-size:24px;">Developer Preview</h1></div>
+      <div class="col-8" style="margin:0"><h1 style="margin: 4px 0 0 0px;padding:0;line-height:16px;
+color:#666;font-weight:100;font-size:27px;">M Developer Preview</h1></div>
 
       <?cs # ADD SEARCH AND MENU ?>
       <?cs call:header_search_widget() ?>
@@ -268,3 +354,22 @@
 
   <?cs
 /def ?>
+
+
+<?cs # (UN)COMMENT THE INSIDE OF THIS METHOD TO TOGGLE VISIBILITY ?>
+<?cs def:butter_bar() ?>
+
+<?cs # HIDE THE BUTTER BAR
+
+    <div style="height:20px"><!-- spacer to bump header down --></div>
+    <div id="butterbar-wrapper">
+      <div id="butterbar">
+        <a href="http://googleblog.blogspot.com/" id="butterbar-message">
+          The Android {version_number} SDK will be available on {Month} {Day}!
+        </a>
+      </div>
+    </div>
+
+?>
+
+<?cs /def ?>
diff --git a/tools/droiddoc/templates-sdk-dyn/customizations.cs b/tools/droiddoc/templates-sdk-dev/customizations.cs
similarity index 92%
rename from tools/droiddoc/templates-sdk-dyn/customizations.cs
rename to tools/droiddoc/templates-sdk-dev/customizations.cs
index 27822d5..c8c88cc 100644
--- a/tools/droiddoc/templates-sdk-dyn/customizations.cs
+++ b/tools/droiddoc/templates-sdk-dev/customizations.cs
@@ -112,6 +112,20 @@
     </script>
 <?cs /def ?><?cs
 
+def:analyze_nav() ?>
+  <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" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      $(document).ready(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+<?cs /def ?><?cs
+
 def:monetize_nav() ?>
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
@@ -290,6 +304,22 @@
     </script>
 <?cs /def ?>
 
+<?cs
+def:preview_nav() ?>
+  <div class="wrap clearfix" id="body-content">
+    <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" ?>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      $(document).ready(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+<?cs /def ?>
+
 <?cs # The default side navigation for the reference docs ?><?cs 
 def:default_left_nav() ?>
 <?cs if:reference.gcm || reference.gms ?>
@@ -337,6 +367,7 @@
 <?cs 
             if:subcount(class.package) ?>
             <ul>
+              <?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) ?>
@@ -345,6 +376,7 @@
             </ul><?cs 
             elif:subcount(package) ?>
             <ul>
+              <?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) ?>
@@ -431,8 +463,8 @@
                 <option value="ja">日本語</option>
                 <option value="ko">한국어</option>
                 <option value="ru">Русский</option>
-                <option value="zh-cn">中文 (中国)</option>
-                <option value="zh-tw">中文 (台灣)</option>
+                <option value="zh-cn">中文(简体)</option>
+                <option value="zh-tw">中文(繁體)</option>
             </select>
           </div>
         <script type="text/javascript">
@@ -526,6 +558,8 @@
       call:engage_nav() ?><?cs
     elif:monetize ?><?cs
       call:monetize_nav() ?><?cs
+    elif:analyze ?><?cs
+      call:analyze_nav() ?><?cs
     elif:disttools ?><?cs
       call:disttools_nav() ?><?cs
     elif:stories ?><?cs
@@ -537,6 +571,8 @@
     call:distribute_nav() ?><?cs
   elif:wear ?><?cs
     call:wear_nav() ?><?cs
+  elif:preview ?><?cs
+    call:preview_nav() ?><?cs
   else ?><?cs
     call:default_left_nav() ?> <?cs
   /if ?><?cs
diff --git a/tools/droiddoc/templates-sdk-dyn/data.hdf b/tools/droiddoc/templates-sdk-dev/data.hdf
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/data.hdf
rename to tools/droiddoc/templates-sdk-dev/data.hdf
diff --git a/tools/droiddoc/templates-sdk-dyn/designpage.cs b/tools/droiddoc/templates-sdk-dev/designpage.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/designpage.cs
rename to tools/droiddoc/templates-sdk-dev/designpage.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/docpage.cs b/tools/droiddoc/templates-sdk-dev/docpage.cs
similarity index 78%
rename from tools/droiddoc/templates-sdk-dyn/docpage.cs
rename to tools/droiddoc/templates-sdk-dev/docpage.cs
index 7eae405..83b1199 100644
--- a/tools/droiddoc/templates-sdk-dyn/docpage.cs
+++ b/tools/droiddoc/templates-sdk-dev/docpage.cs
@@ -2,7 +2,7 @@
 <?cs include:"macros.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs include:"head_tag.cs" ?>
-<body class="gc-documentation 
+<body class="gc-documentation
 
 <?cs
 if:(google || reference.gms || reference.gcm) ?>google<?cs /if ?><?cs
@@ -18,7 +18,7 @@
     if:monetize ?> monetize<?cs /if ?><?cs
     if:disttools ?> disttools<?cs /if ?><?cs
     if:stories ?> stories<?cs /if ?><?cs
-  elif:about ?>about<?cs
+  elif:(about||wear||tv||auto) ?>about<?cs
   elif:design ?>design<?cs
 /if ?><?cs
 if:page.trainingcourse ?> trainingcourse<?cs
@@ -90,7 +90,7 @@
       </div>
     <?cs /if ?><?cs # end if training ?>
   </div>
-  <?cs /if ?>
+  <?cs /if ?><?cs # end if header.hide ?>
 
 <?cs elif:samplesProjectIndex ?>
   <div id="api-info-block">
@@ -103,7 +103,14 @@
   <h1 itemprop="name"><?cs var:projectDir ?></h1>
 
 <?cs else ?>
-
+  <?cs if:training ?>
+<?cs # horrible horrible hack to move TOC up when the next/prev links are not there ?>
+<style>
+  #tb-wrapper {
+    margin-top:6px;
+  }
+</style>
+  <?cs /if ?>
 
   <?cs if:(!fullpage && !header.hide) ?>
     <?cs if:page.landing ?><?cs # header logic for docs that are landing pages ?>
@@ -150,25 +157,9 @@
                     if:fullpage ?>wrap<?cs
                     else ?>layout-content-row<?cs /if ?>"
                     itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <div class="layout-content-col <?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 layout-content-col col-4">
+        <div class="paging-links layout-content-col col-10">
           <?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="下一课"
@@ -185,41 +176,28 @@
                 ja-lang="開始する"
                 es-lang="Empezar"
                 >Get started</a>
+            <a href="#" class="next-class-link hide">Next class</a>
+          <?cs /if ?>
+        </div>
+        <div class="layout-content-col plus-container col-2" >
+          <?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 ?>
       </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="layout-content-row 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" ?>
 </div><!-- end doc-content -->
 
-<!-- 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 -->
-
-
 <?cs include:"trailer.cs" ?>
   <script src="https://developer.android.com/ytblogger_lists_unified.js" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_lists_unified.js" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_extras.js" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_collections.js" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_tag_helpers.js" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_lists_unified.js?v=9" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_extras.js?v=11" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_collections.js?v=12" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_tag_helpers.js?v=5" type="text/javascript"></script>
 
 </body>
 </html>
diff --git a/tools/droiddoc/templates-sdk-dyn/footer.cs b/tools/droiddoc/templates-sdk-dev/footer.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/footer.cs
rename to tools/droiddoc/templates-sdk-dev/footer.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/gcm_navtree_data.cs b/tools/droiddoc/templates-sdk-dev/gcm_navtree_data.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/gcm_navtree_data.cs
rename to tools/droiddoc/templates-sdk-dev/gcm_navtree_data.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/gms_navtree_data.cs b/tools/droiddoc/templates-sdk-dev/gms_navtree_data.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/gms_navtree_data.cs
rename to tools/droiddoc/templates-sdk-dev/gms_navtree_data.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/head_tag.cs b/tools/droiddoc/templates-sdk-dev/head_tag.cs
similarity index 65%
rename from tools/droiddoc/templates-sdk-dyn/head_tag.cs
rename to tools/droiddoc/templates-sdk-dev/head_tag.cs
index 732118f..9f79f54 100644
--- a/tools/droiddoc/templates-sdk-dyn/head_tag.cs
+++ b/tools/droiddoc/templates-sdk-dev/head_tag.cs
@@ -24,8 +24,8 @@
 <meta name="Description" content="<?cs var:page.metaDescription ?>"><?cs
   /if ?>
 <link rel="shortcut icon" type="image/x-icon" href="<?cs var:toroot ?>favicon.ico" />
-<title><?cs 
-  if:page.title ?><?cs 
+<title><?cs
+  if:page.title ?><?cs
     var:page.title ?> | <?cs
   /if ?>Android Developers</title>
 
@@ -38,9 +38,9 @@
 if:android.whichdoc != 'online' ?>http:<?cs
 /if ?>//fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
   title="roboto">
-<link href="<?cs var:toroot ?>assets/css/default.css" rel="stylesheet" type="text/css">
+<link href="<?cs var:toroot ?>assets/css/default.css?v=5" rel="stylesheet" type="text/css">
 
-<?cs if:reference && !(reference.gms || reference.gcm || wear) ?>
+<?cs if:reference && !(reference.gms || reference.gcm || preview) ?>
 <!-- FULLSCREEN STYLESHEET -->
 <link href="<?cs var:toroot ?>assets/css/fullscreen.css" rel="stylesheet" class="fullscreen"
 type="text/css">
@@ -62,17 +62,25 @@
   var metaTags = [<?cs var:meta.tags ?>];
   var devsite = <?cs if:devsite ?>true<?cs else ?>false<?cs /if ?>;
 </script>
-<script src="<?cs var:toroot ?>assets/js/docs.js" type="text/javascript"></script>
+<script src="<?cs var:toroot ?>assets/js/docs.js?v=3" type="text/javascript"></script>
 
-<script type="text/javascript">
-  var _gaq = _gaq || [];
-  _gaq.push(['_setAccount', 'UA-5831155-1']);
-  _gaq.push(['_trackPageview']);
+<?cs if:helpoutsWidget ?>
+<script type="text/javascript" src="https://helpouts.google.com/ps/res/embed.js" defer async
+    data-helpouts-embed data-helpouts-vertical="programming"
+    data-helpouts-tags="<?cs var:page.tags ?>" data-helpouts-prefix="android"
+    data-helpouts-standalone="true"></script>
+<?cs /if ?>
 
-  (function() {
-    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-  })();
+<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>
+
 </head>
diff --git a/tools/droiddoc/templates-sdk-dyn/header.cs b/tools/droiddoc/templates-sdk-dev/header.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/header.cs
rename to tools/droiddoc/templates-sdk-dev/header.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/header_tabs.cs b/tools/droiddoc/templates-sdk-dev/header_tabs.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/header_tabs.cs
rename to tools/droiddoc/templates-sdk-dev/header_tabs.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/jd_lists_unified.cs b/tools/droiddoc/templates-sdk-dev/jd_lists_unified.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/jd_lists_unified.cs
rename to tools/droiddoc/templates-sdk-dev/jd_lists_unified.cs
diff --git a/tools/droiddoc/templates-sdk-dev/macros_override.cs b/tools/droiddoc/templates-sdk-dev/macros_override.cs
new file mode 100644
index 0000000..0a94598
--- /dev/null
+++ b/tools/droiddoc/templates-sdk-dev/macros_override.cs
@@ -0,0 +1,36 @@
+<?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 ?>
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk-dyn/navtree_data.cs b/tools/droiddoc/templates-sdk-dev/navtree_data.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/navtree_data.cs
rename to tools/droiddoc/templates-sdk-dev/navtree_data.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/nosidenavpage.cs b/tools/droiddoc/templates-sdk-dev/nosidenavpage.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/nosidenavpage.cs
rename to tools/droiddoc/templates-sdk-dev/nosidenavpage.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/package.cs b/tools/droiddoc/templates-sdk-dev/package.cs
similarity index 91%
rename from tools/droiddoc/templates-sdk-dyn/package.cs
rename to tools/droiddoc/templates-sdk-dev/package.cs
index 99eaff2..2225565 100644
--- a/tools/droiddoc/templates-sdk-dyn/package.cs
+++ b/tools/droiddoc/templates-sdk-dev/package.cs
@@ -1,10 +1,13 @@
 <?cs include:"doctype.cs" ?>
 <?cs include:"macros.cs" ?>
+<?cs include:"macros_override.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs include:"head_tag.cs" ?>
 
 <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<?cs
+    /if ?><?cs
   elif:design ?>design<?cs
   elif:distribute ?>distribute<?cs
   /if ?>">
@@ -45,6 +48,7 @@
   <?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) ?>
diff --git a/tools/droiddoc/templates-sdk-dyn/packages.cs b/tools/droiddoc/templates-sdk-dev/packages.cs
similarity index 95%
rename from tools/droiddoc/templates-sdk-dyn/packages.cs
rename to tools/droiddoc/templates-sdk-dev/packages.cs
index 44680c3..5056d3a 100644
--- a/tools/droiddoc/templates-sdk-dyn/packages.cs
+++ b/tools/droiddoc/templates-sdk-dev/packages.cs
@@ -4,6 +4,8 @@
 <?cs include:"head_tag.cs" ?>
 <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<?cs
+    /if ?><?cs
   elif:design ?>design<?cs
   elif:distribute ?>distribute<?cs
   /if ?>">
diff --git a/tools/droiddoc/templates-sdk-dyn/sample.cs b/tools/droiddoc/templates-sdk-dev/sample.cs
similarity index 97%
rename from tools/droiddoc/templates-sdk-dyn/sample.cs
rename to tools/droiddoc/templates-sdk-dev/sample.cs
index c6f28f8..32a0788 100644
--- a/tools/droiddoc/templates-sdk-dyn/sample.cs
+++ b/tools/droiddoc/templates-sdk-dev/sample.cs
@@ -18,7 +18,7 @@
   <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="_gaq.push(['_trackEvent', 'Samples', 'Download', <?cs var:projectDir ?>]);"
+    onclick="ga('send', 'event', 'Samples', 'Download', <?cs var:projectDir ?>);"
     >Download</a>
 
 </div><!-- end sum-details-links -->
diff --git a/tools/droiddoc/templates-sdk-dyn/sampleindex.cs b/tools/droiddoc/templates-sdk-dev/sampleindex.cs
similarity index 97%
rename from tools/droiddoc/templates-sdk-dyn/sampleindex.cs
rename to tools/droiddoc/templates-sdk-dev/sampleindex.cs
index 98767b1..1bacb53 100644
--- a/tools/droiddoc/templates-sdk-dyn/sampleindex.cs
+++ b/tools/droiddoc/templates-sdk-dev/sampleindex.cs
@@ -21,7 +21,7 @@
 &#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="_gaq.push(['_trackEvent', 'Samples', 'Download', <?cs var:projectDir ?>]);"
+    onclick="ga('send', 'event', 'Samples', 'Download', <?cs var:projectDir ?>);"
     >Download</a>
 
 </div><!-- end sum-details-links -->
diff --git a/tools/droiddoc/templates-sdk-dyn/samples_navtree_data.cs b/tools/droiddoc/templates-sdk-dev/samples_navtree_data.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/samples_navtree_data.cs
rename to tools/droiddoc/templates-sdk-dev/samples_navtree_data.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/sdkpage.cs b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
similarity index 69%
rename from tools/droiddoc/templates-sdk-dyn/sdkpage.cs
rename to tools/droiddoc/templates-sdk-dev/sdkpage.cs
index 95f6596..817ac47 100644
--- a/tools/droiddoc/templates-sdk-dyn/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
@@ -183,21 +183,7 @@
     <td><?cs var:ndk.linux64.legacy_bytes ?></td>
     <td><?cs var:ndk.linux64.legacy_checksum ?></td>
   </tr> -->
-    <tr>
-      <th>Additional Download</th>
-      <th>Package</th>
-      <th style="white-space:nowrap">Size (Bytes)</th>
-      <th>MD5 Checksum</th>
-  </tr>
-  <tr>
-    <td>STL debug info</td>
-    <td>
-  <a onClick="return onDownload(this)"
-     href="http://dl.google.com/android/ndk/<?cs var:ndk.debug_info_download ?>"><?cs var:ndk.debug_info_download ?></a>
-    </td>
-    <td><?cs var:ndk.debug_info_bytes ?></td>
-    <td><?cs var:ndk.debug_info_checksum ?></td>
-  </tr>
+
   </table>
 
   <?cs ########  HERE IS THE JD DOC CONTENT ######### ?>
@@ -278,89 +264,25 @@
 
 
 
-<h4><a href='' class="expandable"
-  onclick="toggleExpandable(this,'.pax');hideExpandable('.myide,.reqs');return false;"
-  >DOWNLOAD FOR OTHER PLATFORMS</a></h4>
+<div class="pax col-13 online" style="margin:0;">
 
 
-<div class="pax col-13 online" style="display:none;margin:0;">
+<h3>SDK Tools Only</h3>
 
+<p>If you prefer to use a different IDE or run the tools from the
+command line or with build scripts, you can instead download the stand-alone Android SDK Tools.
+These packages provide the basic SDK tools for app development, without an IDE.
+Also see the <a href="<?cs var:toroot ?>tools/sdk/tools-notes.html">SDK tools release notes</a>.</p>
 
-<p class="table-caption"><strong>ADT Bundle</strong></p>
   <table class="download">
     <tr>
       <th>Platform</th>
       <th>Package</th>
       <th>Size</th>
-      <th>MD5 Checksum</th>
+      <th>SHA-1 Checksum</th>
   </tr>
   <tr>
-    <td>Windows 32-bit</td>
-    <td>
-  <a onClick="return onDownload(this)" id="win-bundle32"
-     href="http://dl.google.com/android/adt/<?cs var:sdk.version ?>/<?cs var:sdk.win32_bundle_download ?>"><?cs var:sdk.win32_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.win32_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.win32_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Windows 64-bit</td>
-    <td>
-  <a onClick="return onDownload(this)" id="win-bundle64"
-     href="http://dl.google.com/android/adt/<?cs var:sdk.version ?>/<?cs var:sdk.win64_bundle_download ?>"><?cs var:sdk.win64_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.win64_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.win64_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td><nobr>Mac OS X 64-bit</nobr></td>
-    <td>
-  <a onClick="return onDownload(this)" id="mac-bundle64"
-     href="http://dl.google.com/android/adt/<?cs var:sdk.version ?>/<?cs var:sdk.mac64_bundle_download ?>"><?cs var:sdk.mac64_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.mac64_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.mac64_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Linux 32-bit</td>
-    <td>
-  <a onClick="return onDownload(this)" id="linux-bundle32"
-     href="http://dl.google.com/android/adt/<?cs var:sdk.version ?>/<?cs var:sdk.linux32_bundle_download ?>"><?cs var:sdk.linux32_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.linux32_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.linux32_bundle_checksum ?></td>
-  </tr>
-  <tr>
-    <td>Linux 64-bit</td>
-    <td>
-  <a onClick="return onDownload(this)" id="linux-bundle64"
-     href="http://dl.google.com/android/adt/<?cs var:sdk.version ?>/<?cs var:sdk.linux64_bundle_download ?>"><?cs var:sdk.linux64_bundle_download ?></a>
-    </td>
-    <td><?cs var:sdk.linux64_bundle_bytes ?> bytes</td>
-    <td><?cs var:sdk.linux64_bundle_checksum ?></td>
-  </tr>
-  </table>
-
-
-<p class="table-caption"><strong>SDK Tools Only</strong></p>
-  <table class="download">
-    <tr>
-      <th>Platform</th>
-      <th>Package</th>
-      <th>Size</th>
-      <th>MD5 Checksum</th>
-  </tr>
-  <tr>
-    <td rowspan="2">Windows<br>32 &amp; 64-bit</td>
-    <td>
-  <a onclick="return onDownload(this)" href="http://dl.google.com/android/<?cs var:sdk.win_download
-?>"><?cs var:sdk.win_download ?></a>
-    </td>
-    <td><?cs var:sdk.win_bytes ?> bytes</td>
-    <td><?cs var:sdk.win_checksum ?></td>
-  </tr>
-  <tr>
-    <!-- blank TD from Windows rowspan -->
+    <td rowspan="2">Windows</td>
     <td>
   <a onclick="return onDownload(this)" id="win-tools" href="http://dl.google.com/android/<?cs
 var:sdk.win_installer
@@ -370,7 +292,16 @@
     <td><?cs var:sdk.win_installer_checksum ?></td>
   </tr>
   <tr>
-    <td><nobr>Mac OS X</nobr><br>32 &amp; 64-bit</td>
+    <!-- blank TD from Windows rowspan -->
+    <td>
+  <a onclick="return onDownload(this)" href="http://dl.google.com/android/<?cs var:sdk.win_download
+?>"><?cs var:sdk.win_download ?></a>
+    </td>
+    <td><?cs var:sdk.win_bytes ?> bytes</td>
+    <td><?cs var:sdk.win_checksum ?></td>
+  </tr>
+  <tr>
+    <td><nobr>Mac OS X</nobr></td>
     <td>
   <a onclick="return onDownload(this)" id="mac-tools" href="http://dl.google.com/android/<?cs
 var:sdk.mac_download
@@ -380,7 +311,7 @@
     <td><?cs var:sdk.mac_checksum ?></td>
   </tr>
   <tr>
-    <td>Linux<br>32 &amp; 64-bit</td>
+    <td>Linux</td>
     <td>
   <a onclick="return onDownload(this)" id="linux-tools" href="http://dl.google.com/android/<?cs
 var:sdk.linux_download
@@ -391,6 +322,79 @@
   </tr>
   </table>
 
+
+
+<h3>All Android Studio Packages</h3>
+
+<p>Select a specific Android Studio package for your platform. Also see the
+<a href="<?cs var:toroot ?>tools/revisions/studio.html">Android Studio release notes</a>.</p>
+
+  <table class="download">
+    <tr>
+      <th>Platform</th>
+      <th>Package</th>
+      <th>Size</th>
+      <th>SHA-1 Checksum</th>
+  </tr>
+
+  <tr>
+    <td rowspan="3">Windows</td>
+    <td>
+  <a onclick="return onDownload(this)" id="win-bundle"
+    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_exe_download ?>"
+    ><?cs var:studio.win_bundle_exe_download ?></a><br>(Recommended)
+    </td>
+    <td><?cs var:studio.win_bundle_exe_bytes ?> bytes</td>
+    <td><?cs var:studio.win_bundle_exe_checksum ?></td>
+  </tr>
+
+  <tr>
+    <!-- blank TD from Windows rowspan -->
+    <td>
+  <a onclick="return onDownload(this)"
+    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.win_notools_exe_download ?>"
+    ><?cs var:studio.win_notools_exe_download ?></a><br>(No SDK tools included)
+    </td>
+    <td><?cs var:studio.win_notools_exe_bytes ?> bytes</td>
+    <td><?cs var:studio.win_notools_exe_checksum ?></td>
+  </tr>
+
+  <tr>
+    <!-- blank TD from Windows rowspan -->
+    <td>
+  <a onclick="return onDownload(this)"
+    href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.win_bundle_download ?>"
+    ><?cs var:studio.win_bundle_download ?></a>
+    </td>
+    <td><?cs var:studio.win_bundle_bytes ?> bytes</td>
+    <td><?cs var:studio.win_bundle_checksum ?></td>
+  </tr>
+
+  <tr>
+    <td><nobr>Mac OS X</nobr></td>
+    <td>
+  <a onclick="return onDownload(this)" id="mac-bundle"
+    href="https://dl.google.com/dl/android/studio/install/<?cs var:studio.version ?>/<?cs var:studio.mac_bundle_download ?>"
+    ><?cs var:studio.mac_bundle_download ?></a>
+    </td>
+    <td><?cs var:studio.mac_bundle_bytes ?> bytes</td>
+    <td><?cs var:studio.mac_bundle_checksum ?></td>
+  </tr>
+
+  <tr>
+    <td>Linux</td>
+    <td>
+  <a onclick="return onDownload(this)" id="linux-bundle"
+    href="https://dl.google.com/dl/android/studio/ide-zips/<?cs var:studio.version ?>/<?cs var:studio.linux_bundle_download ?>"
+    ><?cs var:studio.linux_bundle_download ?></a>
+    </td>
+    <td><?cs var:studio.linux_bundle_bytes ?> bytes</td>
+    <td><?cs var:studio.linux_bundle_checksum ?></td>
+  </tr>
+  </table>
+
+
+
 </div><!-- end pax -->
 
 
@@ -411,7 +415,9 @@
   var bundlename;
   var $toolslink;
 
-  if (navigator.appVersion.indexOf("Win")!=-1) {
+  if (navigator.appVersion.indexOf("Mobile")!=-1) {
+    // Do nothing for any "mobile" user agent
+  } else if (navigator.appVersion.indexOf("Win")!=-1) {
     os = "Windows";
     bundlename = '#win-bundle';
     $toolslink = $('#win-tools');
@@ -419,26 +425,18 @@
     os = "Mac";
     bundlename = '#mac-bundle';
     $toolslink = $('#mac-tools');
-  } else if (navigator.appVersion.indexOf("Linux")!=-1) {
+  } else if (navigator.appVersion.indexOf("Linux")!=-1 && navigator.appVersion.indexOf("Android")==-1) {
     os = "Linux";
     bundlename = '#linux-bundle';
     $toolslink = $('#linux-tools');
   }
 
-  if (os) {
+  if (os != undefined) {
     $('#not-supported').hide();
 
-    /* set up primary adt download button */
-    $('#download-bundle-button').show();
-    $('#download-bundle-button').append("Download the SDK <br/><span class='small'>ADT Bundle for " + os + "</span>");
-    $('#download-bundle-button').click(function() {return onDownload(this,true,true);}).attr('href', bundlename);
-
-    /* set up sdk tools only button */
-    $('#download-tools-button').show();
-    $('#download-tools-button').append("Download the SDK Tools for " + os);
-    $('#download-tools-button').click(function() {return onDownload(this,true);}).attr('href', $toolslink.attr('href'));
-  } else {
-    $('.pax').show();
+    /* set up primary Android Studio download button */
+    $('.download-bundle-button').append(" <br/><span class='small'>for " + os + "</span>");
+    $('.download-bundle-button').click(function() {return onDownload(this,true,true);}).attr('href', bundlename);
   }
 
 
@@ -451,44 +449,29 @@
       $("#downloadForRealz").html("Download " + $(link).text());
     }
 
-    /* if it's a bundle, show the 32/64-bit picker */
-    if (bundle) {
-      $("#downloadForRealz").attr('bundle','true');
-      if ($("#downloadForRealz").text().indexOf("Mac") == -1) {
-        $("p#bitpicker").show();
-      } else {
-        /* mac is always 64 bit, so set it checked */
-        $("p#bitpicker input[value=64]").attr('checked', true);
-      }
-      /* save link name until the bit version is chosen */
-      $("#downloadForRealz").attr('name',$(link).attr('href'));
-    } else {
-      /* if not using bundle, set download button to ignore bitpicker and set url */
-      $("#downloadForRealz").attr('bundle','false');
-      $("#downloadForRealz").attr('href',$(link).attr('href'));
-      /* set picker checked as a fake default */
-      $("p#bitpicker input[value=64]").attr('checked', true);
-      $("a#next-link").html("Setting Up an Existing IDE").attr('href',toRoot + 'sdk/installing/index.html');
-    }
+    $("#downloadForRealz").attr('bundle', bundle);
+    $("a#downloadForRealz").attr("name", $(link).attr('href'));
 
-    $("#tos").fadeIn('fast');
-    $("#landing").fadeOut('fast');
+    $("#tos").show();
+    $("#landing").hide();
 
-    location.hash = "download";
+    location.hash = "top";
     return false;
   }
 
 
   function onAgreeChecked() {
-    /* verify that the TOS is agreed and a bit version is chosen */
-    if ($("input#agree").is(":checked") && $("#bitpicker input:checked").length) {
+    /* verify that the TOS is agreed */
+    if ($("input#agree").is(":checked")) {
 
       /* if downloading the bundle */
       if ($("#downloadForRealz").attr('bundle')) {
-        /* construct the name of the link we want based on the bit version */
-        linkId = $("a#downloadForRealz").attr("name") + $("#bitpicker input:checked").val();
+        /* construct the name of the link we want */
+        linkId = $("a#downloadForRealz").attr("name");
         /* set the real url for download */
         $("a#downloadForRealz").attr("href", $(linkId).attr("href"));
+      } else {
+        $("a#downloadForRealz").attr("href", $("a#downloadForRealz").attr("name"));
       }
 
       /* reveal the download button */
@@ -499,16 +482,28 @@
   }
 
   function onDownloadForRealz(link) {
-    if ($("input#agree").is(':checked') && $("#bitpicker input:checked").length) {
+    if ($("input#agree").is(':checked')) {
+      location.hash = "";
+      location.hash = "top";
       $("div.sdk-terms").slideUp();
-      $("#sdk-terms-form,.sdk-terms-intro").fadeOut('slow');
-      $("#next-steps").fadeIn('slow');
-      $("h1#tos-header").text('Get Ready to Code!');
-      _gaq.push(['_trackEvent', 'SDK', 'ADT and Tools', $("#downloadForRealz").html()]);
+      $("h1#tos-header").text('Now downloading...');
+      $(".sdk-terms-intro").text('You\'ll be redirected to the install instructions in a moment.');
+      $("#sdk-terms-form").fadeOut('slow', function() {
+        setTimeout(function() {
+          if ($("#downloadForRealz").attr('bundle') == 'true') {
+            // User downloaded the studio Bundle
+            window.location = "/sdk/installing/index.html?pkg=studio";
+          } else {
+            // User downloaded the SDK Tools
+            window.location = "/sdk/installing/index.html?pkg=tools";
+          }
+        }, 3000);
+      });
+      ga('send', 'event', 'SDK', 'IDE and Tools', $("#downloadForRealz").html());
       return true;
     } else {
-      $("label#agreeLabel,#bitpicker input").parent().stop().animate({color: "#258AAF"}, 200,
-        function() {$("label#agreeLabel,#bitpicker input").parent().stop().animate({color: "#222"}, 200)}
+      $("label#agreeLabel").parent().stop().animate({color: "#258AAF"}, 200,
+        function() {$("label#agreeLabel").parent().stop().animate({color: "#222"}, 200)}
       );
       return false;
     }
diff --git a/tools/droiddoc/templates-sdk-dyn/timestamp.cs b/tools/droiddoc/templates-sdk-dev/timestamp.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/timestamp.cs
rename to tools/droiddoc/templates-sdk-dev/timestamp.cs
diff --git a/tools/droiddoc/templates-sdk-dyn/trailer.cs b/tools/droiddoc/templates-sdk-dev/trailer.cs
similarity index 100%
rename from tools/droiddoc/templates-sdk-dyn/trailer.cs
rename to tools/droiddoc/templates-sdk-dev/trailer.cs
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 2e01559..693027a 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -17,18 +17,32 @@
   height: 100%;
   margin: 0;
   padding: 0;
-  background-color:#F9F9F9;
+  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: #222;
-  font: 14px/19px Roboto, sans-serif;
+  color: #515151;
+  color: rgba(0, 0, 0, .68);
+  font: 14px/24px Roboto, sans-serif;
   font-weight: 400;
   letter-spacing:.1;
-  padding:0 10px; }
+  padding:0 20px;
+}
+
+@media (max-width: 719px) {
+  html {
+    /* Disable accidental horizontal overflow. */
+    overflow-x: hidden;
+  }
+
+  body {
+    padding: 0 10px;
+  }
+}
 
 #page-container {
   width: 940px;
@@ -83,13 +97,8 @@
 }
 
 #side-nav {
-  min-height:5px; /* silly way to avoid doc floating left when nav goes fixed */
-  margin-bottom:1px;
+  padding-top: 20px;
 }
-#devdoc-nav {
-  outline:none;
-  width:auto;
-  margin: 20px 0 0; }
 
 #devdoc-nav h2 {
   border:0;
@@ -98,44 +107,251 @@
 #devdoc-nav.fixed {
   position: fixed;
   margin:0;
-  top: 65px; /* sticky-header height + 20px gutter */
+  top: 84px; /* sticky-header height + 20px gutter */
 }
 
-#devdoc-nav span.small {
-  font-size:12px;
-  font-weight:normal;
+.dac-devdoc-toggle {
+  cursor: pointer;
+  padding: 8px 0;
+}
+
+.scroll-pane {
+  /* Match height of fixed parent. */
+  height: 100%;
 }
 
 #content {
   width: 760px;
   float: left; }
 
-a:hover,
-acronym:hover {
-  color: #7aa1b0 !important; }
 
-a:focus,
-a:active {
-  color: #33b5e5 !important; }
+/***** 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 {
+  max-width: 100%;
+  object-fit: cover;
+}
+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;
+  margin: 24px 0 12px;
+  font-weight: 300;
+}
+h1.short {
+  margin-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: 24px 0 16px;
+}
+h3 {
+  font-size: 24px;
+  line-height: 32px;
+  font-weight: 400;
+  margin: 16px 0;
+}
+h4 {
+  font-size: 18px;
+  line-height: 24px;
+  margin: 12px 0;
+  font-weight: 500;
+}
+h5, h6 {
+  font-size: 16px;
+  line-height: 24px;
+  margin: 8px 0;
+}
+hr { /* applied to the bottom of h2 elements */
+  height: 1px;
+  margin: 7px 0 12px;
+  border: 0;
+  background: #e5e5e5;
+}
+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 {
+  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, Courier, monospace;
+  -webkit-font-smoothing: subpixel-antialiased;
+  -moz-osx-font-smoothing: auto;
+}
+code {
+  background-color: #f7f7f7;
+  padding: 3px 5px;
+}
+
+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: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;
 }
 
-img {
-  border: none; }
 #jd-content img {
   margin-bottom:15px;
 }
 
-ul {
-  margin: 0;
-  padding: 0; }
-
-strong {
-  font-weight: 500; }
-
 em {
   font-style: italic; }
 
@@ -155,6 +371,7 @@
 
 /* disclosures mixin */
 /* content layout */
+/* This grid is deprecated in favor of .cols and .col-X */
 .layout-content-row {
   display: inline-block;
   margin-bottom: 10px; }
@@ -264,33 +481,32 @@
   /* sublinks */ }
   #nav li {
     list-style-type: none;
-    font-size: 14px;
+    font-size: 12px;
     margin:0;
     padding:0;
-    line-height: 15px; }
+    line-height: 18px; }
   #nav a {
-    color: #555555;
+    color: #505050;
     text-decoration: none;
     word-wrap:break-word; }
   #nav .nav-section-header {
     position: relative;
     margin-bottom: 1px;
     padding: 0 30px 0 0; }
-  #nav li.selected a, #nav li.selected > .nav-section-header > a {
-    color: #09C;
+  #nav li.selected a {
+    color: #039BE5;
   }
   #nav li.selected ul li a {
   /* don't highlight child items */
-    color: #555555; }
+    color: #505050; }
   #nav .nav-section .nav-section .nav-section-header {
     /* no white line between second level sections */
     margin-bottom: 0; }
     /* section header links */
     #nav > li > div > a {
       display: block;
-      color: #333333;
-      font-weight: 500;
-      padding: 10px 0 10px 10px; }
+      font-weight: 700;
+      padding: 13px 0 12px 10px; }
     #nav .nav-section-header:after {
       content: '';
       background: transparent url(../images/styles/disclosure_down.png) no-repeat scroll 50% 50%;
@@ -298,7 +514,7 @@
       height: 34px;
       display: block;
       position: absolute;
-      top: 0;
+      top: 6px;
       right: 0; }
     #nav .nav-section-header.empty {
       padding:0; }
@@ -312,22 +528,24 @@
     #nav .nav-section li a {
     /* first gen child (2nd level li) */
       display:block;
-      font-weight: normal;
+      font-weight: 700;
       text-transform: none;
-      padding: 7px 5px 7px 10px;
+      padding: 13px 5px 13px 10px;
        }
     #nav .nav-section li li a {
     /* second gen child (3rd level li) */
-      padding: 5px 5px 5px 10px;
+      font-weight: 400;
+      padding: 7px 5px 7px 10px;
        }
   #nav li.expanded .nav-section-header {
-    background:#e9e9e9;
-    background: rgba(0, 0, 0, 0.05); }
+    background: #f0f0f0; }
+  #nav li.expanded .nav-section-header.empty {
+    background: none; }
   #nav li.expanded li .nav-section-header {
-    background: transparent; }
+    background: none; }
   #nav li.expanded li ul {
   /* 3rd level ul */
-    padding:0 0 0 10px;
+    padding:6px 0 1px 20px;
   }
     #nav li.expanded > .nav-section-header:after {
       content: '';
@@ -394,16 +612,12 @@
       padding-bottom:0;
     }
     #nav li.expanded ul > li {
-      background:#efefef;
-      background: rgba(0, 0, 0, 0.03); }
+      background:#f7f7f7; }
     #nav li.expanded ul > li li {
       background:inherit; }
   #nav li ul.tree-list-children ul {
     display:block; }
 
-#nav.samples-nav li li li {
-  font-size:13px;
-}
 #nav.samples-nav li li li a {
   padding-top:3px;
   padding-bottom:3px;
@@ -423,25 +637,19 @@
 
 /* content header */
 .content-header {
-  height: 30px;
-  margin:36px 0 23px;  /* same as h1 */
-  padding:0 0 10px;}  /* same as h1 */
+  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-header h1 {
-  margin:0;
-  padding:0;
-  width: 700px;
-}
-.content-header > div:first-child {
-  height:1px; /* set fixed height for the header div to ensure the
-                  next/prev links align with toc on training classes */
-}
-
 .content-footer {
-  border-top: 1px solid #ccc;
   margin-top: 10px;
   padding-top:10px;
   width:100%; }
@@ -453,7 +661,7 @@
   margin-right:0;
 }
 .content-footer.wrap {
-  width:940px;
+  max-width:940px;
 }
 .content-footer .plus-container {
   margin:5px 0 0;
@@ -467,7 +675,10 @@
 }
 
 .content-header .paging-links {
-  margin-top:-25px;
+  position: absolute;
+  right: 0;
+  top: 8px;
+  width: 220px;
 }
 .paging-links {
   position: relative;
@@ -476,9 +687,7 @@
     position: absolute; }
   .paging-links a,
   .training-nav-top a {
-    color: #555555;
-    text-decoration: none;
-    text-transform: uppercase; }
+    text-decoration: none; }
     .paging-links .prev-page-link:before,
     .training-nav-top .prev-page-link:before,
     a.back-link:before {
@@ -488,10 +697,6 @@
       height: 10px;
       display: inline-block;
       margin-right: 5px; }
-    .training-nav-top .next-page-link,
-    .training-nav-top .start-class-link,
-    .training-nav-top .start-course-link {
-    right: 10px; }
     .paging-links .prev-page-link {
       left: -15px; }
     .paging-links .next-page-link {
@@ -517,20 +722,25 @@
   }
 
   .training-nav-top a {
+    border-bottom:0;
+    box-sizing: border-box;
+    color: inherit;
     display:block;
     float:left;
-    width:122px;
-    height:28px;
-    padding: 8px;
-    line-height:28px;
+    padding:10px 0;
+    line-height:30px;
     text-align:center;
-    border:1px solid #DADADA;
-    border-bottom:0;
+    width: 50%;
+  }
+  
+  .training-nav-top a.prev-page-link {
+    padding-left: 15px;
+    text-align: left;
   }
 
   .training-nav-top a.next-page-link {
-    border-left:0;
-    width:123px;
+    padding-right: 15px;
+    text-align: right;
   }
 
   .paging-links a.disabled,
@@ -547,41 +757,57 @@
   }
 
   .training-nav-top a.start-class-link,
-  .training-nav-top a.start-course-link {
-    width:262px;
-  }
-
+  .training-nav-top a.start-course-link,
   .paging-links a.start-class-link {
     width:100%;
   }
 
   /* list of classes on course landing page */
   ol.class-list {
-    list-style:none;
-    margin-left:0;
+    counter-reset: class;
+    list-style: none;
+    margin: 60px 0 0;
   }
   ol.class-list>li {
-    margin:0 0 15px;
-    padding:5px 0 0;
-    overflow:hidden;
-    border-top:1px solid #ccc;
+    box-shadow: 0px 2px 5px 0 rgba(0, 0, 0, 0.26);
+    margin: 0 0 20px;
+    overflow: hidden;
   }
-  ol.class-list li a.title {
-    font-size:16px;
-    margin:0;
-    clear:left;
-    display:block;
-    height:32px;
-    padding:0 4px;
+  ol.class-list .title {
+    background: #00bcd4;
+    color: #fff;
+    display: block;
+    font-size: 20px;
+    font-weight: 500;
+    height: 32px;
+    margin: 0;
+    padding: 52px 16px 12px;
+    position: relative;
   }
-  ol.class-list li a.title h2 {
-    color:inherit;
+  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;
     margin:0 0 10px;
     display:block;
     float:left;
     width:675px;
   }
-  ol.class-list li a.title span {
+  ol.class-list .title span {
     display:none;
     float:left;
     font-size:18px;
@@ -590,40 +816,71 @@
     width: 10px;
     height: 32px;
   }
-  ol.class-list li a.title:hover {
-    background:#ddd;
-    color:#258AAF !important;
-  }
-  ol.class-list li a.title:hover span {
-    display:block;
-  }
 
-  #jd-content
-  ol.class-list li img {
-    float:left;
-    clear:left;
-    width:64px;
-    margin:0 20px 0 0;
-  }
-  ol.class-list li p.description {
+  ol.class-list .description {
+    box-sizing: border-box;
     float:left;
     display:block;
-    width:250px;
     margin:0;
+    padding: 16px 10px 16px 16px;
+    width: 50%;
   }
-  ol.class-list li p.description.article {
+  ol.class-list .description.article {
     width: 550px;
   }
   ol.class-list ol {
-    float:left;
-    width:320px;
-    margin:0 0 0 30px;
-    list-style:none;
-    margin:0 0 0 20px;
+    box-sizing: border-box;
+    float: left;
+    list-style: none;
+    margin: 0;
+    padding: 16px 16px 16px 10px;
+    width: 50%;
   }
-  ol.class-list div.lessons li {
-    margin:0 0 6px;
-    line-height:16px;
+  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;
+    }
   }
 
 
@@ -669,7 +926,7 @@
 }
 ul#title-tabs li a:hover,
 ul#title-tabs li a:active {
-  color:#93C !important;
+  color:#039BE5 !important;
 }
 
 
@@ -798,46 +1055,6 @@
   .design li.with-icon.use:before {
     background-image: url(../images/styles/ico_use.png); }
 
-/* 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 */ }
-
 /* video  containers */
 .framed-galaxynexus-land-span-13 {
   background: transparent url(../images/styles/device_galaxynexus_blank_land_span13.png) no-repeat
@@ -1031,6 +1248,15 @@
   .download-button:active {
     background-color: #006699; }
 
+.button.disabled,
+.button.disabled:hover,
+.button.disabled:active {
+  background:#ebebeb;
+  color:#999 !important;
+  border-color:#999;
+  cursor:default;
+}
+
 /* UI tables and other things found in Writing style and Settings pattern */
 .ui-table {
   width: 100%;
@@ -1071,233 +1297,6 @@
 
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/***** PREVIOUSLY style.css ******************/
-
-
-
-
-
-@media screen, projection, print {
-[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 {
-  -ms-interpolation-mode: bicubic;
-  vertical-align: middle;
-  max-width: 100%;
-}
-q {
-    quotes: none;
-}
-sup, sub {
-    font-size: 11px;
-    line-height: 0;
-}
-}
-
-@media screen, projection {
-
-table, fieldset {
-    margin: 0;
-}
-h1 {
-    color:#333;
-    font-size: 34px;
-    margin: 36px 0 27px;
-    padding:0 0 10px;
-    font-weight:300;
-}
-h1, h2 {
-    line-height: 30px;
-}
-h1.short {
-  margin-right:320px;
-}
-h1.short {
-  margin-right:320px;
-}
-h1.super {
-    font-size: 37px;
-}
-h2 {
-    color:#333;
-    font-size: 26px;
-    margin: 32px 0 20px;
-    padding:0;
-    font-weight:300;
-}
-h3 {
-    color:#333;
-    font-size: 21px;
-    font-weight:400;
-    margin:21px 0 14px 0;
-}
-h3, h4 {
-    line-height: 21px;
-}
-h4 {
-  font-size: 18px;
-  margin: 12px 0;
-  font-weight:500;
-}
-h5 {
-  font-size: 14px;
-}
-h5, h6 {
-  margin: 5px 0;
-}
-h6 {
-  font-size: 12px;
-}
-hr { /* applied to the bottom of h2 elements */
-  height: 1px;
-  margin: 3px 0 12px;
-  border: 0;
-  background: #ccc;
-}
-p, pre, table, form {
-    margin: 0 0 15px;
-}
-small {
-  font-size: 11.5px;
-  color: #000;
-}
-ul, ol {
-    margin: 0 0 15px 18px;
-    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 5px;
-}
-dd {
-  margin:0 0 10px 30px;
-}
-dd p,
-dd pre,
-dd ul,
-dd ol,
-dd dl {
-  margin-top:10px;
-}
-li p,
-li pre,
-li ul,
-li ol,
-li dl {
-  margin-top:5px;
-  margin-bottom:5px;
-}
-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/1.5 monospace;
-}
-code {
-    font-weight:bold;
-    font: 13px/14px monospace;
-}
-
-legend {
-    display: none;
-}
-a:link, a:visited, .link-color {
-  color: #258aaf;
-  text-decoration: none;
-}
-a:focus, a:hover, a:active {
-  color: #33B5E5;
-  text-decoration: none;
-}
-a.white {
-  color: #fff;
-  text-decoration:underline;
-}
-a.white:hover, a.white:active {
-  color: #ccc !important;
-}
-strong, b {
-  font-weight:bold;
-  color: #222;
-}
-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:first-of-type th:first-of-type:empty {
-    visibility: hidden;
-}
-
 /* --------------------------------------------------------------------------
 Footer
 */
@@ -1468,430 +1467,23 @@
 }
 
 /* =============================================================================
-   Columns
-   ========================================================================== */
-
-@media screen, projection, print {
-.full {
-  padding: 2.5em 0;
-  border-top: solid 1px #ddd;
-  border-bottom: solid 1px #ddd;
-  background: #f7f7f7;
-}
-.wrap {
-  margin: 0 auto;
-  width: 940px;
-  clear: both;
-}
-.cols {
-    height: 1%;
-    margin: 0 -1.533742331288343558282%;
-    width: 103.06748466257669%}
-*+html .cols {
-    margin-bottom: 20px;
-}
-.cols:after {
-    clear: both;
-    content: ' ';
-    display: block;
-    height: 0;
-    visibility: hidden;
-}
-.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
-.col-13, .col-14, .col-15, .col-16 {
-    display: inline;
-  float: left;
-  margin-left: 10px;
-  margin-right: 10px;
-}
-/*
-* html .col-1, * html .col-2, * html .col-3, * html .col-4, * html .col-5, * html .col-6, * html
-.col-7, * html .col-8, * html .col-9, * html .col-10, * html .col-11, * html .col-12  {
-    margin: 0;
-    padding: 0 1.4% 20px;
-}
-[dir='rtl'] .col-1, [dir='rtl'] .col-2, [dir='rtl'] .col-3, [dir='rtl'] .col-4, [dir='rtl'] .col-5,
-[dir='rtl'] .col-6, [dir='rtl'] .col-7, [dir='rtl'] .col-8, [dir='rtl'] .col-9, [dir='rtl'] .col-10,
-[dir='rtl'] .col-11, [dir='rtl'] .col-12 {
-    float: right;
-}
-*/
-.col-1 { width: 40px }
-.col-2 { width: 100px }
-.col-3 { width: 160px }
-.col-4 { width: 220px }
-.col-5 { width: 280px }
-.col-6 { width: 340px }
-.col-7 { width: 400px }
-.col-8 { width: 460px }
-.col-9 { width: 520px }
-.col-10 { width: 580px }
-.col-11 { width: 640px }
-.col-12 { width: 700px }
-.col-13 { width: 760px }
-.col-14 { width: 820px }
-.col-15 { width: 880px }
-.col-16 { width: 940px }
-}
-
-.col-right {
-  margin-right:0px;
-}
-
-@media screen and (max-width:772px) {
-.col-5, .col-6, .col-7 {
-    clear: both;
-    width: 97.0238096%}
-}
-
-/* =============================================================================
    Layout
    ========================================================================== */
 @media screen, projection, print {
 
-/* --------------------------------------------------------------------------
-Header, Login, Nav-X, Search
-*/
-#header {
-  margin: 0;
-  padding: 0;
-}
-#header:before, #header:after {
-  content: "";
-  display: table;
-  clear: both
-}
-.logo, .nav-x {
-    float: left;
-}
-.nav-x {
-    margin-top: -2px;
-  list-style-type: none;
-}
-.nav-x a {
-    color: #333;
-    font-size: 16px;
-}
-.about a.selected {
-    color: #9933CC;
-}
-.design a.selected {
-    color: #33b5e5;
-}
-.develop a.selected {
-    color: #F80;
-}
-.distribute a.selected {
-    color: #9C0;
-}
-
-
-
-.nav-x li {
-    display: inline;
-    margin-right: 45px;
-}
-.search {
-  float: right;
-  position: relative;
-  width: 220px
-}
-.search .bottom, .search .left, .search .right {
+.training-nav-top {
+  border:1px solid #e5e5e5;
+  border-width: 1px 1px 0;
+  bottom: -56px;
+  box-sizing: border-box;
   position: absolute;
-  background-color: #a3a3a3;
-}
-.search .bottom {
-  width: 220px;
-  height: 1px;
-  top: 24px;
-  left: 0
-}
-.search .left, .search .right {
-  height: 5px;
-  width: 1px
-}
-.search .left { top: 19px; left: 0 }
-.search .right { top: 19px; right: 0 }
-.search form {
-  float: left;
-  margin-top: 2px;
-  width: inherit;
-}
-.search .close,
-#player-frame .close {
-  position: absolute;
-  right: 8px;
-  bottom: 4px;
-  width: 16px;
-  height: 16px;
-  margin: 0;
-  text-indent: -1000em;
-  background: url(../images/close.png) no-repeat 0 0;
-  z-index:9999;
-}
-.search .close:hover, .search .close:focus,
-#player-frame .close:hover, #player-frame .close:focus {
-  background-position: -16px 0;
-  cursor:pointer;
-}
-#player-frame .close {
-  top: 6px;
-}
-.search form input {
-  color: #999;
-  font-size: 1em;
-  width: inherit;
-  border: none;
-  margin: 0;
-  padding:0 0 0 6px;
-  z-index: 1500;
-  background-color: transparent
-}
-.search:hover .bottom, .search:hover .left, .search:hover .right {
-  background-color: #33b5e5;
-}
-.search:hover .icon {
-  background-position: -8px 0
-}
-.search form input:focus {
-  color: #222;
-  font-weight: bold;
-  outline:0;
-}
-/* Search Dropdown */
-.search-dropdown {
-  padding: 15px;
-  width: 192px;
-  border: solid 1px #c5c5c5;
-  background: #fff;
-  position: absolute;
-  top: 35px;
-  left: 0;
-  -moz-box-shadow: 0 0 10px rgba(0,0,0,0.2);
-  -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.2);
-  box-shadow: 0  0 10px rgba(0,0,0,0.2)
-}
-.search-dropdown ul, .search-dropdown ul li {
-  list-style-type: none;
-  margin: 0;
-  padding: 0
-}
-.search-dropdown ul li {
-  clear: both
-}
-.search-dropdown img {
-  float: left;
-  margin: 0 10px 10px 0
-}
-.search-dropdown h6 {
-  color: #222;
-  margin: 0;
-  line-height: normal
-}
-.search-dropdown .desc {
-  color: #999;
-  font-size: 11.5px;
-  line-height: normal;
-  margin: 0;
-}
-.search-dropdown li a:hover h6, .search-dropdown li a:hover .desc {
-  color: #33b5e5
-}
-/* --------------------------------------------------------------------------
-Buttons
-*/
-.button, a.button, .button-secondary, a.button-secondary {
-  border-image: initial;
-    -webkit-border-radius: 2px;
-    -moz-border-radius: 2px;
-    border-radius: 2px;
-    cursor: pointer;
-}
-.button, a.button {
-    display:inline-block;
-    background-color: #09c;
-    background-image: -webkit-gradient(linear, left top, left bottom, from(#2faddb), to(#09c));
-    background-image: -webkit-linear-gradient(top, #2faddb, #09c);
-    background-image: -moz-linear-gradient(top, #2faddb, #09c);
-    background-image: -ms-linear-gradient(top, #2faddb, #09c);
-    background-image: -o-linear-gradient(top, #2faddb, #09c);
-    background-image: linear-gradient(top, #2faddb, #09c);
-    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#2faddb', EndColorStr='#0099cc',GradientType=0);
-    border: 1px solid #3990ab;
-    color: #fff;
-}
-.button-secondary, a.button-secondary {
-    background-color: #f3f3f3;
-    border: 1px solid #dcdcdc;
-    color: #444;
-}
-a.button, a.button:visited, a.button-secondary, a.button-secondary:visited {
-    margin-right: 16px;
-   font-weight: 400;
-    min-width: 54px;
-    outline: 0;
-    padding: 8px 15px;
-    text-align: center;
-}
-.button, .button-secondary {
-    margin-right: 16px;
-  font-weight: 400;
-    min-width: 54px;
-    outline: 0;
-    padding: 0 15px;
-    text-align: center;
-}
-.button:hover, 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',GradientType=0);
-    color: #fff !important;
-}
-.button:active, a.button:active {
-    background-color: #1e799a;
-    background-image: none;
-    border-color: #30b7e6;
-}
-a.button.big.subtitle {
-  line-height:18px;
-}
-.button-secondary:hover, a.button-secondary:hover {
-    border-color: #dbdbdb;
-    background-color: #f3f3f3;
-    background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));
-    background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: -moz-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: -ms-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: -o-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: linear-gradient(top, #f9f9f9, #ececec);
-    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9',
-EndColorStr='#ececec');
-    color: #33B5E5 !important;
-}
-.button-secondary:active, a.button-secondary:active {
-   border-color: #dadada;
-  background: #ebebeb; /* Old browsers */
-  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
-  background:
-url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/
-Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0Jv
-eD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+
-CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIg
-eDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ViZWJl
-YiIgc3RvcC1vcGFjaXR5PSIxIi8+
-CiAgICA8c3RvcCBvZmZzZXQ9IjEwJSIgc3RvcC1jb2xvcj0iI2Y5ZjlmOSIgc3RvcC1vcGFjaXR5PSIxIi8+
-CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2ZhZmFmYSIgc3RvcC1vcGFjaXR5PSIxIi8+
-CiAgICA8c3RvcCBvZmZzZXQ9IjkwJSIgc3RvcC1jb2xvcj0iI2Y5ZjlmOSIgc3RvcC1vcGFjaXR5PSIxIi8+
-CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmNmY2ZjYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFy
-R3JhZGllbnQ+
-CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIg
-Lz4KPC9zdmc+);
-  background: -moz-linear-gradient(top,  #ebebeb 0%, #f9f9f9 5%, #fafafa 50%, #f9f9f9 90%,
-#ffffff 100%); /* FF3.6+ */
-  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ebebeb),
-color-stop(5%,#f9f9f9), color-stop(50%,#fafafa), color-stop(90%,#f9f9f9), color-stop(100%,#ffffff));
-/* Chrome,Safari4+ */
-  background: -webkit-linear-gradient(top,  #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9
-90%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
-  background: -o-linear-gradient(top,  #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9 90%,#ffffff
-100%); /* Opera 11.10+ */
-  background: -ms-linear-gradient(top,  #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9 90%,#ffffff
-100%); /* IE10+ */
-  background: linear-gradient(top,  #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9 90%,#ffffff
-100%); /* W3C */
-  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ebebeb',
-endColorstr='#ffffff',GradientType=0 ); /* IE6-8 */
-  -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);
-  color: #258AAF !important;
-}
-.button.big {
-  font-size:20px;
-  display:inline-block;
-}
-.button.big span.small {
-  font-size:14px;
-}
-.button-caption {
-  margin-top:10px;
-  font-size:12px;
-  font-style:italic;
+  right: 0;
+  width: 280px;
 }
 
-.button.disabled,
-.button.disabled:hover,
-.button.disabled:active {
-  background:#ebebeb;
-  color:#999 !important;
-  border-color:#999;
-  cursor:default;
-}
-
-.training-nav-top a.button-secondary,
-.training-nav-bottom a.button-secondary {
-  display:block;
-  float:left;
-  margin:0;
-  width:130px;
-  text-transform:uppercase;
-  font-weight:bold;
-
-    background-color: #f3f3f3;
-    background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));
-    background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: -moz-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: -ms-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: -o-linear-gradient(top, #f9f9f9, #ececec);
-    background-image: linear-gradient(top, #f9f9f9, #ececec);
-    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9',
-EndColorStr='#ececec');
-    color: #33B5E5;
-}
-
-.training-nav-top a.button-secondary:hover,
-.training-nav-bottom a.button-secondary:hover {
-    background-color: #09c;
-    background-image: -webkit-gradient(linear, left top, left bottom, from(#2faddb), to(#09c));
-    background-image: -webkit-linear-gradient(top, #2faddb, #09c);
-    background-image: -moz-linear-gradient(top, #2faddb, #09c);
-    background-image: -ms-linear-gradient(top, #2faddb, #09c);
-    background-image: -o-linear-gradient(top, #2faddb, #09c);
-    background-image: linear-gradient(top, #2faddb, #09c);
-    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#2faddb', EndColorStr='#09c');
-    border: 1px solid #3990ab;
-    color: #fff !important;
-}
-
-.training-nav-top a.button-secondary.last,
-.training-nav-bottom a.button-secondary.last {
-  border-left:0;
-}
-
-.training-nav-top a.button-secondary.double-size,
-.training-nav-bottom a.button-secondary.double-size {
-  width:291px;
-}
-
-.training-nav-top,
 .training-nav-bottom {
   float:right;
   margin:0 0 0 20px;
-}
-
-.training-nav-top {
-  position:relative;
-  top:73px;
-}
-
-.training-nav-bottom {
   padding:0 0 20px;
 }
 
@@ -1904,33 +1496,38 @@
 }
 
 #tb-wrapper {
-  margin:51px 0 0 20px; /* negative top-margin to counter the content-header bottom margin */
+  margin:56px 0 0 20px; /* negative top-margin to counter the content-header bottom margin */
 }
 
 #tb,
 #qv {
-  font-size:13px;
-  line-height:18px;
-  width:238px;
-  border:1px solid #ccc;
-  float:right;
+  border: 1px solid #e5e5e5;
+  box-sizing: border-box;
+  float: right;
+  line-height: 16px;
+  padding: 5px 0;
+  width: 240px;
 }
 
 #tb {
-  width:278px;
+  width:280px;
 }
 
 #tb h2,
 #qv h2 {
-  margin:10px 15px;
-  padding:0;
-  text-transform:uppercase;
-  border-bottom:1px solid gainsboro;
+  border-top: 1px solid #e5e5e5;
+  color: inherit;
+  font-size: 16px;
+  line-height: 24px;
+  margin: 15px 0 4px;
+  padding: 10px 15px 0;
 }
 
-#tb *,
-#qv * {
-  font-size:inherit;
+#tb h2:first-child,
+#qv h2:first-child {
+  border-top: 0;
+  padding-top: 0;
+  margin-top: 10px;
 }
 
 #tb .download-box,
@@ -1942,7 +1539,28 @@
 #qv .download-box .filename {
   font-size:11px;
   margin:4px 4px 10px;
-  color:#666;
+}
+
+@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;
+  }
 }
 
 
@@ -1959,9 +1577,9 @@
   width:226px;
   font-size:13px;
   line-height:18px;
-  border-left:4px solid #99CC00;
+  border-left:3px solid #a9e27d;
   float:right;
-  padding:0 0 0 10px;
+  padding:0 0 0 20px;
   margin:0 0 1em 20px;
 }
 
@@ -1985,7 +1603,15 @@
 #tb ol,
 #tb ul,
 #qv ul {
-  margin:0 15px 10px 35px;
+  list-style-type: none;
+  margin:0 15px 10px 15px;
+}
+
+#tb li,
+#qv li {
+  margin: 8px 0;
+  padding: 0 0 0 16px;
+  position: relative;
 }
 
 #tb p {
@@ -2005,11 +1631,7 @@
 #qv ul ul,
 .sidebox ol ol,
 .sidebox ul ul {
-  margin-bottom:0;
-}
-
-#qv ol ol {
-  margin:3px 0 3px 15px;
+  margin: 8px 0;
 }
 
 .sidebox p,
@@ -2145,7 +1767,6 @@
     border-radius: 2px;
     margin: 10px 0;
     padding: 20px;
-  color: #666;
     position: relative;
   background: #f9f9f9;
 }
@@ -2332,16 +1953,11 @@
 
 
 /* nav tree */
-#side-nav, #swapper,
-#nav-tree, #tree-list {
+#swapper, #nav-tree, #tree-list {
   overflow:hidden;
   margin-left:0;
 }
 
-#devdoc-nav {
-  overflow:visible !important; /* To keep the "to top" button visible */
-}
-
 #nav-tree ul {
   list-style:none;
   padding:0;
@@ -2443,7 +2059,7 @@
   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;
@@ -2795,7 +2411,7 @@
 }
 
 /* --------------------------------------------------------------------------
-Misc
+Misc and article typography
 */
 
 
@@ -2842,27 +2458,121 @@
 
 p.img-caption {
   margin: -10px 0 20px;
-  font-size:13px;
-  color:#666;
+  font-size: 13px;
 }
 
-div.figure,
-div.figure-right {
-  float:right;
-  clear:right;
-  margin:10px 0 0 0;
-  padding:0 0 0 20px;
+/* 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 */
 }
 
-div.figure-left {
-  float:left;
-  clear:left;
-  margin:10px 0 0 0;
-  padding:0 20px 0 0;
+.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;
@@ -2871,38 +2581,31 @@
 p.table-caption {
   margin: 0 0 4px 0;
   font-size:13px;
-  color:#666;
 }
 
 p.code-caption {
   margin-bottom: 4px;
   font: 12px/1.5 monospace;
-  color:#666;
-}
-
-div.note,
-div.caution,
-div.warning {
-  margin: 0 0 15px;
 }
 
 p.note, div.note,
 p.caution, div.caution,
 p.warning, div.warning {
-  padding: 0 0 0 10px;
-  border-left: 4px solid;
+  padding: 0 0 0 20px;
+  border-left: 3px solid;
+  margin: 16px 0;
 }
 
 p.note, div.note {
-  border-color: #258AAF;
+  border-color: #66c2ff;
 }
 
 p.caution, div.caution {
-  border-color: #FF8800;
+  border-color: #f81;
 }
 
 p.warning, div.warning {
-  border-color: #ff4443;
+  border-color: #f55;
 }
 
 div.note.design {
@@ -2965,8 +2668,7 @@
 a.notice-developers-video,
 a.notice-developers,
 a.notice-designers-video,
-a.notice-designers,
-a.notice-designers-material {
+a.notice-designers {
   float:right;
   clear:right;
   width:238px;
@@ -2977,15 +2679,13 @@
 a.notice-developers-video.wide,
 a.notice-developers.wide,
 a.notice-designers-video.wide,
-a.notice-designers.wide,
-a.notice-designers-material.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,
-a.notice-designers-material div {
+a.notice-designers div {
   min-height:40px;
   background:url('../images/styles/notice-developers@2x.png') no-repeat 10px 10px;
   background-size:40px 40px;
@@ -3003,22 +2703,16 @@
   background:url('../images/styles/notice-developers-video@2x.png') no-repeat 10px 10px;
   background-size:40px 40px;
 }
-a.notice-designers-material div {
-  background:url('../images/styles/notice-designers-material@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,
-a.notice-designers-material: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,
-a.notice-designers-material h3 {
+a.notice-designers h3 {
   font-size:13px;
   line-height:18px;
   font-weight:bold;
@@ -3029,16 +2723,14 @@
 a.notice-developers-video p,
 a.notice-developers p,
 a.notice-designers-video p,
-a.notice-designers p,
-a.notice-designers-material 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,
-a.notice-designers-material.left {
+a.notice-designers.left {
   margin-left:0;
   float:left;
 }
@@ -3465,6 +3157,15 @@
 }
 */
 
+/* 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 {
@@ -3676,6 +3377,7 @@
   font-style:italic;
 }
 
+
 /* Inline api level indicator for methods */
 div.api-level {
   font-size:.8em;
@@ -3696,27 +3398,6 @@
 }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 /* SEARCH FILTER */
 
 .menu-container {
@@ -3726,53 +3407,38 @@
   font-weight:normal;
 }
 
-.search_filtered_wrapper.reference {
-  width: 193px;
-  float: right;
-}
-.search_filtered_wrapper.docs {
-  width:875px;
-  float: left;
-  position:absolute;
-  top:26px;
-  right:66px;
+.search_filtered_wrapper {
+  position: absolute;
+  right: 18px;
+  top: 64px;
 }
 .suggest-card {
+  float:right;
   position:relative;
   width:170px;
   min-height:90px;
-  padding:5px;
   border: solid 1px #C5C5C5;
   background: white;
-  top: 15px;
   margin-right:-5px;
   -moz-box-shadow: 0 0 10px rgba(0,0,0,0.2);
   -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
   box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
 }
 .suggest-card.reference {
-  position:absolute;
-  z-index:999;
-  min-width:171px; /* +padding and border makes this match input width */
-  min-height:93px; /* add 3px because this has 1 not 4px top border */
-  width:auto;
-  top:41px;
-  margin:0;
+  z-index: 998;
+  width: auto;
 }
 .suggest-card.develop {
   z-index:997;
-  border-top: solid 4px #F80;
-  float:right;
+  border-top: solid 4px #ff7043;
 }
 .suggest-card.design {
   z-index:996;
-  border-top: solid 4px #33b5e5;
-  float:right;
+  border-top: solid 4px #00bcd4;
 }
 .suggest-card.distribute {
   z-index:995;
-  border-top: solid 4px #9C0;
-  float:right;
+  border-top: solid 4px #afb42b;
 }
 .child-card {
   width:100%;
@@ -3790,7 +3456,7 @@
 ul.search_filtered {
   min-width:100%;
   list-style: none;
-  margin: 0 0 5px;
+  margin: 5px 0;
   padding: 0;
 }
 .search_filtered .jd-selected {
@@ -3799,7 +3465,7 @@
 }
 .search_filtered .jd-selected,
 .search_filtered .jd-selected a {
-    color:#09C !important;
+    color:#039BE5 !important;
 }
 
 .no-display {
@@ -3809,13 +3475,13 @@
 .search_filtered li.jd-autocomplete {
   font-size: 0.81em;
   border: none;
-  margin: 0 0 2px;
+  margin: 0;
   padding: 0;
   line-height:1.5em;
 }
 
 .search_filtered li a {
-  padding:0 5px;
+  padding: 2px 10px;
   color:#222 !important;
   display:inline-block;
   line-height:12px;
@@ -3825,8 +3491,8 @@
   font-weight:bold;
   color:#444;
   border: none;
-  margin: 8px 0 2px;
-  padding:1px 5px;
+  margin: 0;
+  padding: 2px 10px;
   line-height:1.5em;
 }
 .search_filtered li.header.small {
@@ -3843,6 +3509,51 @@
   margin: 0 0 2px;
 }
 
+@media (max-width: 719px) {
+  .search_filtered_wrapper {
+    left: 24px;
+    right: 24px;
+    top: 44px;
+  }
+
+  .suggest-card {
+    box-shadow: 0 2px 1px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.1);
+    float: none;
+    margin-right: 0;
+    min-height: 0;
+    max-height: 204px;
+    overflow: hidden;
+  }
+
+  .suggest-card.develop,
+  .suggest-card.design,
+  .suggest-card.distribute {
+    display: none !important;
+  }
+
+  ul.search_filtered {
+    margin: 0;
+  }
+
+  .search_filtered li.jd-autocomplete {
+    border-top: solid 1px #C5C5C5;
+    font-size: inherit;
+    text-align: left;
+  }
+
+  .search_filtered li.jd-autocomplete:first-child {
+    border-top: 0;
+  }
+
+  .search_filtered li a {
+    display: block;
+    overflow: hidden;
+    padding: 14px 10px;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+}
+
 .show-item {
   display: table-row;
 }
@@ -3852,8 +3563,6 @@
 
 
 
-
-
 /* SEARCH RESULTS */
 
 
@@ -3950,10 +3659,10 @@
 }
 
 #searchResults .gsc-tabsArea {
-  position:relative;
-  white-space:nowrap;
-  float:left;
-  width:200px;
+  position: relative;
+  white-space: nowrap;
+  float: left;
+  width: 25%;
 }
 
 #searchResults .gsc-above-wrapper-area {
@@ -3961,12 +3670,26 @@
 }
 
 #searchResults .gsc-resultsbox-visible {
-  float:left;
-  width:720px;
-  margin-left:20px;
+  box-sizing: border-box;
+  float: left;
+  padding-left:20px;
+  width: 75%;
+}
+
+@media (max-width: 719px) {
+  #searchResults .gsc-tabsArea {
+    display: none;
+  }
+
+  #searchResults .gsc-resultsbox-visible {
+    float: none;
+    padding-left: 0;
+    width: auto;
+  }
 }
 
 #searchResults .gsc-tabHeader {
+  margin-top: 4px;
   padding: 3px 6px;
   position:relative;
   width:auto;
@@ -3975,7 +3698,7 @@
 
 #searchResults h2#searchTitle {
   padding:0;
-  margin:5px 0;
+  margin:30px 0 5px;
   border:none;
 }
 
@@ -4023,98 +3746,25 @@
 
 #searchResults .gsc-tabHeader.gsc-tabhInactive,
 #searchResults .gsc-cursor-page {
-  text-decoration:none;
-  color:#258AAF;
-  border: solid 1px #DADADA;
-}
-
-#searchResults .gsc-tabHeader.gsc-tabhInactive:hover,
-#searchResults .gsc-cursor-page:hover {
-  border-color: #DBDBDB;
-  background-color: #F3F3F3;
-  background-image: -webkit-gradient(linear, left top, left bottom, from(#F9F9F9), to(#ECECEC));
-  background-image: -webkit-linear-gradient(top, #F9F9F9, #ECECEC);
-  background-image: -moz-linear-gradient(top, #F9F9F9, #ECECEC);
-  background-image: -ms-linear-gradient(top, #F9F9F9, #ECECEC);
-  background-image: -o-linear-gradient(top, #F9F9F9, #ECECEC);
-  background-image: linear-gradient(top, #F9F9F9, #ECECEC);
-  filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9',
-EndColorStr='#ececec');
-  color: #33B5E5;
+  background: #F0F0F0;
+  border: 0;
+  color: #039BE5;
 }
 
 #searchResults .gsc-tabHeader.gsc-tabhActive,
 #searchResults .gsc-tabHeader.gsc-tabhActive:hover,
 #searchResults .gsc-cursor-page.gsc-cursor-current-page,
 #searchResults .gsc-cursor-page.gsc-cursor-current-page:hover {
-  color:#fff;
-  background-color: #09C;
-  background-image: -webkit-gradient(linear, left top, left bottom, from(#2FADDB), to(#09C));
-  background-image: -webkit-linear-gradient(top, #2FADDB, #09C);
-  background-image: -moz-linear-gradient(top, #2FADDB, #09C);
-  background-image: -ms-linear-gradient(top, #2FADDB, #09C);
-  background-image: -o-linear-gradient(top, #2FADDB, #09C);
-  background-image: linear-gradient(top, #2FADDB, #09C);
-  filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#2faddb', EndColorStr='#09c');
-  border: 1px solid #3990AB;
-  z-index:100;
+  background-color: #039BE5;
+  border: 0;
+  color: #fff;
 }
 
 
 
 
-
 /************ STICKY NAV BAR ******************/
 
-#header-wrapper {
-  background: #f9f9f9;
-  margin: 0 -10px 0 -10px;
-  padding: 31px 10px 0px 10px;
-  position: relative;
-}
-#header-wrapper #nav-x div.wrap {
-  max-width: 940px;
-  height: 38px;
-}
-#header-wrapper #nav-x ul.nav-x li {
-  margin-right: 31px !important;
-  margin-top: 5px;
-  margin-bottom: 0px;
-  height: 30px;
-}
-#header-wrapper #nav-x > div.wrap ul.nav-x li.active  {
-  color: #669900;
-  border-bottom: 3px solid #669900;
-}
-#header-wrapper #nav-x > div.wrap ul.nav-x li.active a {
-  color: #669900;
-}
-#header-wrapper #nav-x > div.wrap ul.nav-x a {
-  font-size: 14.5px;
-}
-#header-wrapper .developer-console-btn {
-  float: right;
-  background: #fefefe;
-  border-radius: 4px;
-  padding: 8px 14px;
-  box-shadow: 1px 1px 0px #7a7a7a;
-  font-size: 14px;
-  margin-top: -6px;
-  cursor: pointer;
-  color: #464646;
-  margin-right: 20px;
-}
-/* not currently used */
-#header-wrapper .shadow {
-  width: 1034px;
-  height: 4px;
-  position: absolute;
-  left: 50%;
-  margin-left: -517px;
-  bottom: -4px;
-  background-image: url(../images/header-shadow.png);
-}
-
 #context {
   clear: both;
   padding-top: 14px;
@@ -4158,75 +3808,6 @@
   display: none;
 }
 
-/* Sticky Nav overrides */
-.sticky-menu {
-  position: fixed;
-  width: 940px;
-  height: 0px;
-  z-index: 51;
-  top: 12px;
-}
-#sticky-header {
-  display: none;
-  padding: 0 10px;
-  position: fixed;
-  background: #f9f9f9;
-  top: 0px;
-  left: 0px;
-  right: 0px;
-  height: 45px;
-  box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.1);
-  border-bottom: 1px solid #a5c43a;
-  z-index: 50;
-}
-#sticky-header.design {
-  border-bottom: 1px solid #33b5e5;
-}
-#sticky-header.develop {
-  border-bottom: 1px solid #F80;
-}
-#sticky-header.distribute {
-  border-bottom: 1px solid #9C0;
-}
-#sticky-header.about {
-  border-bottom: 1px solid #9933CC;
-}
-#sticky-header > div {
-  overflow: hidden;
-  *zoom: 1;
-  width: 940px;
-  margin: 0 auto;
-  clear: both;
-  padding-top: 9px;
-}
-#sticky-header > div .logo {
-  float: left;
-  width: 26px;
-  height: 25px;
-  background: url(../images/dac_logo.png);
-  background-image: -webkit-image-set(url(../images/dac_logo.png) 1x, url(../images/dac_logo@2x.png) 2x);
-  z-index: 52;
-  position: relative;
-}
-#sticky-header > div .top {
-  float: left;
-  width: 38px;
-  height: 38px;
-  position: relative;
-  background: url(../images/styles/gototop.png);
-  z-index: 52;
-}
-#sticky-header > div .breadcrumb {
-  float: left;
-  padding: 0 0 0 10px;
-  border-left: 1px solid #d2d2d2;
-  line-height: 24px;
-  font-size: 14px;
-  position: relative;
-  top: 0px;
-  z-index: 52;
-}
-
 /* offset the <a name=""> tags to account for sticky nav */
 body.reference a[name] {
   visibility: hidden;
@@ -4236,76 +3817,6 @@
 }
 
 
-}
-
-
-
-
-
-
-
-/*********** PREVIOUSLY dac-styles.css ***************/
-
-
-#header {
-  border-bottom:0;
-}
-
-#header .wrap {
-  max-width:940px;
-  height:41px;
-  border-bottom:1px solid;
-  border-color: #ccc;
-  position:relative;
-}
-
-.about #header .wrap {
-  border-color: #9933CC;
-}
-
-.design #header .wrap {
-  border-color: #33b5e5;
-}
-
-.develop #header .wrap {
-  border-color: #F80;
-}
-
-.distribute #header .wrap {
-  border-color: #9C0;
-}
-
-.logo a {
-  float:left;
-}
-
-#header .logo {
-  margin-top: -6px;
-  margin-left: 0px;
-  margin-bottom:0px;
-  width: 160px;
-  padding-right:10px;
-}
-
-
-#header-wrap .logo.landing-logo {
-  width:220px;
-  margin:0;
-  padding:0;
-  margin-bottom:22px;
-}
-#header-wrap .logo.landing-logo img {
-  padding:0 0 0 10px;
-}
-
-.search {
-  height:25px;
-  margin-top: -3px;
-  margin-bottom: 0px;
-}
-
-
-
 /* Quicknav */
 .btn-quicknav {
   width:20px;
@@ -4343,17 +3854,6 @@
   display:block;
 }
 
-.nav-x li {
-  display:block;
-  float:left;
-  margin-right:45px;
-  -webkit-transition: all 0.25s linear;
-      -moz-transition: all 0.25s linear;
-       -ms-transition: all 0.25s linear;
-        -o-transition: all 0.25s linear;
-           transition: all 0.25s linear;
-}
-
 #header-wrap.quicknav .nav-x li {
   min-width:160px;
   margin-right:20px;
@@ -4439,105 +3939,6 @@
 
 }
 
-/* SEARCH AND MORE */
-.search {
-  position: absolute;
-  width: 50px;
-  height:28px;
-  display: block;
-  margin-top:-3px;
-  margin-bottom:7px;
-  overflow:hidden;
-  z-index:100;
-  right:54px;
-  -webkit-transition: width 0.4s ease;
-     -moz-transition: width 0.4s ease;
-       -o-transition: width 0.4s ease;
-          transition: width 0.4s ease;
-}
-
-.search #search-btn {
-  width:50px;
-  height:28px;
-  background:url(../images/icon_search.png) no-repeat;
-  float:left;
-}
-
-.search-inner {
-  width:245px;
-}
-
-.search:hover, .search.active {
-  width:245px;
-}
-
-.search .bottom, .search .left, .search .right {
-  position: absolute;
-  background-color: #a2a2a2
-}
-
-.search .bottom {
-  width: 214px;
-  height: 1px;
-  top: 24px;
-  left: 0
-}
-
-.search .left, .search .right {
-  height: 5px;
-  width: 1px
-}
-
-.search .left {
-  top: 22px;
-  left: 56px;
-  background-color:#CCC;
-}
-
-.search .right {
-  top: 22px;
-  left: 238px;
-  background-color:#CCC;
-}
-
-.search form {
-  margin-top: 2px;
-  width: 162px;
-  float:left;
-}
-
-.search form input {
-  color: #2f2f2f;
-  font-size: 0.95em;
-  width: 178px;
-  border: none;
-  margin-left: 6px;
-  z-index: 1500;
-  position: relative;
-  background-color: transparent;
-  border-bottom:1px solid #CCC;
-  padding:0 0 0 4px;
-  outline:none;
-  height:24px;
-}
-
-.search:hover form input {
-  border-bottom:1px solid #33B5E5;
-}
-
-.search:hover .bottom, .search:hover .left, .search:hover .right {
-  background-color: #33b5e5;
-}
-
-.search:hover #search-btn {
-  background-position: 0 -28px
-}
-
-.search form input:focus {
-  color: #222;
-  font-weight: bold
-}
-
 .moremenu {
   float: right;
   position: relative;
@@ -4690,9 +4091,9 @@
   height:12px;
   text-indent:-8000px;
   list-style:none;
-  margin: 0 2px;
+  margin: 0 3px;
   border-radius:6px;
-  background-color:#ccc;
+  background-color:#ddd;
   cursor:pointer;
         -webkit-transition:color .5s ease-in;
         -moz-transition:color .5s ease-in;
@@ -4700,13 +4101,13 @@
         transition:color .5s ease-in;
 }
 .slideshow-container .pagination ul li:hover {
-  background-color:#999;
+  background-color:#bbb;
 }
 .slideshow-container .pagination ul li.active {
-  background-color:#33b5e5;
+  background-color:#6ab344;
 }
 .slideshow-container .pagination ul li.active:hover {
-  background-color:#33b5e5;
+  background-color:#6ab344;
 }
 .slideshow-container ul li {
   display:inline;
@@ -4726,27 +4127,14 @@
     padding-bottom:0px;
 }
 
-#nav-x {
-  padding-top: 13px;
-}
-
-#nav-x .wrap {
-  min-height:32px;
-}
-
-#nav-x .wrap,
 #searchResults.wrap {
     max-width:940px;
-    border-bottom:1px solid #CCC;
+    border-bottom:1px solid #e5e5e5;
 }
 
 #searchResults.wrap #leftSearchControl {
   min-height:700px
 }
-.nav-x {
-    margin-left:0;
-    margin-bottom:0;
-}
 
 
 
@@ -4816,7 +4204,7 @@
 }
 
 .jspDrag {
-  background: #bbb;
+  background: #ccc;
   position: relative;
   top: 0;
   left: 0;
@@ -5059,7 +4447,7 @@
   display:none;
   margin: -1px auto 0;
   position: relative;
-  width: 940px;
+  max-width: 940px;
   height: 0px;
 }
 #player-frame {
@@ -5071,6 +4459,22 @@
   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;
+}
 
 
 
@@ -5125,7 +4529,7 @@
 }
 
 .landing-docs .normal-links a {
-  color:#258aaf !important;
+  color:#039BE5 !important;
 }
 
 .plusone {
@@ -5232,7 +4636,7 @@
   float: left;
   width: 100%;
   text-align: center;
-  color: #09c !important;
+  color: #039BE5 !important;
 }
 .home-sections ul li a {
   font-weight: bold;
@@ -5249,9 +4653,6 @@
 .home-sections ul li.last {
   margin-right: 0px;
 }
-.fullpage #footer {
-  margin-top: -40px;
-}
 
 /************ DISTRIBUTE PAGES ******************/
 
@@ -5280,1241 +4681,6 @@
   clear: both;
 }
 
-.border-img {
-  border: 1px solid #CCC;
-}
-
-.center-img {
-  margin: auto;
-  text-align: center;
-}
-.center-img img {
-  margin-bottom: 15px;
-}
-
-.figure img, .border-img {
-  margin-bottom: 15px;
-}
-
-/************ RESOURCE CARDS ******************/
-
-/* Resource cards, 12, 13, 16-col */
-
-/* Basic card-styling with shadow */
-.resource-card {
-  border-radius: 1px;
-  box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.12);
-  background: #fefefe;
-}
-
-/* Styling for background image including tinting and section icons in stacks */
-.card-bg {
-  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.2);
-  -webkit-transition: opacity 0.5s;
-  -moz-transition: opacity 0.5s;
-  -o-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;
-  -webkit-box-sizing: border-box;
-  -moz-box-sizing: border-box;
-  box-sizing: border-box;
-  top: 0;
-  right: 0;
-  bottom: 0;
-  left: 0;
-  overflow: hidden;
-  background: #fefefe;
-  padding: 4px 12px 6px 12px;
-}
-.card-info .section {
-  text-transform: uppercase;
-  color: #898989;
-  font-size: 12px;
-  margin-bottom: 1px;
-}
-.card-info .title {
-  color: #363636;
-  white-space: nowrap;
-  overflow: hidden;
-  text-overflow: ellipsis;
-  padding-bottom: 5px;
-  margin-bottom: -2px;
-  font-size: 16px;
-}
-.card-info .description {
-  overflow: hidden;
-}
-.card-info .description .text {
-  color: #464646;
-  font: 13px/15px Roboto Condensed;
-  overflow: hidden;
-  width:100%;
-}
-.card-info .description .util {
-  position: absolute;
-  right: 5px;
-  bottom: 70px; /*-2px;*/
-  opacity: 0;
-  -webkit-transition: opacity 0.5s;
-  -moz-transition: opacity 0.5s;
-  -o-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;
-}
-/* Truncate card summaries at bounding box and
- * and apply ellipsis at lower right */
-.ellipsis {
-  overflow: hidden;
-  float:right;
-  line-height: 15px;
-  width:100%;
-}
-.resource-card-6x6 .card-info .description .teddddddxt {
- float:left;
-  position:relative;
-  margin-left:0;
-}
-.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;
-  -webkit-box-sizing: content-box;
-  -moz-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: -moz-linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white);
-  background: -o-linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white);
-  background: -ms-linear-gradient(to right, 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;
-}
-
-/* Flow Layout */
-.resource-flow-layout {
-  display: inline-block;
-}
-.resource-flow-layout .resource-card, .resource-flow-layout .resource-card-stack {
-  float: left;
-  position: relative;
-}
-.resource-flow-layout .resource-card-stack > .resource-card {
-  margin-right: 0px !important;
-}
-.resource-flow-layout:after {
-  content: ".";
-  display: block;
-  height: 0;
-  position:relative;
-  clear: both;
-  visibility: hidden;
-}
-.resource-card:hover {
-  cursor: pointer;
-}
-.static .resource-card:hover {
-  cursor: auto;
-}
-.resource-card:hover .card-bg:after {
-  opacity: 0;
-}
-/* disabled to make way for fade/ellipsis truncation,
-   and the plusone moves up.
-.resource-card:hover .card-info .description .text {
-  padding-right: 70px;
-} */
-.resource-card:hover .card-info .description .util {
-  opacity: 1;
-}
-
-/* Carousel Layout */
-/* Carousel styles for landing page */
-.resource-carousel-layout {
-  margin: 20px 0 20px 0;
-  position: relative;
-  overflow: hidden;
-}
-.resource-carousel-layout .slideshow-prev, .resource-carousel-layout .slideshow-next {
-  display: none;
-}
-.resource-carousel-layout .pagination {
-  bottom: 0px;
-}
-.resource-carousel-layout .frame li {
-  position: relative;
-}
-.resource-carousel-layout .frame li .card-bg {
-  height: 300px;
-}
-.resource-carousel-layout .frame li .card-info {
-  padding: 7px 15px 0px 15px;
-  top: 300px;
-}
-.resource-carousel-layout .frame li .card-info .section {
-  font-size: 13px;
-  margin-bottom: 7px;
-}
-.resource-carousel-layout .frame li .card-info .title {
-  font-size: 25px;
-  margin-bottom: 2px;
-}
-.resource-carousel-layout .frame li .card-info .description {
-  font-family: 15px/16px Roboto Condensed, sans-serif;
-}
-.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;
-}
-.resource-stack-layout .resource-card-stack {
-  float: left;
-  position: relative;
-}
-.resource-stack-layout .resource-card {
-  margin-bottom: 20px;
-  display: block;
-  position: relative;
-}
-.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: 24px;
-  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:link, .resource-stack-layout .section-card-menu .card-info ul li a:visited, .resource-stack-layout .section-card-menu .card-info ul li a:active, .resource-stack-layout .section-card-menu .card-info ul li a:hover {
-  color: #363636 !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;
-  -moz-transition: opacity 0.5s;
-  -o-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;
-  -moz-transition: max-height 0.5s, opacity 1s;
-  -o-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;
-  -moz-transition: opacity 0.25s;
-  -o-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;
-  -moz-transition: max-height 0.5s, opacity 0.5s;
-  -o-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;
-}
-
-/* Generate the flow layout styles for a 3-column 16-col span */
-.resource-flow-layout.col-16 {
-  margin: 0 -14px 0 0;
-  width: 954px;
-}
-.resource-flow-layout.col-16 .resource-card, .resource-flow-layout.col-16 .resource-card-stack {
-  margin: 0 14px 20px 0;
-}
-.resource-flow-layout.col-16 .resource-card-row-stack-last {
-  margin-bottom: 0px !important;
-}
-.resource-flow-layout.col-16 .resource-card-col-stack-last {
-  margin-bottom: 0px !important;
-}
-.resource-flow-layout.col-16 .resource-card-3x6 {
-  width: 145px;
-  height: 284px;
-}
-.resource-flow-layout.col-16 .resource-card-3x12 {
-  width: 145px;
-  height: 588px;
-}
-.resource-flow-layout.col-16 .resource-card-3x18 {
-  width: 145px;
-  height: 892px;
-}
-.resource-flow-layout.col-16 .resource-card-6x6 {
-  width: 304px;
-  height: 284px;
-}
-.resource-flow-layout.col-16 .resource-card-6x12 {
-  width: 304px;
-  height: 588px;
-}
-.resource-flow-layout.col-16 .resource-card-6x18 {
-  width: 304px;
-  height: 892px;
-}
-.resource-flow-layout.col-16 .resource-card-9x6 {
-  width: 463px;
-  height: 284px;
-}
-.resource-flow-layout.col-16 .resource-card-9x12 {
-  width: 463px;
-  height: 588px;
-}
-.resource-flow-layout.col-16 .resource-card-9x18 {
-  width: 463px;
-  height: 892px;
-}
-.resource-flow-layout.col-16 .resource-card-12x6 {
-  width: 622px;
-  height: 284px;
-}
-.resource-flow-layout.col-16 .resource-card-12x12 {
-  width: 622px;
-  height: 588px;
-}
-.resource-flow-layout.col-16 .resource-card-12x18 {
-  width: 622px;
-  height: 892px;
-}
-.resource-flow-layout.col-16 .resource-card-15x6 {
-  width: 781px;
-  height: 284px;
-}
-.resource-flow-layout.col-16 .resource-card-15x12 {
-  width: 781px;
-  height: 588px;
-}
-.resource-flow-layout.col-16 .resource-card-15x18 {
-  width: 781px;
-  height: 892px;
-}
-.resource-flow-layout.col-16 .resource-card-18x6 {
-  width: 940px;
-  height: 284px;
-}
-.resource-flow-layout.col-16 .resource-card-18x12 {
-  width: 940px;
-  height: 420px;
-}
-.resource-flow-layout.col-16 .resource-card-18x18 {
-  width: 940px;
-  height: 892px;
-}
-.resource-flow-layout.col-16 .resource-card-3x2 {
-  width: 145px;
-  height: 95px;
-}
-.resource-flow-layout.col-16 .resource-card-3x2x3 {
-  width: 145px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-16 .resource-card-3x3 {
-  width: 145px;
-  height: 142px;
-}
-.resource-flow-layout.col-16 .resource-card-3x3x2 {
-  width: 145px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-16 .resource-card-6x2 {
-  width: 304px;
-  height: 95px;
-}
-.resource-flow-layout.col-16 .resource-card-6x2x3 {
-  width: 304px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-16 .resource-card-6x3 {
-  width: 304px;
-  height: 142px;
-}
-.resource-flow-layout.col-16 .resource-card-6x3x2 {
-  width: 304px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-16 .resource-card-9x2 {
-  width: 463px;
-  height: 95px;
-}
-.resource-flow-layout.col-16 .resource-card-9x2x3 {
-  width: 463px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-16 .resource-card-9x3 {
-  width: 463px;
-  height: 142px;
-}
-.resource-flow-layout.col-16 .resource-card-9x3x2 {
-  width: 463px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-16 .resource-card-12x2 {
-  width: 622px;
-  height: 95px;
-}
-.resource-flow-layout.col-16 .resource-card-12x2x3 {
-  width: 622px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-16 .resource-card-12x3 {
-  width: 622px;
-  height: 142px;
-}
-.resource-flow-layout.col-16 .resource-card-12x3x2 {
-  width: 622px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-16 .resource-card-15x2 {
-  width: 781px;
-  height: 95px;
-}
-.resource-flow-layout.col-16 .resource-card-15x2x3 {
-  width: 781px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-16 .resource-card-15x3 {
-  width: 781px;
-  height: 142px;
-}
-.resource-flow-layout.col-16 .resource-card-15x3x2 {
-  width: 781px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-16 .resource-card-18x2 {
-  width: 940px;
-  height: 95px;
-}
-.resource-flow-layout.col-16 .resource-card-18x2x3 {
-  width: 940px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-16 .resource-card-18x3 {
-  width: 940px;
-  height: 142px;
-}
-.resource-flow-layout.col-16 .resource-card-18x3x2 {
-  width: 940px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-
-/* Generate the flow layout styles for a 3-column 16-col span */
-.resource-flow-layout.col-12 {
-  margin: 0 -14px 0 0;
-  width: 714px;
-}
-
-.resource-flow-layout.col-12 .resource-card, .resource-flow-layout.col-12 .resource-card-stack {
-  margin: 0 14px 20px 0;
-}
-.resource-flow-layout.col-12 .resource-card-row-stack-last {
-  margin-bottom: 0px !important;
-}
-.resource-flow-layout.col-12 .resource-card-col-stack-last {
-  margin-bottom: 0px !important;
-}
-.resource-flow-layout.col-12 .resource-card-3x6 {
-  width: 105px;
-  height: 284px;
-}
-.resource-flow-layout.col-12 .resource-card-3x12 {
-  width: 105px;
-  height: 588px;
-}
-.resource-flow-layout.col-12 .resource-card-3x18 {
-  width: 105px;
-  height: 892px;
-}
-.resource-flow-layout.col-12 .resource-card-6x6 {
-  width: 224px;
-  height: 284px;
-}
-.resource-flow-layout.col-12 .resource-card-6x12 {
-  width: 224px;
-  height: 588px;
-}
-.resource-flow-layout.col-12 .resource-card-6x18 {
-  width: 224px;
-  height: 892px;
-}
-.resource-flow-layout.col-12 .resource-card-9x6 {
-  width: 343px;
-  height: 284px;
-}
-.resource-flow-layout.col-12 .resource-card-9x12 {
-  width: 343px;
-  height: 588px;
-}
-.resource-flow-layout.col-12 .resource-card-9x18 {
-  width: 343px;
-  height: 892px;
-}
-.resource-flow-layout.col-12 .resource-card-12x6 {
-  width: 462px;
-  height: 284px;
-}
-.resource-flow-layout.col-12 .resource-card-12x12 {
-  width: 462px;
-  height: 588px;
-}
-.resource-flow-layout.col-12 .resource-card-12x18 {
-  width: 462px;
-  height: 892px;
-}
-.resource-flow-layout.col-12 .resource-card-15x6 {
-  width: 581px;
-  height: 284px;
-}
-.resource-flow-layout.col-12 .resource-card-15x12 {
-  width: 581px;
-  height: 588px;
-}
-.resource-flow-layout.col-12 .resource-card-15x18 {
-  width: 581px;
-  height: 892px;
-}
-.resource-flow-layout.col-12 .resource-card-18x6 {
-  width: 700px;
-  height: 284px;
-}
-.resource-flow-layout.col-12 .resource-card-18x12 {
-  width: 700px;
-  height: 420px;
-}
-.resource-flow-layout.col-12 .resource-card-18x18 {
-  width: 700px;
-  height: 892px;
-}
-.resource-flow-layout.col-12 .resource-card-3x2 {
-  width: 105px;
-  height: 95px;
-}
-.resource-flow-layout.col-12 .resource-card-3x2x3 {
-  width: 105px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-12 .resource-card-3x3 {
-  width: 105px;
-  height: 142px;
-}
-.resource-flow-layout.col-12 .resource-card-3x3x2 {
-  width: 105px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-12 .resource-card-6x2 {
-  width: 224px;
-  height: 95px;
-}
-.resource-flow-layout.col-12 .resource-card-6x2x3 {
-  width: 224px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-12 .resource-card-6x3 {
-  width: 224px;
-  height: 142px;
-}
-.resource-flow-layout.col-12 .resource-card-6x3x2 {
-  width: 224px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-12 .resource-card-9x2 {
-  width: 343px;
-  height: 95px;
-}
-.resource-flow-layout.col-12 .resource-card-9x2x3 {
-  width: 343px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-12 .resource-card-9x3 {
-  width: 343px;
-  height: 142px;
-}
-.resource-flow-layout.col-12 .resource-card-9x3x2 {
-  width: 343px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-12 .resource-card-12x2 {
-  width: 462px;
-  height: 95px;
-}
-.resource-flow-layout.col-12 .resource-card-12x2x3 {
-  width: 462px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-12 .resource-card-12x3 {
-  width: 462px;
-  height: 142px;
-}
-.resource-flow-layout.col-12 .resource-card-12x3x2 {
-  width: 462px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-12 .resource-card-15x2 {
-  width: 581px;
-  height: 95px;
-}
-.resource-flow-layout.col-12 .resource-card-15x2x3 {
-  width: 581px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-12 .resource-card-15x3 {
-  width: 581px;
-  height: 142px;
-}
-.resource-flow-layout.col-12 .resource-card-15x3x2 {
-  width: 581px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-12 .resource-card-18x2 {
-  width: 700px;
-  height: 95px;
-}
-.resource-flow-layout.col-12 .resource-card-18x2x3 {
-  width: 700px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-12 .resource-card-18x3 {
-  width: 700px;
-  height: 142px;
-}
-.resource-flow-layout.col-12 .resource-card-18x3x2 {
-  width: 700px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-
-/* Generate the flow layout styles for a 3-column 13-col span */
-
-.resource-flow-layout.col-13 {
-  margin: 0 -14px 0 0;
-  width: 774px;
-}
-.resource-flow-layout.col-13 .resource-card, .resource-flow-layout.col-13 .resource-card-stack {
-  margin: 0 14px 20px 0;
-}
-.resource-flow-layout.col-13 .resource-card-row-stack-last {
-  margin-bottom: 0px !important;
-}
-.resource-flow-layout.col-13 .resource-card-col-stack-last {
-  margin-bottom: 0px !important;
-}
-.resource-flow-layout.col-13 .resource-card-3x6 {
-  width: 115px;
-  height: 284px;
-}
-.resource-flow-layout.col-13 .resource-card-3x12 {
-  width: 115px;
-  height: 588px;
-}
-.resource-flow-layout.col-13 .resource-card-3x18 {
-  width: 115px;
-  height: 892px;
-}
-.resource-flow-layout.col-13 .resource-card-6x6 {
-  width: 244px;
-  height: 284px;
-}
-.resource-flow-layout.col-13 .resource-card-6x12 {
-  width: 244px;
-  height: 588px;
-}
-.resource-flow-layout.col-13 .resource-card-6x18 {
-  width: 244px;
-  height: 892px;
-}
-.resource-flow-layout.col-13 .resource-card-9x6 {
-  width: 373px;
-  height: 284px;
-}
-.resource-flow-layout.col-13 .resource-card-9x12 {
-  width: 373px;
-  height: 588px;
-}
-.resource-flow-layout.col-13 .resource-card-9x18 {
-  width: 373px;
-  height: 892px;
-}
-.resource-flow-layout.col-13 .resource-card-12x6 {
-  width: 502px;
-  height: 284px;
-}
-.resource-flow-layout.col-13 .resource-card-12x12 {
-  width: 502px;
-  height: 588px;
-}
-.resource-flow-layout.col-13 .resource-card-12x18 {
-  width: 502px;
-  height: 892px;
-}
-.resource-flow-layout.col-13 .resource-card-15x6 {
-  width: 631px;
-  height: 284px;
-}
-.resource-flow-layout.col-13 .resource-card-15x12 {
-  width: 631px;
-  height: 588px;
-}
-.resource-flow-layout.col-13 .resource-card-15x18 {
-  width: 631px;
-  height: 892px;
-}
-.resource-flow-layout.col-13 .resource-card-18x6 {
-  width: 760px;
-  height: 284px;
-}
-.resource-flow-layout.col-13 .resource-card-18x12 {
-  width: 760px;
-  height: 420px;
-}
-.resource-flow-layout.col-13 .resource-card-18x18 {
-  width: 760px;
-  height: 892px;
-}
-.resource-flow-layout.col-13 .resource-card-3x2 {
-  width: 115px;
-  height: 95px;
-}
-.resource-flow-layout.col-13 .resource-card-3x2x3 {
-  width: 115px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-13 .resource-card-3x3 {
-  width: 115px;
-  height: 142px;
-}
-.resource-flow-layout.col-13 .resource-card-3x3x2 {
-  width: 115px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-13 .resource-card-6x2 {
-  width: 244px;
-  height: 95px;
-}
-.resource-flow-layout.col-13 .resource-card-6x2x3 {
-  width: 244px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-13 .resource-card-6x3 {
-  width: 244px;
-  height: 142px;
-}
-.resource-flow-layout.col-13 .resource-card-6x3x2 {
-  width: 244px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-13 .resource-card-9x2 {
-  width: 373px;
-  height: 95px;
-}
-.resource-flow-layout.col-13 .resource-card-9x2x3 {
-  width: 373px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-13 .resource-card-9x3 {
-  width: 373px;
-  height: 142px;
-}
-.resource-flow-layout.col-13 .resource-card-9x3x2 {
-  width: 373px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-13 .resource-card-12x2 {
-  width: 502px;
-  height: 95px;
-}
-.resource-flow-layout.col-13 .resource-card-12x2x3 {
-  width: 502px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-13 .resource-card-12x3 {
-  width: 502px;
-  height: 142px;
-}
-.resource-flow-layout.col-13 .resource-card-12x3x2 {
-  width: 502px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-13 .resource-card-15x2 {
-  width: 631px;
-  height: 95px;
-}
-.resource-flow-layout.col-13 .resource-card-15x2x3 {
-  width: 631px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-13 .resource-card-15x3 {
-  width: 631px;
-  height: 142px;
-}
-.resource-flow-layout.col-13 .resource-card-15x3x2 {
-  width: 631px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-.resource-flow-layout.col-13 .resource-card-18x2 {
-  width: 760px;
-  height: 95px;
-}
-.resource-flow-layout.col-13 .resource-card-18x2x3 {
-  width: 760px;
-  height: 90px;
-  margin-bottom: 7px;
-}
-.resource-flow-layout.col-13 .resource-card-18x3 {
-  width: 760px;
-  height: 142px;
-}
-.resource-flow-layout.col-13 .resource-card-18x3x2 {
-  width: 760px;
-  height: 138px;
-  margin-bottom: 8px;
-}
-
-/*
-  The following are styles for cards in the flowlayout above, styled by the number of rows they span
-*/
-/* Single row items, might be simpler to just apply a class */
-.resource-card-3x6 > .card-bg, .resource-card-6x6 > .card-bg, .resource-card-9x6 > .card-bg, .resource-card-12x6 > .card-bg, .resource-card-15x6 > .card-bg, .resource-card-18x6 > .card-bg {
-  height: 192px;
-}
-.resource-card-3x6 > .card-info, .resource-card-6x6 > .card-info, .resource-card-9x6 > .card-info, .resource-card-12x6 > .card-info, .resource-card-15x6 > .card-info, .resource-card-18x6 > .card-info {
-  padding: 4px 12px 6px 12px;
-  top: 192px;
-}
-.resource-card-3x6 > .card-info .section, .resource-card-6x6 > .card-info .section, .resource-card-9x6 > .card-info .section, .resource-card-12x6 > .card-info .section, .resource-card-15x6 > .card-info .section, .resource-card-18x6 > .card-info .section {
-  font-size: 12px;
-  margin-bottom: 1px;
-}
-.resource-card-3x6 > .card-info .title, .resource-card-6x6 > .card-info .title, .resource-card-9x6 > .card-info .title, .resource-card-12x6 > .card-info .title, .resource-card-15x6 > .card-info .title, .resource-card-18x6 > .card-info .title {
-  font-size: 16px;
-  margin-bottom: -2px;
-}
-.resource-card-3x6 > .card-info .description, .resource-card-6x6 > .card-info .description, .resource-card-9x6 > .card-info .description, .resource-card-12x6 > .card-info .description, .resource-card-15x6 > .card-info .description, .resource-card-18x6 > .card-info .description {
-  font-size: 13px;
-  line-height: 15px;
-}
-.resource-card-3x6 > .card-info .description .text, .resource-card-6x6 > .card-info .description .text, .resource-card-9x6 > .card-info .description .text, .resource-card-12x6 > .card-info .description .text, .resource-card-15x6 > .card-info .description .text, .resource-card-18x6 > .card-info .description .text {
-  height: 30px;
-}
-
-/* Double row items */
-.resource-card-3x12 > .card-bg, .resource-card-6x12 > .card-bg, .resource-card-9x12 > .card-bg, .resource-card-12x12 > .card-bg, .resource-card-15x12 > .card-bg, .resource-card-18x12 > .card-bg {
-  height: 320px;
-}
-.resource-card-3x12 > .card-info, .resource-card-6x12 > .card-info, .resource-card-9x12 > .card-info, .resource-card-12x12 > .card-info, .resource-card-15x12 > .card-info, .resource-card-18x12 > .card-info {
-  padding: 4px 12px 6px 12px;
-  top: 320px;
-}
-.resource-card-3x12 > .card-info .section, .resource-card-6x12 > .card-info .section, .resource-card-9x12 > .card-info .section, .resource-card-12x12 > .card-info .section, .resource-card-15x12 > .card-info .section, .resource-card-18x12 > .card-info .section {
-  font-size: 12px;
-  margin-bottom: 1px;
-}
-.resource-card-3x12 > .card-info .title, .resource-card-6x12 > .card-info .title, .resource-card-9x12 > .card-info .title, .resource-card-12x12 > .card-info .title, .resource-card-15x12 > .card-info .title, .resource-card-18x12 > .card-info .title {
-  font-size: 16px;
-  margin-bottom: -2px;
-  white-space: normal;
-}
-.resource-card-3x12 > .card-info .description, .resource-card-6x12 > .card-info .description, .resource-card-9x12 > .card-info .description, .resource-card-12x12 > .card-info .description, .resource-card-15x12 > .card-info .description, .resource-card-18x12 > .card-info .description {
-  font-size: 13px;
-  line-height: 15px;
-}
-
-/* 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 {
-  left: 90px;
-  padding: 4px 12px 4px 12px;
-  height: 80px;
-  overflow: hidden;
-}
-.resource-card-3x2 > .card-info .section, .resource-card-6x2 > .card-info .section, .resource-card-6x3 > .card-info .section, .resource-card-9x2 > .card-info .section, .resource-card-12x2 > .card-info .section, .resource-card-15x2 > .card-info .section, .resource-card-18x2 > .card-info .section {
-  font-size: 12px;
-  margin-bottom: 1px;
-  /* display: none; */
-}
-.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 {
-  font-size: 16px;
-  margin-bottom: -2px;
-  white-space: normal;
-  overflow: visible;
-  text-overflow: ellipsis;
-}
-.resource-card-3x2 > .card-info .title:after, .resource-card-6x2 > .card-info .title:after, .resource-card-9x2 > .card-info .title:after, .resource-card-12x2 > .card-info .title:after, .resource-card-15x2 > .card-info .title:after, .resource-card-18x2 > .card-info .title:after {
-  /* content: url(../images/link-out.png); */
-  display: block;
-}
-.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;
-}
-
-
-/* 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 > .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 {
-  left: 90px;
-  padding: 4px 12px 0px 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 {
-  font-size: 12px;
-  margin-bottom: 1px;
-  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 {
-  font-size: 16px;
-  margin-bottom: -2px;
-  white-space: normal;
-  overflow: visible;
-}
-.resource-card-3x3 > .card-info .description .text, .resource-card-6x3 > .card-info .description .text, .resource-card-9x3 > .card-info .description .text, .resource-card-12x3 > .card-info .description .text, .resource-card-15x3 > .card-info .description .text, .resource-card-18x3 > .card-info .description .text {
-  font-size: 12px;
-  line-height: 15px;
-  padding-right: 0px !important;
-  height: 80px;
-}
-.resource-card-3x3 > .card-info .description .util, .resource-card-6x3 > .card-info .description .util, .resource-card-9x3 > .card-info .description .util, .resource-card-12x3 > .card-info .description .util, .resource-card-15x3 > .card-info .description .util, .resource-card-18x3 > .card-info .description .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" and puts the title above a hairline rule. */
-.landing .card-info .section, .resource-flow-layout.col-16.landing .resource-card-9x6 .card-info .section {
-  display:none;
-}
-.landing  .card-info .title {
-  color: #898989;
-  font-size: 17px;
-  line-height: 24px;
-  margin-bottom: 6px;
-  border-bottom: 1px solid #959595;
-  padding-bottom: 0px;
-}
-.landing .card-info .description {
-  font-size: 13px;
-  line-height: 15px;
-}
-.landing .card-info .description .text {
-height:30px;
-}
-.landing .resource-card-6x6 > .card-info .description .util, .landing .resource-card-9x6 > .card-info .description .util {
-  bottom:2px;
-}
-/*
-  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;
-}
-
-
 
 /**
  * UTILITIES
@@ -6541,11 +4707,13 @@
  */
 
 .landing-h1 {
-  font-weight: 100;
-  font-size: 60px;
-  line-height: 78px;
+  color: #44555d;
+  font-weight: 300;
+  font-size: 56px;
+  line-height: 80px;
   text-align: center;
   letter-spacing: -1px;
+  margin-bottom: 6px;
 }
 
 .landing-pre-h1 {
@@ -6556,11 +4724,11 @@
   text-align: center;
   letter-spacing: -1px;
   text-transform: uppercase;
-
 }
 
 .landing-h1.hero {
   text-align: left;
+  color: #fff;
 }
 
 .landing-h2 {
@@ -6571,10 +4739,10 @@
 }
 
 .landing-subhead {
-  color: #999999;
+  color: #78868d;
   font-size: 20px;
-  line-height: 28px;
-  font-weight:300;
+  font-weight: 300;
+  line-height: 32px;
   text-align: center;
 }
 .landing-subhead.hero {
@@ -6611,23 +4779,21 @@
  * LAYOUT
  */
 
-#body-content,
-.fullpage,
-#jd-content,
-.jd-descr,
-.landing-body-content {
-  height: 100%;
-}
-
 .landing-section {
-  padding: 80px 10px 80px;
-  width: 100%;
-  margin-left: -10px;
+  background: #eceff1;
+  clear: both;
+  padding: 80px 20px 80px;
+  margin: 0 -20px;
   text-rendering: optimizeLegibility;
 }
 
-#extending-android-to-wearables {
-  padding-top: 30px;
+@media (max-width: 719px) {
+  .landing-section {
+    margin-left: -10px;
+    margin-right: -10px;
+    padding-left: 10px;
+    padding-right: 10px;
+  }
 }
 
 .landing-short-section {
@@ -6635,7 +4801,7 @@
 }
 
 .landing-gray-background {
-  background-color: #e9e9e9;
+  background-color: #b0bec5;
 }
 
 .landing-white-background {
@@ -6647,24 +4813,19 @@
   background-color: hsl(8, 70%, 54%);
 }
 
-.landing-subhead-red {
+.landing-red-background .landing-h1 {
+  color: white;
+}
+
+.landing-red-background .landing-subhead {
   color: hsl(8, 71%, 84%);
   text-align: left;
 }
 
-.landing-subhead-red p {
-  margin-top: 20px;
-}
-
-.landing-hero-container {
-  height: 100%;
-}
-
 
 .preview-hero {
-  height: calc(100% - 110px);
+  height: calc(100vh - 128px);
   min-height: 504px;
-  margin-top: -5px;
   padding-top: 0;
   padding-bottom: 0;
   background-image: url(../../preview/images/hero.jpg);
@@ -6676,9 +4837,8 @@
 }
 
 .wear-hero {
-  height: calc(100% - 110px);
+  height: calc(100vh - 128px);
   min-height: 504px;
-  margin-top: -5px;
   padding-top: 0;
   padding-bottom: 0;
   background-image: url(../../wear/images/hero.jpg);
@@ -6690,9 +4850,8 @@
 }
 
 .tv-hero {
-  height: calc(100% - 110px);
+  height: calc(100vh - 128px);
   min-height: 504px;
-  margin-top: -5px;
   padding-top: 0;
   padding-bottom: 0;
   background-image: url(../../tv/images/hero.jpg);
@@ -6704,9 +4863,8 @@
 }
 
 .auto-hero {
-  height: calc(100% - 110px);
+  height: calc(100vh - 128px);
   min-height: 504px;
-  margin-top: -5px;
   padding-top: 0;
   padding-bottom: 0;
   background-image: url(../../auto/images/hero.jpg);
@@ -6719,16 +4877,16 @@
 
 .landing-hero-scrim {
   background: black;
-  opacity: .2;
-  position: absolute;
-  width: 100%;
   height: 100%;
-  margin-left: -10px;
+  left: 0;
+  position: absolute;
+  opacity: .2;
+  width: 100%;
 }
 
 .landing-hero-wrap {
   margin: 0 auto;
-  width: 940px;
+  max-width: 940px;
   clear: both;
   height: 100%;
   position: relative;
@@ -6747,56 +4905,6 @@
   line-height: 24px;
 }
 
-.landing-button {
-  white-space: nowrap;
-  display: inline-block;
-  padding: 16px 32px;
-  font-size: 18px;
-  font-weight: 500;
-  line-height: 24px;
-  cursor: pointer;
-  color: white;
-  -webkit-user-select: none;
-     -moz-user-select: none;
-       -o-user-select: none;
-  user-select: none;
-  -webkit-transition: .2s background-color ease-in-out;
-     -moz-transition: .2s background-color ease-in-out;
-       -o-transition: .2s background-color ease-in-out;
-  transition: .2s background-color ease-in-out;
-}
-
-.landing-primary {
-  background-color: hsl(8, 70%, 44%);
-  color: #f8f8f8;
-}
-
-.landing-button.landing-primary:hover {
-  background-color: hsl(8, 70%, 36%);
-}
-
-.landing-button.landing-primary:active {
-  background-color: hsl(8, 70%, 30%);
-}
-
-.landing-button.landing-secondary {
-  background-color: #2faddb;
-}
-
-.landing-button.landing-secondary:hover {
-  background-color: #09c;
-}
-
-.landing-button.landing-secondary:active {
-  background-color: #3990ab;
-}
-
-a.landing-button,
-a.landing-button:hover,
-a.landing-button:visited {
-  color: white !important;
-}
-
 .landing-video-link {
   white-space: nowrap;
   display: inline-block;
@@ -6915,17 +5023,6 @@
   margin-bottom: 20px;
 }
 
-.col-3-wide {
-  display: inline;
-  float: left;
-  margin-left: 10px;
-  margin-right: 10px;
-}
-
-.col-3-wide {
-  width: 302px;
-}
-
 /**
  * ANIMATION
  */
@@ -6969,7 +5066,7 @@
 }
 
 #video-frame {
-  width:940px;
+  max-width:940px;
   height:100%;
   margin:72px auto;
   display:none;
@@ -7032,6 +5129,69 @@
   content:url("../images/play-circle-grey.png") url("../images/play-circle-grey_2x.png");
 }
 
+/*
+ * Responsive YouTube embeds from DevSite
+ *
+ * When applied to a <div> that wraps a video, "video-wrapper" forces the video
+ * to float right at 50% of the column width on desktop, but appear as a block
+ * element at 100% of the column width on smaller screens.
+ * "video-wrapper-full-width" works the same but is always 100% width.
+ */
+.video-wrapper,
+.video-wrapper-left {
+  float: right;
+  margin: 0 0 40px 40px;
+  padding-top: calc(((100% - 40px) / 2) / 16 * 9); /* 16:9 including margin */
+  position: relative;
+  width: calc((100% - 40px) / 2);                  /* 50% including margin */
+}
+
+/*
+ * "video-wrapper-left" forces 50% without the float
+ * This is useful for heading content when you want the video to
+ * appear next to an element that is already floated right
+ * (e.g. tb-wrapper <div>)
+ */
+.video-wrapper-left {
+  float: none;
+  margin: 16px 0 20px 0;
+}
+
+.video-wrapper-full-width {
+  margin: 16px 0;
+  padding-top: 56.25%; /* Forces div to 16:9 at 100% width */
+  position: relative;
+  width: 100%;
+}
+
+.video-wrapper embed,
+.video-wrapper iframe,
+.video-wrapper object,
+.video-wrapper-full-width embed,
+.video-wrapper-full-width iframe,
+.video-wrapper-full-width object,
+.video-wrapper-left embed,
+.video-wrapper-left iframe,
+.video-wrapper-left object {
+  height: 100%;
+  left: 0;
+  position: absolute;
+  top: 0;
+  width: 100%;
+}
+
+@media screen and (max-width: 1000px) {
+
+  .video-wrapper,
+  .video-wrapper-left {
+    float: none;
+    margin: 16px 0;
+    padding-top: 56.25%; /* Forces div to 16:9 at 100% width */
+    width: 100%;
+  }
+}
+
+
 /******************
 Styles for d.a.c/index:
 *******************/
@@ -7040,8 +5200,7 @@
 
 /* Generic full screen carousel styling to be used across pages. */
 .fullscreen-carousel {
-  margin: 0 -10px;
-  width: 100%;
+  margin: 0 -20px;
   overflow: hidden;
   position: relative;
 }
@@ -7080,7 +5239,6 @@
   font-weight: 300;
   font-size: 18px;
   line-height: 24px;
-  -webkit-font-smoothing: antialiased;
 }
 
 .fullscreen-carousel .hero .hero-bg {
@@ -7214,48 +5372,18 @@
 }
 
 
-
-
-
-/*
-   Styles for the entity link used in the actions bar and in the cta of
-   the resources that appear in the tab carousel.
-*/
-.actions-bar a:after,
-.resource .cta:after {
-  content: '›';
-  font-weight: 400;
-  font-size: 22px;
-  left: 5px;
-  line-height: 1;
-  position: relative;
-  top: 1px;
-  transition: left 190ms ease-out;
-}
-
-.actions-bar a:hover:after,
-.resource .cta:hover:after {
-  left: 10px;
-}
-
-
-
-
 /*
   Styles for the actions bar.
 */
 .actions-bar {
-  background: #9acd00;
-  margin: 0 -10px;
+  background: #b0bec5;
   text-align: center;
 }
 
 .actions-bar .actions {
-  padding: 30px 0 30px;
-  text-align: justify;
+  padding: 24px 0;
   font-size: 0.1px;
   line-height: 0.1px;
-  margin: 0 10px 0 0;
 }
 
 .actions-bar .actions:after {
@@ -7266,26 +5394,36 @@
 
 .actions-bar .actions > div {
   display: inline-block;
+  margin: 0 16px;
 }
 
-.actions-bar a {
-  font-size: 21px;
-  line-height: 27px;
+.actions-bar .actions a {
   color: #fff;
+  font-size: 24px;
   font-weight: 300;
-  -webkit-font-smoothing: antialiased;
+  line-height: 50px;
+  -webkit-transition: opacity .3s;
+  transition: opacity .3s;
 }
 
-.actions-bar a:after {
-  top: 0px;
-  font-size: 22px;
+.actions-bar .actions a:hover {
+  opacity: .54;
 }
 
-.actions-bar a:hover {
-  color: #fff !important;
+.actions-bar .actions .dac-sprite {
+  margin: 0 -8px 0 -12px;
 }
 
+@media (max-width: 719px) {
+  .actions-bar {
+    text-align: left;
+  }
 
+  .actions-bar .actions > div {
+    display: block;
+    margin: 0;
+  }
+}
 
 
 
@@ -7449,3 +5587,3203 @@
 .resource-card-6x2 > .card-bg.helpouts-card-bg:after {
   display:none;
 }
+
+.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;
+}
+
+/**
+ * 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;
+  left: 50%;
+  margin-left: -35px;
+  line-height: 65px;
+  padding-left: 4px;
+  position: absolute;
+  opacity: .6;
+  text-align: center;
+  -webkit-transition: opacity .5s;
+          transition: opacity .5s;
+  top: 50px;
+  width: 70px;
+  z-index: 1; }
+  .resource-card-6x6 .play-button {
+    display: block; }
+
+/* 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: 24px;
+    margin-bottom: 2px;
+    max-height: 48px;
+    overflow: hidden;
+    padding-bottom: 5px;
+    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; }
+
+/* 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: 24px;
+    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: 48px;
+    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: 96px;
+      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; }
+
+.dac-fab, .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-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-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; }
+
+.dac-fab {
+  background: #fff;
+  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);
+  border-radius: 50%;
+  font-size: 0;
+  height: 36px;
+  line-height: 36px;
+  min-width: 0;
+  overflow: hidden;
+  padding: 0;
+  vertical-align: middle;
+  width: 36px; }
+  .dac-fab:hover, a:hover > .dac-fab {
+    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.26); }
+  .dac-fab.dac-primary {
+    background: #00c7a0; }
+  .dac-fab.dac-large {
+    height: 54px;
+    line-height: 54px;
+    width: 54px; }
+
+.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;
+  /* Modifier for landing pages, to snuggle closer to sections. */ }
+  .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 {
+    margin-left: 4px; }
+  .dac-footer-separator {
+    background: #f0f0f0;
+    margin: 0 0 12px; }
+  .dac-footer-links a + a:before {
+    content: '|';
+    cursor: default;
+    margin: 0 10px 0 8px; }
+  .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 .locales {
+      display: block;
+      float: none;
+      margin-top: 15px; } }
+
+/* =============================================================================
+   Columns
+   ========================================================================== */
+.wrap {
+  margin: 0 auto;
+  max-width: 940px;
+  clear: both; }
+
+.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: 960px) 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.33333333%; }
+
+@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;
+} }
+
+/* Header component */
+.dac-header {
+  background: #fff;
+  height: 64px;
+  margin: 0 -20px;
+}
+
+@media (max-width: 719px) {
+  .dac-header {
+    margin: 0 -10px;
+  }
+}
+
+.about .dac-header, .distribute .dac-header, .develop .dac-header {
+  height: 128px;
+}
+
+.dac-header-inner {
+  background: #fff;
+  box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.07);
+  box-sizing: border-box;
+  height: 64px;
+  left: 0;
+  right: 0;
+  top: 0;
+  z-index: 52;
+}
+
+.dac-header.dac-sub .dac-header-inner {
+  border-bottom: 1px solid #e5e5e5;
+  box-shadow: none;
+}
+
+.dac-header.is-sticky .dac-header-inner {
+  position: fixed;
+  -webkit-animation: .3s dac-header-show;
+  animation: .3s dac-header-show;
+}
+
+.dac-header-logo {
+  border-right: 1px solid #e5e5e5;
+  display: block;
+  font-size: 20px;
+  font-weight: 300;
+  float: left;
+  letter-spacing: .3px;
+  line-height: 36px;
+  margin-right: 16px;
+  padding: 14px 24px 14px;
+}
+
+.dac-header-logo, .dac-header-logo:hover, .dac-header-logo:focus {
+  color: #444;
+}
+
+.dac-header-logo-image {
+  margin-right: 5px;
+  vertical-align: top;
+}
+
+.dac-header-console-btn {
+  border: 1px solid #c5c5c5;
+  border-radius: 3px;
+  box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.11);
+  background: #fff;
+  float: right;
+  font-size: 14px;
+  line-height: 28px;
+  margin: 17px 30px 17px 10px;
+  padding: 0 10px;
+  position: relative;
+  z-index: 52;
+}
+
+.dac-header-console-btn > .dac-sprite {
+  margin-right: 5px;
+}
+
+.dac-header-console-btn, .dac-header-console-btn:hover, .dac-header-console-btn:focus {
+  color: #666;
+}
+
+.dac-header-console-btn:focus {
+  background: rgba(63, 81, 181, 0.1);
+  outline: 0;
+}
+
+@media (max-width: 719px) {
+  .dac-header {
+    height: 64px !important;
+    text-align: center;
+  }
+
+  .dac-header-inner {
+    position: fixed;
+  }
+
+  .dac-header-logo {
+    border-right: 0;
+    display: inline-block;
+    margin-right: 0;
+    float: none;
+  }
+
+  .dac-header.dac-sub {
+    display: none;
+  }
+
+  .dac-header-console-btn {
+    display: none;
+  }
+}
+
+@-webkit-keyframes dac-header-show {
+  0% {
+    -webkit-transform: translateY(-64px);
+    transform: translateY(-64px);
+  }
+
+  100% {
+    -webkit-transform: translateY(0);
+    transform: translateY(0);
+  }
+}
+
+@keyframes dac-header-show {
+  0% {
+    -webkit-transform: translateY(-64px);
+    transform: translateY(-64px);
+  }
+
+  100% {
+    -webkit-transform: translateY(0);
+    transform: translateY(0);
+  }
+}
+
+/* Header Breadcrumbs component */
+.dac-header-crumbs {
+  display: none;
+  list-style-type: none;
+  margin: 0;
+}
+
+.is-sticky .dac-header-crumbs {
+  display: block;
+}
+
+.dac-header-crumbs-item {
+  float: left;
+  position: relative;
+  margin: 0;
+  padding-left: 10px;
+}
+
+.dac-header-crumbs-item:before {
+  color: #444;
+  content: '>';
+  font-weight: 300;
+  font-size: 20px;
+  left: 0;
+  line-height: 28px;
+  padding: 16px 0;
+  position: absolute;
+}
+
+.dac-header-crumbs-item:first-child:before {
+  content: none;
+}
+
+.dac-header-crumbs-link {
+  color: #444;
+  display: block;
+  font-size: 16px;
+  font-weight: 300;
+  line-height: 32px;
+  padding: 16px 16px;
+  -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-header-crumbs-link:hover, .dac-header-crumbs-link:focus {
+  color: rgba(68, 68, 68, 0.7);
+}
+
+.dac-header-crumbs-link:focus {
+  background: rgba(63, 81, 181, 0.1);
+  outline: 0;
+}
+
+.dac-header-crumbs-link.current {
+  color: #6ab344;
+  font-weight: 400;
+}
+
+.dac-header-crumbs-link.current.ndk {
+  color: #00BCD4;
+}
+
+@media (max-width: 719px) {
+  .dac-header-crumbs {
+    display: none;
+  }
+}
+
+/* Header site search component */
+.dac-header-search {
+  background: #fff;
+  border-left: 1px solid #e5e5e5;
+  display: block;
+  float: right;
+  height: 28px;
+  padding: 18px 0;
+  position: relative;
+  overflow: hidden;
+  -webkit-transition: width 0.4s ease, left 0.4s ease;
+  transition: width 0.4s ease, left 0.4s ease;
+  width: 64px;
+  z-index: 52;
+}
+
+.dac-header-search:hover, .dac-header-search.active {
+  width: 228px;
+}
+
+.dac-header-search-inner {
+  width: 228px;
+}
+
+.dac-header-search-btn {
+  left: 20px;
+  position: absolute;
+  top: 20px;
+  opacity: .54;
+}
+
+.dac-header-search-form {
+  left: 54px;
+  opacity: 0;
+  position: absolute;
+  right: 24px;
+  top: 20px;
+  -webkit-transition: opacity .4s;
+  transition: opacity .4s;
+}
+
+.dac-header-search:hover .dac-header-search-form, .dac-header-search.active .dac-header-search-form {
+  opacity: 1;
+}
+
+.dac-header-search-input {
+  background-color: transparent;
+  border: none;
+  border-bottom: 1px solid #CCC;
+  border-radius: 0;
+  box-sizing: border-box;
+  color: #2f2f2f;
+  font-size: 14px;
+  height: 24px;
+  outline: none;
+  padding: 4px 20px 4px 0;
+  width: 100%;
+  z-index: 1500;
+}
+
+.dac-header-search-input:focus {
+  color: #222;
+  font-weight: bold;
+  outline: 0;
+}
+
+.dac-header-search-close {
+  position: absolute;
+  right: 4px;
+  bottom: 4px;
+  width: 16px;
+  height: 16px;
+  margin: 0;
+  text-indent: -1000em;
+  background: url(../images/close.png) no-repeat 0 0;
+  z-index: 9999;
+}
+
+.dac-header-search-close:hover, .dac-header-search-close:focus {
+  background-position: -16px 0;
+  cursor: pointer;
+}
+
+@media (max-width: 719px) {
+  .dac-header-search {
+    position: absolute;
+    left: calc(100% - 64px);
+    right: 0;
+    top: 0;
+    width: auto;
+  }
+
+  .dac-header-search:hover, .dac-header-search.active {
+    left: 64px;
+    width: auto;
+  }
+}
+
+/* Main navigation component */
+.is-sticky .dac-nav, .dac-nav-head, .dac-nav-toggle {
+  display: none;
+}
+
+.dac-nav-list {
+  list-style-type: none;
+  left: 192px;
+  margin: 0;
+  position: absolute;
+  right: 0;
+  top: 0;
+  z-index: 51;
+}
+
+.dac-nav-item {
+  float: left;
+  margin: 0;
+}
+
+.dac-nav-head {
+  margin-bottom: 10px;
+}
+
+.dac-nav-dimmer {
+  background: #000;
+  display: none;
+  height: 100%;
+  left: 0;
+  opacity: 0;
+  position: fixed;
+  top: 0;
+  -webkit-transition: visibility 0s linear .3s, opacity .3s linear;
+  transition: visibility 0s linear .3s, opacity .3s linear;
+  -webkit-transform: translateZ(0);
+  transform: translateZ(0);
+  visibility: hidden;
+  width: 100%;
+  z-index: 52;
+}
+
+.dac-nav-hamburger {
+  display: inline-block;
+  height: 15px;
+  width: 16px;
+}
+
+.dac-nav-hamburger-top, .dac-nav-hamburger-mid, .dac-nav-hamburger-bot {
+  background: #999;
+  display: block;
+  height: 3px;
+  margin: 3px 0 0;
+  width: 100%;
+}
+
+.dac-nav-link {
+  color: #444;
+  display: block;
+  font-size: 16px;
+  font-weight: 300;
+  letter-spacing: .24px;
+  line-height: 32px;
+  padding: 18px 16px 14px;
+  -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-link.has-subnav, .dac-nav-link.selected {
+  border-bottom: 3px solid #6ab344;
+  font-weight: 500;
+  padding-bottom: 11px;
+}
+
+.dac-nav-link.has-subnav.ndk, .dac-nav-link.selected.ndk {
+  border-bottom: 3px solid #00BCD4;
+}
+
+.dac-nav-secondary {
+  border-bottom: 1px solid #e5e5e5;
+  display: none;
+  left: -192px;
+  list-style-type: none;
+  margin: 0;
+  position: absolute;
+  top: 64px;
+  right: 0;
+}
+
+.dac-nav-link.has-subnav + .dac-nav-secondary, .dac-nav-link.selected + .dac-nav-secondary {
+  display: block;
+}
+
+.dac-nav-secondary .dac-nav-link {
+  color: #666;
+  padding: 17px 16px 15px;
+}
+
+.dac-nav-secondary .dac-nav-link:hover, .dac-nav-secondary .dac-nav-link:focus {
+  color: rgba(102, 102, 102, 0.7);
+}
+
+@media (min-width: 720px) and (max-width: 979px) {
+  .dac-nav-secondary .dac-nav-link {
+    padding-left: 8px;
+    padding-right: 8px;
+  }
+}
+
+.dac-nav-secondary .dac-nav-link.selected {
+  border: none;
+  font-weight: 700;
+}
+
+.dac-nav-secondary .dac-nav-link.selected.ndk {
+  border: none;
+  font-weight: 700;
+}
+
+@media (max-width: 719px) {
+  .dac-nav-open {
+    overflow: hidden;
+  }
+
+  .dac-nav-toggle {
+    border-right: 1px solid #e5e5e5;
+    display: inline-block;
+    position: absolute;
+    left: 0;
+    line-height: 64px;
+    text-align: center;
+    width: 64px;
+  }
+
+  .dac-nav-head, .dac-nav-secondary, .dac-nav-dimmer {
+    display: block;
+  }
+
+  .dac-nav-dimmer.dac-nav-open {
+    opacity: .8;
+    -webkit-transition-delay: 0s;
+    transition-delay: 0s;
+    visibility: visible;
+  }
+
+  .dac-nav-list {
+    background: #fff;
+    bottom: 0;
+    left: auto;
+    max-width: 280px;
+    -webkit-overflow-scrolling: touch;
+    overflow-y: scroll;
+    padding: 0 0 20px 0;
+    position: fixed;
+    right: 100%;
+    top: 0;
+    -webkit-transition: -webkit-transform .3s ease;
+    transition: transform .3s ease;
+    width: 85%;
+    z-index: 52;
+  }
+
+  .dac-nav-list.dac-nav-open {
+    -webkit-transform: translate3d(100%, 0, 0);
+    transform: translate3d(100%, 0, 0);
+  }
+
+  .dac-nav-secondary {
+    border: none;
+    position: static;
+    width: 100%;
+  }
+
+  .dac-nav-item {
+    float: none;
+  }
+
+  .dac-nav-link {
+    display: block;
+    font-size: 12px;
+    font-weight: 600;
+    color: #333;
+    padding: 0 20px;
+  }
+
+  .dac-nav-link.selected {
+    color: #09f;
+  }
+
+  .dac-nav-secondary .dac-nav-link {
+    font-weight: 400;
+    margin-left: 20px;
+    margin-right: 20px;
+    padding: 0 20px;
+  }
+
+  .dac-nav-link.has-subnav, .dac-nav-link.selected {
+    border: none;
+    padding: 0 20px;
+  }
+
+  .dac-nav-link.has-subnav.ndk, .dac-nav-link.selected.ndk {
+    border: none;
+    padding: 0 20px;
+  }
+
+  .dac-logo-image {
+    margin-right: 5px;
+    vertical-align: top;
+  }
+
+  .dac-nav-logo {
+    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.04);
+    font-size: 20px;
+    font-weight: 300;
+    letter-spacing: .3px;
+    line-height: 36px;
+    padding: 14px 24px;
+  }
+
+  .dac-nav-logo, .dac-nav-logo:hover, .dac-nav-logo:focus {
+    color: #444;
+  }
+}
+
+/* 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;
+}
+
+@media (max-width: 719px) {
+  .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;
+}
+
+@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 {
+  margin-left: -8px;
+}
+
+@media (max-width: 719px) {
+  .dac-hero-cta {
+    line-height: 28px;
+  }
+}
+
+.dac-hero-figure {
+  text-align: center;
+}
+
+@media (max-width: 719px) {
+  .dac-hero-figure {
+    height: 150px;
+    margin: 15px 0;
+  }
+
+  .dac-hero-figure img {
+    max-height: 150px;
+  }
+}
+
+.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(.75);
+  transform: translate3d(0, 0, 0) scale(.75);
+}
+
+.dac-form-radio, .dac-form-checkbox {
+  opacity: 0;
+  position: absolute;
+}
+
+.dac-form-radio-group, .dac-form-checkbox-group {
+  display: table;
+  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: '';
+  border-radius: 50%;
+  display: block;
+  height: 100%;
+  position: absolute;
+  width: 100%;
+}
+
+.dac-form-radio-button::before, .dac-form-checkbox-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, .dac-form-checkbox-button::after {
+  border: 2px solid rgba(0, 0, 0, 0.7);
+}
+
+.dac-form-radio:checked + .dac-form-radio-button::before, .dac-form-checkbox:checked + .dac-form-checkbox-button::before {
+  -webkit-transform: translateZ(0) scale(.5);
+  transform: translateZ(0) scale(.5);
+}
+
+.dac-form-radio:focus + .dac-form-radio-button::after, .dac-form-checkbox:focus + .dac-form-checkbox-button::after {
+  border: 2px solid #09f;
+}
+
+.dac-form-checkbox-button::after, .dac-form-checkbox-button::before {
+  border-radius: 0;
+}
+
+@media (max-width: 719px) {
+  .dac-form-legend {
+    margin-bottom: 0;
+  }
+}
+
+/* Media component */
+.dac-media {
+  display: -webkit-box;
+  display: -webkit-flex;
+  display: -ms-flexbox;
+  display: flex;
+  -webkit-flex-flow: row wrap;
+  -ms-flex-flow: row wrap;
+  flex-flow: row wrap;
+}
+
+.dac-media-figure {
+  margin: 0;
+}
+
+.dac-media-body {
+  -webkit-box-flex: 1;
+  -webkit-flex: 1;
+  -ms-flex: 1;
+  flex: 1;
+}
+
+.no-flexbox .dac-media {
+  display: table;
+  width: 100%;
+}
+
+.no-flexbox .dac-media-body, .no-flexbox .dac-media-figure {
+  display: table-cell;
+}
+
+.no-flexbox .dac-media-figure {
+  padding: 0;
+}
+
+.no-flexbox .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-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 {
+  background: rgba(0, 0, 0, 0.8);
+  bottom: 0;
+  left: 0;
+  opacity: 0;
+  overflow-x: hidden;
+  overflow-y: auto;
+  position: fixed;
+  right: 0;
+  top: 0;
+  -webkit-transition: visibility 0s linear .3s, opacity .3s linear;
+  transition: visibility 0s linear .3s, opacity .3s linear;
+  visibility: hidden;
+  z-index: 52;
+}
+
+.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;
+  border-radius: 5px;
+  box-sizing: border-box;
+  margin: 20px auto;
+  -webkit-transition: -webkit-transform .3s;
+  transition: transform .3s;
+  -webkit-transform: translate(0, -30px);
+  -ms-transform: translate(0, -30px);
+  transform: translate(0, -30px);
+  width: 960px;
+}
+
+.dac-modal.dac-active .dac-modal-window {
+  -webkit-transform: translate(0, 0);
+  -ms-transform: translate(0, 0);
+  transform: translate(0, 0);
+}
+
+.dac-modal-header {
+  background: #00695c;
+  border-top-left-radius: 5px;
+  border-top-right-radius: 5px;
+  padding: 35px 35px 30px;
+  position: relative;
+}
+
+.dac-modal-header-close {
+  background: none;
+  border: none;
+  cursor: pointer;
+  line-height: 0;
+  outline: 0;
+  opacity: .7;
+  padding: 8px;
+  position: absolute;
+  right: 5px;
+  -webkit-transition: background-color .3s;
+  transition: background-color .3s;
+  top: 5px;
+}
+
+.dac-modal-header-close:active {
+  background: rgba(255, 255, 255, 0.2);
+}
+
+.dac-modal-header-title {
+  color: #fff;
+  font-size: 24px;
+  font-weight: 300;
+  line-height: 32px;
+  margin: 0;
+  padding-right: 150px;
+}
+
+.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-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-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: #b2b2b2;
+  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: #b0bec5;
+}
+
+.dac-dark.dac-hero, .dac-dark.dac-section {
+  background-color: #37474f;
+}
+
+.dac-red.dac-hero, .dac-red.dac-section {
+  background-color: #dc4d38;
+}
+
+.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 {
+  opacity: .87;
+}
+
+.dac-invert .dac-hero-cta .dac-sprite, .dac-invert .dac-section-title .dac-sprite, .dac-invert .dac-section-links .dac-sprite {
+  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: #b2b2b2;
+  color: rgba(255, 255, 255, 0.7);
+}
+
+.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 {
+  padding-bottom: 32px;
+  padding-top: 32px;
+}
+
+.dac-section-title {
+  text-align: center;
+  margin-bottom: 40px;
+  margin-top: 0;
+}
+
+.dac-section-subtitle {
+  font-size: 16px;
+  margin-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 {
+  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, #tb li:before, #qv li:before {
+  background-image: url(/assets/images/sprite.png);
+  display: inline-block;
+  vertical-align: middle; }
+  @media screen and (min-device-pixel-ratio: 1.5) {
+    .dac-sprite, #tb li:before, #qv li:before {
+      background-image: url(/assets/images/sprite-2x.png);
+      background-size: 50% 50%; } }
+
+.dac-sprite.dac-auto-chevron {
+  background-position: 0px -196px;
+  height: 24px;
+  width: 24px;
+  vertical-align: -6px; }
+  .dac-invert .dac-sprite.dac-auto-chevron {
+    background-position: 0px -222px;
+    height: 24px;
+    width: 24px; }
+.dac-sprite.dac-auto-chevron-large {
+  background-position: 0px -404px;
+  height: 36px;
+  width: 36px;
+  vertical-align: -10px; }
+  .dac-invert .dac-sprite.dac-auto-chevron-large {
+    background-position: 0px -442px;
+    height: 36px;
+    width: 36px; }
+.dac-sprite.dac-auto-unfold-less {
+  background-position: 0px -352px;
+  height: 24px;
+  width: 24px;
+  vertical-align: -6px; }
+  .dac-invert .dac-sprite.dac-auto-unfold-less {
+    background-position: 0px -326px;
+    height: 24px;
+    width: 24px; }
+.dac-sprite.dac-auto-unfold-more {
+  background-position: 0px -300px;
+  height: 24px;
+  width: 24px;
+  vertical-align: -6px; }
+  .dac-invert .dac-sprite.dac-auto-unfold-more {
+    background-position: 0px -378px;
+    height: 24px;
+    width: 24px; }
+
+.dac-sprite.dac-arrow-down-gray {
+  background-position: 0px 0px;
+  height: 11px;
+  width: 19px; }
+
+.dac-sprite.dac-arrow-right {
+  background-position: 0px -128px;
+  height: 18px;
+  width: 11px; }
+
+.dac-sprite.dac-chevron-large-right-black {
+  background-position: 0px -404px;
+  height: 36px;
+  width: 36px; }
+
+.dac-sprite.dac-chevron-large-right-white {
+  background-position: 0px -442px;
+  height: 36px;
+  width: 36px; }
+
+.dac-sprite.dac-chevron-right-black {
+  background-position: 0px -196px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-chevron-right-white {
+  background-position: 0px -222px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-close {
+  background-position: 0px -27px;
+  height: 12px;
+  width: 12px; }
+
+.dac-sprite.dac-expand-less-black {
+  background-position: 0px -248px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-expand-more-black {
+  background-position: 0px -170px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-google-play {
+  background-position: 0px -108px;
+  height: 18px;
+  width: 16px; }
+
+.dac-sprite.dac-gplus {
+  background-position: 0px -89px;
+  height: 17px;
+  width: 16px; }
+
+.dac-sprite.dac-mail {
+  background-position: 0px -13px;
+  height: 12px;
+  width: 16px; }
+
+.dac-sprite.dac-play-white {
+  background-position: 0px -148px;
+  height: 20px;
+  width: 16px; }
+
+.dac-sprite.dac-rss {
+  background-position: 0px -41px;
+  height: 14px;
+  width: 14px; }
+
+.dac-sprite.dac-search {
+  background-position: 0px -274px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-twitter {
+  background-position: 0px -73px;
+  height: 14px;
+  width: 16px; }
+
+.dac-sprite.dac-unfold-less-white {
+  background-position: 0px -326px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-unfold-less {
+  background-position: 0px -352px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-unfold-more-white {
+  background-position: 0px -378px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-unfold-more {
+  background-position: 0px -300px;
+  height: 24px;
+  width: 24px; }
+
+.dac-sprite.dac-youtube {
+  background-position: 0px -57px;
+  height: 14px;
+  width: 18px; }
+
+.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; } }
+
+.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; }
+
+/**
+ * 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;
+}
+
+#tb li:before, #qv li:before {
+  background-position: 0px -196px;
+  height: 24px;
+  width: 24px;
+  content: '';
+  left: -8px;
+  opacity: .7;
+  position: absolute;
+  top: -4px;
+}
diff --git a/tools/droiddoc/templates-sdk/assets/css/fullscreen.css b/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
index 7912e34..0f108e0 100644
--- a/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
+++ b/tools/droiddoc/templates-sdk/assets/css/fullscreen.css
@@ -14,195 +14,7 @@
 */
 
 @media screen, projection, print {
-.full {
-	padding: 2.5em 0;
-	border-top: solid 1px #ddd;
-	border-bottom: solid 1px #ddd;
-	background: #f7f7f7;	
+  .wrap {
+    max-width: none;
+  }
 }
-.wrap {
-	margin: 0 auto;
-	width: 100%;
-	min-width:600px;
-	clear: both;
-}
-.cols {
-    height: 1%;
-    margin: 0 -1.533742331288343558282%;
-    width: 103.06748466257669%}
-*+html .cols {
-    margin-bottom: 20px;
-}
-.cols:after {
-    clear: both;
-    content: ' ';
-    display: block;
-    height: 0;
-    visibility: hidden;
-}
-.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
-.col-13, .col-14, .col-15, .col-16 {
-    float: left;
-    margin: 0 1.063829787234% 20px 1.063829787234%;
-}
-* html .col-1, * html .col-2, * html .col-3, * html .col-4, * html .col-5, * html .col-6, * html
-.col-7, * html .col-8, * html .col-9, * html .col-10, * html .col-11, * html .col-12, * html
-.col-13, * html .col-14, * html .col-15, * html .col-16  {
-    margin: 0;
-    margin: 0 1.063829787234% 20px 1.063829787234%;
-}
-[dir='rtl'] .col-1, [dir='rtl'] .col-2, [dir='rtl'] .col-3, [dir='rtl'] .col-4, [dir='rtl'] .col-5,
-[dir='rtl'] .col-6, [dir='rtl'] .col-7, [dir='rtl'] .col-8, [dir='rtl'] .col-9, [dir='rtl'] .col-10,
-[dir='rtl'] .col-11, [dir='rtl'] .col-12 {
-    float: right;
-}
-.col-1 {
-    width: 4.16666666666667%;
-}
-.col-2 {
-    width: 10.4166666666667%;
-}
-.col-3 {
-    width: 16.6666666666667%;
-}
-.col-4 {
-    width: 22.9166666666667%;
-}
-.col-5 {
-    width: 29.1666666666667%;
-}
-.col-6 {
-    width: 35.4166666666667%;
-}
-.col-7 {
-    width: 41.6666666666667%;
-}
-.col-8 {
-    width: 47.9166666666667%;
-}
-.col-9 {
-    width: 55.3333333333333%;
-}
-.col-10 {
-    width: 60.4166666666667%;
-}
-.col-11 {
-    width: 66.6666666666667%;
-}
-.col-12 {
-    width: 72.9166666666667%;
-}
-.col-13 {
-    width: 79.1666666666667%;
-}
-.col-14 {
-    width: 85.4166666666667%;
-}
-.col-15 {
-    width: 91.6666666666667%;
-}
-.col-16 {
-    width: 97.9166666666667%;
-}
-
-
-
-
-
-
-
-#header .col-1,
-#nav-x .col-1 { width: 40px }
-#header .col-2,
-#nav-x .col-2 { width: 100px }
-#header .col-3,
-#nav-x .col-3 { width: 160px }
-#header .col-4,
-#nav-x .col-4 { width: 220px }
-#header .col-5,
-#nav-x .col-5 { width: 280px }
-#header .col-6,
-#nav-x .col-6 { width: 340px }
-#header .col-7,
-#nav-x .col-7 { width: 400px }
-#header .col-8,
-#nav-x .col-8 { width: 460px }
-#header .col-9,
-#nav-x .col-9 { width: 520px }
-#header .col-10,
-#nav-x .col-10 { width: 580px }
-#header .col-11,
-#nav-x .col-11 { width: 640px }
-#header .col-12,
-#nav-x .col-12 { width: 700px }
-#header .col-13,
-#nav-x .col-13 { width: 760px }
-#header .col-14,
-#nav-x .col-14 { width: 820px }
-#header .col-15,
-#nav-x .col-15 { width: 880px }
-#header .col-16,
-#nav-x .col-16 { width: 940px }
-
-
-
-body {
-  padding:0 20px;
-}
-#header,
-#searchResults,
-#nav-x {
-  margin:0;
-}
-#body-content {
-  margin:0;
-}
-#body-content > .col-12 {
-  width:77.9804965%;
-  margin:0 0 0 0.97%; /* this percentage chosen to make IE9 happy */
-}
-#side-nav {
-  width: 19.9804965%;
-  margin:0 1.063829787234% 0 0;
-}
-
-#header .wrap {
-  max-width: 100%;
-}
-
-#header-wrapper #nav-x div.wrap,
-#searchResults.wrap {
-    max-width:100%;
-}
-
-.nav-x {
-  margin:-2px 0 0 0;
-}
-
-#devdoc-nav.fixed,
-#devdoc-nav.fixed a.totop {
-  left:20px; /* !important ... for IE i think */
-}
-
-#sticky-header {
-  padding: 0 20px;
-}
-
-#sticky-header > div {
-  width: 100%;
-}
-
-.sticky-menu {
-  width:100%;
-  left:-20px;
-}
-
-.col-right {
-  margin-right:0px;
-}
-
-@media screen and (max-width:772px) {
-.col-5, .col-6, .col-7 {
-    clear: both;
-    width: 97.0238096%}
-}
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/images/android_logo.png b/tools/droiddoc/templates-sdk/assets/images/android_logo.png
new file mode 100644
index 0000000..5f19215
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/android_logo.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/android_logo@2x.png b/tools/droiddoc/templates-sdk/assets/images/android_logo@2x.png
new file mode 100644
index 0000000..04132cc
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/android_logo@2x.png
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
new file mode 100644
index 0000000..3f39f4d
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk@2x.png b/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk@2x.png
new file mode 100644
index 0000000..8081ac5
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/android_logo_ndk@2x.png
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
index 8050744..398030f 100644
--- a/tools/droiddoc/templates-sdk/assets/images/resource-card-default-android.jpg
+++ b/tools/droiddoc/templates-sdk/assets/images/resource-card-default-android.jpg
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
new file mode 100644
index 0000000..185b7e8
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/sprite-2x.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/images/sprite.png b/tools/droiddoc/templates-sdk/assets/images/sprite.png
new file mode 100644
index 0000000..7fef43e
--- /dev/null
+++ b/tools/droiddoc/templates-sdk/assets/images/sprite.png
Binary files differ
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index 7f4be4e..d88c0e6 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -56,7 +56,7 @@
 
   // setup keyboard listener for search shortcut
   $('body').keyup(function(event) {
-    if (event.which == 191) {
+    if (event.which == 191 && $(event.target).is(':not(:input)')) {
       $('#search_autocomplete').focus();
     }
   });
@@ -71,18 +71,12 @@
   });
 
   // initialize the divs with custom scrollbars
-  $('.scroll-pane').jScrollPane( {verticalGutter:0} );
-
-  // add HRs below all H2s (except for a few other h2 variants)
-  $('h2').not('#qv h2')
-         .not('#tb h2')
-         .not('.sidebox h2')
-         .not('#devdoc-nav h2')
-         .not('h2.norule').css({marginBottom:0})
-         .after('<hr/>');
+  if (window.innerWidth >= 720) {
+    $('.scroll-pane').jScrollPane({verticalGutter: 0});
+  }
 
   // set up the search close button
-  $('.search .close').click(function() {
+  $('#search-close').on('click touchend', function() {
     $searchInput = $('#search_autocomplete');
     $searchInput.attr('value', '');
     $(this).addClass("hide");
@@ -92,38 +86,13 @@
     hideResults();
   });
 
-  // Set up quicknav
-  var quicknav_open = false;
-  $("#btn-quicknav").click(function() {
-    if (quicknav_open) {
-      $(this).removeClass('active');
-      quicknav_open = false;
-      collapse();
-    } else {
-      $(this).addClass('active');
-      quicknav_open = true;
-      expand();
-    }
-  })
-
-  var expand = function() {
-   $('#header-wrap').addClass('quicknav');
-   $('#quicknav').stop().show().animate({opacity:'1'});
-  }
-
-  var collapse = function() {
-    $('#quicknav').stop().animate({opacity:'0'}, 100, function() {
-      $(this).hide();
-      $('#header-wrap').removeClass('quicknav');
-    });
-  }
-
 
   //Set up search
   $("#search_autocomplete").focus(function() {
     $("#search-container").addClass('active');
   })
-  $("#search-container").mouseover(function() {
+  $("#search-container").on('mouseover touchend', function(e) {
+    if ($(e.target).is('#search-close')) { return; }
     $("#search-container").addClass('active');
     $("#search_autocomplete").focus();
   })
@@ -180,73 +149,88 @@
 
   // Highlight the header tabs...
   // highlight Design tab
-  if ($("body").hasClass("design")) {
-    $("#header li.design a").addClass("selected");
-    $("#sticky-header").addClass("design");
+  var urlSegments = pagePathOriginal.split('/');
+  var navEl = $(".dac-nav-list");
+  var subNavEl = navEl.find(".dac-nav-secondary");
+  var parentNavEl;
 
+  if ($("body").hasClass("design")) {
+    navEl.find("> li.design > a").addClass("selected");
   // highlight About tabs
   } else if ($("body").hasClass("about")) {
-    var rootDir = pagePathOriginal.substring(1,pagePathOriginal.indexOf('/', 1));
-    if (rootDir == "about") {
-      $("#nav-x li.about a").addClass("selected");
-    } else if (rootDir == "wear") {
-      $("#nav-x li.wear a").addClass("selected");
-    } else if (rootDir == "tv") {
-      $("#nav-x li.tv a").addClass("selected");
-    } else if (rootDir == "auto") {
-      $("#nav-x li.auto a").addClass("selected");
+    if (urlSegments[1] == "about" || urlSegments[1] == "wear" || urlSegments[1] == "tv" || urlSegments[1] == "auto") {
+      navEl.find("> li.home > a").addClass('has-subnav');
+      subNavEl.find("li." + urlSegments[1] + " > a").addClass("selected");
+    } else {
+      navEl.find("> li.home > a").addClass('selected');
     }
+
+// highlight NDK tabs
+  } else if ($("body").hasClass("ndk")) {
+    parentNavEl = navEl.find("> li.ndk > a");
+    parentNavEl.addClass('has-subnav');
+    if ($("body").hasClass("guide")) {
+      navEl.find("> li.guides > a").addClass("selected ndk");
+    } else if ($("body").hasClass("reference")) {
+      navEl.find("> li.reference > a").addClass("selected ndk");
+    } else if ($("body").hasClass("samples")) {
+      navEl.find("> li.samples > a").addClass("selected ndk");
+    } else if ($("body").hasClass("downloads")) {
+      navEl.find("> li.downloads > a").addClass("selected ndk");
+    }
+
   // highlight Develop tab
   } else if ($("body").hasClass("develop") || $("body").hasClass("google")) {
-    $("#header li.develop a").addClass("selected");
-    $("#sticky-header").addClass("develop");
+    parentNavEl = navEl.find("> li.develop > a");
+    parentNavEl.addClass('has-subnav');
+
     // In Develop docs, also highlight appropriate sub-tab
-    var rootDir = pagePathOriginal.substring(1,pagePathOriginal.indexOf('/', 1));
-    if (rootDir == "training") {
-      $("#nav-x li.training a").addClass("selected");
-    } else if (rootDir == "guide") {
-      $("#nav-x li.guide a").addClass("selected");
-    } else if (rootDir == "reference") {
+    if (urlSegments[1] == "training") {
+      subNavEl.find("li.training > a").addClass("selected");
+    } else if (urlSegments[1] == "guide") {
+      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")) {
-        $("#nav-x li.google a").addClass("selected");
+        subNavEl.find("li.google > a").addClass("selected");
       } else {
-        $("#nav-x li.reference a").addClass("selected");
+        subNavEl.find("li.reference > a").addClass("selected");
       }
-    } else if ((rootDir == "tools") || (rootDir == "sdk")) {
-      $("#nav-x li.tools a").addClass("selected");
+    } else if ((urlSegments[1] == "tools") || (urlSegments[1] == "sdk")) {
+      subNavEl.find("li.tools > a").addClass("selected");
     } else if ($("body").hasClass("google")) {
-      $("#nav-x li.google a").addClass("selected");
+      subNavEl.find("li.google > a").addClass("selected");
     } else if ($("body").hasClass("samples")) {
-      $("#nav-x li.samples a").addClass("selected");
+      subNavEl.find("li.samples > a").addClass("selected");
+    } else if ($("body").hasClass("preview")) {
+      subNavEl.find("li.preview > a").addClass("selected");
+    } else {
+      parentNavEl.removeClass('has-subnav').addClass("selected");
     }
-
   // highlight Distribute tab
   } else if ($("body").hasClass("distribute")) {
-    $("#header li.distribute a").addClass("selected");
-    $("#sticky-header").addClass("distribute");
+    parentNavEl = navEl.find("> li.distribute > a");
+    parentNavEl.addClass('has-subnav');
 
-    var baseFrag = pagePathOriginal.indexOf('/', 1) + 1;
-    var secondFrag = pagePathOriginal.substring(baseFrag, pagePathOriginal.indexOf('/', baseFrag));
-    if (secondFrag == "users") {
-      $("#nav-x li.users a").addClass("selected");
-    } else if (secondFrag == "engage") {
-      $("#nav-x li.engage a").addClass("selected");
-    } else if (secondFrag == "monetize") {
-      $("#nav-x li.monetize a").addClass("selected");
-    } else if (secondFrag == "analyze") {
-      $("#nav-x li.analyze a").addClass("selected");
-    } else if (secondFrag == "tools") {
-      $("#nav-x li.disttools a").addClass("selected");
-    } else if (secondFrag == "stories") {
-      $("#nav-x li.stories a").addClass("selected");
-    } else if (secondFrag == "essentials") {
-      $("#nav-x li.essentials a").addClass("selected");
-    } else if (secondFrag == "googleplay") {
-      $("#nav-x li.googleplay a").addClass("selected");
+    if (urlSegments[2] == "users") {
+      subNavEl.find("li.users > a").addClass("selected");
+    } else if (urlSegments[2] == "engage") {
+      subNavEl.find("li.engage > a").addClass("selected");
+    } else if (urlSegments[2] == "monetize") {
+      subNavEl.find("li.monetize > a").addClass("selected");
+    } else if (urlSegments[2] == "analyze") {
+      subNavEl.find("li.analyze > a").addClass("selected");
+    } else if (urlSegments[2] == "tools") {
+      subNavEl.find("li.essentials > a").addClass("selected");
+    } else if (urlSegments[2] == "stories") {
+      subNavEl.find("li.stories > a").addClass("selected");
+    } else if (urlSegments[2] == "essentials") {
+      subNavEl.find("li.essentials > a").addClass("selected");
+    } else if (urlSegments[2] == "googleplay") {
+      subNavEl.find("li.googleplay > a").addClass("selected");
+    } else {
+      parentNavEl.removeClass('has-subnav').addClass("selected");
     }
-  } else if ($("body").hasClass("about")) {
-    $("#sticky-header").addClass("about");
   }
 
   // set global variable so we can highlight the sidenav a bit later (such as for google reference)
@@ -392,14 +376,13 @@
 
     var $olClasses  = $('<ol class="class-list"></ol>');
     var $liClass;
-    var $imgIcon;
     var $h2Title;
     var $pSummary;
     var $olLessons;
     var $liLesson;
     $classLinks.each(function(index) {
-      $liClass  = $('<li></li>');
-      $h2Title  = $('<a class="title" href="'+$(this).attr('href')+'"><h2>' + $(this).html()+'</h2><span></span></a>');
+      $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>');
@@ -407,18 +390,14 @@
       $lessons = $(this).closest('li').find('ul li a');
 
       if ($lessons.length) {
-        $imgIcon = $('<img src="'+toRoot+'assets/images/resource-tutorial.png" '
-            + ' width="64" height="64" alt=""/>');
         $lessons.each(function(index) {
           $olLessons.append('<li><a href="'+$(this).attr('href')+'">' + $(this).html()+'</a></li>');
         });
       } else {
-        $imgIcon = $('<img src="'+toRoot+'assets/images/resource-article.png" '
-            + ' width="64" height="64" alt=""/>');
         $pSummary.addClass('article');
       }
 
-      $liClass.append($h2Title).append($imgIcon).append($pSummary).append($olLessons);
+      $liClass.append($h2Title).append($pSummary).append($olLessons);
       $olClasses.append($liClass);
     });
     $('.jd-descr').append($olClasses);
@@ -436,23 +415,15 @@
   /* Resize nav height when window height changes */
   $(window).resize(function() {
     if ($('#side-nav').length == 0) return;
-    var stylesheet = $('link[rel="stylesheet"][class="fullscreen"]');
-    setNavBarLeftPos(); // do this even if sidenav isn't fixed because it could become fixed
+    setNavBarDimensions(); // do this even if sidenav isn't fixed because it could become fixed
     // make sidenav behave when resizing the window and side-scolling is a concern
-    if (sticky) {
-      if ((stylesheet.attr("disabled") == "disabled") || stylesheet.length == 0) {
-        updateSideNavPosition();
-      } else {
-        updateSidenavFullscreenWidth();
-      }
-    }
-    resizeNav();
+    updateSideNavDimensions();
+    checkSticky();
+    resizeNav(250);
   });
 
-
-  var navBarLeftPos;
   if ($('#devdoc-nav').length) {
-    setNavBarLeftPos();
+    setNavBarDimensions();
   }
 
 
@@ -495,7 +466,12 @@
   $('h2').click(function() {
     var id = $(this).attr('id');
     if (id) {
-      document.location.hash = id;
+      if (history && history.replaceState) {
+        // Change url without scrolling.
+        history.replaceState({}, '', '#' + id);
+      } else {
+        document.location.hash = id;
+      }
     }
   });
 
@@ -504,15 +480,6 @@
   po.src = 'https://apis.google.com/js/plusone.js';
   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 
-
-  // Revise the sidenav widths to make room for the scrollbar
-  // which avoids the visible width from changing each time the bar appears
-  var $sidenav = $("#side-nav");
-  var sidenav_width = parseInt($sidenav.innerWidth());
-
-  $("#devdoc-nav  #nav").css("width", sidenav_width - 4 + "px"); // 4px is scrollbar width
-
-
   $(".scroll-pane").removeAttr("tabindex"); // get rid of tabindex added by jscroller
 
   if ($(".scroll-pane").length > 1) {
@@ -738,21 +705,28 @@
 
 /** Create the list of breadcrumb links in the sticky header */
 function buildBreadcrumbs() {
-  var $breadcrumbUl =  $("#sticky-header ul.breadcrumb");
+  var $breadcrumbUl =  $(".dac-header-crumbs");
+  var primaryNavLink = ".dac-nav-list > .dac-nav-item > .dac-nav-link";
+
   // Add the secondary horizontal nav item, if provided
-  var $selectedSecondNav = $("div#nav-x ul.nav-x a.selected").clone().removeClass("selected");
+  var $selectedSecondNav = $(".dac-nav-secondary .dac-nav-link.selected").clone()
+    .attr('class', 'dac-header-crumbs-link');
+
   if ($selectedSecondNav.length) {
-    $breadcrumbUl.prepend($("<li>").append($selectedSecondNav))
+    $breadcrumbUl.prepend($('<li class="dac-header-crumbs-item">').append($selectedSecondNav));
   }
+
   // Add the primary horizontal nav
-  var $selectedFirstNav = $("div#header-wrap ul.nav-x a.selected").clone().removeClass("selected");
+  var $selectedFirstNav = $(primaryNavLink + ".selected, " + primaryNavLink + ".has-subnav").clone()
+    .attr('class', 'dac-header-crumbs-link');
+
   // If there's no header nav item, use the logo link and title from alt text
   if ($selectedFirstNav.length < 1) {
-    $selectedFirstNav = $("<a>")
+    $selectedFirstNav = $('<a class="dac-header-crumbs-link">')
         .attr('href', $("div#header .logo a").attr('href'))
         .text($("div#header .logo img").attr('alt'));
   }
-  $breadcrumbUl.prepend($("<li>").append($selectedFirstNav));
+  $breadcrumbUl.prepend($('<li class="dac-header-crumbs-item">').append($selectedFirstNav));
 }
 
 
@@ -809,22 +783,25 @@
     enabled = false;
   }
   writeCookie("fullscreen", enabled, null);
-  setNavBarLeftPos();
+  setNavBarDimensions();
   resizeNav(delay);
-  updateSideNavPosition();
+  updateSideNavDimensions();
   setTimeout(initSidenavHeightResize,delay);
 }
 
-
-function setNavBarLeftPos() {
+// TODO: Refactor into a closure.
+var navBarLeftPos;
+var navBarWidth;
+function setNavBarDimensions() {
   navBarLeftPos = $('#body-content').offset().left;
+  navBarWidth = $('#side-nav').width();
 }
 
 
-function updateSideNavPosition() {
+function updateSideNavDimensions() {
   var newLeft = $(window).scrollLeft() - navBarLeftPos;
-  $('#devdoc-nav').css({left: -newLeft});
-  $('#devdoc-nav .totop').css({left: -(newLeft - parseInt($('#side-nav').css('margin-left')))});
+  $('#devdoc-nav').css({left: -newLeft, width: navBarWidth});
+  $('#devdoc-nav .totop').css({left: -(newLeft - parseInt($('#side-nav').css('padding-left')))});
 }
 
 // TODO: use $(document).ready instead
@@ -858,7 +835,7 @@
 
 
 
-/* ######### RESIZE THE SIDENAV HEIGHT ########## */
+/* ######### RESIZE THE SIDENAV ########## */
 
 function resizeNav(delay) {
   var $nav = $("#devdoc-nav");
@@ -874,7 +851,7 @@
 
   // get the height of space between nav and top of window.
   // Could be either margin or top position, depending on whether the nav is fixed.
-  var topMargin = (parseInt($nav.css('margin-top')) || parseInt($nav.css('top'))) + 1;
+  var topMargin = (parseInt($nav.css('top')) || 20) + 1;
   // add 1 for the #side-nav bottom margin
 
   // Depending on whether the header is visible, set the side nav's height.
@@ -889,7 +866,9 @@
 
 
   $scrollPanes = $(".scroll-pane");
-  if ($scrollPanes.length > 1) {
+  if ($window.width() < 720) {
+    $nav.css('height', '');
+  } else if ($scrollPanes.length > 1) {
     // subtract the height of the api level widget and nav swapper from the available nav height
     navHeight -= ($('#api-nav-header').outerHeight(true) + $('#nav-swap').outerHeight(true));
 
@@ -957,7 +936,7 @@
 function reInitScrollbars() {
   var pane = $(".scroll-pane").each(function(){
     var api = $(this).data('jsp');
-    if (!api) { setTimeout(reInitScrollbars,300); return;}
+    if (!api) {return;}
     api.reinitialise( {verticalGutter:0} );
   });
   $(".scroll-pane").removeAttr("tabindex"); // get rid of tabindex added by jscroller
@@ -993,6 +972,7 @@
 /** Scroll the jScrollPane to make the currently selected item visible
     This is called when the page finished loading. */
 function scrollIntoView(nav) {
+  return;
   var $nav = $("#"+nav);
   var element = $nav.jScrollPane({/* ...settings... */});
   var api = element.data('jsp');
@@ -1068,39 +1048,45 @@
 /* Sets the vertical scoll position at which the sticky bar should appear.
    This method is called to reset the position when search results appear or hide */
 function setStickyTop() {
-  stickyTop = $('#header-wrapper').outerHeight() - $('#sticky-header').outerHeight();
+  stickyTop = $('#header-wrapper').outerHeight() - $('#header > .dac-header-inner').outerHeight();
 }
 
 /*
  * Displays sticky nav bar on pages when dac header scrolls out of view
  */
 $(window).scroll(function(event) {
-
-  setStickyTop();
-  var hiding = false;
-  var $stickyEl = $('#sticky-header');
-  var $menuEl = $('.menu-container');
-  // Exit if there's no sidenav
-  if ($('#side-nav').length == 0) return;
   // Exit if the mouse target is a DIV, because that means the event is coming
   // from a scrollable div and so there's no need to make adjustments to our layout
   if ($(event.target).nodeName == "DIV") {
     return;
   }
 
+  checkSticky();
+});
+
+function checkSticky() {
+  setStickyTop();
+  var $headerEl = $('#header');
+  // Exit if there's no sidenav
+  if ($('#side-nav').length == 0) return;
+
   var top = $(window).scrollTop();
   // we set the navbar fixed when the scroll position is beyond the height of the site header...
-  var shouldBeSticky = top >= stickyTop;
+  var shouldBeSticky = top > stickyTop;
   // ... except if the document content is shorter than the sidenav height.
   // (this is necessary to avoid crazy behavior on OSX Lion due to overscroll bouncing)
   if ($("#doc-col").height() < $("#side-nav").height()) {
     shouldBeSticky = false;
   }
+  // Nor on mobile
+  if (window.innerWidth < 720) {
+    shouldBeSticky = false;
+  }
   // Account for horizontal scroll
   var scrollLeft = $(window).scrollLeft();
   // When the sidenav is fixed and user scrolls horizontally, reposition the sidenav to match
   if (sticky && (scrollLeft != prevScrollLeft)) {
-    updateSideNavPosition();
+    updateSideNavDimensions();
     prevScrollLeft = scrollLeft;
   }
 
@@ -1113,41 +1099,29 @@
   // If sticky header visible and position is now near top, hide sticky
   if (sticky && !shouldBeSticky) {
     sticky = false;
-    hiding = true;
     // make the sidenav static again
     $('#devdoc-nav')
-        .removeClass('fixed')
-        .css({'width':'auto','margin':''})
-        .prependTo('#side-nav');
+      .removeClass('fixed')
+      .css({'width':'auto','margin':''});
     // delay hide the sticky
-    $menuEl.removeClass('sticky-menu');
-    $stickyEl.fadeOut(250);
-    hiding = false;
+    $headerEl.removeClass('is-sticky');
 
     // update the sidenaav position for side scrolling
-    updateSideNavPosition();
+    updateSideNavDimensions();
   } else if (!sticky && shouldBeSticky) {
     sticky = true;
-    $stickyEl.fadeIn(10);
-    $menuEl.addClass('sticky-menu');
+    $headerEl.addClass('is-sticky');
 
     // make the sidenav fixed
-    var width = $('#devdoc-nav').width();
     $('#devdoc-nav')
-        .addClass('fixed')
-        .css({'width':width+'px'})
-        .prependTo('#body-content');
+      .addClass('fixed');
 
     // update the sidenaav position for side scrolling
-    updateSideNavPosition();
+    updateSideNavDimensions();
 
-  } else if (hiding && top < 15) {
-    $menuEl.removeClass('sticky-menu');
-    $stickyEl.hide();
-    hiding = false;
   }
   resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance
-});
+}
 
 /*
  * Manages secion card states and nav resize to conclude loading
@@ -1352,13 +1326,13 @@
 
 
 function changeNavLang(lang) {
-  var $links = $("#devdoc-nav,#header,#nav-x,.training-nav-top,.content-footer").find("a["+lang+"-lang]");
-  $links.each(function(i){ // for each link with a translation
+  if (lang === 'en') { return; }
+
+  var $links = $('a[' + lang + '-lang]');
+  $links.each(function(){ // for each link with a translation
     var $link = $(this);
-    if (lang != "en") { // No need to worry about English, because a language change invokes new request
-      // put the desired language from the attribute as the text
-      $link.text($link.attr(lang+"-lang"))
-    }
+    // put the desired language from the attribute as the text
+    $link.text($link.attr(lang + '-lang'))
   });
 }
 
@@ -1841,12 +1815,11 @@
     // if there are api results
     if ((gMatches.length > 0) || (gGoogleMatches.length > 0)) {
       // reveal suggestion list
-      $('.suggest-card.dummy').show();
       $('.suggest-card.reference').show();
       var listIndex = 0; // list index position
 
       // reset the lists
-      $(".search_filtered_wrapper.reference li").remove();
+      $(".suggest-card.reference li").remove();
 
       // ########### ANDROID RESULTS #############
       if (gMatches.length > 0) {
@@ -1876,13 +1849,12 @@
       }
     } else {
       $('.suggest-card.reference').hide();
-      $('.suggest-card.dummy').hide();
     }
 
     // ########### JD DOC RESULTS #############
     if (gDocsMatches.length > 0) {
         // reset the lists
-        $(".search_filtered_wrapper.docs li").remove();
+        $(".suggest-card:not(.reference) li").remove();
 
         // determine google results to show
         // NOTE: The order of the conditions below for the sugg.type MUST BE SPECIFIC:
@@ -1947,7 +1919,7 @@
         }
 
     } else {
-      $('.search_filtered_wrapper.docs .suggest-card:not(.dummy)').hide(300);
+      $('.suggest-card:not(.reference)').hide(300);
     }
 }
 
@@ -1971,14 +1943,14 @@
 
     // show/hide the close button
     if (text != '') {
-        $(".search .close").removeClass("hide");
+        $("#search-close").removeClass("hide");
     } else {
-        $(".search .close").addClass("hide");
+        $("#search-close").addClass("hide");
     }
     // 27 = esc
     if (e.keyCode == 27) {
         // close all search results
-        if (kd) $('.search .close').trigger('click');
+        if (kd) $('#search-close').trigger('click');
         return true;
     }
     // 13 = enter
@@ -2129,9 +2101,8 @@
 
         // Search for matching JD docs
         if (text.length >= 2) {
-          // Regex to match only the beginning of a word
-          var textRegex = new RegExp("\\b" + text.toLowerCase(), "g");
-
+          // match only the beginning of a word
+          var queryStr = text.toLowerCase();
 
           // Search for Training classes
           for (var i=0; i<TRAINING_RESOURCES.length; i++) {
@@ -2145,7 +2116,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2155,7 +2126,7 @@
             if ((s.lang == currentLang) &&
                   (!(s.type == "training" && s.url.indexOf("index.html") == -1) || matched)) {
               // it matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2179,7 +2150,8 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
+
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2187,7 +2159,7 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2211,7 +2183,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+                if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2219,7 +2191,7 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+                if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2243,7 +2215,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2251,7 +2223,7 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2275,7 +2247,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2283,7 +2255,7 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2307,7 +2279,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2315,7 +2287,7 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2339,7 +2311,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2347,7 +2319,7 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2370,7 +2342,7 @@
             // Check if query matches any tags; work backwards toward 1 to assist ranking
             for (var j = s.keywords.length - 1; j >= 0; j--) {
               // it matches a tag
-              if (s.keywords[j].toLowerCase().match(textRegex)) {
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_tag = j + 1; // add 1 to index position
               }
@@ -2378,7 +2350,38 @@
             // Check if query matches the doc title, but only for current language
             if (s.lang == currentLang) {
               // if query matches the doc title.t
-              if (s.title.toLowerCase().match(textRegex)) {
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
+                matched = true;
+                s.matched_title = 1;
+              }
+            }
+            if (matched) {
+              gDocsMatches[matchedCountDocs] = s;
+              matchedCountDocs++;
+            }
+          }
+
+          // Search for Preview Guides
+          for (var i=0; i<PREVIEW_RESOURCES.length; i++) {
+            // current search comparison, with counters for tag and title,
+            // used later to improve ranking
+            var s = PREVIEW_RESOURCES[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
+            for (var j = s.keywords.length - 1; j >= 0; j--) {
+              // it matches a tag
+              if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) {
+                matched = true;
+                s.matched_tag = j + 1; // add 1 to index position
+              }
+            }
+            // Check if query matches the doc title, but only for current language
+            if (s.lang == currentLang) {
+              // if query matches the doc title
+              if (s.title.toLowerCase().indexOf(queryStr) == 0) {
                 matched = true;
                 s.matched_title = 1;
               }
@@ -2536,7 +2539,7 @@
 {
     if (!focused) {
         if(obj.value == ""){
-          $(".search .close").addClass("hide");
+          $("#search-close").addClass("hide");
         }
         $(".suggest-card").hide();
     }
@@ -2553,7 +2556,7 @@
 
 function hideResults() {
   $("#searchResults").slideUp('fast', setStickyTop);
-  $(".search .close").addClass("hide");
+  $("#search-close").addClass("hide");
   location.hash = '';
 
   $("#search_autocomplete").val("").blur();
@@ -2670,7 +2673,7 @@
   } else {
     // first time loading search results for this page
     $('#searchResults').slideDown('slow', setStickyTop);
-    $(".search .close").removeClass("hide");
+    $("#search-close").removeClass("hide");
     loadSearchResults();
   }
 }, true);
@@ -2714,7 +2717,7 @@
   searchControl.execute(query);
   $('#searchResults').slideDown('slow', setStickyTop);
   $("#search_autocomplete").focus();
-  $(".search .close").removeClass("hide");
+  $("#search-close").removeClass("hide");
 
   updateResultTitle(query);
 });
@@ -3146,6 +3149,10 @@
   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");
@@ -3536,6 +3543,10 @@
   var addedPageResources = {};
 
   $(document).ready(function() {
+    // Need to initialize hero carousel before other sections for dedupe
+    // to work correctly.
+    $('[data-carousel-query]').dacCarouselQuery();
+
     $('.resource-widget').each(function() {
       initResourceWidget(this);
     });
@@ -3545,8 +3556,8 @@
     showing lines that are cut off. This works with the css ellipsis
     classes to fade last text line and apply an ellipsis char. */
 
-    //card text currently uses 15px line height.
-    var lineHeight = 15;
+    //card text currently uses 20px line height.
+    var lineHeight = 20;
     $('.card-info .text').ellipsisfade(lineHeight);
   });
 
@@ -3562,21 +3573,20 @@
         isCarousel = $widget.hasClass('resource-carousel-layout'),
         isStack = $widget.hasClass('resource-stack-layout');
 
-    // find size of widget by pulling out its class name
-    var sizeCols = 1;
+    // remove illegal col-x class which is not relevant anymore thanks to responsive styles.
     var m = $widget.get(0).className.match(/\bcol-(\d+)\b/);
-    if (m) {
-      sizeCols = parseInt(m[1], 10);
+    if (m && !$widget.is('.cols > *')) {
+      $widget.removeClass('col-' + m[1]);
     }
 
     var opts = {
       cardSizes: ($widget.data('cardsizes') || '').split(','),
       maxResults: parseInt($widget.data('maxresults') || '100', 10),
+      initialResults: $widget.data('initialResults'),
       itemsPerPage: $widget.data('itemsperpage'),
       sortOrder: $widget.data('sortorder'),
       query: $widget.data('query'),
       section: $widget.data('section'),
-      sizeCols: sizeCols,
       /* Added by LFL 6/6/14 */
       resourceStyle: $widget.data('resourcestyle') || 'card',
       stackSort: $widget.data('stacksort') || 'true'
@@ -3604,7 +3614,7 @@
   /* Initializes a Resource Carousel Widget */
   function drawResourcesCarouselWidget($widget, opts, resources) {
     $widget.empty();
-    var plusone = true; //always show plusone on carousel
+    var plusone = false; // stop showing plusone buttons on cards
 
     $widget.addClass('resource-card slideshow-container')
       .append($('<a>').addClass('slideshow-prev').text('Prev'))
@@ -3642,7 +3652,7 @@
   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 = true; //by default show plusone on section cards
+    var plusone = false; // stop showing plusone buttons on cards
     var cards = $widget.find('.resource-card').detach().toArray();
     var numStacks = opts.numStacks || 1;
     var $stacks = [];
@@ -3737,22 +3747,49 @@
 
     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) {
-    $widget.empty();
+    $widget.empty().addClass('cols');
     var cardSizes = opts.cardSizes || ['6x6'];
+    var initialResults = opts.initialResults || resources.length;
     var i = 0, j = 0;
-    var plusone = true; // by default show plusone on resource cards
+    var plusone = false; // stop showing plusone buttons on cards
+    var cardParent = $widget;
 
     while (i < resources.length) {
+
+      if (i === initialResults && initialResults < resources.length) {
+        // Toggle remaining cards
+        cardParent = $('<div class="dac-toggle-content clearfix">').appendTo($widget);
+        $widget.addClass('dac-toggle');
+        $('<div class="col-1of1 dac-section-links dac-text-center">')
+          .append(
+            $('<div class="dac-section-link" data-toggle="section">')
+              .append('<span class="dac-toggle-expand">More<i class="dac-sprite dac-auto-unfold-more"></i></span>')
+              .append('<span class="dac-toggle-collapse">Less<i class="dac-sprite dac-auto-unfold-less"></i></span>')
+          )
+          .appendTo($widget)
+      }
+
       var cardSize = cardSizes[j++ % cardSizes.length];
       cardSize = cardSize.replace(/^\s+|\s+$/,'');
-      // Some card sizes do not get a plusone button, such as where space is constrained
-      // or for cards commonly embedded in docs (to improve overall page speed).
-      plusone = !((cardSize == "6x2") || (cardSize == "6x3") ||
-                  (cardSize == "9x2") || (cardSize == "9x3") ||
-                  (cardSize == "12x2") || (cardSize == "12x3"));
+      
+      var column = createResponsiveFlowColumn(cardSize).appendTo(cardParent);
 
       // A stack has a third dimension which is the number of stacked items
       var isStack = cardSize.match(/(\d+)x(\d+)x(\d+)/);
@@ -3763,7 +3800,7 @@
         // 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($widget);
+            + 'x' + isStack[2] * isStack[3]) .appendTo(column);
       }
 
       // Build each stack item or just a single item
@@ -3785,7 +3822,7 @@
           stackCount = 0;
         }
 
-        $card.appendTo($stackDiv || $widget);
+        $card.appendTo($stackDiv || column);
 
       } while (++i < resources.length && stackCount > 0);
     }
@@ -3800,6 +3837,10 @@
   }
 
   function buildResourceList(opts) {
+    return $.queryResources(opts);
+  }
+
+  $.queryResources = function(opts) {
     var maxResults = opts.maxResults || 100;
 
     var query = opts.query || '';
@@ -3848,8 +3889,9 @@
 
       // add to list of already added indices
       for (var j = 0; j < resources.length; j++) {
-        // console.log(resources[j].title);
-        addedResourceIndices[resources[j].index] = 1;
+        if (resources[j]) {
+          addedResourceIndices[resources[j].index] = 1;
+        }
       }
 
       // concat to final results list
@@ -3891,7 +3933,7 @@
 
   function getResourceNotAlreadyAddedFilter(addedResourceIndices) {
     return function(resource) {
-      return !addedResourceIndices[resource.index];
+      return resource && !addedResourceIndices[resource.index];
     };
   }
 
@@ -4020,6 +4062,12 @@
       imgUrl = toRoot + imgUrl;
     }
 
+    if (resource.type === 'youtube') {
+      $('<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') + ')')
@@ -4155,7 +4203,7 @@
             $this.parent().siblings().each(function ()
             {
               if ($(this).is(":visible")) {
-                var h = $(this).height();
+                var h = $(this).outerHeight(true);
                 remainingHeight = remainingHeight - h;
               }
             });
@@ -4354,3 +4402,895 @@
     }
   }
 })();
+
+/**
+ * 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({marginBottom: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 = $hr.nextUntil('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();
+      $contents.wrapAll('<div class="dac-toggle-content"><div>'); // extra div used for max-height calculation.
+
+      // 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);
+    });
+  }
+
+  $(function() {
+    initWidget();
+  });
+})(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);
+
+/* global toRoot, CAROUSEL_OVERRIDE */
+(function($) {
+  // Ordering matters
+  var TAG_MAP = [
+    {from: 'developerstory', to: 'Android Developer Story'},
+    {from: 'googleplay', to: 'Google Play'}
+  ];
+
+  function DacCarouselQuery(el) {
+    this.el = $(el);
+
+    var opts = this.el.data();
+    opts.maxResults = parseInt(opts.maxResults || '100', 10);
+    opts.query = opts.carouselQuery;
+    var resources = $.queryResources(opts);
+
+    this.el.empty();
+    $(resources).map(function() {
+      var resource = $.extend({}, this, CAROUSEL_OVERRIDE[this.url]);
+      var slide = $('<article class="dac-expand dac-hero">');
+      var image = cleanUrl(resource.heroImage || resource.image);
+      var fullBleed = image && !resource.heroColor;
+
+      // 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 && 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());
+      return slide[0];
+    }).prependTo(this.el);
+
+    // Pagination element.
+    this.el.append('<div class="dac-hero-carousel-pagination"><div class="wrap" data-carousel-pagination>');
+
+    this.el.dacCarousel();
+  }
+
+  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.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);
+
+(function($) {
+  'use strict';
+
+  function Modal(el, options) {
+    this.el = $(el);
+    this.options = $.extend({}, ToggleModal.DEFAULTS_, options);
+    this.isOpen = false;
+
+    this.el.on('click', function(event) {
+      if (!$.contains($('.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() {
+    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 ToggleModal(el, options) {
+    this.el = $(el);
+    this.options = $.extend({}, ToggleModal.DEFAULTS_, options);
+    this.modal = this.options.modalToggle ? $('[data-modal="' + this.options.modalToggle + '"]') :
+      this.el.closest('[data-modal]');
+
+    this.el.on('click', this.clickHandler_.bind(this));
+  }
+
+  ToggleModal.prototype.clickHandler_ = function(event) {
+    event.preventDefault();
+    this.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());
+    });
+
+    $('[data-modal-toggle]').each(function() {
+      $(this).dacToggleModal($(this).data());
+    });
+  });
+})(jQuery);
+
+(function($) {
+  'use strict';
+
+  /**
+   * Toggle the visabilty of the mobile navigation.
+   * @param {HTMLElement} el - The DOM element.
+   * @param options
+   * @constructor
+   */
+  function ToggleNav(el, options) {
+    this.el = $(el);
+    this.options = $.extend({}, ToggleNav.DEFAULTS_, options);
+    this.options.target = [this.options.navigation];
+
+    if (this.options.body) {this.options.target.push('body')}
+    if (this.options.dimmer) {this.options.target.push(this.options.dimmer)}
+
+    this.el.on('click', this.clickHandler_.bind(this));
+  }
+
+  /**
+   * ToggleNav Default Settings
+   * @type {{body: boolean, dimmer: string, navigation: string, toggleClass: string}}
+   * @private
+   */
+  ToggleNav.DEFAULTS_ = {
+    body: true,
+    dimmer: '.dac-nav-dimmer',
+    navigation: '[data-dac-nav]',
+    toggleClass: 'dac-nav-open'
+  };
+
+  /**
+   * The actual toggle logic.
+   * @param event
+   * @private
+   */
+  ToggleNav.prototype.clickHandler_ = function(event) {
+    event.preventDefault();
+    $(this.options.target.join(', ')).toggleClass(this.options.toggleClass);
+  };
+
+  /**
+   * jQuery plugin
+   * @param  {object} options - Override default options.
+   */
+  $.fn.dacToggleMobileNav = function(options) {
+    return this.each(function() {
+      new ToggleNav(this, options);
+    });
+  };
+
+  /**
+   * Data Attribute API
+   */
+  $(window).on('load.aranja', function() {
+    $('[data-dac-toggle-nav]').each(function() {
+      $(this).dacToggleMobileNav($(this).data());
+    });
+  });
+})(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.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);
+
+(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: 0,
+    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();
+
+    $(this.options.scrollContainer).animate({
+      scrollTop: this.target.offset().top - this.options.offset
+    }, this.options);
+  };
+
+  /**
+   * 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);
+
+(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.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));
+  }
+
+  /**
+   * SwapContent's default settings.
+   * @type {{activeClass: string, container: string, transitionSpeed: number}}
+   * @private
+   */
+  SwapContent.DEFAULTS_ = {
+    activeClass: 'dac-active',
+    container: '[data-swap-container]',
+    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() {
+    console.log(this.containers);
+    this.containers.each(function(index, container) {
+      container = $(container);
+      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);
+
+(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('maxHeight', contentHeight + 'px')
+        .resolveStyles();
+    }
+
+    // Transition to new state
+    $el.css('maxHeight', targetHeight);
+
+    // Reset maxHeight to css value after transition.
+    setTimeout(function() {
+      $el.css('maxHeight', '');
+    }, 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);
diff --git a/tools/droiddoc/templates-sdk/class.cs b/tools/droiddoc/templates-sdk/class.cs
index 693eaed..44eae97 100644
--- a/tools/droiddoc/templates-sdk/class.cs
+++ b/tools/droiddoc/templates-sdk/class.cs
@@ -169,15 +169,13 @@
 
 <div class="jd-descr">
 <?cs call:deprecated_warning(class) ?>
-<?cs if:subcount(class.descr) || subcount(class.annotationdocumentation) ?>
+<?cs if:subcount(class.descr) ?>
 <h2>Class Overview</h2>
-<?cs if:subcount(class.descr) ?><p itemprop="articleBody"><?cs call:tag_list(class.descr) ?></p><?cs /if ?>
-<?cs if:subcount(class.annotationdocumentation) ?><?cs each:annodoc = class.annotationdocumentation?>
-<p><?cs var:annodoc.text ?></p>
-<?cs /each?><?cs /if?>
+<p itemprop="articleBody"><?cs call:tag_list(class.descr) ?></p>
 <?cs /if ?>
 
 <?cs call:see_also_tags(class.seeAlso) ?>
+
 </div><!-- jd-descr -->
 
 
@@ -198,12 +196,12 @@
         </td>
         <td class="jd-linkcol" width="100%"><nobr>
         <span class="sympad"><?cs call:cond_link(method.name, toroot, method.href, included) ?></span>(<?cs call:parameter_list(method.params) ?>)</nobr>
-        <?cs if:subcount(method.shortDescr) || subcount(method.deprecated) || subcount(method.showAnnotations) ?>
-          <div class="jd-descrdiv">
-            <?cs if:subcount(method.shortDescr) || subcount(method.annotationdocumentation) ?><?cs call:short_descr(method)?><?cs /if?>
-            <?cs call:show_annotations_list(method) ?>
-          </div>
-        <?cs /if ?>
+        <?cs if:subcount(method.shortDescr) || subcount(method.deprecated) ?>
+        <div class="jd-descrdiv">
+          <?cs call:short_descr(method) ?>
+          <?cs call:show_annotations_list(method) ?>
+        </div>
+  <?cs /if ?>
   </td></tr>
 <?cs set:count = count + #1 ?>
 <?cs /each ?>
@@ -669,10 +667,9 @@
 <?cs # the next two lines must be exactly like this to be parsed by eclipse ?>
 <!-- ========= END OF CLASS DATA ========= -->
 <A NAME="navbar_top"></A>
-
-<?cs include:"footer.cs" ?>
 </div> <!-- jd-content -->
 
+<?cs include:"footer.cs" ?>
 </div><!-- end doc-content -->
 
 <?cs include:"trailer.cs" ?>
diff --git a/tools/droiddoc/templates-sdk/classes.cs b/tools/droiddoc/templates-sdk/classes.cs
index 405892d..32966a0 100644
--- a/tools/droiddoc/templates-sdk/classes.cs
+++ b/tools/droiddoc/templates-sdk/classes.cs
@@ -43,11 +43,12 @@
 </table>
 <?cs /each ?>
 
-<?cs include:"footer.cs" ?>
 </div><!-- end jd-content -->
+
+<?cs include:"footer.cs" ?>
 </div><!-- end doc-content -->
 
 <?cs include:"trailer.cs" ?>
 
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs
index c09dc02..838ddbe 100644
--- a/tools/droiddoc/templates-sdk/components/masthead.cs
+++ b/tools/droiddoc/templates-sdk/components/masthead.cs
@@ -1,10 +1,7 @@
 <?cs def:custom_masthead() ?>
-<?cs if:preview ?>
-  <?cs call:preview_masthead() ?>
-<?cs else ?>
 <a name="top"></a>
 
-<!-- dialog to prompt lang pref change when loaded from hardcoded URL 
+<!-- dialog to prompt lang pref change when loaded from hardcoded URL
 <div id="langMessage" style="display:none">
   <div>
     <div class="lang en">
@@ -52,254 +49,47 @@
 <?cs if:!devsite ?><?cs # leave out the global header for devsite; it is in devsite template ?>
   <!-- Header -->
   <div id="header-wrapper">
-    <div id="header"><?cs call:butter_bar() ?>
-      <div class="wrap" id="header-wrap">
-        <div class="col-3 logo">
-          <a href="<?cs var:toroot ?>index.html">
-            <img src="<?cs var:toroot ?>assets/images/dac_logo.png"
-                srcset="<?cs var:toroot ?>assets/images/dac_logo@2x.png 2x"
-                width="123" height="25" alt="Android Developers" />
-          </a>
-          <div class="btn-quicknav" id="btn-quicknav">
-            <a href="#" class="arrow-inactive">Quicknav</a>
-            <a href="#" class="arrow-active">Quicknav</a>
-          </div>
-        </div>
-        <ul class="nav-x col-9">
-            <li class="design">
-              <a 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="develop"><a 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 class="distribute last"><a 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></li>
+    <div class="dac-header" id="header"><?cs call:butter_bar() ?>
+      <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" href="<?cs var:toroot ?>ndk/index.html">
+          <img class="dac-header-logo-image" src="<?cs var:toroot ?>assets/images/android_logo_ndk.png"
+              srcset="<?cs var:toroot ?>assets/images/android_logo_ndk@2x.png 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/android_logo@2x.png 2x"
+              width="32" height="36" alt="Android" /> Developers
+          </a><?cs /if ?>
+
+        <ul class="dac-header-crumbs">
+          <?cs # More <li> elements added here with javascript ?>
+          <?cs if:!section.landing ?><li class="dac-header-crumbs-item"><span class="dac-header-crumbs-link current <?cs
+            if:ndk ?>ndk<?cs /if ?>"><?cs var:page.title ?></a></li><?cs
+          /if ?>
         </ul>
 
-
         <?cs # ADD SEARCH AND MENU ?>
+        <?cs if:!ndk ?>
         <?cs call:header_search_widget() ?>
-
-
-        <!-- Expanded quicknav -->
-        <div id="quicknav" class="col-13">
-          <ul>
-            <li class="about">
-              <ul>
-                <li><a href="<?cs var:toroot ?>about/index.html">About</a></li>
-                <li><a href="<?cs var:toroot ?>wear/index.html">Wear</a></li>
-                <li><a href="<?cs var:toroot ?>tv/index.html">TV</a></li>
-                <li><a href="<?cs var:toroot ?>auto/index.html">Auto</a></li>
-              </ul>
-            </li>
-            <li class="design">
-              <ul>
-                <li><a href="<?cs var:toroot ?>design/index.html">Get Started</a></li>
-                <li><a href="<?cs var:toroot ?>design/devices.html">Devices</a></li>
-                <li><a href="<?cs var:toroot ?>design/style/index.html">Style</a></li>
-                <li><a href="<?cs var:toroot ?>design/patterns/index.html">Patterns</a></li>
-                <li><a href="<?cs var:toroot ?>design/building-blocks/index.html">Building Blocks</a></li>
-                <li><a href="<?cs var:toroot ?>design/downloads/index.html">Downloads</a></li>
-                <li><a href="<?cs var:toroot ?>design/videos/index.html">Videos</a></li>
-              </ul>
-            </li>
-            <li class="develop">
-              <ul>
-                <li><a 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><a 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><a 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><a 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><a href="<?cs var:toroot ?>google/index.html">Google Services</a>
-                </li>
-                <?cs if:android.hasSamples ?>
-                  <li><a href="<?cs var:toroot ?>samples/index.html">Samples</a>
-                  </li>
-                <?cs /if ?>
-              </ul>
-            </li>
-            <li class="distribute last">
-              <ul>
-                <li><a href="<?cs var:toroot ?>distribute/googleplay/index.html">Google Play</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/essentials/index.html">Essentials</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/users/index.html">Get Users</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/engage/index.html">Engage &amp; Retain</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/monetize/index.html">Monetize</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/analyze/index.html">Analyze</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/tools/index.html">Tools &amp; Reference</a></li>
-                <li><a href="<?cs var:toroot ?>distribute/stories/index.html">Developer Stories</a></li>
-              </ul>
-            </li>
-          </ul>
-        </div><!-- /Expanded quicknav -->
-      </div><!-- end header-wrap.wrap -->
-    </div><!-- end header -->
-
-  <?cs if:about || wear || tv || auto ?>
-    <!-- Secondary x-nav -->
-    <div id="nav-x">
-        <div class="wrap">
-            <ul class="nav-x col-9 about" style="width:100%">
-                <li class="about"><a href="<?cs var:toroot ?>about/index.html"
-                  >About</a></li>
-                <li class="wear"><a href="<?cs var:toroot ?>wear/index.html"
-                  >Wear</a></li>
-                <li class="tv"><a href="<?cs var:toroot ?>tv/index.html"
-                  >TV</a></li>
-                <li class="auto"><a href="<?cs var:toroot ?>auto/index.html"
-                  >Auto</a></li>
-            </ul>
-        </div>
-    </div>
-    <!-- /Sendondary x-nav ABOUT -->
-
-
-
-  <?cs elif:training || guide || reference || tools || develop || google || samples ?>
-    <!-- Secondary x-nav -->
-    <div id="nav-x">
-        <div class="wrap" style="position:relative;z-index:1">
-
-        <?cs if:reference ?>
-        <?cs # HIDE HELPOUTS RECRUIT BANNER
-            <a id="helpoutsLink" class="resource resource-card resource-card-6x2x3 resource-card-6x2 helpouts-card" 
-              href="http://helpouts.google.com/partner/landing/provider/googledevelopers?utm_source=dac&utm_medium=banner&utm_campaign=android_provider_banner3" target="_blank">
-              <div class="card-bg helpouts-card-bg"></div>
-              <div class="card-info">
-                <div class="helpouts-description">
-                  <div class="text">Help Android Wear and TV developers<br/>
-                    <span id="helpoutsLinkText" class="link-color" 
-                    style="display:block;padding-top:5px;text-align:right">Learn more</span>
-                  </div>
-                </div>
-              </div>
-            </a>
-        # END HIDE HELPOUTS ?>
         <?cs /if ?>
 
-            <ul class="nav-x col-9 develop" style="width:100%">
-                <li class="training"><a 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="guide"><a 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="reference"><a 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="tools"><a 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="google"><a href="<?cs var:toroot ?>google/index.html"
-                  >Google Services</a>
-                </li>
-                <?cs if:android.hasSamples ?>
-                  <li class="samples"><a href="<?cs var:toroot ?>samples/index.html"
-                    >Samples</a>
-                  </li>
-                <?cs /if ?>
-            </ul>
-        </div>
-    </div>
-    <!-- /Sendondary x-nav DEVELOP -->
+        <?cs if:ndk ?><a class="dac-header-console-btn" href="http://developer.android.com">
+          <span class="dac-visible-desktop-inline">Back to Android Developers</span>
+        </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 elif:distribute || googleplay || essentials || users || engage || monetize || analyze ||  disttools || stories ?>
-    <!-- Secondary distribute x-nav -->
-    <div id="nav-x">
-        <div class="wrap">
-            <ul class="nav-x distribute">
-                <li class="googleplay"><a href="<?cs var:toroot ?>distribute/googleplay/index.html"
-                  >Google Play</a></li>
-                <li class="essentials"><a href="<?cs var:toroot ?>distribute/essentials/index.html"
-                  >Essentials</a></li>
-                <li class="users"><a href="<?cs var:toroot ?>distribute/users/index.html"
-                  >Get Users</a></li>
-                <li class="engage"><a href="<?cs var:toroot ?>distribute/engage/index.html"
-                  >Engage &amp; Retain</a></li>
-                <li class="monetize"><a href="<?cs var:toroot ?>distribute/monetize/index.html"
-                  >Monetize</a>
-                </li>
-                <li class="analyze"><a href="<?cs var:toroot ?>distribute/analyze/index.html"
-                  >Analyze</a>
-                </li>
-                <li class="disttools"><a href="<?cs var:toroot ?>distribute/tools/index.html"
-                  >Tools</a>
-                </li>
-                <li class="stories"><a href="<?cs var:toroot ?>distribute/stories/index.html"
-                  >Stories</a>
-                </li>
-            </ul>
-            <a href="https://play.google.com/apps/publish/" class="developer-console-btn">Developer Console</a>
-        </div> <!-- /Secondary distribute x-nav -->
-    </div>
-    <!-- /Sendondary x-nav DISTRIBUTE -->
-  <?cs /if ?>
+      </div><!-- end header-wrap.wrap -->
+    </div><!-- end header -->
 
     <div id="searchResults" class="wrap" style="display:none;">
       <h2 id="searchTitle">Results</h2>
@@ -307,66 +97,180 @@
     </div>
   </div> <!--end header-wrapper -->
 
-  <div id="sticky-header">
-    <div>
-      <a class="logo" href="#top"></a>
-      <a class="top" href="#top"></a>
-      <ul class="breadcrumb">
-        <?cs # More <li> elements added here with javascript ?>
-        <?cs if:!section.landing ?><li class="current"><?cs var:page.title ?></li><?cs
-        /if ?>
-      </ul>
-    </div>
-  </div>
+  <?cs if:ndk ?>
+  <!-- NDK Navigation-->
+  <nav class="dac-nav">
+    <div class="dac-nav-dimmer" data-dac-toggle-nav></div>
 
-<?cs /if ?><?cs # end if/else !devsite ?>
-<?cs /if ?><?cs # end if/else preview ?><?cs
-/def ?>
-
-<?cs def:preview_masthead() ?>
-<a name="top"></a>
-
-
-<!-- Header -->
-<div id="header-wrapper">
-  <div id="header"><?cs call:butter_bar() ?>
-    <div class="wrap" id="header-wrap">
-      <div class="col_3 logo landing-logo" style="width:240px">
-        <a href="<?cs var:toroot ?>preview/index.html">
-          <img src="<?cs var:toroot ?>assets/images/android.png" height="25" alt="Android"
-            style="margin:-3px 0 0" />
+    <ul class="dac-nav-list" data-dac-nav>
+      <li class="dac-nav-item dac-nav-head">
+        <a class="dac-nav-link dac-nav-logo" data-dac-toggle-nav href="javascript:;" title="Close navigation">
+          <img class="dac-logo-image" src="<?cs var:toroot ?>assets/images/android_logo_ndk.png"
+               srcset="<?cs var:toroot ?>assets/images/android_logo_ndk@2x.png 2x"
+               width="32" height="36" alt="Android" /> NDK
         </a>
-      </div>
-      <div class="col-8" style="margin:0"><h1 style="margin: 4px 0 0 0px;padding:0;line-height:16px;
-color:#666;font-weight:100;font-size:27px;">L Developer Preview</h1></div>
-
-      <?cs # ADD SEARCH AND MENU ?>
-      <?cs call:header_search_widget() ?>
-
-    </div><!-- end header-wrap -->
-  </div><!-- /Header -->
-
-
-  <div id="searchResults" class="wrap" style="display:none;">
-          <h2 id="searchTitle">Results</h2>
-          <div id="leftSearchControl" class="search-control">Loading...</div>
-  </div>
-</div> <!--end header-wrapper -->
-
-<div id="sticky-header">
-  <div>
-    <a class="logo" href="#top"></a>
-    <a class="top" href="#top"></a>
-    <ul class="breadcrumb">
-      <?cs # More <li> elements added here with javascript ?>
-      <?cs if:!section.landing ?><li class="current"><?cs var:page.title ?></li><?cs
-      /if ?>
+      </li>
+      <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>
 
-  <?cs
-/def ?>
+    <ul class="dac-nav-list" data-dac-nav>
+      <li class="dac-nav-item dac-nav-head">
+        <a class="dac-nav-link dac-nav-logo" data-dac-toggle-nav href="javascript:;" title="Close navigation">
+          <img class="dac-logo-image" src="<?cs var:toroot ?>assets/images/android_logo.png"
+               srcset="<?cs var:toroot ?>assets/images/android_logo@2x.png 2x"
+               width="32" height="36" alt="Android" /> Developers
+        </a>
+      </li>
+      <li class="dac-nav-item home">
+        <a class="dac-nav-link dac-visible-mobile-block" href="<?cs var:toroot ?>index.html">Home</a>
+        <ul class="dac-nav-secondary about">
+          <li class="dac-nav-item about">
+            <a class="dac-nav-link" href="<?cs var:toroot ?>about/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>
+        <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 ?>
+          <li class="dac-nav-item preview">
+            <a class="dac-nav-link" href="<?cs var:toroot ?>preview/index.html">Preview</a>
+          </li>
+        </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>
+        <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>
+    </ul>
+  </nav>
+  <!-- end navigation-->
+  <?cs /if ?>
+<?cs /if ?><?cs # end if/else !devsite ?>
+
+<?cs
+/def ?><?cs # end custom_masthead() ?>
 
 
 <?cs # (UN)COMMENT THE INSIDE OF THIS METHOD TO TOGGLE VISIBILITY ?>
@@ -383,6 +287,6 @@
       </div>
     </div>
 
-?>    
+?>
 
 <?cs /def ?>
diff --git a/tools/droiddoc/templates-sdk/customizations.cs b/tools/droiddoc/templates-sdk/customizations.cs
index c8c88cc..aaef8ed 100644
--- a/tools/droiddoc/templates-sdk/customizations.cs
+++ b/tools/droiddoc/templates-sdk/customizations.cs
@@ -1,33 +1,41 @@
-<?cs 
+<?cs
+def:mobile_nav_toggle() ?>
+  <div class="dac-visible-mobile-block" data-toggle="section">
+    <span class="dac-toggle-expand dac-devdoc-toggle"><i class="dac-sprite dac-expand-more-black"></i> Show navigation</span>
+    <span class="dac-toggle-collapse dac-devdoc-toggle" data-toggle-section><i class="dac-sprite dac-expand-less-black"></i> Hide navigation</span>
+  </div>
+<?cs /def ?><?cs
+
 def:fullpage() ?>
   <div id="body-content">
+    <div>
 <?cs /def ?>
 <?cs 
 def:sdk_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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/sdk/sdk_toc.cs" ?>
-
-
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
 <?cs /def ?><?cs
 
 def:no_nav() ?>
   <div class="wrap clearfix" id="body-content">
+    <div>
 <?cs /def ?><?cs
 
 def:tools_nav() ?>
-  <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/tools/tools_toc.cs" ?>
-        
-        
+  <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 include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -38,15 +46,13 @@
 <?cs /def ?>
 <?cs
 def:training_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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/training/training_toc.cs" ?>
-        
-
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -57,10 +63,30 @@
 <?cs /def ?><?cs
 
 def:googleplay_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
+        </div>
+      </div>
+    </div> <!-- end side-nav -->
+    <script>
+      $(document).ready(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+<?cs /def ?><?cs
+
+def:preview_nav() ?>
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -71,10 +97,13 @@
 <?cs /def ?><?cs
 
 def:essentials_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -85,10 +114,13 @@
 <?cs /def ?><?cs
 
 def:users_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -99,10 +131,13 @@
 <?cs /def ?><?cs
 
 def:engage_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -113,10 +148,13 @@
 <?cs /def ?><?cs
 
 def:analyze_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -127,10 +165,13 @@
 <?cs /def ?><?cs
 
 def:monetize_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -141,10 +182,13 @@
 <?cs /def ?><?cs
 
 def:disttools_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -155,10 +199,13 @@
 <?cs /def ?><?cs
 
 def:stories_nav() ?>
-  <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">
+  <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 include:"../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -169,14 +216,13 @@
 <?cs /def ?><?cs
 
 def:guide_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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/guide/guide_toc.cs" ?>
-        
-
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -187,15 +233,13 @@
 <?cs /def ?>
 <?cs
 def:design_nav() ?>
-  <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/design/design_toc.cs" ?>
-       
-
+  <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 include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -206,14 +250,13 @@
 <?cs /def ?>
 <?cs
 def:distribute_nav() ?>
-  <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/distribute_toc.cs" ?>
-        
-
+  <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 include:"../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -225,13 +268,13 @@
 
 <?cs
 def:samples_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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/samples/samples_toc.cs" ?>
-
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
+        </div>
       </div>
 
     </div> <!-- end side-nav -->
@@ -244,14 +287,13 @@
 
 <?cs
 def:google_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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/google/google_toc.cs" ?>
-        
-
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+        </div>
       </div>
       <script type="text/javascript">
        showGoogleRefTree();
@@ -267,14 +309,13 @@
 
 <?cs
 def:about_nav() ?>
-  <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/about/about_toc.cs" ?>
-        
-
+  <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 include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -287,14 +328,13 @@
 
 <?cs
 def:wear_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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/wear/wear_toc.cs" ?>
-
-
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 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 include:"../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
+        </div>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -304,29 +344,14 @@
     </script>
 <?cs /def ?>
 
-<?cs
-def:preview_nav() ?>
-  <div class="wrap clearfix" id="body-content">
-    <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" ?>
-      </div>
-    </div> <!-- end side-nav -->
-    <script>
-      $(document).ready(function() {
-        scrollIntoView("devdoc-nav");
-        });
-    </script>
-<?cs /def ?>
 
-<?cs # The default side navigation for the reference docs ?><?cs 
+<?cs # The default side navigation for the reference docs ?><?cs
 def:default_left_nav() ?>
 <?cs if:reference.gcm || reference.gms ?>
   <?cs call:google_nav() ?>
 <?cs else ?>
-  <div class="wrap clearfix" id="body-content">
-    <div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
+  <div class="wrap clearfix" id="body-content"><div class="cols">
+    <div class="col-4 dac-hidden-mobile" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav">
       <div id="api-nav-header">
         <div id="api-level-toggle">
@@ -341,15 +366,15 @@
         <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 
+        var SINCE_DATA = [ <?cs
+          each:since = since ?>'<?cs
+            var:since.name ?>'<?cs
             if:!last(since) ?>, <?cs /if ?><?cs
-          /each 
+          /each
         ?> ];
         buildApiLevelSelector();
       </script>
-                  
+
       <div id="swapper">
         <div id="nav-panels">
           <div id="resize-packages-nav">
@@ -364,7 +389,7 @@
           <div id="classes-nav" class="scroll-pane">
 
 
-<?cs 
+<?cs
             if:subcount(class.package) ?>
             <ul>
               <?cs call:list("Annotations", class.package.annotations) ?>
@@ -373,7 +398,7 @@
               <?cs call:list("Enums", class.package.enums) ?>
               <?cs call:list("Exceptions", class.package.exceptions) ?>
               <?cs call:list("Errors", class.package.errors) ?>
-            </ul><?cs 
+            </ul><?cs
             elif:subcount(package) ?>
             <ul>
               <?cs call:class_link_list("Annotations", package.annotations) ?>
@@ -382,11 +407,11 @@
               <?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 
+            </ul><?cs
             else ?>
-              <p style="padding:10px">Select a package to view its members</p><?cs 
+              <p style="padding:10px">Select a package to view its members</p><?cs
             /if ?><br/>
-        
+
 
           </div><!-- end classes -->
         </div><!-- end nav-panels -->
@@ -427,84 +452,53 @@
         });
     </script>
 <?cs /if ?>
-    <?cs 
+    <?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 -->
+    <script>
+      $(document).ready(function() {
+        scrollIntoView("devdoc-nav");
+        });
+    </script>
+<?cs /def ?>
 
 <?cs
 def:header_search_widget() ?>
-<div class="menu-container">
-  <div class="moremenu">
-    <div id="more-btn"></div>
-  </div>
-  <div class="morehover" id="moremenu">
-    <div class="top"></div>
-    <div class="mid">
-      <div class="header">Links</div>
-      <ul>
-        <li><a href="https://play.google.com/apps/publish/" target="_googleplay">Google Play Developer Console</a></li>
-        <li><a href="http://android-developers.blogspot.com/">Android Developers Blog</a></li>
-        <li><a href="<?cs var:toroot ?>about/index.html">About Android</a></li>
-      </ul>
-      <div class="header">Android Sites</div>
-      <ul>
-        <li><a href="http://www.android.com">Android.com</a></li>
-        <li class="active"><a>Android Developers</a></li>
-        <li><a href="http://source.android.com">Android Open Source Project</a></li>
-      </ul>
-
-      <?cs # Include language switcher only in online docs ?>
-      <?cs if:android.whichdoc == "online" ?>
-        <div class="header">Language</div>
-          <div id="language" class="locales">
-            <select name="language" onChange="changeLangPref(this.value, true)">
-                <option value="en">English</option>
-                <option value="es">Español</option>
-                <option value="ja">日本語</option>
-                <option value="ko">한국어</option>
-                <option value="ru">Русский</option>
-                <option value="zh-cn">中文(简体)</option>
-                <option value="zh-tw">中文(繁體)</option>
-            </select>
-          </div>
-        <script type="text/javascript">
-          <!--
-          loadLangPref();
-            //-->
-        </script>
-      <?cs /if ?>
-      <?cs # End of lang switcher ?>
-      <br class="clearfix" />
-    </div><!-- end 'mid' -->
-    <div class="bottom"></div>
-  </div><!-- end 'moremenu' -->
-
-  <div class="search" id="search-container">
-    <div class="search-inner">
-      <div id="search-btn"></div>
-      <div class="left"></div>
-      <form onsubmit="return submit_search()">
+  <div class="dac-header-search" id="search-container">
+    <div class="dac-header-search-inner">
+      <div class="dac-sprite dac-search dac-header-search-btn" id="search-btn"></div>
+      <form class="dac-header-search-form" onsubmit="return submit_search()">
         <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q"
           onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)"
           onkeydown="return search_changed(event, true, '<?cs var:toroot ?>')"
-          onkeyup="return search_changed(event, false, '<?cs var:toroot ?>')" />
+          onkeyup="return search_changed(event, false, '<?cs var:toroot ?>')"
+          class="dac-header-search-input" placeholder="Search" />
+          <a class="dac-header-search-close hide" id="search-close">close</a>
       </form>
-      <div class="right"></div>
-      <a class="close hide">close</a>
-      <div class="left"></div>
-      <div class="right"></div>
-    </div><!-- end search-inner -->
-  </div><!-- end search-container -->
+    </div><!-- end dac-header-search-inner -->
+  </div><!-- end dac-header-search -->
 
-  <div class="search_filtered_wrapper reference">
+  <div class="search_filtered_wrapper">
     <div class="suggest-card reference no-display">
       <ul class="search_filtered">
       </ul>
     </div>
-  </div>
-
-  <div class="search_filtered_wrapper docs">
-    <div class="suggest-card dummy no-display">&nbsp;</div>
     <div class="suggest-card develop no-display">
       <ul class="search_filtered">
       </ul>
@@ -524,87 +518,98 @@
       </ul>
     </div>
   </div>
-</div><!-- end menu-container (search and menu widget) -->
 <?cs /def ?>
 
 
-
-<?cs 
+<?cs
 def:custom_left_nav() ?><?cs
-  if:fullpage ?><?cs
-    call:fullpage() ?><?cs
-  elif:nonavpage ?><?cs
-    call:no_nav() ?><?cs
-  elif:guide ?><?cs 
-    call:guide_nav() ?><?cs 
-  elif:design ?><?cs
-    call:design_nav() ?><?cs 
-  elif:training ?><?cs 
-    call:training_nav() ?><?cs 
-  elif:tools ?><?cs 
-    call:tools_nav() ?><?cs
-  elif:google ?><?cs 
-    call:google_nav() ?><?cs 
-  elif:samples ?><?cs
-    call:samples_nav() ?><?cs
-  elif:distribute ?><?cs 
-    if:googleplay ?><?cs
-      call:googleplay_nav() ?><?cs
-    elif:essentials ?><?cs
-      call:essentials_nav() ?><?cs
-    elif:users ?><?cs
-      call:users_nav() ?><?cs
-    elif:engage ?><?cs
-      call:engage_nav() ?><?cs
-    elif:monetize ?><?cs
-      call:monetize_nav() ?><?cs
-    elif:analyze ?><?cs
-      call:analyze_nav() ?><?cs
-    elif:disttools ?><?cs
-      call:disttools_nav() ?><?cs
-    elif:stories ?><?cs
-      call:stories_nav() ?><?cs
+  if:ndk ?><?cs
+    if:fullpage ?><?cs
+      call:fullpage() ?><?cs
+    elif:nonavpage ?><?cs
+      call:no_nav() ?><?cs
+    elif:guide || reference || samples || downloads ?><?cs      
+      call:ndk_nav() ?><?cs
+    else ?><?cs
+      call:default_left_nav() ?> <?cs
     /if ?><?cs
-  elif:about ?><?cs
-    call:about_nav() ?><?cs
-  elif:distribute ?><?cs
-    call:distribute_nav() ?><?cs
-  elif:wear ?><?cs
-    call:wear_nav() ?><?cs
-  elif:preview ?><?cs
-    call:preview_nav() ?><?cs
   else ?><?cs
-    call:default_left_nav() ?> <?cs
+    if:fullpage ?><?cs
+      call:fullpage() ?><?cs
+    elif:nonavpage ?><?cs
+      call:no_nav() ?><?cs
+    elif:guide ?><?cs
+      call:guide_nav() ?><?cs
+    elif:design ?><?cs
+      call:design_nav() ?><?cs
+    elif:training ?><?cs
+      call:training_nav() ?><?cs
+    elif:tools ?><?cs
+      call:tools_nav() ?><?cs
+    elif:google ?><?cs
+      call:google_nav() ?><?cs
+    elif:samples ?><?cs
+      call:samples_nav() ?><?cs
+    elif:preview ?><?cs
+      call:preview_nav() ?><?cs
+    elif:distribute ?><?cs
+      if:googleplay ?><?cs
+        call:googleplay_nav() ?><?cs
+      elif:essentials ?><?cs
+        call:essentials_nav() ?><?cs
+      elif:users ?><?cs
+        call:users_nav() ?><?cs
+      elif:engage ?><?cs
+        call:engage_nav() ?><?cs
+      elif:monetize ?><?cs
+        call:monetize_nav() ?><?cs
+      elif:analyze ?><?cs
+        call:analyze_nav() ?><?cs
+      elif:disttools ?><?cs
+        call:disttools_nav() ?><?cs
+      elif:stories ?><?cs
+        call:stories_nav() ?><?cs
+      /if ?><?cs
+    elif:about ?><?cs
+      call:about_nav() ?><?cs
+    elif:distribute ?><?cs
+      call:distribute_nav() ?><?cs
+    elif:wear ?><?cs
+      call:wear_nav() ?><?cs
+    else ?><?cs
+      call:default_left_nav() ?> <?cs
+    /if ?><?cs
   /if ?><?cs
 /def ?>
 
-<?cs # appears at the bottom of every page ?><?cs 
+<?cs # appears at the bottom of every page ?><?cs
 def:custom_cc_copyright() ?>
-  Except as noted, this content is 
+  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 
+  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 
+<?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>. 
+  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 
+  Content License</a>.<?cs
 /def ?>
 
-<?cs 
+<?cs
 def:custom_footerlinks() ?>
-  <p>
-    <a href="<?cs var:toroot ?>about/index.html">About Android</a>&nbsp;&nbsp;|&nbsp;
-    <a href="<?cs var:toroot ?>legal.html">Legal</a>&nbsp;&nbsp;|&nbsp;
-    <a href="<?cs var:toroot ?>support.html">Support</a>
-  </p><?cs 
+  <a href="<?cs var:toroot ?>about/index.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 
+<?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
diff --git a/tools/droiddoc/templates-sdk/designpage.cs b/tools/droiddoc/templates-sdk/designpage.cs
index 2be179d..b945a1c 100644
--- a/tools/droiddoc/templates-sdk/designpage.cs
+++ b/tools/droiddoc/templates-sdk/designpage.cs
@@ -37,14 +37,12 @@
 
 <?cs if:header.hide ?>
 <?cs else ?>
-<div class="layout-content-row content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
-  <div class="layout-content-col span-9">
+<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>
-  <div class="paging-links layout-content-col span-4" itemscope itemtype="http://schema.org/SiteNavigationElement">
+  <div class="paging-links" itemscope itemtype="http://schema.org/SiteNavigationElement">
     <a href="#" class="prev-page-link">Previous</a>
     <a href="#" class="next-page-link">Next</a>
   </div>
@@ -55,9 +53,9 @@
 
 <?cs if:footer.hide ?>
 <?cs else ?>
-<div class="layout-content-row content-footer" itemscope itemtype="http://schema.org/SiteNavigationElement">
-  <div class="paging-links layout-content-col span-9">&nbsp;</div>
-  <div class="paging-links layout-content-col span-4">
+<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>
diff --git a/tools/droiddoc/templates-sdk/docpage.cs b/tools/droiddoc/templates-sdk/docpage.cs
index 83b1199..668105b 100644
--- a/tools/droiddoc/templates-sdk/docpage.cs
+++ b/tools/droiddoc/templates-sdk/docpage.cs
@@ -4,31 +4,39 @@
 <?cs include:"head_tag.cs" ?>
 <body 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:(guide||develop||training||reference||tools||sdk||samples) ?>develop<?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
-  elif:(distribute||googleplay||essentials||users||engage||monetize||disttools||stories)
-    ?>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
-  elif:(about||wear||tv||auto) ?>about<?cs
-  elif:design ?>design<?cs
-/if ?><?cs
-if:page.trainingcourse ?> trainingcourse<?cs
+    if:reference ?> reference<?cs /if ?><?cs
+    if:downloads ?> downloads<?cs /if ?><?cs
+  else ?><?cs
+    if:(guide||develop||training||reference||tools||sdk||google||samples||preview) ?>develop<?cs
+      if:guide ?> guide<?cs /if ?><?cs
+      if:samples ?> samples<?cs /if ?><?cs
+      if:preview ?> preview<?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:(about||wear||tv||auto) ?>about<?cs
+    elif:design ?>design<?cs
+    /if ?><?cs
+    if:page.trainingcourse ?> trainingcourse<?cs /if ?><?cs
 /if ?>" itemscope itemtype="http://schema.org/Article"><?cs
 include:"header.cs" ?>
 
 <div <?cs
   if:fullpage
     ?>class="fullpage"<?cs
-  elif:(design||tools||about||sdk||googleplay||essentials||users||monetize||disttools) && !nonavpage
+  elif:(design||tools||about||sdk||googleplay||essentials||users||engage||monetize||disttools||stories) && !nonavpage
     ?>class="col-13" id="doc-col"<?cs
   elif:!nonavpage
     ?>class="col-12" id="doc-col"<?cs /if ?> >
@@ -36,14 +44,12 @@
 <?cs if:(design||training||walkthru) && !page.trainingcourse && !page.article ?><?cs # header logic for docs that provide previous/next buttons ?>
   <?cs if:header.hide ?>
   <?cs else ?>
-  <div class="layout-content-row content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
-    <div class="layout-content-col <?cs if:training ?>span-7<?cs else ?>span-9<?cs /if ?>">
+  <div class="content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
       <?cs if:header.justLinks ?>&nbsp;
       <?cs else ?><h1 itemprop="name"><?cs var:page.title ?></h1>
       <?cs /if ?>
-    </div>
     <?cs if:training ?>
-      <div class="training-nav-top layout-content-col span-5" itemscope itemtype="http://schema.org/SiteNavigationElement">
+      <div class="training-nav-top" itemscope itemtype="http://schema.org/SiteNavigationElement">
         <a href="#" class="prev-page-link hide"
             zh-tw-lang="上一堂課"
             zh-cn-lang="上一课"
@@ -70,7 +76,7 @@
             >Get started</a>
       </div>
     <?cs elif:!page.trainingcourse ?>
-      <div class="paging-links layout-content-col span-4" itemscope itemtype="http://schema.org/SiteNavigationElement">
+      <div class="paging-links" itemscope itemtype="http://schema.org/SiteNavigationElement">
         <a href="#" class="prev-page-link hide"
             zh-tw-lang="上一堂課"
             zh-cn-lang="上一课"
@@ -116,16 +122,18 @@
     <?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="col-6">
-          <img src="<?cs var:toroot ?><?cs var:page.landing.image ?>" alt="" />
-        </div>
-        <div class="col-6">
+        <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>
@@ -153,13 +161,11 @@
     <?cs call:tag_list(root.descr) ?>
     </div>
 
+    <?cs if:!fullscreen && (design||training||walkthru) && !page.landing && !page.trainingcourse && !footer.hide ?>
       <div class="content-footer <?cs
-                    if:fullpage ?>wrap<?cs
-                    else ?>layout-content-row<?cs /if ?>"
+                    if:fullpage ?>wrap<?cs /if ?>"
                     itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <?cs if:!fullscreen ?>
-        <div class="paging-links layout-content-col col-10">
-          <?cs if:(design||training||walkthru) && !page.landing && !page.trainingcourse && !footer.hide ?>
+          <div class="paging-links">
             <a href="#" class="next-page-link hide"
                 zh-tw-lang="下一堂課"
                 zh-cn-lang="下一课"
@@ -177,15 +183,9 @@
                 es-lang="Empezar"
                 >Get started</a>
             <a href="#" class="next-class-link hide">Next class</a>
-          <?cs /if ?>
-        </div>
-        <div class="layout-content-col plus-container col-2" >
-          <?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 ?>
+          </div>
       </div>
+    <?cs /if ?>
 
   </div> <!-- end jd-content -->
 
@@ -194,13 +194,10 @@
 
 <?cs include:"trailer.cs" ?>
   <script src="https://developer.android.com/ytblogger_lists_unified.js" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_lists_unified.js?v=9" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_extras.js?v=11" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_collections.js?v=12" type="text/javascript"></script>
-  <script src="<?cs var:toroot ?>jd_tag_helpers.js?v=5" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_lists_unified.js?v=15" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_extras.js?v=15" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_collections.js?v=15" type="text/javascript"></script>
+  <script src="<?cs var:toroot ?>jd_tag_helpers.js?v=15" type="text/javascript"></script>
 
 </body>
 </html>
-
-
-
diff --git a/tools/droiddoc/templates-sdk/footer.cs b/tools/droiddoc/templates-sdk/footer.cs
index b609d3b..1ffee63 100644
--- a/tools/droiddoc/templates-sdk/footer.cs
+++ b/tools/droiddoc/templates-sdk/footer.cs
@@ -1,20 +1,172 @@
-<div id="footer" class="wrap" <?cs if:fullpage ?>style="width:940px"<?cs /if ?>>
-        
-<?cs if:reference ?>
-  <div id="copyright">
-    <?cs call:custom_copyright() ?>
+<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" 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-fab dac-footer-social-link" href="https://www.youtube.com/user/androiddevelopers"><i class="dac-sprite dac-youtube"></i></a>
+          <a class="dac-fab dac-footer-social-link" href="https://plus.google.com/+AndroidDevelopers"><i class="dac-sprite dac-gplus"></i></a>
+          <a class="dac-fab 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/index.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="ja">日本語</option>
+          <option value="ko">한국어</option>
+          <option value="pt-br">Português Brasileiro</option>
+          <option value="ru">Русский</option>
+          <option value="zh-cn">中文(简体)</option>
+          <option value="zh-tw">中文(繁體)</option>
+        </select>
+      </span>
+    </p>
   </div>
-  <div id="build_info">
-    <?cs call:custom_buildinfo() ?>
+</div> <!-- end footer -->
+
+<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">
+        <button class="dac-modal-header-close" data-modal-toggle><i class="dac-sprite dac-close"></i></button>
+        <div class="dac-swap" data-swap-container>
+          <section class="dac-swap-section dac-active dac-down">
+            <h2 class="norule dac-modal-header-title">Get the latest Android developer news and tips that will help you find success on Google Play.</h2>
+            <p class="dac-modal-header-subtitle">&#42; Required Fields</p>
+          </section>
+          <section class="dac-swap-section dac-up">
+            <h2 class="norule dac-modal-header-title">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">
+            <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">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">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">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">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">Which best describes your business:<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">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">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">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">Add me to the mailing list for the monthly newsletter and occasional emails about development and Google Play opportunities.<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">I acknowledge that the information provided in this form will be subject to <a href="https://www.google.com/policies/privacy/">Google's privacy policy</a>.<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">
+              You have successfully signed up for the latest Android developer news and tips.
+            </p>
+          </div>
+        </section>
+      </div>
+    </div>
   </div>
-<?cs elif:!hide_license_footer ?>
-  <div id="copyright">
-    <?cs call:custom_cc_copyright() ?>
-  </div>
-<?cs /if ?>
-<?cs if:!no_footer_links ?>
-  <div id="footerlinks">
-    <?cs call:custom_footerlinks() ?>
-  </div>
-<?cs /if ?>
-</div> <!-- end footer -->
\ No newline at end of file
+</div> <!-- end footer -->
diff --git a/tools/droiddoc/templates-sdk/head_tag.cs b/tools/droiddoc/templates-sdk/head_tag.cs
index 9f79f54..babb3c7 100644
--- a/tools/droiddoc/templates-sdk/head_tag.cs
+++ b/tools/droiddoc/templates-sdk/head_tag.cs
@@ -15,10 +15,8 @@
 ?><?cs
   # END if/else devsite ?>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="viewport" content="width=<?cs
-  if:page.viewport_width ?><?cs
-    var:page.viewport_width ?><?cs
-  else ?>device-width<?cs /if ?>" />
+<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">
 <?cs
   if:page.metaDescription ?>
 <meta name="Description" content="<?cs var:page.metaDescription ?>"><?cs
@@ -38,7 +36,12 @@
 if:android.whichdoc != 'online' ?>http:<?cs
 /if ?>//fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
   title="roboto">
-<link href="<?cs var:toroot ?>assets/css/default.css?v=5" rel="stylesheet" type="text/css">
+<?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=7" rel="stylesheet" type="text/css">
 
 <?cs if:reference && !(reference.gms || reference.gcm || preview) ?>
 <!-- FULLSCREEN STYLESHEET -->
@@ -62,7 +65,7 @@
   var metaTags = [<?cs var:meta.tags ?>];
   var devsite = <?cs if:devsite ?>true<?cs else ?>false<?cs /if ?>;
 </script>
-<script src="<?cs var:toroot ?>assets/js/docs.js?v=3" type="text/javascript"></script>
+<script src="<?cs var:toroot ?>assets/js/docs.js?v=6" type="text/javascript"></script>
 
 <?cs if:helpoutsWidget ?>
 <script type="text/javascript" src="https://helpouts.google.com/ps/res/embed.js" defer async
diff --git a/tools/droiddoc/templates-sdk/nosidenavpage.cs b/tools/droiddoc/templates-sdk/nosidenavpage.cs
index 8e59693..61754f0 100644
--- a/tools/droiddoc/templates-sdk/nosidenavpage.cs
+++ b/tools/droiddoc/templates-sdk/nosidenavpage.cs
@@ -11,6 +11,7 @@
 <?cs call:custom_masthead() ?>
 
 <div id="body-content">
+<div>
 <div id="doc-content" style="position:relative;">
 
 <?cs call:tag_list(root.descr) ?>
diff --git a/tools/droiddoc/templates-sdk/package.cs b/tools/droiddoc/templates-sdk/package.cs
index 2225565..72d5538 100644
--- a/tools/droiddoc/templates-sdk/package.cs
+++ b/tools/droiddoc/templates-sdk/package.cs
@@ -55,8 +55,9 @@
 <?cs call:class_table("Exceptions", package.exceptions) ?>
 <?cs call:class_table("Errors", package.errors) ?>
 
-<?cs include:"footer.cs" ?>
 </div><!-- end jd-content -->
+
+<?cs include:"footer.cs" ?>
 </div><!-- doc-content -->
 
 <?cs include:"trailer.cs" ?>
diff --git a/tools/droiddoc/templates-sdk/packages.cs b/tools/droiddoc/templates-sdk/packages.cs
index 5056d3a..fe6a5aa 100644
--- a/tools/droiddoc/templates-sdk/packages.cs
+++ b/tools/droiddoc/templates-sdk/packages.cs
@@ -35,8 +35,9 @@
 <?cs /each ?>
 </table>
 
-<?cs include:"footer.cs" ?>
 </div><!-- end jd-content -->
+
+<?cs include:"footer.cs" ?>
 </div> <!-- end doc-content -->
 
 <?cs include:"trailer.cs" ?>
diff --git a/tools/droiddoc/templates-sdk/sample.cs b/tools/droiddoc/templates-sdk/sample.cs
index 32a0788..7b4bf0f 100644
--- a/tools/droiddoc/templates-sdk/sample.cs
+++ b/tools/droiddoc/templates-sdk/sample.cs
@@ -92,9 +92,9 @@
 
       <div class="content-footer <?cs
                     if:fullpage ?>wrap<?cs
-                    else ?>layout-content-row<?cs /if ?>"
+                    else ?>cols<?cs /if ?>"
                     itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <div class="layout-content-col <?cs
+        <div class="<?cs
                     if:fullpage ?>col-16<?cs
                     elif:training||guide ?>col-8<?cs
                     else ?>col-9<?cs /if ?>" style="padding-top:4px">
@@ -103,7 +103,7 @@
           <?cs /if ?>
         </div>
         <?cs if:!fullscreen ?>
-        <div class="paging-links layout-content-col col-4">
+        <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="上一堂課"
@@ -128,7 +128,7 @@
 
       <?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="layout-content-row content-footer next-class" style="display:none" itemscope itemtype="http://schema.org/SiteNavigationElement">
+      <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 ?>
diff --git a/tools/droiddoc/templates-sdk/sampleindex.cs b/tools/droiddoc/templates-sdk/sampleindex.cs
index 1bacb53..e62d3fe 100644
--- a/tools/droiddoc/templates-sdk/sampleindex.cs
+++ b/tools/droiddoc/templates-sdk/sampleindex.cs
@@ -82,9 +82,9 @@
 <?cs /if ?><?cs # end if/else online docs ?>
       <div class="content-footer <?cs
                     if:fullpage ?>wrap<?cs
-                    else ?>layout-content-row<?cs /if ?>"
+                    else ?>cols<?cs /if ?>"
                     itemscope itemtype="http://schema.org/SiteNavigationElement">
-        <div class="layout-content-col <?cs
+        <div class="<?cs
                     if:fullpage ?>col-16<?cs
                     elif:training||guide ?>col-8<?cs
                     else ?>col-9<?cs /if ?>" style="padding-top:4px">
@@ -93,7 +93,7 @@
           <?cs /if ?>
         </div>
         <?cs if:!fullscreen ?>
-        <div class="paging-links layout-content-col col-4">
+        <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="上一堂課"
@@ -118,7 +118,7 @@
 
       <?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="layout-content-row content-footer next-class" style="display:none" itemscope itemtype="http://schema.org/SiteNavigationElement">
+      <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 ?>
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index 817ac47..8ec034f 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -116,6 +116,7 @@
     <td><?cs var:ndk.win64.legacy_bytes ?></td>
     <td><?cs var:ndk.win64.legacy_checksum ?></td>
   </tr> -->
+<!--   (this item is deprecated)
   <tr>
     <td>Mac OS X 32-bit</td>
     <td>
@@ -124,8 +125,9 @@
     </td>
     <td><?cs var:ndk.mac32_bytes ?></td>
     <td><?cs var:ndk.mac32_checksum ?></td>
-  </tr>
- <!--  <tr>
+  </tr> -->
+ <!-- (this item is deprecated)
+  <tr>
     <td>
   <a onClick="return onDownload(this)"
      href="http://dl.google.com/android/ndk/<?cs var:ndk.mac32.legacy_download ?>"><?cs var:ndk.mac32.legacy_download ?></a>
@@ -399,9 +401,6 @@
 
 
 
-</div><!-- end col-13 for lower-half content -->
-
-
 
 
 <script>
diff --git a/tools/droiddoc/templates-sdk/trailer.cs b/tools/droiddoc/templates-sdk/trailer.cs
index 337f8d3..225b2c1 100644
--- a/tools/droiddoc/templates-sdk/trailer.cs
+++ b/tools/droiddoc/templates-sdk/trailer.cs
@@ -1,3 +1,4 @@
+</div> <!-- end .cols --> <?cs # normally opened by header.cs ?>
 </div> <!-- end body-content --> <?cs # normally opened by header.cs ?>
 
 <?cs if:carousel ?>
diff --git a/tools/fs_config/Android.mk b/tools/fs_config/Android.mk
index 02deabb..34a3522 100644
--- a/tools/fs_config/Android.mk
+++ b/tools/fs_config/Android.mk
@@ -13,11 +13,73 @@
 # limitations under the License.
 
 LOCAL_PATH := $(call my-dir)
+
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := fs_config.c
 LOCAL_MODULE := fs_config
-LOCAL_STATIC_LIBRARIES := libselinux
-LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_SHARED_LIBRARIES := libcutils libselinux
+LOCAL_CFLAGS := -Werror
 
 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
+ANDROID_FS_CONFIG_H := android_filesystem_config.h
+
+ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),)
+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))".)
+endif
+
+my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)
+else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),)
+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_SHARED_LIBRARIES := libcutils
+LOCAL_CFLAGS := -Werror -Wno-error=\#warnings
+LOCAL_C_INCLUDES := $(dir $(my_fs_config_h))
+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)
+
+LOCAL_MODULE := fs_config_dirs
+LOCAL_MODULE_CLASS := ETC
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
+	@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)
+
+LOCAL_MODULE := fs_config_files
+LOCAL_MODULE_CLASS := ETC
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
+	@mkdir -p $(dir $@)
+	$< -F -o $@
+
+ANDROID_FS_CONFIG_H :=
+my_fs_config_h :=
+fs_config_generate_bin :=
diff --git a/tools/fs_config/default/android_filesystem_config.h b/tools/fs_config/default/android_filesystem_config.h
new file mode 100644
index 0000000..820b04a
--- /dev/null
+++ b/tools/fs_config/default/android_filesystem_config.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 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.
+ */
+
+/* This file is used to enhance the properties of the filesystem
+** images generated by build tools (mkbootfs and mkyaffs2image) and
+** 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
+** way up to the root.
+*/
+
+#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS 1 /* opt out of specifying */
+
+/* Rules for files.
+** These rules are applied based on "first match", so they
+** should start with the most specific path and work their
+** way up to the root. Prefixes ending in * denotes wildcard
+** and will allow partial matches.
+*/
+
+#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES 1 /* opt out of specifying */
diff --git a/tools/fs_config/fs_config_generate.c b/tools/fs_config/fs_config_generate.c
new file mode 100644
index 0000000..c06213f
--- /dev/null
+++ b/tools/fs_config/fs_config_generate.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 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.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <private/android_filesystem_config.h>
+
+/*
+ * This program expects android_device_dirs and android_device_files
+ * to be defined in the supplied android_filesystem_config.h file in
+ * the device/<vendor>/<product> $(TARGET_DEVICE_DIR). Then generates
+ * the binary format used in the /system/etc/fs_config_dirs and
+ * the /system/etc/fs_config_files to be used by the runtimes.
+ */
+#include "android_filesystem_config.h"
+
+#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS
+  static const struct fs_path_config android_device_dirs[] = {
+};
+#endif
+
+#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES
+static const struct fs_path_config android_device_files[] = {
+#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS
+    { 0, AID_ROOT, AID_ROOT, 0, "system/etc/fs_config_dirs" },
+#endif
+    { 0, AID_ROOT, AID_ROOT, 0, "system/etc/fs_config_files" },
+};
+#endif
+
+static void usage() {
+  fprintf(stderr,
+    "Generate binary content for fs_config_dirs (-D) and fs_config_files (-F)\n"
+    "from device-specific android_filesystem_config.h override\n\n"
+    "Usage: fs_config_generate -D|-F [-o output-file]\n");
+}
+
+int main(int argc, char** argv) {
+  const struct fs_path_config *pc;
+  const struct fs_path_config *end;
+  bool dir = false, file = false;
+  FILE *fp = stdout;
+  int opt;
+
+  while((opt = getopt(argc, argv, "DFho:")) != -1) {
+    switch(opt) {
+    case 'D':
+      if (file) {
+        fprintf(stderr, "Must specify only -D or -F\n");
+        usage();
+        exit(EXIT_FAILURE);
+      }
+      dir = true;
+      break;
+    case 'F':
+      if (dir) {
+        fprintf(stderr, "Must specify only -F or -D\n");
+        usage();
+        exit(EXIT_FAILURE);
+      }
+      file = true;
+      break;
+    case 'o':
+      if (fp != stdout) {
+        fprintf(stderr, "Specify only one output file\n");
+        usage();
+        exit(EXIT_FAILURE);
+      }
+      fp = fopen(optarg, "wb");
+      if (fp == NULL) {
+        fprintf(stderr, "Can not open \"%s\"\n", optarg);
+        exit(EXIT_FAILURE);
+      }
+      break;
+    case 'h':
+      usage();
+      exit(EXIT_SUCCESS);
+    default:
+      usage();
+      exit(EXIT_FAILURE);
+    }
+  }
+
+  if (!file && !dir) {
+    fprintf(stderr, "Must specify either -F or -D\n");
+    usage();
+    exit(EXIT_FAILURE);
+  }
+
+  if (dir) {
+    pc = android_device_dirs;
+    end = &android_device_dirs[sizeof(android_device_dirs) / sizeof(android_device_dirs[0])];
+  } else {
+    pc = android_device_files;
+    end = &android_device_files[sizeof(android_device_files) / sizeof(android_device_files[0])];
+  }
+  for(; (pc < end) && pc->prefix; pc++) {
+    char buffer[512];
+    ssize_t len = fs_config_generate(buffer, sizeof(buffer), pc);
+    if (len < 0) {
+      fprintf(stderr, "Entry too large\n");
+      exit(EXIT_FAILURE);
+    }
+    if (fwrite(buffer, 1, len, fp) != (size_t)len) {
+      fprintf(stderr, "Write failure\n");
+      exit(EXIT_FAILURE);
+    }
+  }
+  fclose(fp);
+
+  return 0;
+}
diff --git a/tools/fs_get_stats/Android.mk b/tools/fs_get_stats/Android.mk
index c9b4a05..4501c1f 100644
--- a/tools/fs_get_stats/Android.mk
+++ b/tools/fs_get_stats/Android.mk
@@ -6,4 +6,6 @@
 
 LOCAL_MODULE := fs_get_stats
 
+LOCAL_SHARED_LIBRARIES := libcutils liblog
+
 include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/post_process_props.py b/tools/post_process_props.py
index 030826d..fa6106f 100755
--- a/tools/post_process_props.py
+++ b/tools/post_process_props.py
@@ -56,8 +56,6 @@
   """
   check_pass = True
   buildprops = prop.to_dict()
-  dev_build = buildprops.get("ro.build.version.incremental",
-                             "").startswith("eng")
   for key, value in buildprops.iteritems():
     # Check build properties' length.
     if len(key) > PROP_NAME_MAX:
@@ -66,19 +64,10 @@
                        (key, PROP_NAME_MAX))
       sys.stderr.write("%s (%d)\n" % (key, len(key)))
     if len(value) > PROP_VALUE_MAX:
-      # If dev build, show a warning message, otherwise fail the
-      # build with error message
-      if dev_build:
-        sys.stderr.write("warning: %s exceeds %d bytes: " %
-                         (key, PROP_VALUE_MAX))
-        sys.stderr.write("%s (%d)\n" % (value, len(value)))
-        sys.stderr.write("warning: This will cause the %s " % key)
-        sys.stderr.write("property return as empty at runtime\n")
-      else:
-        check_pass = False
-        sys.stderr.write("error: %s cannot exceed %d bytes: " %
-                         (key, PROP_VALUE_MAX))
-        sys.stderr.write("%s (%d)\n" % (value, len(value)))
+      check_pass = False
+      sys.stderr.write("error: %s cannot exceed %d bytes: " %
+                       (key, PROP_VALUE_MAX))
+      sys.stderr.write("%s (%d)\n" % (value, len(value)))
   return check_pass
 
 class PropFile:
diff --git a/tools/product_debug.py b/tools/product_debug.py
index 661c5b7..ff2657c 100755
--- a/tools/product_debug.py
+++ b/tools/product_debug.py
@@ -89,7 +89,6 @@
       "PRODUCT_COPY_FILES",
       "PRODUCT_PACKAGES",
       "PRODUCT_LOCALES",
-      "PRODUCT_FACTORY_RAMDISK_MODULES",
       "PRODUCT_PROPERTY_OVERRIDES",
     )
 
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index e98e4b6..7984ad6 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -30,9 +30,6 @@
 
 import errno
 import os
-import re
-import shutil
-import subprocess
 import tempfile
 import zipfile
 
@@ -58,22 +55,20 @@
     return
 
   def output_sink(fn, data):
-     ofile = open(os.path.join(OPTIONS.input_tmp,"SYSTEM",fn), "w")
-     ofile.write(data)
-     ofile.close()
+    ofile = open(os.path.join(OPTIONS.input_tmp, "SYSTEM", fn), "w")
+    ofile.write(data)
+    ofile.close()
 
   if OPTIONS.rebuild_recovery:
-    print("Building new recovery patch")
-    common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink, recovery_img, boot_img,
-                             info_dict=OPTIONS.info_dict)
+    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)
-  with open(imgname, "rb") as f:
-    common.ZipWriteStr(output_zip, prefix + "system.img", f.read())
-  with open(block_list, "rb") as f:
-    common.ZipWriteStr(output_zip, prefix + "system.map", f.read())
+  common.ZipWrite(output_zip, imgname, prefix + "system.img")
+  common.ZipWrite(output_zip, block_list, prefix + "system.map")
 
 
 def BuildSystem(input_dir, info_dict, block_list=None):
@@ -93,11 +88,9 @@
 
   block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map")
   imgname = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict,
-                     block_list=block_list)
-  with open(imgname, "rb") as f:
-    common.ZipWriteStr(output_zip, prefix + "vendor.img", f.read())
-  with open(block_list, "rb") as f:
-    common.ZipWriteStr(output_zip, prefix + "vendor.map", f.read())
+                        block_list=block_list)
+  common.ZipWrite(output_zip, imgname, prefix + "vendor.img")
+  common.ZipWrite(output_zip, block_list, prefix + "vendor.map")
 
 
 def BuildVendor(input_dir, info_dict, block_list=None):
@@ -117,18 +110,18 @@
   try:
     os.symlink(os.path.join(input_dir, what.upper()),
                os.path.join(input_dir, what))
-  except OSError, e:
-      # bogus error on my mac version?
-      #   File "./build/tools/releasetools/img_from_target_files", line 86, in AddSystem
-      #     os.path.join(OPTIONS.input_tmp, "system"))
-      # OSError: [Errno 17] File exists
-    if (e.errno == errno.EEXIST):
+  except OSError as e:
+    # bogus error on my mac version?
+    #   File "./build/tools/releasetools/img_from_target_files"
+    #     os.path.join(OPTIONS.input_tmp, "system"))
+    # OSError: [Errno 17] File exists
+    if e.errno == errno.EEXIST:
       pass
 
   image_props = build_image.ImagePropFromGlobalDict(info_dict, what)
   fstab = info_dict["fstab"]
   if fstab:
-    image_props["fs_type" ] = fstab["/" + what].fs_type
+    image_props["fs_type"] = fstab["/" + what].fs_type
 
   if what == "system":
     fs_config_prefix = ""
@@ -137,16 +130,27 @@
 
   fs_config = os.path.join(
       input_dir, "META/" + fs_config_prefix + "filesystem_config.txt")
-  if not os.path.exists(fs_config): fs_config = None
+  if not os.path.exists(fs_config):
+    fs_config = None
 
   fc_config = os.path.join(input_dir, "BOOT/RAMDISK/file_contexts")
-  if not os.path.exists(fc_config): fc_config = None
+  if not os.path.exists(fc_config):
+    fc_config = None
+
+  # Override values loaded from info_dict.
+  if fs_config:
+    image_props["fs_config"] = fs_config
+  if fc_config:
+    image_props["selinux_fc"] = fc_config
+  if block_list:
+    image_props["block_list"] = block_list
+  if image_props.get("system_root_image") == "true":
+    image_props["ramdisk_dir"] = os.path.join(input_dir, "BOOT/RAMDISK")
+    image_props["ramdisk_fs_config"] = os.path.join(
+        input_dir, "META/boot_filesystem_config.txt")
 
   succ = build_image.BuildImage(os.path.join(input_dir, what),
-                                image_props, img,
-                                fs_config=fs_config,
-                                fc_config=fc_config,
-                                block_list=block_list)
+                                image_props, img)
   assert succ, "build " + what + ".img image failed"
 
   return img
@@ -180,7 +184,7 @@
 
   fstab = OPTIONS.info_dict["fstab"]
   if fstab:
-    image_props["fs_type" ] = fstab["/data"].fs_type
+    image_props["fs_type"] = fstab["/data"].fs_type
   succ = build_image.BuildImage(user_dir, image_props, img.name)
   assert succ, "build userdata.img image failed"
 
@@ -217,7 +221,7 @@
 
   fstab = OPTIONS.info_dict["fstab"]
   if fstab:
-    image_props["fs_type" ] = fstab["/cache"].fs_type
+    image_props["fs_type"] = fstab["/cache"].fs_type
   succ = build_image.BuildImage(user_dir, image_props, img.name)
   assert succ, "build cache.img image failed"
 
@@ -296,8 +300,7 @@
   output_zip.close()
 
 def main(argv):
-
-  def option_handler(o, a):
+  def option_handler(o, _):
     if o in ("-a", "--add_missing"):
       OPTIONS.add_missing = True
     elif o in ("-r", "--rebuild_recovery",):
@@ -306,12 +309,10 @@
       return False
     return True
 
-  args = common.ParseOptions(argv, __doc__,
-                             extra_opts="ar",
-                             extra_long_opts=["add_missing",
-                                              "rebuild_recovery",
-                                              ],
-                             extra_option_handler=option_handler)
+  args = common.ParseOptions(
+      argv, __doc__, extra_opts="ar",
+      extra_long_opts=["add_missing", "rebuild_recovery"],
+      extra_option_handler=option_handler)
 
 
   if len(args) != 1:
@@ -325,7 +326,7 @@
   try:
     common.CloseInheritedPipes()
     main(sys.argv[1:])
-  except common.ExternalError, e:
+  except common.ExternalError as e:
     print
     print "   ERROR: %s" % (e,)
     print
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index 51031ce..d549f70 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -20,17 +20,17 @@
 import itertools
 import multiprocessing
 import os
-import pprint
 import re
 import subprocess
-import sys
 import threading
 import tempfile
 
-from rangelib import *
+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-")
@@ -69,11 +69,19 @@
     except OSError:
       pass
 
-class EmptyImage(object):
+
+class Image(object):
+  def ReadRangeSet(self, ranges):
+    raise NotImplementedError
+
+  def TotalSha1(self):
+    raise NotImplementedError
+
+
+class EmptyImage(Image):
   """A zero-length image."""
   blocksize = 4096
   care_map = RangeSet()
-  clobbered_blocks = RangeSet()
   total_blocks = 0
   file_map = {}
   def ReadRangeSet(self, ranges):
@@ -82,7 +90,7 @@
     return sha1().hexdigest()
 
 
-class DataImage(object):
+class DataImage(Image):
   """An image wrapped around a single string of data."""
 
   def __init__(self, data, trim=False, pad=False):
@@ -106,7 +114,6 @@
 
     self.total_blocks = len(self.data) / self.blocksize
     self.care_map = RangeSet(data=(0, self.total_blocks))
-    self.clobbered_blocks = RangeSet()
 
     zero_blocks = []
     nonzero_blocks = []
@@ -128,8 +135,6 @@
     return [self.data[s*self.blocksize:e*self.blocksize] for (s, e) in ranges]
 
   def TotalSha1(self):
-    # DataImage always carries empty clobbered_blocks.
-    assert self.clobbered_blocks.size() == 0
     return sha1(self.data).hexdigest()
 
 
@@ -142,8 +147,11 @@
     self.style = style
     self.intact = (getattr(tgt_ranges, "monotonic", False) and
                    getattr(src_ranges, "monotonic", False))
-    self.goes_before = {}
-    self.goes_after = {}
+
+    # We use OrderedDict rather than dict so that the output is repeatable;
+    # otherwise it would depend on the hash values of the Transfer objects.
+    self.goes_before = OrderedDict()
+    self.goes_after = OrderedDict()
 
     self.stash_before = []
     self.use_stash = []
@@ -176,10 +184,6 @@
 #      (Typically a domain is a file, and the key in file_map is the
 #      pathname.)
 #
-#    clobbered_blocks: a RangeSet containing which blocks contain data
-#      but may be altered by the FS. They need to be excluded when
-#      verifying the partition integrity.
-#
 #    ReadRangeSet(): a function that takes a RangeSet and returns the
 #      data contained in the image blocks of that RangeSet.  The data
 #      is returned as a list or tuple of strings; concatenating the
@@ -189,7 +193,7 @@
 #
 #    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).
+#      care_map)
 #
 # When creating a BlockImageDiff, the src image may be None, in which
 # case the list of transfers produced will never read from the
@@ -199,9 +203,13 @@
   def __init__(self, tgt, src=None, threads=None, version=2):
     if threads is None:
       threads = multiprocessing.cpu_count() // 2
-      if threads == 0: threads = 1
+      if threads == 0:
+        threads = 1
     self.threads = threads
     self.version = version
+    self.transfers = []
+    self.src_basenames = {}
+    self.src_numpatterns = {}
 
     assert version in (1, 2)
 
@@ -250,6 +258,15 @@
     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):
     out = []
 
@@ -283,9 +300,11 @@
       if stashed_blocks > max_stashed_blocks:
         max_stashed_blocks = stashed_blocks
 
+      free_string = []
+
       if self.version == 1:
-        src_string = xf.src_ranges.to_string_raw()
-      elif self.version == 2:
+        src_str = xf.src_ranges.to_string_raw()
+      elif self.version >= 2:
 
         #   <# blocks> <src ranges>
         #     OR
@@ -294,7 +313,7 @@
         #   <# blocks> - <stash refs...>
 
         size = xf.src_ranges.size()
-        src_string = [str(size)]
+        src_str = [str(size)]
 
         unstashed_src_ranges = xf.src_ranges
         mapped_stashes = []
@@ -304,21 +323,29 @@
           unstashed_src_ranges = unstashed_src_ranges.subtract(sr)
           sr = xf.src_ranges.map_within(sr)
           mapped_stashes.append(sr)
-          src_string.append("%d:%s" % (sid, sr.to_string_raw()))
+          if self.version == 2:
+            src_str.append("%d:%s" % (sid, sr.to_string_raw()))
+          else:
+            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))
+              stashes.pop(sh)
           heapq.heappush(free_stash_ids, sid)
 
         if unstashed_src_ranges:
-          src_string.insert(1, unstashed_src_ranges.to_string_raw())
+          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_string.insert(2, mapped_unstashed.to_string_raw())
+            src_str.insert(2, mapped_unstashed.to_string_raw())
             mapped_stashes.append(mapped_unstashed)
             self.AssertPartition(RangeSet(data=(0, size)), mapped_stashes)
         else:
-          src_string.insert(1, "-")
+          src_str.insert(1, "-")
           self.AssertPartition(RangeSet(data=(0, size)), mapped_stashes)
 
-        src_string = " ".join(src_string)
+        src_str = " ".join(src_str)
 
       # both versions:
       #   zero <rangeset>
@@ -331,9 +358,14 @@
       #   move <src rangeset> <tgt rangeset>
       #
       # version 2:
-      #   bsdiff patchstart patchlen <tgt rangeset> <src_string>
-      #   imgdiff patchstart patchlen <tgt rangeset> <src_string>
-      #   move <tgt rangeset> <src_string>
+      #   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>
 
       tgt_size = xf.tgt_ranges.size()
 
@@ -353,7 +385,18 @@
           elif self.version == 2:
             out.append("%s %s %s\n" % (
                 xf.style,
-                xf.tgt_ranges.to_string_raw(), src_string))
+                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
+
+            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"):
         performs_read = True
@@ -366,7 +409,20 @@
         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_string))
+              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
+
+          out.append("%s %d %d %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_ranges.to_string_raw(), src_str))
         total += tgt_size
       elif xf.style == "zero":
         assert xf.tgt_ranges
@@ -375,8 +431,10 @@
           out.append("%s %s\n" % (xf.style, to_zero.to_string_raw()))
           total += to_zero.size()
       else:
-        raise ValueError, "unknown transfer style '%s'\n" % (xf.style,)
+        raise ValueError("unknown transfer style '%s'\n" % xf.style)
 
+      if free_string:
+        out.append("".join(free_string))
 
       # sanity check: abort if we're going to need more than 512 MB if
       # stash space
@@ -482,11 +540,13 @@
 
       patches = [None] * patch_num
 
+      # TODO: Rewrite with multiprocessing.ThreadPool?
       lock = threading.Lock()
       def diff_worker():
         while True:
           with lock:
-            if not diff_q: return
+            if not diff_q:
+              return
             tgt_size, src, tgt, xf, patchnum = diff_q.pop()
           patch = compute_patch(src, tgt, imgdiff=(xf.style == "imgdiff"))
           size = len(patch)
@@ -498,7 +558,7 @@
                     xf.tgt_name + " (from " + xf.src_name + ")")))
 
       threads = [threading.Thread(target=diff_worker)
-                 for i in range(self.threads)]
+                 for _ in range(self.threads)]
       for th in threads:
         th.start()
       while threads:
@@ -625,8 +685,6 @@
     stash_size = 0
 
     for xf in self.transfers:
-      lost = 0
-      size = xf.src_ranges.size()
       for u in xf.goes_before.copy():
         # xf should go before u
         if xf.order < u.order:
@@ -692,7 +750,8 @@
       # Put all sinks at the end of the sequence.
       while True:
         sinks = [u for u in G if not u.outgoing]
-        if not sinks: break
+        if not sinks:
+          break
         for u in sinks:
           s2.appendleft(u)
           del G[u]
@@ -702,14 +761,16 @@
       # Put all the sources at the beginning of the sequence.
       while True:
         sources = [u for u in G if not u.incoming]
-        if not sources: break
+        if not sources:
+          break
         for u in sources:
           s1.append(u)
           del G[u]
           for iu in u.outgoing:
             del iu.incoming[u]
 
-      if not G: break
+      if not G:
+        break
 
       # Find the "best" vertex to put next.  "Best" is the one that
       # maximizes the net difference in source blocks saved we get by
@@ -747,7 +808,8 @@
     print("Generating digraph...")
     for a in self.transfers:
       for b in self.transfers:
-        if a is b: continue
+        if a is b:
+          continue
 
         # If the blocks written by A are read by B, then B needs to go before A.
         i = a.tgt_ranges.intersect(b.src_ranges)
@@ -762,7 +824,6 @@
           a.goes_after[b] = size
 
   def FindTransfers(self):
-    self.transfers = []
     empty = RangeSet()
     for tgt_fn, tgt_ranges in self.tgt.file_map.items():
       if tgt_fn == "__ZERO":
@@ -774,13 +835,6 @@
                  "zero", self.transfers)
         continue
 
-      elif tgt_fn == "__COPY":
-        # "__COPY" domain includes all the blocks not contained in any
-        # file and that need to be copied unconditionally to the target.
-        print("FindTransfers: new", tgt_ranges);
-        Transfer(tgt_fn, None, tgt_ranges, empty, "new", self.transfers)
-        continue
-
       elif tgt_fn in self.src.file_map:
         # Look for an exact pathname match in the source.
         Transfer(tgt_fn, tgt_fn, tgt_ranges, self.src.file_map[tgt_fn],
@@ -809,9 +863,6 @@
       Transfer(tgt_fn, None, tgt_ranges, empty, "new", self.transfers)
 
   def AbbreviateSourceNames(self):
-    self.src_basenames = {}
-    self.src_numpatterns = {}
-
     for k in self.src.file_map.keys():
       b = os.path.basename(k)
       self.src_basenames[b] = k
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 24d5665..033ade9 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -72,14 +72,15 @@
   """
   success, verity_tree_size = GetVerityTreeSize(partition_size)
   if not success:
-    return 0;
+    return 0
   success, verity_metadata_size = GetVerityMetadataSize(partition_size)
   if not success:
     return 0
   return partition_size - verity_tree_size - verity_metadata_size
 
 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))
+  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:
@@ -92,14 +93,10 @@
 
 def BuildVerityMetadata(image_size, verity_metadata_path, root_hash, salt,
                         block_device, signer_path, key):
-  cmd = ("system/extras/verity/build_verity_metadata.py %s %s %s %s %s %s %s" %
-              (image_size,
-              verity_metadata_path,
-              root_hash,
-              salt,
-              block_device,
-              signer_path,
-              key))
+  cmd_template = (
+      "system/extras/verity/build_verity_metadata.py %s %s %s %s %s %s %s")
+  cmd = cmd_template % (image_size, verity_metadata_path, root_hash, salt,
+                        block_device, signer_path, key)
   print cmd
   status, output = commands.getstatusoutput(cmd)
   if status:
@@ -125,10 +122,13 @@
     return False
   return True
 
-def BuildVerifiedImage(data_image_path, verity_image_path, verity_metadata_path):
-  if not Append2Simg(data_image_path, verity_metadata_path, "Could not append verity metadata!"):
+def BuildVerifiedImage(data_image_path, verity_image_path,
+                       verity_metadata_path):
+  if not Append2Simg(data_image_path, verity_metadata_path,
+                     "Could not append verity metadata!"):
     return False
-  if not Append2Simg(data_image_path, verity_image_path, "Could not append verity tree!"):
+  if not Append2Simg(data_image_path, verity_image_path,
+                     "Could not append verity tree!"):
     return False
   return True
 
@@ -153,7 +153,8 @@
 
   Args:
     out_file: the location to write the verifiable image at
-    prop_dict: a dictionary of properties required for image creation and verification
+    prop_dict: a dictionary of properties required for image creation and
+               verification
   Returns:
     True on success, False otherwise.
   """
@@ -178,13 +179,8 @@
   # build the metadata blocks
   root_hash = prop_dict["verity_root_hash"]
   salt = prop_dict["verity_salt"]
-  if not BuildVerityMetadata(image_size,
-                              verity_metadata_path,
-                              root_hash,
-                              salt,
-                              block_dev,
-                              signer_path,
-                              signer_key):
+  if not BuildVerityMetadata(image_size, verity_metadata_path, root_hash, salt,
+                             block_dev, signer_path, signer_key):
     shutil.rmtree(tempdir_name, ignore_errors=True)
     return False
 
@@ -198,33 +194,51 @@
   shutil.rmtree(tempdir_name, ignore_errors=True)
   return True
 
-def BuildImage(in_dir, prop_dict, out_file,
-               fs_config=None,
-               fc_config=None,
-               block_list=None):
+def BuildImage(in_dir, prop_dict, out_file):
   """Build an image to out_file from in_dir with property prop_dict.
 
   Args:
     in_dir: path of input directory.
     prop_dict: property dictionary.
     out_file: path of the output image file.
-    fs_config: path to the fs_config file (typically
-      META/filesystem_config.txt).  If None then the configuration in
-      the local client will be used.
-    fc_config: path to the SELinux file_contexts file.  If None then
-      the value from prop_dict['selinux_fc'] will be used.
 
   Returns:
     True iff the image is built successfully.
   """
+  # system_root_image=true: build a system.img that combines the contents of /system
+  # and the ramdisk, and can be mounted at the root of the file system.
+  origin_in = in_dir
+  fs_config = prop_dict.get("fs_config")
+  if (prop_dict.get("system_root_image") == "true"
+      and prop_dict["mount_point"] == "system"):
+    in_dir = tempfile.mkdtemp()
+    # Change the mount point to "/"
+    prop_dict["mount_point"] = "/"
+    if fs_config:
+      # We need to merge the fs_config files of system and ramdisk.
+      fd, merged_fs_config = tempfile.mkstemp(prefix="root_fs_config",
+                                              suffix=".txt")
+      os.close(fd)
+      with open(merged_fs_config, "w") as fw:
+        if "ramdisk_fs_config" in prop_dict:
+          with open(prop_dict["ramdisk_fs_config"]) as fr:
+            fw.writelines(fr.readlines())
+        with open(fs_config) as fr:
+          fw.writelines(fr.readlines())
+      fs_config = merged_fs_config
+
   build_command = []
   fs_type = prop_dict.get("fs_type", "")
   run_fsck = False
 
+  fs_spans_partition = True
+  if fs_type.startswith("squash"):
+      fs_spans_partition = False
+
   is_verity_partition = "verity_block_device" in prop_dict
   verity_supported = prop_dict.get("verity") == "true"
   # adjust the partition size to make room for the hashes if this is to be verified
-  if verity_supported and is_verity_partition:
+  if verity_supported and is_verity_partition and fs_spans_partition:
     partition_size = int(prop_dict.get("partition_size"))
     adjusted_size = AdjustPartitionSizeForVerity(partition_size)
     if not adjusted_size:
@@ -244,14 +258,24 @@
       build_command.extend(["-j", prop_dict["journal_size"]])
     if "timestamp" in prop_dict:
       build_command.extend(["-T", str(prop_dict["timestamp"])])
-    if fs_config is not None:
+    if fs_config:
       build_command.extend(["-C", fs_config])
-    if block_list is not None:
-      build_command.extend(["-B", block_list])
-    if fc_config is not None:
-      build_command.append(fc_config)
-    elif "selinux_fc" in prop_dict:
+    if "block_list" in prop_dict:
+      build_command.extend(["-B", prop_dict["block_list"]])
+    build_command.extend(["-L", prop_dict["mount_point"]])
+    if "selinux_fc" in prop_dict:
       build_command.append(prop_dict["selinux_fc"])
+  elif fs_type.startswith("squash"):
+    build_command = ["mksquashfsimage.sh"]
+    build_command.extend([in_dir, out_file])
+    build_command.extend(["-s"])
+    build_command.extend(["-m", prop_dict["mount_point"]])
+    if "selinux_fc" in prop_dict:
+      build_command.extend(["-c", prop_dict["selinux_fc"]])
+    if "squashfs_compressor" in prop_dict:
+      build_command.extend(["-z", prop_dict["squashfs_compressor"]])
+    if "squashfs_compressor_opt" in prop_dict:
+      build_command.extend(["-zo", prop_dict["squashfs_compressor_opt"]])
   elif fs_type.startswith("f2fs"):
     build_command = ["mkf2fsuserimg.sh"]
     build_command.extend([out_file, prop_dict["partition_size"]])
@@ -265,10 +289,40 @@
       build_command.append(prop_dict["selinux_fc"])
       build_command.append(prop_dict["mount_point"])
 
-  exit_code = RunCommand(build_command)
+  if in_dir != origin_in:
+    # Construct a staging directory of the root file system.
+    ramdisk_dir = prop_dict.get("ramdisk_dir")
+    if ramdisk_dir:
+      shutil.rmtree(in_dir)
+      shutil.copytree(ramdisk_dir, in_dir, symlinks=True)
+    staging_system = os.path.join(in_dir, "system")
+    shutil.rmtree(staging_system, ignore_errors=True)
+    shutil.copytree(origin_in, staging_system, symlinks=True)
+  try:
+    exit_code = RunCommand(build_command)
+  finally:
+    if in_dir != origin_in:
+      # Clean up temporary directories and files.
+      shutil.rmtree(in_dir, ignore_errors=True)
+      if fs_config:
+        os.remove(fs_config)
   if exit_code != 0:
     return False
 
+  if not fs_spans_partition:
+    mount_point = prop_dict.get("mount_point")
+    partition_size = int(prop_dict.get("partition_size"))
+    image_size = os.stat(out_file).st_size
+    if image_size > partition_size:
+        print "Error: %s image size of %d is larger than partition size of %d" % (mount_point, image_size, partition_size)
+        return False
+    if verity_supported and is_verity_partition:
+        if 2 * image_size - AdjustPartitionSizeForVerity(image_size) > partition_size:
+            print "Error: No more room on %s to fit verity data" % mount_point
+            return False
+    prop_dict["original_partition_size"] = prop_dict["partition_size"]
+    prop_dict["partition_size"] = str(image_size)
+
   # create the verified image if this is to be verified
   if verity_supported and is_verity_partition:
     if not MakeVerityEnabledImage(out_file, prop_dict):
@@ -320,9 +374,16 @@
   d["mount_point"] = mount_point
   if mount_point == "system":
     copy_prop("fs_type", "fs_type")
+    # Copy the generic sysetem fs type first, override with specific one if
+    # available.
+    copy_prop("system_fs_type", "fs_type")
     copy_prop("system_size", "partition_size")
     copy_prop("system_journal_size", "journal_size")
     copy_prop("system_verity_block_device", "verity_block_device")
+    copy_prop("system_root_image","system_root_image")
+    copy_prop("ramdisk_dir","ramdisk_dir")
+    copy_prop("system_squashfs_compressor", "squashfs_compressor")
+    copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt")
   elif mount_point == "data":
     # Copy the generic fs type first, override with specific one if available.
     copy_prop("fs_type", "fs_type")
@@ -391,7 +452,8 @@
     image_properties = ImagePropFromGlobalDict(glob_dict, mount_point)
 
   if not BuildImage(in_dir, image_properties, out_file):
-    print >> sys.stderr, "error: failed to build %s from %s" % (out_file, in_dir)
+    print >> sys.stderr, "error: failed to build %s from %s" % (out_file,
+                                                                in_dir)
     exit(1)
 
 
diff --git a/tools/releasetools/check_target_files_signatures b/tools/releasetools/check_target_files_signatures
new file mode 120000
index 0000000..9f62aa3
--- /dev/null
+++ b/tools/releasetools/check_target_files_signatures
@@ -0,0 +1 @@
+check_target_files_signatures.py
\ No newline at end of file
diff --git a/tools/releasetools/check_target_files_signatures b/tools/releasetools/check_target_files_signatures.py
similarity index 96%
rename from tools/releasetools/check_target_files_signatures
rename to tools/releasetools/check_target_files_signatures.py
index b2f46c1..dd57033 100755
--- a/tools/releasetools/check_target_files_signatures
+++ b/tools/releasetools/check_target_files_signatures.py
@@ -49,14 +49,8 @@
 import re
 import shutil
 import subprocess
-import tempfile
 import zipfile
 
-try:
-  from hashlib import sha1 as sha1
-except ImportError:
-  from sha import sha as sha1
-
 import common
 
 # Work around a bug in python's zipfile module that prevents opening
@@ -127,7 +121,7 @@
   def FindLocalCerts(self):
     to_load = []
     for top in OPTIONS.local_cert_dirs:
-      for dirpath, dirnames, filenames in os.walk(top):
+      for dirpath, _, filenames in os.walk(top):
         certs = [os.path.join(dirpath, i)
                  for i in filenames if i.endswith(".x509.pem")]
         if certs:
@@ -172,6 +166,10 @@
 class APK(object):
   def __init__(self, full_filename, filename):
     self.filename = filename
+    self.certs = None
+    self.shared_uid = None
+    self.package = None
+
     Push(filename+":")
     try:
       self.RecordCerts(full_filename)
@@ -212,7 +210,7 @@
 
     for line in manifest.split("\n"):
       line = line.strip()
-      m = re.search('A: (\S*?)(?:\(0x[0-9a-f]+\))?="(.*?)" \(Raw', line)
+      m = re.search(r'A: (\S*?)(?:\(0x[0-9a-f]+\))?="(.*?)" \(Raw', line)
       if m:
         name = m.group(1)
         if name == "android:sharedUserId":
@@ -232,13 +230,16 @@
   def __init__(self):
     self.max_pkg_len = 30
     self.max_fn_len = 20
+    self.apks = None
+    self.apks_by_basename = None
+    self.certmap = None
 
   def LoadZipFile(self, filename):
     d, z = common.UnzipTemp(filename, '*.apk')
     try:
       self.apks = {}
       self.apks_by_basename = {}
-      for dirpath, dirnames, filenames in os.walk(d):
+      for dirpath, _, filenames in os.walk(d):
         for fn in filenames:
           if fn.endswith(".apk"):
             fullname = os.path.join(dirpath, fn)
@@ -323,8 +324,8 @@
     """Look for instances where a given package that exists in both
     self and other have different certs."""
 
-    all = set(self.apks.keys())
-    all.update(other.apks.keys())
+    all_apks = set(self.apks.keys())
+    all_apks.update(other.apks.keys())
 
     max_pkg_len = max(self.max_pkg_len, other.max_pkg_len)
 
@@ -434,7 +435,7 @@
   try:
     r = main(sys.argv[1:])
     sys.exit(r)
-  except common.ExternalError, e:
+  except common.ExternalError as e:
     print
     print "   ERROR: %s" % (e,)
     print
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index b28cbf1..592ed19 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -30,44 +30,45 @@
 import zipfile
 
 import blockimgdiff
-from rangelib import *
+import rangelib
 
 try:
   from hashlib import sha1 as sha1
 except ImportError:
   from sha import sha as sha1
 
-# missing in Python 2.4 and before
-if not hasattr(os, "SEEK_SET"):
-  os.SEEK_SET = 0
 
-class Options(object): pass
-OPTIONS = Options()
-
-DEFAULT_SEARCH_PATH_BY_PLATFORM = {
-    "linux2": "out/host/linux-x86",
-    "darwin": "out/host/darwin-x86",
+class Options(object):
+  def __init__(self):
+    platform_search_path = {
+        "linux2": "out/host/linux-x86",
+        "darwin": "out/host/darwin-x86",
     }
-OPTIONS.search_path = DEFAULT_SEARCH_PATH_BY_PLATFORM.get(sys.platform, None)
 
-OPTIONS.signapk_path = "framework/signapk.jar"  # Relative to search_path
-OPTIONS.extra_signapk_args = []
-OPTIONS.java_path = "java"  # Use the one on the path by default.
-OPTIONS.java_args = "-Xmx2048m" # JVM Args
-OPTIONS.public_key_suffix = ".x509.pem"
-OPTIONS.private_key_suffix = ".pk8"
-OPTIONS.verbose = False
-OPTIONS.tempfiles = []
-OPTIONS.device_specific = None
-OPTIONS.extras = {}
-OPTIONS.info_dict = None
+    self.search_path = platform_search_path.get(sys.platform, None)
+    self.signapk_path = "framework/signapk.jar"  # Relative to search_path
+    self.extra_signapk_args = []
+    self.java_path = "java"  # Use the one on the path by default.
+    self.java_args = "-Xmx2048m" # JVM Args
+    self.public_key_suffix = ".x509.pem"
+    self.private_key_suffix = ".pk8"
+    self.verbose = False
+    self.tempfiles = []
+    self.device_specific = None
+    self.extras = {}
+    self.info_dict = None
+    self.worker_threads = None
+
+
+OPTIONS = Options()
 
 
 # Values for "certificate" in apkcerts that mean special things.
 SPECIAL_CERT_STRINGS = ("PRESIGNED", "EXTERNAL")
 
 
-class ExternalError(RuntimeError): pass
+class ExternalError(RuntimeError):
+  pass
 
 
 def Run(args, **kwargs):
@@ -94,19 +95,19 @@
       pass
 
 
-def LoadInfoDict(input):
+def LoadInfoDict(input_file):
   """Read and parse the META/misc_info.txt key/value pairs from the
   input target files and return a dict."""
 
   def read_helper(fn):
-    if isinstance(input, zipfile.ZipFile):
-      return input.read(fn)
+    if isinstance(input_file, zipfile.ZipFile):
+      return input_file.read(fn)
     else:
-      path = os.path.join(input, *fn.split("/"))
+      path = os.path.join(input_file, *fn.split("/"))
       try:
         with open(path) as f:
           return f.read()
-      except IOError, e:
+      except IOError as e:
         if e.errno == errno.ENOENT:
           raise KeyError(fn)
   d = {}
@@ -122,14 +123,16 @@
 
   if "mkyaffs2_extra_flags" not in d:
     try:
-      d["mkyaffs2_extra_flags"] = read_helper("META/mkyaffs2-extra-flags.txt").strip()
+      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()
+      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")
 
@@ -146,9 +149,11 @@
   try:
     data = read_helper("META/imagesizes.txt")
     for line in data.split("\n"):
-      if not line: continue
+      if not line:
+        continue
       name, value = line.split(" ", 1)
-      if not value: continue
+      if not value:
+        continue
       if name == "blocksize":
         d[name] = value
       else:
@@ -186,7 +191,8 @@
   d = {}
   for line in lines:
     line = line.strip()
-    if not line or line.startswith("#"): continue
+    if not line or line.startswith("#"):
+      continue
     if "=" in line:
       name, value = line.split("=", 1)
       d[name] = value
@@ -194,7 +200,12 @@
 
 def LoadRecoveryFSTab(read_helper, fstab_version):
   class Partition(object):
-    pass
+    def __init__(self, mount_point, fs_type, device, length, device2):
+      self.mount_point = mount_point
+      self.fs_type = fs_type
+      self.device = device
+      self.length = length
+      self.device2 = device2
 
   try:
     data = read_helper("RECOVERY/RAMDISK/etc/recovery.fstab")
@@ -206,68 +217,65 @@
     d = {}
     for line in data.split("\n"):
       line = line.strip()
-      if not line or line.startswith("#"): continue
+      if not line or line.startswith("#"):
+        continue
       pieces = line.split()
-      if not (3 <= len(pieces) <= 4):
+      if not 3 <= len(pieces) <= 4:
         raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))
-
-      p = Partition()
-      p.mount_point = pieces[0]
-      p.fs_type = pieces[1]
-      p.device = pieces[2]
-      p.length = 0
       options = None
       if len(pieces) >= 4:
         if pieces[3].startswith("/"):
-          p.device2 = pieces[3]
+          device2 = pieces[3]
           if len(pieces) >= 5:
             options = pieces[4]
         else:
-          p.device2 = None
+          device2 = None
           options = pieces[3]
       else:
-        p.device2 = None
+        device2 = None
 
+      mount_point = pieces[0]
+      length = 0
       if options:
         options = options.split(",")
         for i in options:
           if i.startswith("length="):
-            p.length = int(i[7:])
+            length = int(i[7:])
           else:
-              print "%s: unknown option \"%s\"" % (p.mount_point, i)
+            print "%s: unknown option \"%s\"" % (mount_point, i)
 
-      d[p.mount_point] = p
+      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
+      if not line or line.startswith("#"):
+        continue
       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
+      if "voldmanaged=" in options:
+        continue
 
       # It's a good line, parse it
-      p = Partition()
-      p.device = pieces[0]
-      p.mount_point = pieces[1]
-      p.fs_type = pieces[2]
-      p.device2 = None
-      p.length = 0
-
+      length = 0
       options = options.split(",")
       for i in options:
         if i.startswith("length="):
-          p.length = int(i[7:])
+          length = int(i[7:])
         else:
           # Ignore all unknown options in the unified fstab
           continue
 
-      d[p.mount_point] = p
+      mount_point = pieces[1]
+      d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[2],
+                                 device=pieces[0], length=length, device2=None)
 
   else:
     raise ValueError("Unknown fstab_version: \"%d\"" % (fstab_version,))
@@ -279,6 +287,7 @@
   for k, v in sorted(d.items()):
     print "%-25s = (%s) %s" % (k, type(v).__name__, v)
 
+
 def BuildBootableImage(sourcedir, fs_config_file, info_dict=None):
   """Take a kernel, cmdline, and ramdisk directory from the input (in
   'sourcedir'), and turn them into a boot image.  Return the image
@@ -305,8 +314,8 @@
 
   p2.wait()
   p1.wait()
-  assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (targetname,)
-  assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (targetname,)
+  assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (sourcedir,)
+  assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (sourcedir,)
 
   # use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
   mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"
@@ -337,8 +346,14 @@
   if args and args.strip():
     cmd.extend(shlex.split(args))
 
-  cmd.extend(["--ramdisk", ramdisk_img.name,
-              "--output", img.name])
+  img_unsigned = None
+  if info_dict.get("vboot", None):
+    img_unsigned = tempfile.NamedTemporaryFile()
+    cmd.extend(["--ramdisk", ramdisk_img.name,
+                "--output", img_unsigned.name])
+  else:
+    cmd.extend(["--ramdisk", ramdisk_img.name,
+                "--output", img.name])
 
   p = Run(cmd, stdout=subprocess.PIPE)
   p.communicate()
@@ -347,11 +362,24 @@
 
   if info_dict.get("verity_key", None):
     path = "/" + os.path.basename(sourcedir).lower()
-    cmd = ["boot_signer", path, img.name, info_dict["verity_key"] + ".pk8", info_dict["verity_key"] + ".x509.pem", img.name]
+    cmd = ["boot_signer", path, img.name, info_dict["verity_key"] + ".pk8",
+           info_dict["verity_key"] + ".x509.pem", img.name]
     p = Run(cmd, stdout=subprocess.PIPE)
     p.communicate()
     assert p.returncode == 0, "boot_signer of %s image failed" % path
 
+  # Sign the image if vboot is non-empty.
+  elif info_dict.get("vboot", None):
+    path = "/" + os.path.basename(sourcedir).lower()
+    img_keyblock = tempfile.NamedTemporaryFile()
+    cmd = [info_dict["vboot_signer_cmd"], info_dict["futility"],
+           img_unsigned.name, info_dict["vboot_key"] + ".vbpubk",
+           info_dict["vboot_key"] + ".vbprivk", img_keyblock.name,
+           img.name]
+    p = Run(cmd, stdout=subprocess.PIPE)
+    p.communicate()
+    assert p.returncode == 0, "vboot_signer of %s image failed" % path
+
   img.seek(os.SEEK_SET, 0)
   data = img.read()
 
@@ -453,7 +481,7 @@
               stdin=devnull.fileno(),
               stdout=devnull.fileno(),
               stderr=subprocess.PIPE)
-      stdout, stderr = p.communicate()
+      _, stderr = p.communicate()
       if p.returncode == 0:
         # Encrypted key with empty string as password.
         key_passwords[k] = ''
@@ -524,20 +552,23 @@
   any, for the given target.  Raise exception if the data is too big.
   Print a warning if the data is nearing the maximum size."""
 
-  if target.endswith(".img"): target = target[:-4]
+  if target.endswith(".img"):
+    target = target[:-4]
   mount_point = "/" + target
 
   fs_type = None
   limit = None
   if info_dict["fstab"]:
-    if mount_point == "/userdata": mount_point = "/data"
+    if mount_point == "/userdata":
+      mount_point = "/data"
     p = info_dict["fstab"][mount_point]
     fs_type = p.fs_type
     device = p.device
     if "/" in device:
       device = device[device.rfind("/")+1:]
     limit = info_dict.get(device + "_size", None)
-  if not fs_type or not limit: return
+  if not fs_type or not limit:
+    return
 
   if fs_type == "yaffs2":
     # image size should be increased by 1/64th to account for the
@@ -562,7 +593,8 @@
   certmap = {}
   for line in tf_zip.read("META/apkcerts.txt").split("\n"):
     line = line.strip()
-    if not line: continue
+    if not line:
+      continue
     m = re.match(r'^name="(.*)"\s+certificate="(.*)"\s+'
                  r'private_key="(.*)"$', line)
     if m:
@@ -622,13 +654,11 @@
          "java_path=", "java_args=", "public_key_suffix=",
          "private_key_suffix=", "device_specific=", "extra="] +
         list(extra_long_opts))
-  except getopt.GetoptError, err:
+  except getopt.GetoptError as err:
     Usage(docstring)
     print "**", str(err), "**"
     sys.exit(2)
 
-  path_specified = False
-
   for o, a in opts:
     if o in ("-h", "--help"):
       Usage(docstring)
@@ -707,7 +737,8 @@
         if i not in current or not current[i]:
           missing.append(i)
       # Are all the passwords already in the file?
-      if not missing: return current
+      if not missing:
+        return current
 
       for i in missing:
         current[i] = ""
@@ -721,7 +752,7 @@
 
       current = self.UpdateAndReadFile(current)
 
-  def PromptResult(self, current):
+  def PromptResult(self, current): # pylint: disable=no-self-use
     """Prompt the user to enter a value (password) for each key in
     'current' whose value is fales.  Returns a new dict with all the
     values.
@@ -732,9 +763,10 @@
         result[k] = v
       else:
         while True:
-          result[k] = getpass.getpass("Enter password for %s key> "
-                                      % (k,)).strip()
-          if result[k]: break
+          result[k] = getpass.getpass(
+              "Enter password for %s key> " % k).strip()
+          if result[k]:
+            break
     return result
 
   def UpdateAndReadFile(self, current):
@@ -742,14 +774,13 @@
       return self.PromptResult(current)
 
     f = open(self.pwfile, "w")
-    os.chmod(self.pwfile, 0600)
+    os.chmod(self.pwfile, 0o600)
     f.write("# Enter key passwords between the [[[ ]]] brackets.\n")
     f.write("# (Additional spaces are harmless.)\n\n")
 
     first_line = None
-    sorted = [(not v, k, v) for (k, v) in current.iteritems()]
-    sorted.sort()
-    for i, (_, k, v) in enumerate(sorted):
+    sorted_list = sorted([(not v, k, v) for (k, v) in current.iteritems()])
+    for i, (_, k, v) in enumerate(sorted_list):
       f.write("[[[  %s  ]]] %s\n" % (v, k))
       if not v and first_line is None:
         # position cursor on first line with no password.
@@ -763,34 +794,76 @@
 
   def ReadFile(self):
     result = {}
-    if self.pwfile is None: return result
+    if self.pwfile is None:
+      return result
     try:
       f = open(self.pwfile, "r")
       for line in f:
         line = line.strip()
-        if not line or line[0] == '#': continue
+        if not line or line[0] == '#':
+          continue
         m = re.match(r"^\[\[\[\s*(.*?)\s*\]\]\]\s*(\S+)$", line)
         if not m:
           print "failed to parse password file: ", line
         else:
           result[m.group(2)] = m.group(1)
       f.close()
-    except IOError, e:
+    except IOError as e:
       if e.errno != errno.ENOENT:
         print "error reading password file: ", str(e)
     return result
 
 
-def ZipWriteStr(zip, filename, data, perms=0644, compression=None):
+def ZipWrite(zip_file, filename, arcname=None, perms=0o644,
+             compress_type=None):
+  import datetime
+
+  # http://b/18015246
+  # Python 2.7's zipfile implementation wrongly thinks that zip64 is required
+  # for files larger than 2GiB. We can work around this by adjusting their
+  # limit. Note that `zipfile.writestr()` will not work for strings larger than
+  # 2GiB. The Python interpreter sometimes rejects strings that large (though
+  # it isn't clear to me exactly what circumstances cause this).
+  # `zipfile.write()` must be used directly to work around this.
+  #
+  # This mess can be avoided if we port to python3.
+  saved_zip64_limit = zipfile.ZIP64_LIMIT
+  zipfile.ZIP64_LIMIT = (1 << 32) - 1
+
+  if compress_type is None:
+    compress_type = zip_file.compression
+  if arcname is None:
+    arcname = filename
+
+  saved_stat = os.stat(filename)
+
+  try:
+    # `zipfile.write()` doesn't allow us to pass ZipInfo, so just modify the
+    # file to be zipped and reset it when we're done.
+    os.chmod(filename, perms)
+
+    # Use a fixed timestamp so the output is repeatable.
+    epoch = datetime.datetime.fromtimestamp(0)
+    timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds()
+    os.utime(filename, (timestamp, timestamp))
+
+    zip_file.write(filename, arcname=arcname, compress_type=compress_type)
+  finally:
+    os.chmod(filename, saved_stat.st_mode)
+    os.utime(filename, (saved_stat.st_atime, saved_stat.st_mtime))
+    zipfile.ZIP64_LIMIT = saved_zip64_limit
+
+
+def ZipWriteStr(zip_file, filename, data, perms=0o644, compression=None):
   # use a fixed timestamp so the output is repeatable.
   zinfo = zipfile.ZipInfo(filename=filename,
                           date_time=(2009, 1, 1, 0, 0, 0))
   if compression is None:
-    zinfo.compress_type = zip.compression
+    zinfo.compress_type = zip_file.compression
   else:
     zinfo.compress_type = compression
   zinfo.external_attr = perms << 16
-  zip.writestr(zinfo, data)
+  zip_file.writestr(zinfo, data)
 
 
 class DeviceSpecificParams(object):
@@ -805,7 +878,8 @@
 
     if self.module is None:
       path = OPTIONS.device_specific
-      if not path: return
+      if not path:
+        return
       try:
         if os.path.isdir(path):
           info = imp.find_module("releasetools", [path])
@@ -943,7 +1017,8 @@
       err = []
       def run():
         _, e = p.communicate()
-        if e: err.append(e)
+        if e:
+          err.append(e)
       th = threading.Thread(target=run)
       th.start()
       th.join(timeout=300)   # 5 mins
@@ -1010,7 +1085,7 @@
           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, e:
+    except Exception as e:
       print e
       raise
 
@@ -1023,16 +1098,14 @@
     threads.pop().join()
 
 
-class BlockDifference:
-  def __init__(self, partition, tgt, src=None, check_first_block=False, version=None):
+class BlockDifference(object):
+  def __init__(self, partition, tgt, src=None, check_first_block=False,
+               version=None):
     self.tgt = tgt
     self.src = src
     self.partition = partition
     self.check_first_block = check_first_block
 
-    # Due to http://b/20939131, check_first_block is disabled temporarily.
-    assert not self.check_first_block
-
     if version is None:
       version = 1
       if OPTIONS.info_dict:
@@ -1057,7 +1130,8 @@
     else:
       script.Print("Patching %s image after verification." % (self.partition,))
 
-    if progress: script.ShowProgress(progress, 0)
+    if progress:
+      script.ShowProgress(progress, 0)
     self._WriteUpdate(script, output_zip)
 
   def WriteVerifyScript(self, script):
@@ -1065,10 +1139,18 @@
     if not self.src:
       script.Print("Image %s will be patched unconditionally." % (partition,))
     else:
-      ranges = self.src.care_map.subtract(self.src.clobbered_blocks)
-      ranges_str = ranges.to_string_raw()
-      script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
-                         self.device, ranges_str, self.src.TotalSha1()))
+      if 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, self.src.care_map.to_string_raw(),
+                            self.src.TotalSha1(),
+                            self.device, partition, partition, partition))
+      else:
+        script.AppendExtra('if range_sha1("%s", "%s") == "%s" then' % (
+            self.device, self.src.care_map.to_string_raw(),
+            self.src.TotalSha1()))
       script.Print('Verified %s image...' % (partition,))
       script.AppendExtra('else')
 
@@ -1081,55 +1163,71 @@
       if self.check_first_block:
         self._CheckFirstBlock(script)
 
-      script.AppendExtra(('  abort("%s partition has unexpected contents");\n'
-                          'endif;') % (partition))
+      # Abort the OTA update. Note that the incremental OTA cannot be applied
+      # even if it may match the checksum of the target partition.
+      # a) If version < 3, operations like move and erase will make changes
+      #    unconditionally and damage the partition.
+      # b) If version >= 3, it won't even reach here.
+      script.AppendExtra(('abort("%s partition has unexpected contents");\n'
+                          'endif;') % (partition,))
 
   def _WriteUpdate(self, script, output_zip):
-    partition = self.partition
-    with open(self.path + ".transfer.list", "rb") as f:
-      ZipWriteStr(output_zip, partition + ".transfer.list", f.read())
-    with open(self.path + ".new.dat", "rb") as f:
-      ZipWriteStr(output_zip, partition + ".new.dat", f.read())
-    with open(self.path + ".patch.dat", "rb") as f:
-      ZipWriteStr(output_zip, partition + ".patch.dat", f.read(),
-                         compression=zipfile.ZIP_STORED)
+    ZipWrite(output_zip,
+             '{}.transfer.list'.format(self.path),
+             '{}.transfer.list'.format(self.partition))
+    ZipWrite(output_zip,
+             '{}.new.dat'.format(self.path),
+             '{}.new.dat'.format(self.partition))
+    ZipWrite(output_zip,
+             '{}.patch.dat'.format(self.path),
+             '{}.patch.dat'.format(self.partition),
+             compress_type=zipfile.ZIP_STORED)
 
-    call = (('block_image_update("%s", '
-             'package_extract_file("%s.transfer.list"), '
-             '"%s.new.dat", "%s.patch.dat");\n') %
-            (self.device, partition, partition, partition))
-    script.AppendExtra(script._WordWrap(call))
+    call = ('block_image_update("{device}", '
+            'package_extract_file("{partition}.transfer.list"), '
+            '"{partition}.new.dat", "{partition}.patch.dat");\n'.format(
+                device=self.device, partition=self.partition))
+    script.AppendExtra(script.WordWrap(call))
 
-  # TODO(tbao): Due to http://b/20939131, block 0 may be changed without
-  # remounting R/W. Will change the checking to a finer-grained way to
-  # mask off those bits.
+  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 _CheckFirstBlock(self, script):
-    r = RangeSet((0, 1))
-    h = sha1()
-    for data in self.src.ReadRangeSet(r):
-      h.update(data)
-    h = h.hexdigest()
+    r = rangelib.RangeSet((0, 1))
+    srchash = self._HashBlocks(self.src, r)
 
     script.AppendExtra(('(range_sha1("%s", "%s") == "%s") || '
                         'abort("%s has been remounted R/W; '
                         'reflash device to reenable OTA updates");')
-                       % (self.device, r.to_string_raw(), h, self.device))
-
+                       % (self.device, r.to_string_raw(), srchash,
+                          self.device))
 
 DataImage = blockimgdiff.DataImage
 
 
 # map recovery.fstab's fs_types to mount/format "partition types"
-PARTITION_TYPES = { "yaffs2": "MTD", "mtd": "MTD",
-                    "ext4": "EMMC", "emmc": "EMMC",
-                    "f2fs": "EMMC" }
+PARTITION_TYPES = {
+    "yaffs2": "MTD",
+    "mtd": "MTD",
+    "ext4": "EMMC",
+    "emmc": "EMMC",
+    "f2fs": "EMMC",
+    "squashfs": "EMMC"
+}
 
 def GetTypeAndDevice(mount_point, info):
   fstab = info["fstab"]
   if fstab:
-    return PARTITION_TYPES[fstab[mount_point].fs_type], fstab[mount_point].device
+    return (PARTITION_TYPES[fstab[mount_point].fs_type],
+            fstab[mount_point].device)
   else:
-    return None
+    raise KeyError
 
 
 def ParseCertificate(data):
@@ -1176,14 +1274,11 @@
   _, _, patch = d.ComputePatch()
   output_sink("recovery-from-boot.p", patch)
 
-  td_pair = GetTypeAndDevice("/boot", info_dict)
-  if not td_pair:
+  try:
+    boot_type, boot_device = GetTypeAndDevice("/boot", info_dict)
+    recovery_type, recovery_device = GetTypeAndDevice("/recovery", info_dict)
+  except KeyError:
     return
-  boot_type, boot_device = td_pair
-  td_pair = GetTypeAndDevice("/recovery", info_dict)
-  if not td_pair:
-    return
-  recovery_type, recovery_device = td_pair
 
   sh = """#!/system/bin/sh
 if ! applypatch -c %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then
@@ -1191,16 +1286,15 @@
 else
   log -t recovery "Recovery image already installed"
 fi
-""" % { 'boot_size': boot_img.size,
-        'boot_sha1': boot_img.sha1,
-        'recovery_size': recovery_img.size,
-        'recovery_sha1': recovery_img.sha1,
-        'boot_type': boot_type,
-        'boot_device': boot_device,
-        'recovery_type': recovery_type,
-        'recovery_device': recovery_device,
-        'bonus_args': bonus_args,
-        }
+""" % {'boot_size': boot_img.size,
+       'boot_sha1': boot_img.sha1,
+       'recovery_size': recovery_img.size,
+       'recovery_sha1': recovery_img.sha1,
+       'boot_type': boot_type,
+       'boot_device': boot_device,
+       'recovery_type': recovery_type,
+       'recovery_device': recovery_device,
+       'bonus_args': bonus_args}
 
   # The install script location moved from /system/etc to /system/bin
   # in the L release.  Parse the init.rc file to find out where the
@@ -1209,12 +1303,12 @@
   try:
     with open(os.path.join(input_dir, "BOOT", "RAMDISK", "init.rc")) as f:
       for line in f:
-        m = re.match("^service flash_recovery /system/(\S+)\s*$", line)
+        m = re.match(r"^service flash_recovery /system/(\S+)\s*$", line)
         if m:
           sh_location = m.group(1)
           print "putting script in", sh_location
           break
-  except (OSError, IOError), e:
+  except (OSError, IOError) as e:
     print "failed to read init.rc: %s" % (e,)
 
   output_sink(sh_location, sh)
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index e52c264..3d0da88 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import os
 import re
 
 import common
@@ -36,7 +35,7 @@
     return x
 
   @staticmethod
-  def _WordWrap(cmd, linelen=80):
+  def WordWrap(cmd, linelen=80):
     """'cmd' should be a function call with null characters after each
     parameter (eg, "somefun(foo,\0bar,\0baz)").  This function wraps cmd
     to a given line length, replacing nulls with spaces and/or newlines
@@ -74,35 +73,33 @@
       raise ValueError("must specify an OEM property")
     if not value:
       raise ValueError("must specify the OEM value")
-    cmd = ('file_getprop("/oem/oem.prop", "%s") == "%s" || '
-           'abort("This package expects the value \\"%s\\"  for '
-           '\\"%s\\" on the OEM partition; '
-           'this has value \\"" + file_getprop("/oem/oem.prop") + "\\".");'
-           ) % (name, value, name, value)
+    cmd = ('file_getprop("/oem/oem.prop", "{name}") == "{value}" || '
+           'abort("This package expects the value \\"{value}\\" for '
+           '\\"{name}\\" on the OEM partition; this has value \\"" + '
+           'file_getprop("/oem/oem.prop", "{name}") + "\\".");').format(
+               name=name, value=value)
     self.script.append(cmd)
 
   def AssertSomeFingerprint(self, *fp):
     """Assert that the current recovery build fingerprint is one of *fp."""
     if not fp:
       raise ValueError("must specify some fingerprints")
-    cmd = (
-           ' ||\n    '.join([('getprop("ro.build.fingerprint") == "%s"')
-                        % i for i in fp]) +
+    cmd = (' ||\n    '.join([('getprop("ro.build.fingerprint") == "%s"') % i
+                             for i in fp]) +
            ' ||\n    abort("Package expects build fingerprint of %s; this '
-           'device has " + getprop("ro.build.fingerprint") + ".");'
-           ) % (" or ".join(fp),)
+           'device has " + getprop("ro.build.fingerprint") + ".");') % (
+               " or ".join(fp))
     self.script.append(cmd)
 
   def AssertSomeThumbprint(self, *fp):
     """Assert that the current recovery build thumbprint is one of *fp."""
     if not fp:
       raise ValueError("must specify some thumbprints")
-    cmd = (
-           ' ||\n    '.join([('getprop("ro.build.thumbprint") == "%s"')
-                        % i for i in fp]) +
+    cmd = (' ||\n    '.join([('getprop("ro.build.thumbprint") == "%s"') % i
+                             for i in fp]) +
            ' ||\n    abort("Package expects build thumbprint of %s; this '
-           'device has " + getprop("ro.build.thumbprint") + ".");'
-           ) % (" or ".join(fp),)
+           'device has " + getprop("ro.build.thumbprint") + ".");') % (
+               " or ".join(fp))
     self.script.append(cmd)
 
   def AssertOlderBuild(self, timestamp, timestamp_text):
@@ -111,15 +108,15 @@
     self.script.append(
         ('(!less_than_int(%s, getprop("ro.build.date.utc"))) || '
          'abort("Can\'t install this package (%s) over newer '
-         'build (" + getprop("ro.build.date") + ").");'
-         ) % (timestamp, timestamp_text))
+         'build (" + getprop("ro.build.date") + ").");') % (timestamp,
+                                                            timestamp_text))
 
   def AssertDevice(self, device):
     """Assert that the device identifier is the given string."""
     cmd = ('getprop("ro.product.device") == "%s" || '
            'abort("This package is for \\"%s\\" devices; '
-           'this is a \\"" + getprop("ro.product.device") + "\\".");'
-           ) % (device, device)
+           'this is a \\"" + getprop("ro.product.device") + "\\".");') % (
+               device, device)
     self.script.append(cmd)
 
   def AssertSomeBootloader(self, *bootloaders):
@@ -128,7 +125,7 @@
            " ||\0".join(['getprop("ro.bootloader") == "%s"' % (b,)
                          for b in bootloaders]) +
            ");")
-    self.script.append(self._WordWrap(cmd))
+    self.script.append(self.WordWrap(cmd))
 
   def ShowProgress(self, frac, dur):
     """Update the progress bar, advancing it over 'frac' over the next
@@ -180,9 +177,9 @@
           if "=" in option:
             key, value = option.split("=", 1)
             mount_dict[key] = value
-      self.script.append('mount("%s", "%s", "%s", "%s", "%s");' %
-                         (p.fs_type, common.PARTITION_TYPES[p.fs_type],
-                          p.device, p.mount_point, mount_dict.get(p.fs_type, "")))
+      self.script.append('mount("%s", "%s", "%s", "%s", "%s");' % (
+          p.fs_type, common.PARTITION_TYPES[p.fs_type], p.device,
+          p.mount_point, mount_dict.get(p.fs_type, "")))
       self.mounts.add(p.mount_point)
 
   def UnpackPackageDir(self, src, dst):
@@ -205,18 +202,17 @@
     fstab = self.info.get("fstab", None)
     if fstab:
       p = fstab[partition]
-      if (p.fs_type not in ( "ext2", "ext3", "ext4")):
+      if p.fs_type not in ("ext2", "ext3", "ext4"):
         raise ValueError("Partition %s cannot be tuned\n" % (partition,))
-    self.script.append('tune2fs(' +
-                       "".join(['"%s", ' % (i,) for i in options]) +
-                       '"%s") || abort("Failed to tune partition %s");'
-                       % ( p.device,partition));
+    self.script.append(
+        'tune2fs(' + "".join(['"%s", ' % (i,) for i in options]) +
+        '"%s") || abort("Failed to tune partition %s");' % (
+            p.device, partition))
 
   def FormatPartition(self, partition):
     """Format the given partition, specified by its mount point (eg,
     "/system")."""
 
-    reserve_size = 0
     fstab = self.info.get("fstab", None)
     if fstab:
       p = fstab[partition]
@@ -235,9 +231,10 @@
 
   def DeleteFiles(self, file_list):
     """Delete all files in file_list."""
-    if not file_list: return
+    if not file_list:
+      return
     cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");"
-    self.script.append(self._WordWrap(cmd))
+    self.script.append(self.WordWrap(cmd))
 
   def RenameFile(self, srcfile, tgtfile):
     """Moves a file from one location to another."""
@@ -251,7 +248,7 @@
        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))
+    self.script.append(self.WordWrap(cmd))
 
   def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
     """Apply binary patches (in *patchpairs) to the given srcfile to
@@ -265,7 +262,7 @@
       cmd.append(',\0%s, package_extract_file("%s")' % patchpairs[i:i+2])
     cmd.append(');')
     cmd = "".join(cmd)
-    self.script.append(self._WordWrap(cmd))
+    self.script.append(self.WordWrap(cmd))
 
   def WriteRawImage(self, mount_point, fn, mapfn=None):
     """Write the given package file into the partition for the given
@@ -289,33 +286,37 @@
           self.script.append(
               'package_extract_file("%(fn)s", "%(device)s");' % args)
       else:
-        raise ValueError("don't know how to write \"%s\" partitions" % (p.fs_type,))
+        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"
+      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 += ', "selabel", "%s"' % selabel
       cmd += ');'
       self.script.append(cmd)
 
-  def SetPermissionsRecursive(self, fn, uid, gid, dmode, fmode, selabel, capabilities):
+  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"
+      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 += ', "selabel", "%s"' % selabel
       cmd += ');'
       self.script.append(cmd)
 
@@ -328,15 +329,15 @@
     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))
+      self.script.append(self.WordWrap(cmd))
 
   def AppendExtra(self, extra):
     """Append text verbatim to the output script."""
     self.script.append(extra)
 
   def Unmount(self, mount_point):
-    self.script.append('unmount("%s");' % (mount_point,))
-    self.mounts.remove(mount_point);
+    self.script.append('unmount("%s");' % mount_point)
+    self.mounts.remove(mount_point)
 
   def UnmountAll(self):
     for p in sorted(self.mounts):
@@ -359,4 +360,4 @@
     else:
       data = open(input_path, "rb").read()
     common.ZipWriteStr(output_zip, "META-INF/com/google/android/update-binary",
-                       data, perms=0755)
+                       data, perms=0o755)
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 4b88e73..8c5acd8 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -32,18 +32,10 @@
   print >> sys.stderr, "Python 2.7 or newer is required."
   sys.exit(1)
 
-import errno
 import os
-import re
 import shutil
-import subprocess
-import tempfile
 import zipfile
 
-# missing in Python 2.4 and before
-if not hasattr(os, "SEEK_SET"):
-  os.SEEK_SET = 0
-
 import common
 
 OPTIONS = common.OPTIONS
@@ -58,7 +50,7 @@
 def main(argv):
   bootable_only = [False]
 
-  def option_handler(o, a):
+  def option_handler(o, _):
     if o in ("-z", "--bootable_zip"):
       bootable_only[0] = True
     else:
@@ -88,11 +80,13 @@
       # and all we have to do is copy them to the output zip.
       images = os.listdir(images_path)
       if images:
-        for i in images:
-          if bootable_only and i not in ("boot.img", "recovery.img"): continue
-          if not i.endswith(".img"): continue
-          with open(os.path.join(images_path, i), "r") as f:
-            common.ZipWriteStr(output_zip, i, f.read())
+        for image in images:
+          if bootable_only and image not in ("boot.img", "recovery.img"):
+            continue
+          if not image.endswith(".img"):
+            continue
+          common.ZipWrite(
+              output_zip, os.path.join(images_path, image), image)
         done = True
 
     if not done:
@@ -114,7 +108,7 @@
       boot_image = common.GetBootableImage(
           "boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
       if boot_image:
-          boot_image.AddToZip(output_zip)
+        boot_image.AddToZip(output_zip)
       recovery_image = common.GetBootableImage(
           "recovery.img", "recovery.img", OPTIONS.input_tmp, "RECOVERY")
       if recovery_image:
@@ -139,7 +133,13 @@
 
   finally:
     print "cleaning up..."
+    # http://b/18015246
+    # See common.py for context.  zipfile also refers to ZIP64_LIMIT during
+    # close() when it writes out the central directory.
+    saved_zip64_limit = zipfile.ZIP64_LIMIT
+    zipfile.ZIP64_LIMIT = (1 << 32) - 1
     output_zip.close()
+    zipfile.ZIP64_LIMIT = saved_zip64_limit
     shutil.rmtree(OPTIONS.input_tmp)
 
   print "done."
@@ -149,7 +149,7 @@
   try:
     common.CloseInheritedPipes()
     main(sys.argv[1:])
-  except common.ExternalError, e:
+  except common.ExternalError as e:
     print
     print "   ERROR: %s" % (e,)
     print
diff --git a/tools/releasetools/make_recovery_patch b/tools/releasetools/make_recovery_patch
new file mode 120000
index 0000000..45cec08
--- /dev/null
+++ b/tools/releasetools/make_recovery_patch
@@ -0,0 +1 @@
+make_recovery_patch.py
\ No newline at end of file
diff --git a/tools/releasetools/make_recovery_patch b/tools/releasetools/make_recovery_patch.py
similarity index 100%
rename from tools/releasetools/make_recovery_patch
rename to tools/releasetools/make_recovery_patch.py
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
new file mode 120000
index 0000000..6755a90
--- /dev/null
+++ b/tools/releasetools/ota_from_target_files
@@ -0,0 +1 @@
+ota_from_target_files.py
\ No newline at end of file
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files.py
similarity index 84%
rename from tools/releasetools/ota_from_target_files
rename to tools/releasetools/ota_from_target_files.py
index 768f4cb..eab3daa 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files.py
@@ -37,6 +37,11 @@
       Generate an incremental OTA using the given target-files zip as
       the starting build.
 
+  --full_radio
+      When generating an incremental OTA, always include a full copy of
+      radio image. This option is only meaningful when -i is specified,
+      because a full radio is always included in a full OTA if applicable.
+
   -v  (--verify)
       Remount and verify the checksums of the files written to the
       system and vendor (if used) partitions.  Incremental builds only.
@@ -88,21 +93,13 @@
   sys.exit(1)
 
 import copy
-import errno
 import multiprocessing
 import os
-import re
-import subprocess
 import tempfile
-import time
 import zipfile
 
-from hashlib import sha1 as sha1
-
 import common
 import edify_generator
-import build_image
-import blockimgdiff
 import sparse_img
 
 OPTIONS = common.OPTIONS
@@ -125,12 +122,14 @@
 OPTIONS.updater_binary = None
 OPTIONS.oem_source = None
 OPTIONS.fallback_to_full = True
+OPTIONS.full_radio = False
 
 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
+  if not x:
+    return default
   x.sort()
   return x[-1][1]
 
@@ -138,12 +137,12 @@
 def IsSymlink(info):
   """Return true if the zipfile.ZipInfo object passed in represents a
   symlink."""
-  return (info.external_attr >> 16) == 0120777
+  return (info.external_attr >> 16) == 0o120777
 
 def IsRegular(info):
   """Return true if the zipfile.ZipInfo object passed in represents a
   symlink."""
-  return (info.external_attr >> 28) == 010
+  return (info.external_attr >> 28) == 0o10
 
 def ClosestFileMatch(src, tgtfiles, existing):
   """Returns the closest file match between a source file and list
@@ -170,15 +169,15 @@
     return result
   return None
 
-class ItemSet:
+class ItemSet(object):
   def __init__(self, partition, fs_config):
     self.partition = partition
     self.fs_config = fs_config
     self.ITEMS = {}
 
-  def Get(self, name, dir=False):
+  def Get(self, name, is_dir=False):
     if name not in self.ITEMS:
-      self.ITEMS[name] = Item(self, name, dir=dir)
+      self.ITEMS[name] = Item(self, name, is_dir=is_dir)
     return self.ITEMS[name]
 
   def GetMetadata(self, input_zip):
@@ -187,7 +186,8 @@
     output = input_zip.read(self.fs_config)
 
     for line in output.split("\n"):
-      if not line: continue
+      if not line:
+        continue
       columns = line.split()
       name, uid, gid, mode = columns[:4]
       selabel = None
@@ -209,20 +209,22 @@
         i.mode = int(mode, 8)
         i.selabel = selabel
         i.capabilities = capabilities
-        if i.dir:
+        if i.is_dir:
           i.children.sort(key=lambda i: i.name)
 
     # set metadata for the files generated by this script.
     i = self.ITEMS.get("system/recovery-from-boot.p", None)
-    if i: i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0644, None, 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, 0544, None, None
+    if i:
+      i.uid, i.gid, i.mode, i.selabel, i.capabilities = 0, 0, 0o544, None, None
 
 
-class Item:
+class Item(object):
   """Items represent the metadata (user, group, mode) of files and
   directories in the system image."""
-  def __init__(self, itemset, name, dir=False):
+  def __init__(self, itemset, name, is_dir=False):
     self.itemset = itemset
     self.name = name
     self.uid = None
@@ -230,22 +232,26 @@
     self.mode = None
     self.selabel = None
     self.capabilities = None
-    self.dir = dir
+    self.is_dir = is_dir
+    self.descendants = None
+    self.best_subtree = None
 
     if name:
-      self.parent = itemset.Get(os.path.dirname(name), dir=True)
+      self.parent = itemset.Get(os.path.dirname(name), is_dir=True)
       self.parent.children.append(self)
     else:
       self.parent = None
-    if dir:
+    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)
+      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.dir:
+      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:
@@ -253,21 +259,24 @@
 
   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
+    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.
+    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.dir
-    d = self.descendants = {(self.uid, self.gid, self.mode, None, self.selabel, self.capabilities): 1}
+    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.dir:
+      if i.is_dir:
         for k, v in i.CountChildMetadata().iteritems():
           d[k] = d.get(k, 0) + v
       else:
@@ -286,17 +295,23 @@
 
     # Now find the dmode, fmode, selabel, and capabilities that match
     # the most descendants with that (uid, gid), and choose those.
-    best_dmode = (0, 0755)
-    best_fmode = (0, 0644)
+    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])
+      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
 
@@ -308,11 +323,11 @@
     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
+      # 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.dir:
+      if item.is_dir:
         if current != item.best_subtree:
           script.SetPermissionsRecursive("/"+item.name, *item.best_subtree)
           current = item.best_subtree
@@ -349,8 +364,9 @@
   partition = itemset.partition
 
   for info in input_zip.infolist():
-    if info.filename.startswith(partition.upper() + "/"):
-      basefilename = info.filename[7:]
+    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))
@@ -366,9 +382,9 @@
             data = input_zip.read(info.filename)
           output_zip.writestr(info2, data)
         if fn.endswith("/"):
-          itemset.Get(fn[:-1], dir=True)
+          itemset.Get(fn[:-1], is_dir=True)
         else:
-          itemset.Get(fn, dir=False)
+          itemset.Get(fn)
 
   symlinks.sort()
   return symlinks
@@ -382,17 +398,19 @@
                   whole_file=True)
 
 
-def AppendAssertions(script, info_dict, oem_dict = None):
+def AppendAssertions(script, info_dict, oem_dict=None):
   oem_props = info_dict.get("oem_fingerprint_properties")
   if oem_props is None or len(oem_props) == 0:
     device = GetBuildProp("ro.product.device", info_dict)
     script.AssertDevice(device)
   else:
     if oem_dict is None:
-      raise common.ExternalError("No OEM file provided to answer expected assertions")
+      raise common.ExternalError(
+          "No OEM file provided to answer expected assertions")
     for prop in oem_props.split():
       if oem_dict.get(prop) is None:
-        raise common.ExternalError("The OEM file is missing the property %s" % prop)
+        raise common.ExternalError(
+            "The OEM file is missing the property %s" % prop)
       script.AssertOemProperty(prop, oem_dict.get(prop))
 
 
@@ -420,10 +438,10 @@
   if oem_props is None:
     return GetBuildProp("ro.build.fingerprint", info_dict)
   return "%s/%s/%s:%s" % (
-    GetOemProperty("ro.product.brand", oem_props, oem_dict, info_dict),
-    GetOemProperty("ro.product.name", oem_props, oem_dict, info_dict),
-    GetOemProperty("ro.product.device", oem_props, oem_dict, info_dict),
-    GetBuildProp("ro.build.thumbprint", info_dict))
+      GetOemProperty("ro.product.brand", oem_props, oem_dict, info_dict),
+      GetOemProperty("ro.product.name", oem_props, oem_dict, info_dict),
+      GetOemProperty("ro.product.device", oem_props, oem_dict, info_dict),
+      GetBuildProp("ro.build.thumbprint", info_dict))
 
 
 def GetImage(which, tmpdir, info_dict):
@@ -457,13 +475,7 @@
       path = add_img_to_target_files.BuildVendor(
           tmpdir, info_dict, block_list=mappath)
 
-  # Bug: http://b/20939131
-  # In ext4 filesystems, block 0 might be changed even being mounted
-  # R/O. We add it to clobbered_blocks so that it will be written to the
-  # target unconditionally. Note that they are still part of care_map.
-  clobbered_blocks = "0"
-
-  return sparse_img.SparseImage(path, mappath, clobbered_blocks)
+  return sparse_img.SparseImage(path, mappath)
 
 
 def WriteFullOTAPackage(input_zip, output_zip):
@@ -479,15 +491,16 @@
     if OPTIONS.oem_source is None:
       raise common.ExternalError("OEM source required for this build")
     script.Mount("/oem", recovery_mount_options)
-    oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
+    oem_dict = common.LoadDictionaryFromLines(
+        open(OPTIONS.oem_source).readlines())
 
-  metadata = {"post-build": CalculateFingerprint(
-                               oem_props, oem_dict, OPTIONS.info_dict),
-              "pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
+  metadata = {
+      "post-build": CalculateFingerprint(oem_props, oem_dict,
                                          OPTIONS.info_dict),
-              "post-timestamp": GetBuildProp("ro.build.date.utc",
-                                             OPTIONS.info_dict),
-              }
+      "pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
+                                   OPTIONS.info_dict),
+      "post-timestamp": GetBuildProp("ro.build.date.utc", OPTIONS.info_dict),
+  }
 
   device_specific = common.DeviceSpecificParams(
       input_zip=input_zip,
@@ -526,7 +539,8 @@
   #    do normal full package installation:
   #       wipe and install system, boot image, etc.
   #       set up system to update recovery partition on first boot
-  #    complete script normally (allow recovery to mark itself finished and reboot)
+  #    complete script normally
+  #    (allow recovery to mark itself finished and reboot)
 
   recovery_img = common.GetBootableImage("recovery.img", "recovery.img",
                                          OPTIONS.input_tmp, "RECOVERY")
@@ -548,6 +562,10 @@
 else if get_stage("%(bcb_dev)s") == "3/3" then
 """ % bcb_dev)
 
+  # Dump fingerprints
+  script.Print("Target: %s" % CalculateFingerprint(
+      oem_props, oem_dict, OPTIONS.info_dict))
+
   device_specific.FullOTA_InstallBegin()
 
   system_progress = 0.75
@@ -590,7 +608,7 @@
   if not block_based:
     def output_sink(fn, data):
       common.ZipWriteStr(output_zip, "recovery/" + fn, data)
-      system_items.Get("system/" + fn, dir=False)
+      system_items.Get("system/" + fn)
 
     common.MakeRecoveryPatch(OPTIONS.input_tmp, output_sink,
                              recovery_img, boot_img)
@@ -652,10 +670,8 @@
   WriteMetadata(metadata, output_zip)
 
 
-def WritePolicyConfig(file_context, output_zip):
-  f = open(file_context, 'r');
-  basename = os.path.basename(file_context)
-  common.ZipWriteStr(output_zip, basename, f.read())
+def WritePolicyConfig(file_name, output_zip):
+  common.ZipWrite(output_zip, file_name, os.path.basename(file_name))
 
 
 def WriteMetadata(metadata, output_zip):
@@ -671,7 +687,7 @@
   prefix = partition.upper() + "/"
   for info in z.infolist():
     if info.filename.startswith(prefix) and not IsSymlink(info):
-      basefilename = info.filename[7:]
+      basefilename = info.filename[len(prefix):]
       fn = partition + "/" + basefilename
       data = z.read(info.filename)
       out[fn] = common.File(fn, data)
@@ -693,7 +709,7 @@
   while len(dirs) > 0:
     path = "/".join(dirs)
     if path in known_paths:
-      break;
+      break
     known_paths.add(path)
     dirs.pop()
 
@@ -708,11 +724,12 @@
   script = edify_generator.EdifyGenerator(source_version,
                                           OPTIONS.target_info_dict)
 
-  metadata = {"pre-device": GetBuildProp("ro.product.device",
-                                         OPTIONS.source_info_dict),
-              "post-timestamp": GetBuildProp("ro.build.date.utc",
-                                             OPTIONS.target_info_dict),
-              }
+  metadata = {
+      "pre-device": GetBuildProp("ro.product.device",
+                                 OPTIONS.source_info_dict),
+      "post-timestamp": GetBuildProp("ro.build.date.utc",
+                                     OPTIONS.target_info_dict),
+  }
 
   device_specific = common.DeviceSpecificParams(
       source_zip=source_zip,
@@ -724,6 +741,12 @@
       metadata=metadata,
       info_dict=OPTIONS.info_dict)
 
+  # TODO: Currently this works differently from WriteIncrementalOTAPackage().
+  # This function doesn't consider thumbprints when writing
+  # metadata["pre/post-build"]. One possible reason is that the current
+  # devices with thumbprints are all using file-based OTAs. Long term we
+  # should factor out the common parts into a shared one to avoid further
+  # divergence.
   source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
   target_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.target_info_dict)
   metadata["pre-build"] = source_fp
@@ -737,12 +760,8 @@
   updating_boot = (not OPTIONS.two_step and
                    (source_boot.data != target_boot.data))
 
-  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)
 
   system_src = GetImage("system", OPTIONS.source_tmp, OPTIONS.source_info_dict)
   system_tgt = GetImage("system", OPTIONS.target_tmp, OPTIONS.target_info_dict)
@@ -754,28 +773,32 @@
         OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(","))
 
   system_diff = common.BlockDifference("system", system_tgt, system_src,
-                                       check_first_block=False,
+                                       check_first_block=True,
                                        version=blockimgdiff_version)
 
   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,
+                          OPTIONS.source_info_dict)
+    vendor_tgt = GetImage("vendor", OPTIONS.target_tmp,
+                          OPTIONS.target_info_dict)
     vendor_diff = common.BlockDifference("vendor", vendor_tgt, vendor_src,
-                                         check_first_block=False,
+                                         check_first_block=True,
                                          version=blockimgdiff_version)
   else:
     vendor_diff = None
 
   oem_props = OPTIONS.target_info_dict.get("oem_fingerprint_properties")
-  recovery_mount_options = OPTIONS.target_info_dict.get("recovery_mount_options")
+  recovery_mount_options = OPTIONS.target_info_dict.get(
+      "recovery_mount_options")
   oem_dict = None
   if oem_props is not None and len(oem_props) > 0:
     if OPTIONS.oem_source is None:
       raise common.ExternalError("OEM source required for this build")
     script.Mount("/oem", recovery_mount_options)
-    oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
+    oem_dict = common.LoadDictionaryFromLines(
+        open(OPTIONS.oem_source).readlines())
 
   AppendAssertions(script, OPTIONS.target_info_dict, oem_dict)
   device_specific.IncrementalOTA_Assertions()
@@ -799,7 +822,8 @@
   #       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)
+  #    complete script normally
+  #    (allow recovery to mark itself finished and reboot)
 
   if OPTIONS.two_step:
     if not OPTIONS.info_dict.get("multistage_support", None):
@@ -812,7 +836,7 @@
     script.AppendExtra("""
 if get_stage("%(bcb_dev)s") == "2/3" then
 """ % bcb_dev)
-    script.AppendExtra("sleep(20);\n");
+    script.AppendExtra("sleep(20);\n")
     script.WriteRawImage("/recovery", "recovery.img")
     script.AppendExtra("""
 set_stage("%(bcb_dev)s", "3/3");
@@ -820,6 +844,12 @@
 else if get_stage("%(bcb_dev)s") != "3/3" then
 """ % bcb_dev)
 
+  # Dump fingerprints
+  script.Print("Source: %s" % CalculateFingerprint(
+      oem_props, oem_dict, OPTIONS.source_info_dict))
+  script.Print("Target: %s" % CalculateFingerprint(
+      oem_props, oem_dict, OPTIONS.target_info_dict))
+
   script.Print("Verifying current system...")
 
   device_specific.IncrementalOTA_VerifyBegin()
@@ -936,8 +966,9 @@
   WriteMetadata(metadata, output_zip)
 
 
-class FileDifference:
+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..."
@@ -1010,7 +1041,7 @@
 
   def EmitVerification(self, script):
     so_far = 0
-    for tf, sf, size, patch_sha in self.patch_list:
+    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)
@@ -1018,18 +1049,18 @@
     return so_far
 
   def EmitExplicitTargetVerification(self, script):
-    for fn, size, sha1 in self.verbatim_targets:
-      if (fn[-1] != "/"):
+    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=()):
-    script.DeleteFiles(["/"+i[0] for i in self.verbatim_targets] +
-                       ["/"+i for i in sorted(self.source_data)
-                              if i not in self.target_data and
-                              i not in self.renames] +
-                       list(extras))
+    script.DeleteFiles(
+        ["/" + i[0] for i in self.verbatim_targets] +
+        ["/" + i for i in sorted(self.source_data)
+         if i not in self.target_data and i not in self.renames] +
+        list(extras))
 
   def TotalPatchSize(self):
     return sum(i[1].size for i in self.patch_list)
@@ -1037,22 +1068,24 @@
   def EmitPatches(self, script, total_patch_size, so_far):
     self.deferred_patch_list = deferred_patch_list = []
     for item in self.patch_list:
-      tf, sf, size, _ = item
+      tf, sf, _, _ = item
       if tf.name == "system/build.prop":
         deferred_patch_list.append(item)
         continue
-      if (sf.name != tf.name):
+      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")
+      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, size, _ = item
-      script.ApplyPatch("/"+sf.name, "-", tf.size, tf.sha1, sf.sha1, "patch/"+sf.name+".p")
-    script.SetPermissions("/system/build.prop", 0, 0, 0644, None, None)
+      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:
@@ -1062,8 +1095,6 @@
         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)
@@ -1089,13 +1120,15 @@
     if OPTIONS.oem_source is None:
       raise common.ExternalError("OEM source required for this build")
     script.Mount("/oem", recovery_mount_options)
-    oem_dict = common.LoadDictionaryFromLines(open(OPTIONS.oem_source).readlines())
+    oem_dict = common.LoadDictionaryFromLines(
+        open(OPTIONS.oem_source).readlines())
 
-  metadata = {"pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
-                                         OPTIONS.source_info_dict),
-              "post-timestamp": GetBuildProp("ro.build.date.utc",
-                                             OPTIONS.target_info_dict),
-              }
+  metadata = {
+      "pre-device": GetOemProperty("ro.product.device", oem_props, oem_dict,
+                                   OPTIONS.source_info_dict),
+      "post-timestamp": GetBuildProp("ro.build.date.utc",
+                                     OPTIONS.target_info_dict),
+  }
 
   device_specific = common.DeviceSpecificParams(
       source_zip=source_zip,
@@ -1115,8 +1148,10 @@
   else:
     vendor_diff = None
 
-  target_fp = CalculateFingerprint(oem_props, oem_dict, OPTIONS.target_info_dict)
-  source_fp = CalculateFingerprint(oem_props, oem_dict, OPTIONS.source_info_dict)
+  target_fp = CalculateFingerprint(oem_props, oem_dict,
+                                   OPTIONS.target_info_dict)
+  source_fp = CalculateFingerprint(oem_props, oem_dict,
+                                   OPTIONS.source_info_dict)
 
   if oem_props is None:
     script.AssertSomeFingerprint(source_fp, target_fp)
@@ -1171,7 +1206,8 @@
   #       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)
+  #    complete script normally
+  #    (allow recovery to mark itself finished and reboot)
 
   if OPTIONS.two_step:
     if not OPTIONS.info_dict.get("multistage_support", None):
@@ -1184,7 +1220,7 @@
     script.AppendExtra("""
 if get_stage("%(bcb_dev)s") == "2/3" then
 """ % bcb_dev)
-    script.AppendExtra("sleep(20);\n");
+    script.AppendExtra("sleep(20);\n")
     script.WriteRawImage("/recovery", "recovery.img")
     script.AppendExtra("""
 set_stage("%(bcb_dev)s", "3/3");
@@ -1192,6 +1228,10 @@
 else if get_stage("%(bcb_dev)s") != "3/3" then
 """ % bcb_dev)
 
+  # Dump fingerprints
+  script.Print("Source: %s" % (source_fp,))
+  script.Print("Target: %s" % (target_fp,))
+
   script.Print("Verifying current system...")
 
   device_specific.IncrementalOTA_VerifyBegin()
@@ -1218,9 +1258,11 @@
     so_far += source_boot.size
 
   size = []
-  if system_diff.patch_list: size.append(system_diff.largest_source_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 vendor_diff.patch_list:
+      size.append(vendor_diff.largest_source_size)
   if size or updating_recovery or updating_boot:
     script.CacheFreeSpaceCheck(max(size))
 
@@ -1297,7 +1339,7 @@
     if not target_has_recovery_patch:
       def output_sink(fn, data):
         common.ZipWriteStr(output_zip, "recovery/" + fn, data)
-        system_items.Get("system/" + fn, dir=False)
+        system_items.Get("system/" + fn)
 
       common.MakeRecoveryPatch(OPTIONS.target_tmp, output_sink,
                                target_recovery, target_boot)
@@ -1420,6 +1462,8 @@
       OPTIONS.package_key = a
     elif o in ("-i", "--incremental_from"):
       OPTIONS.incremental_source = a
+    elif o == "--full_radio":
+      OPTIONS.full_radio = True
     elif o in ("-w", "--wipe_user_data"):
       OPTIONS.wipe_user_data = True
     elif o in ("-n", "--no_prereq"):
@@ -1443,7 +1487,7 @@
       OPTIONS.two_step = True
     elif o == "--no_signing":
       OPTIONS.no_signing = True
-    elif o in ("--verify"):
+    elif o == "--verify":
       OPTIONS.verify = True
     elif o == "--block":
       OPTIONS.block_based = True
@@ -1457,23 +1501,24 @@
 
   args = common.ParseOptions(argv, __doc__,
                              extra_opts="b:k:i:d:wne:t:a:2o:",
-                             extra_long_opts=["board_config=",
-                                              "package_key=",
-                                              "incremental_from=",
-                                              "wipe_user_data",
-                                              "no_prereq",
-                                              "extra_script=",
-                                              "worker_threads=",
-                                              "aslr_mode=",
-                                              "two_step",
-                                              "no_signing",
-                                              "block",
-                                              "binary=",
-                                              "oem_settings=",
-                                              "verify",
-                                              "no_fallback_to_full",
-                                              ],
-                             extra_option_handler=option_handler)
+                             extra_long_opts=[
+                                 "board_config=",
+                                 "package_key=",
+                                 "incremental_from=",
+                                 "full_radio",
+                                 "wipe_user_data",
+                                 "no_prereq",
+                                 "extra_script=",
+                                 "worker_threads=",
+                                 "aslr_mode=",
+                                 "two_step",
+                                 "no_signing",
+                                 "block",
+                                 "binary=",
+                                 "oem_settings=",
+                                 "verify",
+                                 "no_fallback_to_full",
+                             ], extra_option_handler=option_handler)
 
   if len(args) != 2:
     common.Usage(__doc__)
@@ -1493,8 +1538,8 @@
   # is in the out/ directory tree, but for repacking from target-files.zip it's
   # in the root directory of the ramdisk.
   if "selinux_fc" in OPTIONS.info_dict:
-    OPTIONS.info_dict["selinux_fc"] = os.path.join(OPTIONS.input_tmp, "BOOT", "RAMDISK",
-        "file_contexts")
+    OPTIONS.info_dict["selinux_fc"] = os.path.join(
+        OPTIONS.input_tmp, "BOOT", "RAMDISK", "file_contexts")
 
   if OPTIONS.verbose:
     print "--- target info ---"
@@ -1521,8 +1566,10 @@
   while True:
 
     if OPTIONS.no_signing:
-      if os.path.exists(args[1]): os.unlink(args[1])
-      output_zip = zipfile.ZipFile(args[1], "w", compression=zipfile.ZIP_DEFLATED)
+      if os.path.exists(args[1]):
+        os.unlink(args[1])
+      output_zip = zipfile.ZipFile(args[1], "w",
+                                   compression=zipfile.ZIP_DEFLATED)
     else:
       temp_zip_file = tempfile.NamedTemporaryFile()
       output_zip = zipfile.ZipFile(temp_zip_file, "w",
@@ -1538,12 +1585,13 @@
 
     else:
       print "unzipping source target-files..."
-      OPTIONS.source_tmp, source_zip = common.UnzipTemp(OPTIONS.incremental_source)
+      OPTIONS.source_tmp, source_zip = common.UnzipTemp(
+          OPTIONS.incremental_source)
       OPTIONS.target_info_dict = OPTIONS.info_dict
       OPTIONS.source_info_dict = common.LoadInfoDict(source_zip)
       if "selinux_fc" in OPTIONS.source_info_dict:
-        OPTIONS.source_info_dict["selinux_fc"] = os.path.join(OPTIONS.source_tmp, "BOOT", "RAMDISK",
-                                                              "file_contexts")
+        OPTIONS.source_info_dict["selinux_fc"] = os.path.join(
+            OPTIONS.source_tmp, "BOOT", "RAMDISK", "file_contexts")
       if OPTIONS.package_key is None:
         OPTIONS.package_key = OPTIONS.source_info_dict.get(
             "default_system_dev_certificate",
@@ -1555,7 +1603,8 @@
         WriteIncrementalOTAPackage(input_zip, source_zip, output_zip)
         break
       except ValueError:
-        if not OPTIONS.fallback_to_full: raise
+        if not OPTIONS.fallback_to_full:
+          raise
         print "--- failed to build incremental; falling back to full ---"
         OPTIONS.incremental_source = None
         output_zip.close()
@@ -1573,7 +1622,7 @@
   try:
     common.CloseInheritedPipes()
     main(sys.argv[1:])
-  except common.ExternalError, e:
+  except common.ExternalError as e:
     print
     print "   ERROR: %s" % (e,)
     print
diff --git a/tools/releasetools/pylintrc b/tools/releasetools/pylintrc
new file mode 100644
index 0000000..90de1af
--- /dev/null
+++ b/tools/releasetools/pylintrc
@@ -0,0 +1,382 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+# Use multiple processes to speed up Pylint.
+jobs=1
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code
+extension-pkg-whitelist=
+
+# Allow optimization of some AST trees. This will activate a peephole AST
+# optimizer, which will apply various small optimizations. For instance, it can
+# be used to obtain the result of joining multiple strings with the addition
+# operator. Joining a lot of strings can lead to a maximum recursion error in
+# Pylint and this flag can prevent that. It has one side effect, the resulting
+# AST will be different than the one from reality.
+optimize-ast=no
+
+
+[MESSAGES CONTROL]
+
+# Only show warnings with the listed confidence levels. Leave empty to show
+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
+confidence=
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time. See also the "--disable" option for examples.
+#enable=
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+disable=invalid-name,missing-docstring,too-many-branches,too-many-locals,too-many-arguments,too-many-statements,duplicate-code,too-few-public-methods,too-many-instance-attributes,too-many-lines,too-many-public-methods,locally-disabled,fixme
+
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html. You can also give a reporter class, eg
+# mypackage.mymodule.MyReporterClass.
+output-format=text
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells whether to display a full report or only the messages
+reports=yes
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note). You have access to the variables errors warning, statement which
+# respectively contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (RP0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (RP0004).
+comment=no
+
+# Template used to display messages. This is a python new-style format string
+# used to format the message information. See doc for all details
+#msg-template=
+
+
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
+
+# Ignore imports when computing similarities.
+ignore-imports=no
+
+
+[TYPECHECK]
+
+# Tells whether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# List of module names for which member attributes should not be checked
+# (useful for modules/projects where namespaces are manipulated during runtime
+# and thus existing member attributes cannot be deduced by static analysis
+ignored-modules=
+
+# List of classes names for which member attributes should not be checked
+# (useful for classes with attributes dynamically set).
+ignored-classes=SQLObject
+
+# When zope mode is activated, add a predefined set of Zope acquired attributes
+# to generated-members.
+zope=no
+
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=REQUEST,acl_users,aq_parent
+
+
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,XXX,TODO
+
+
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=map,filter,input
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# Colon-delimited sets of names that determine each other's naming style when
+# the name regexes allow several styles.
+name-group=
+
+# Include a hint for the correct naming format with invalid-name
+include-naming-hint=no
+
+# Regular expression matching correct function names
+function-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for function names
+function-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct variable names
+variable-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for variable names
+variable-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct constant names
+const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Naming hint for constant names
+const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Regular expression matching correct attribute names
+attr-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for attribute names
+attr-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct argument names
+argument-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for argument names
+argument-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct class attribute names
+class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
+
+# Naming hint for class attribute names
+class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
+
+# Regular expression matching correct inline iteration names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Naming hint for inline iteration names
+inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
+
+# Regular expression matching correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Naming hint for class names
+class-name-hint=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression matching correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Naming hint for module names
+module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression matching correct method names
+method-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for method names
+method-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression which should only match function or class names that do
+# not require a docstring.
+no-docstring-rgx=__.*__
+
+# Minimum line length for functions/classes that require docstrings, shorter
+# ones are exempt.
+docstring-min-length=-1
+
+
+[SPELLING]
+
+# Spelling dictionary name. Available dictionaries: none. To make it working
+# install python-enchant package.
+spelling-dict=
+
+# List of comma separated words that should not be checked.
+spelling-ignore-words=
+
+# A path to a file that contains private dictionary; one word per line.
+spelling-private-dict-file=
+
+# Tells whether to store unknown words to indicated private dictionary in
+# --spelling-private-dict-file option instead of raising a message.
+spelling-store-unknown-words=no
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=80
+
+# Regexp for a line that is allowed to be longer than the limit.
+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
+
+# Allow the body of an if to be on the same line as the test if there is no
+# else.
+single-line-if-stmt=no
+
+# List of optional constructs for which whitespace checking is disabled
+no-space-check=trailing-comma,dict-separator
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string='  '
+
+# Number of spaces of indent required inside a hanging or continued line.
+indent-after-paren=4
+
+# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
+expected-line-ending-format=LF
+
+
+[LOGGING]
+
+# Logging modules to check that the string format arguments are in logging
+# function parameter format
+logging-modules=logging
+
+
+[VARIABLES]
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching the name of dummy variables (i.e. expectedly
+# not used).
+dummy-variables-rgx=_$|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+# List of strings which can identify a callback function by name. A callback
+# name must start or end with one of those strings.
+callbacks=cb_,_cb
+
+
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=5
+
+# Argument names that match this expression will be ignored. Default to name
+# with leading underscore
+ignored-argument-names=_.*
+
+# Maximum number of locals for function / method body
+max-locals=15
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branches=12
+
+# Maximum number of statements in function / method body
+max-statements=50
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=7
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report RP0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report RP0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report RP0402 must
+# not be disabled)
+int-import-graph=
+
+
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp
+
+# List of valid names for the first argument in a class method.
+valid-classmethod-first-arg=cls
+
+# List of valid names for the first argument in a metaclass class method.
+valid-metaclass-classmethod-first-arg=mcs
+
+# List of member names, which should be excluded from the protected access
+# warning.
+exclude-protected=_asdict,_fields,_replace,_source,_make
+
+
+[EXCEPTIONS]
+
+# Exceptions that will emit a warning when being caught. Defaults to
+# "Exception"
+overgeneral-exceptions=Exception
diff --git a/tools/releasetools/rangelib.py b/tools/releasetools/rangelib.py
index 7279c60..8b327fe 100644
--- a/tools/releasetools/rangelib.py
+++ b/tools/releasetools/rangelib.py
@@ -24,6 +24,7 @@
   lots of runs."""
 
   def __init__(self, data=None):
+    self.monotonic = False
     if isinstance(data, str):
       self._parse_internal(data)
     elif data:
@@ -185,7 +186,7 @@
     # This is like intersect, but we can stop as soon as we discover the
     # output is going to be nonempty.
     z = 0
-    for p, d in heapq.merge(zip(self.data, itertools.cycle((+1, -1))),
+    for _, d in heapq.merge(zip(self.data, itertools.cycle((+1, -1))),
                             zip(other.data, itertools.cycle((+1, -1)))):
       if (z == 1 and d == 1) or (z == 2 and d == -1):
         return True
diff --git a/tools/releasetools/sign_target_files_apks b/tools/releasetools/sign_target_files_apks
new file mode 120000
index 0000000..b5ec59a
--- /dev/null
+++ b/tools/releasetools/sign_target_files_apks
@@ -0,0 +1 @@
+sign_target_files_apks.py
\ No newline at end of file
diff --git a/tools/releasetools/sign_target_files_apks b/tools/releasetools/sign_target_files_apks.py
similarity index 93%
rename from tools/releasetools/sign_target_files_apks
rename to tools/releasetools/sign_target_files_apks.py
index 931acb8..d47cc4f 100755
--- a/tools/releasetools/sign_target_files_apks
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -169,21 +169,25 @@
           f.write(data)
 
   for info in input_tf_zip.infolist():
-    if info.filename.startswith("IMAGES/"): continue
+    if info.filename.startswith("IMAGES/"):
+      continue
 
     data = input_tf_zip.read(info.filename)
     out_info = copy.copy(info)
 
     if (info.filename == "META/misc_info.txt" and
         OPTIONS.replace_verity_private_key):
-      ReplaceVerityPrivateKey(input_tf_zip, output_tf_zip, misc_info, OPTIONS.replace_verity_private_key[1])
+      ReplaceVerityPrivateKey(input_tf_zip, output_tf_zip, misc_info,
+                              OPTIONS.replace_verity_private_key[1])
     elif (info.filename == "BOOT/RAMDISK/verity_key" and
-        OPTIONS.replace_verity_public_key):
-      ReplaceVerityPublicKey(output_tf_zip, OPTIONS.replace_verity_public_key[1])
+          OPTIONS.replace_verity_public_key):
+      new_data = ReplaceVerityPublicKey(output_tf_zip,
+                                        OPTIONS.replace_verity_public_key[1])
+      write_to_temp(info.filename, info.external_attr, new_data)
     elif (info.filename.startswith("BOOT/") or
-        info.filename.startswith("RECOVERY/") or
-        info.filename.startswith("META/") or
-        info.filename == "SYSTEM/etc/recovery-resource.dat"):
+          info.filename.startswith("RECOVERY/") or
+          info.filename.startswith("META/") or
+          info.filename == "SYSTEM/etc/recovery-resource.dat"):
       write_to_temp(info.filename, info.external_attr, data)
 
     if info.filename.endswith(".apk"):
@@ -230,7 +234,7 @@
   if OPTIONS.replace_ota_keys:
     new_recovery_keys = ReplaceOtaKeys(input_tf_zip, output_tf_zip, misc_info)
     if new_recovery_keys:
-      write_to_temp("RECOVERY/RAMDISK/res/keys", 0755 << 16, new_recovery_keys)
+      write_to_temp("RECOVERY/RAMDISK/res/keys", 0o755 << 16, new_recovery_keys)
 
   if rebuild_recovery:
     recovery_img = common.GetBootableImage(
@@ -267,8 +271,8 @@
       if OPTIONS.verbose:
         print "    Replaced %d occurence(s) of %s.x509.pem with " \
             "%s.x509.pem" % (num, old, new)
-    except IOError, e:
-      if (e.errno == errno.ENOENT and not OPTIONS.verbose):
+    except IOError as e:
+      if e.errno == errno.ENOENT and not OPTIONS.verbose:
         continue
 
       print "    Error accessing %s. %s. Skip replacing %s.x509.pem " \
@@ -302,7 +306,7 @@
         pieces[-1] = EditTags(pieces[-1])
         value = "/".join(pieces)
       elif (key in ("ro.build.thumbprint", "ro.vendor.build.thumbprint")
-          and misc_info.get("oem_fingerprint_properties") is not None):
+            and misc_info.get("oem_fingerprint_properties") is not None):
         pieces = value.split("/")
         pieces[-1] = EditTags(pieces[-1])
         value = "/".join(pieces)
@@ -379,27 +383,31 @@
   # put into a zipfile system/etc/security/otacerts.zip.
   # We DO NOT include the extra_recovery_keys (if any) here.
 
-  tempfile = cStringIO.StringIO()
-  certs_zip = zipfile.ZipFile(tempfile, "w")
+  temp_file = cStringIO.StringIO()
+  certs_zip = zipfile.ZipFile(temp_file, "w")
   for k in mapped_keys:
     certs_zip.write(k)
   certs_zip.close()
   common.ZipWriteStr(output_tf_zip, "SYSTEM/etc/security/otacerts.zip",
-                     tempfile.getvalue())
+                     temp_file.getvalue())
 
   return new_recovery_keys
 
 def ReplaceVerityPublicKey(targetfile_zip, key_path):
   print "Replacing verity public key with %s" % key_path
   with open(key_path) as f:
-    common.ZipWriteStr(targetfile_zip, "BOOT/RAMDISK/verity_key", f.read())
+    data = f.read()
+  common.ZipWriteStr(targetfile_zip, "BOOT/RAMDISK/verity_key", data)
+  return data
 
-def ReplaceVerityPrivateKey(targetfile_input_zip, targetfile_output_zip, misc_info, key_path):
+def ReplaceVerityPrivateKey(targetfile_input_zip, targetfile_output_zip,
+                            misc_info, key_path):
   print "Replacing verity private key with %s" % key_path
   current_key = misc_info["verity_key"]
   original_misc_info = targetfile_input_zip.read("META/misc_info.txt")
   new_misc_info = original_misc_info.replace(current_key, key_path)
   common.ZipWriteStr(targetfile_output_zip, "META/misc_info.txt", new_misc_info)
+  misc_info["verity_key"] = key_path
 
 def BuildKeyMap(misc_info, key_mapping_options):
   for s, d in key_mapping_options:
diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py
index e253fbf..78f3057 100644
--- a/tools/releasetools/sparse_img.py
+++ b/tools/releasetools/sparse_img.py
@@ -14,25 +14,17 @@
 
 import bisect
 import os
-import sys
 import struct
-import pprint
 from hashlib import sha1
 
-from rangelib import *
+import rangelib
+
 
 class SparseImage(object):
-  """Wraps a sparse image file into an image object.
+  """Wraps a sparse image file (and optional file map) into an image
+  object suitable for passing to BlockImageDiff."""
 
-  Wraps a sparse image file (and optional file map and clobbered_blocks) into
-  an image object suitable for passing to BlockImageDiff. file_map contains
-  the mapping between files and their blocks. clobbered_blocks contains the set
-  of blocks that should be always written to the target regardless of the old
-  contents (i.e. copying instead of patching). clobbered_blocks should be in
-  the form of a string like "0" or "0 1-5 8".
-  """
-
-  def __init__(self, simg_fn, file_map_fn=None, clobbered_blocks=None):
+  def __init__(self, simg_fn, file_map_fn=None):
     self.simg_f = f = open(simg_fn, "rb")
 
     header_bin = f.read(28)
@@ -46,7 +38,6 @@
     self.blocksize = blk_sz = header[5]
     self.total_blocks = total_blks = header[6]
     total_chunks = header[7]
-    image_checksum = header[8]
 
     if magic != 0xED26FF3A:
       raise ValueError("Magic should be 0xED26FF3A but is 0x%08X" % (magic,))
@@ -66,13 +57,11 @@
     pos = 0   # in blocks
     care_data = []
     self.offset_map = offset_map = []
-    self.clobbered_blocks = RangeSet(data=clobbered_blocks)
 
     for i in range(total_chunks):
       header_bin = f.read(12)
       header = struct.unpack("<2H2I", header_bin)
       chunk_type = header[0]
-      reserved1 = header[1]
       chunk_sz = header[2]
       total_sz = header[3]
       data_sz = total_sz - 12
@@ -110,11 +99,11 @@
         raise ValueError("Unknown chunk type 0x%04X not supported" %
                          (chunk_type,))
 
-    self.care_map = RangeSet(care_data)
+    self.care_map = rangelib.RangeSet(care_data)
     self.offset_index = [i[0] for i in offset_map]
 
     if file_map_fn:
-      self.LoadFileBlockMap(file_map_fn, self.clobbered_blocks)
+      self.LoadFileBlockMap(file_map_fn)
     else:
       self.file_map = {"__DATA": self.care_map}
 
@@ -122,10 +111,9 @@
     return [d for d in self._GetRangeData(ranges)]
 
   def TotalSha1(self):
-    """Return the SHA-1 hash of all data in the 'care' regions but not in
-    clobbered_blocks of this image."""
+    """Return the SHA-1 hash of all data in the 'care' regions of this image."""
     h = sha1()
-    for d in self._GetRangeData(self.care_map.subtract(self.clobbered_blocks)):
+    for d in self._GetRangeData(self.care_map):
       h.update(d)
     return h.hexdigest()
 
@@ -168,30 +156,24 @@
           yield fill_data * (this_read * (self.blocksize >> 2))
         to_read -= this_read
 
-  def LoadFileBlockMap(self, fn, clobbered_blocks):
+  def LoadFileBlockMap(self, fn):
     remaining = self.care_map
     self.file_map = out = {}
 
     with open(fn) as f:
       for line in f:
         fn, ranges = line.split(None, 1)
-        ranges = RangeSet.parse(ranges)
+        ranges = rangelib.RangeSet.parse(ranges)
         out[fn] = ranges
         assert ranges.size() == ranges.intersect(remaining).size()
-
-        # Currently we assume that blocks in clobbered_blocks are not part of
-        # any file.
-        assert not clobbered_blocks.overlaps(ranges)
         remaining = remaining.subtract(ranges)
 
-    remaining = remaining.subtract(clobbered_blocks)
-
     # For all the remaining blocks in the care_map (ie, those that
-    # aren't part of the data for any file nor part of the clobbered_blocks),
-    # divide them into blocks that are all zero and blocks that aren't.
-    # (Zero blocks are handled specially because (1) there are usually
-    # a lot of them and (2) bsdiff handles files with long sequences of
-    # repeated bytes especially poorly.)
+    # aren't part of the data for any file), divide them into blocks
+    # that are all zero and blocks that aren't.  (Zero blocks are
+    # handled specially because (1) there are usually a lot of them
+    # and (2) bsdiff handles files with long sequences of repeated
+    # bytes especially poorly.)
 
     zero_blocks = []
     nonzero_blocks = []
@@ -201,7 +183,7 @@
     for s, e in remaining:
       for b in range(s, e):
         idx = bisect.bisect_right(self.offset_index, b) - 1
-        chunk_start, chunk_len, filepos, fill_data = self.offset_map[idx]
+        chunk_start, _, filepos, fill_data = self.offset_map[idx]
         if filepos is not None:
           filepos += (b-chunk_start) * self.blocksize
           f.seek(filepos, os.SEEK_SET)
@@ -219,9 +201,12 @@
           nonzero_blocks.append(b)
           nonzero_blocks.append(b+1)
 
-    out["__ZERO"] = RangeSet(data=zero_blocks)
-    out["__NONZERO"] = RangeSet(data=nonzero_blocks)
-    out["__COPY"] = clobbered_blocks
+    assert zero_blocks or nonzero_blocks
+
+    if zero_blocks:
+      out["__ZERO"] = rangelib.RangeSet(data=zero_blocks)
+    if nonzero_blocks:
+      out["__NONZERO"] = rangelib.RangeSet(data=nonzero_blocks)
 
   def ResetFileMap(self):
     """Throw away the file map and treat the entire image as
diff --git a/tools/releasetools/test_common.py b/tools/releasetools/test_common.py
new file mode 100644
index 0000000..5fdc132
--- /dev/null
+++ b/tools/releasetools/test_common.py
@@ -0,0 +1,110 @@
+#
+# Copyright (C) 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.
+#
+import os
+import tempfile
+import time
+import unittest
+import zipfile
+
+import common
+
+
+def random_string_with_holes(size, block_size, step_size):
+  data = ["\0"] * size
+  for begin in range(0, size, step_size):
+    end = begin + block_size
+    data[begin:end] = os.urandom(block_size)
+  return "".join(data)
+
+
+class CommonZipTest(unittest.TestCase):
+  def _test_ZipWrite(self, contents, extra_zipwrite_args=None):
+    extra_zipwrite_args = dict(extra_zipwrite_args or {})
+
+    test_file = tempfile.NamedTemporaryFile(delete=False)
+    zip_file = tempfile.NamedTemporaryFile(delete=False)
+
+    test_file_name = test_file.name
+    zip_file_name = zip_file.name
+
+    # File names within an archive strip the leading slash.
+    arcname = extra_zipwrite_args.get("arcname", test_file_name)
+    if arcname[0] == "/":
+      arcname = arcname[1:]
+
+    zip_file.close()
+    zip_file = zipfile.ZipFile(zip_file_name, "w")
+
+    try:
+      test_file.write(contents)
+      test_file.close()
+
+      old_stat = os.stat(test_file_name)
+      expected_mode = extra_zipwrite_args.get("perms", 0o644)
+
+      time.sleep(5)  # Make sure the atime/mtime will change measurably.
+
+      common.ZipWrite(zip_file, test_file_name, **extra_zipwrite_args)
+
+      new_stat = os.stat(test_file_name)
+      self.assertEqual(int(old_stat.st_mode), int(new_stat.st_mode))
+      self.assertEqual(int(old_stat.st_mtime), int(new_stat.st_mtime))
+      self.assertIsNone(zip_file.testzip())
+
+      zip_file.close()
+      zip_file = zipfile.ZipFile(zip_file_name, "r")
+      info = zip_file.getinfo(arcname)
+
+      self.assertEqual(info.date_time, (2009, 1, 1, 0, 0, 0))
+      mode = (info.external_attr >> 16) & 0o777
+      self.assertEqual(mode, expected_mode)
+      self.assertEqual(zip_file.read(arcname), contents)
+      self.assertIsNone(zip_file.testzip())
+    finally:
+      os.remove(test_file_name)
+      os.remove(zip_file_name)
+
+  def test_ZipWrite(self):
+    file_contents = os.urandom(1024)
+    self._test_ZipWrite(file_contents)
+
+  def test_ZipWrite_with_opts(self):
+    file_contents = os.urandom(1024)
+    self._test_ZipWrite(file_contents, {
+        "arcname": "foobar",
+        "perms": 0o777,
+        "compress_type": zipfile.ZIP_DEFLATED,
+    })
+
+  def test_ZipWrite_large_file(self):
+    kilobytes = 1024
+    megabytes = 1024 * kilobytes
+    gigabytes = 1024 * megabytes
+
+    size = int(2 * gigabytes + 1)
+    block_size = 4 * kilobytes
+    step_size = 4 * megabytes
+    file_contents = random_string_with_holes(
+        size, block_size, step_size)
+    self._test_ZipWrite(file_contents, {
+        "compress_type": zipfile.ZIP_DEFLATED,
+    })
+
+  def test_ZipWrite_resets_ZIP64_LIMIT(self):
+    default_limit = (1 << 31) - 1
+    self.assertEqual(default_limit, zipfile.ZIP64_LIMIT)
+    self._test_ZipWrite('')
+    self.assertEqual(default_limit, zipfile.ZIP64_LIMIT)
diff --git a/tools/signapk/SignApk.java b/tools/signapk/SignApk.java
index e661e50..88f486a 100644
--- a/tools/signapk/SignApk.java
+++ b/tools/signapk/SignApk.java
@@ -35,6 +35,7 @@
 import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
 import org.bouncycastle.util.encoders.Base64;
 
+import java.io.Console;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -166,18 +167,17 @@
     }
 
     /**
-     * Reads the password from stdin and returns it as a string.
+     * Reads the password from console and returns it as a string.
      *
      * @param keyFile The file containing the private key.  Used to prompt the user.
      */
     private static String readPassword(File keyFile) {
-        // TODO: use Console.readPassword() when it's available.
-        System.out.print("Enter password for " + keyFile + " (password will not be hidden): ");
-        System.out.flush();
-        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
-        try {
-            return stdin.readLine();
-        } catch (IOException ex) {
+        Console console;
+        char[] pwd;
+        if((console = System.console()) != null &&
+           (pwd = console.readPassword("[%s]", "Enter password for " + keyFile)) != null){
+            return String.valueOf(pwd);
+        } else {
             return null;
         }
     }
@@ -621,8 +621,12 @@
             this.type = new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId());
         }
 
+        /**
+         * This should actually return byte[] or something similar, but nothing
+         * actually checks it currently.
+         */
         public Object getContent() {
-            throw new UnsupportedOperationException();
+            return this;
         }
 
         public ASN1ObjectIdentifier getContentType() {
diff --git a/tools/signtos/Android.mk b/tools/signtos/Android.mk
new file mode 100644
index 0000000..94ab944
--- /dev/null
+++ b/tools/signtos/Android.mk
@@ -0,0 +1,25 @@
+#
+# Copyright (C) 2014 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.
+#
+LOCAL_PATH := $(call my-dir)
+
+# the signtos tool - signs Trusty images
+# ============================================================
+include $(CLEAR_VARS)
+LOCAL_MODULE := signtos
+LOCAL_SRC_FILES := SignTos.java
+LOCAL_JAR_MANIFEST := SignTos.mf
+LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-host bouncycastle-bcpkix-host
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/signtos/SignTos.java b/tools/signtos/SignTos.java
new file mode 100644
index 0000000..485ad2f
--- /dev/null
+++ b/tools/signtos/SignTos.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2014 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.signtos;
+
+import org.bouncycastle.asn1.ASN1InputStream;
+import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.lang.reflect.Constructor;
+import java.security.GeneralSecurityException;
+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.Signature;
+import java.security.interfaces.ECKey;
+import java.security.interfaces.ECPublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.Arrays;
+
+import javax.crypto.Cipher;
+import javax.crypto.EncryptedPrivateKeyInfo;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
+
+/**
+ * Signs Trusty images for use with operating systems that support it.
+ */
+public class SignTos {
+    /** Size of the signature footer in bytes. */
+    private static final int SIGNATURE_BLOCK_SIZE = 256;
+
+    /** Current signature version code we use. */
+    private static final int VERSION_CODE = 1;
+
+    /** Size of the header on the file to skip. */
+    private static final int HEADER_SIZE = 512;
+
+    private static BouncyCastleProvider sBouncyCastleProvider;
+
+    /**
+     * Reads the password from stdin and returns it as a string.
+     *
+     * @param keyFile The file containing the private key.  Used to prompt the user.
+     */
+    private static String readPassword(File keyFile) {
+        // TODO: use Console.readPassword() when it's available.
+        System.out.print("Enter password for " + keyFile + " (password will not be hidden): ");
+        System.out.flush();
+        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+        try {
+            return stdin.readLine();
+        } catch (IOException ex) {
+            return null;
+        }
+    }
+
+    /**
+     * Decrypt an encrypted PKCS#8 format private key.
+     *
+     * Based on ghstark's post on Aug 6, 2006 at
+     * http://forums.sun.com/thread.jspa?threadID=758133&messageID=4330949
+     *
+     * @param encryptedPrivateKey The raw data of the private key
+     * @param keyFile The file containing the private key
+     */
+    private static PKCS8EncodedKeySpec decryptPrivateKey(byte[] encryptedPrivateKey, File keyFile)
+        throws GeneralSecurityException {
+        EncryptedPrivateKeyInfo epkInfo;
+        try {
+            epkInfo = new EncryptedPrivateKeyInfo(encryptedPrivateKey);
+        } catch (IOException ex) {
+            // Probably not an encrypted key.
+            return null;
+        }
+
+        char[] password = readPassword(keyFile).toCharArray();
+
+        SecretKeyFactory skFactory = SecretKeyFactory.getInstance(epkInfo.getAlgName());
+        Key key = skFactory.generateSecret(new PBEKeySpec(password));
+
+        Cipher cipher = Cipher.getInstance(epkInfo.getAlgName());
+        cipher.init(Cipher.DECRYPT_MODE, key, epkInfo.getAlgParameters());
+
+        try {
+            return epkInfo.getKeySpec(cipher);
+        } catch (InvalidKeySpecException ex) {
+            System.err.println("signapk: Password for " + keyFile + " may be bad.");
+            throw ex;
+        }
+    }
+
+    /** Read a PKCS#8 format private key. */
+    private static PrivateKey readPrivateKey(File file) throws IOException,
+            GeneralSecurityException {
+        DataInputStream input = new DataInputStream(new FileInputStream(file));
+        try {
+            byte[] bytes = new byte[(int) file.length()];
+            input.read(bytes);
+
+            /* Check to see if this is in an EncryptedPrivateKeyInfo structure. */
+            PKCS8EncodedKeySpec spec = decryptPrivateKey(bytes, file);
+            if (spec == null) {
+                spec = new PKCS8EncodedKeySpec(bytes);
+            }
+
+            /*
+             * Now it's in a PKCS#8 PrivateKeyInfo structure. Read its Algorithm
+             * OID and use that to construct a KeyFactory.
+             */
+            ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream(spec.getEncoded()));
+            PrivateKeyInfo pki = PrivateKeyInfo.getInstance(bIn.readObject());
+            String algOid = pki.getPrivateKeyAlgorithm().getAlgorithm().getId();
+
+            return KeyFactory.getInstance(algOid).generatePrivate(spec);
+        } finally {
+            input.close();
+        }
+    }
+
+    /**
+     * Tries to load a JSE Provider by class name. This is for custom PrivateKey
+     * types that might be stored in PKCS#11-like storage.
+     */
+    private static void loadProviderIfNecessary(String providerClassName) {
+        if (providerClassName == null) {
+            return;
+        }
+
+        final Class<?> klass;
+        try {
+            final ClassLoader sysLoader = ClassLoader.getSystemClassLoader();
+            if (sysLoader != null) {
+                klass = sysLoader.loadClass(providerClassName);
+            } else {
+                klass = Class.forName(providerClassName);
+            }
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            System.exit(1);
+            return;
+        }
+
+        Constructor<?> constructor = null;
+        for (Constructor<?> c : klass.getConstructors()) {
+            if (c.getParameterTypes().length == 0) {
+                constructor = c;
+                break;
+            }
+        }
+        if (constructor == null) {
+            System.err.println("No zero-arg constructor found for " + providerClassName);
+            System.exit(1);
+            return;
+        }
+
+        final Object o;
+        try {
+            o = constructor.newInstance();
+        } catch (Exception e) {
+            e.printStackTrace();
+            System.exit(1);
+            return;
+        }
+        if (!(o instanceof Provider)) {
+            System.err.println("Not a Provider class: " + providerClassName);
+            System.exit(1);
+        }
+
+        Security.insertProviderAt((Provider) o, 1);
+    }
+
+    private static String getSignatureAlgorithm(Key key) {
+        if ("EC".equals(key.getAlgorithm())) {
+            ECKey ecKey = (ECKey) key;
+            int curveSize = ecKey.getParams().getOrder().bitLength();
+            if (curveSize <= 256) {
+                return "SHA256withECDSA";
+            } else if (curveSize <= 384) {
+                return "SHA384withECDSA";
+            } else {
+                return "SHA512withECDSA";
+            }
+        } else {
+            throw new IllegalArgumentException("Unsupported key type " + key.getAlgorithm());
+        }
+    }
+
+    /**
+     * @param inputFilename
+     * @param outputFilename
+     */
+    private static void signWholeFile(InputStream input, OutputStream output, PrivateKey signingKey)
+            throws Exception {
+        Signature sig = Signature.getInstance(getSignatureAlgorithm(signingKey));
+        sig.initSign(signingKey);
+
+        byte[] buffer = new byte[8192];
+
+        /* Skip the header. */
+        int skippedBytes = 0;
+        while (skippedBytes != HEADER_SIZE) {
+            int bytesRead = input.read(buffer, 0, HEADER_SIZE - skippedBytes);
+            output.write(buffer, 0, bytesRead);
+            skippedBytes += bytesRead;
+        }
+
+        int totalBytes = 0;
+        for (;;) {
+            int bytesRead = input.read(buffer);
+            if (bytesRead == -1) {
+                break;
+            }
+            totalBytes += bytesRead;
+            sig.update(buffer, 0, bytesRead);
+            output.write(buffer, 0, bytesRead);
+        }
+
+        byte[] sigBlock = new byte[SIGNATURE_BLOCK_SIZE];
+        sigBlock[0] = VERSION_CODE;
+        sig.sign(sigBlock, 1, sigBlock.length - 1);
+
+        output.write(sigBlock);
+    }
+
+    private static void usage() {
+        System.err.println("Usage: signtos " +
+                           "[-providerClass <className>] " +
+                           " privatekey.pk8 " +
+                           "input.img output.img");
+        System.exit(2);
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length < 3) {
+            usage();
+        }
+
+        String providerClass = null;
+        String providerArg = null;
+
+        int argstart = 0;
+        while (argstart < args.length && args[argstart].startsWith("-")) {
+            if ("-providerClass".equals(args[argstart])) {
+                if (argstart + 1 >= args.length) {
+                    usage();
+                }
+                providerClass = args[++argstart];
+                ++argstart;
+            } else {
+                usage();
+            }
+        }
+
+        /*
+         * Should only be "<privatekey> <input> <output>" left.
+         */
+        if (argstart != args.length - 3) {
+            usage();
+        }
+
+        sBouncyCastleProvider = new BouncyCastleProvider();
+        Security.addProvider(sBouncyCastleProvider);
+
+        loadProviderIfNecessary(providerClass);
+
+        String keyFilename = args[args.length - 3];
+        String inputFilename = args[args.length - 2];
+        String outputFilename = args[args.length - 1];
+
+        PrivateKey privateKey = readPrivateKey(new File(keyFilename));
+
+        InputStream input = new BufferedInputStream(new FileInputStream(inputFilename));
+        OutputStream output = new BufferedOutputStream(new FileOutputStream(outputFilename));
+        try {
+            SignTos.signWholeFile(input, output, privateKey);
+        } finally {
+            input.close();
+            output.close();
+        }
+
+        System.out.println("Successfully signed: " + outputFilename);
+    }
+}
diff --git a/tools/signtos/SignTos.mf b/tools/signtos/SignTos.mf
new file mode 100644
index 0000000..d860296
--- /dev/null
+++ b/tools/signtos/SignTos.mf
@@ -0,0 +1 @@
+Main-Class: com.android.signtos.SignTos
diff --git a/tools/zipalign/Android.mk b/tools/zipalign/Android.mk
index 7986798..4194f81 100644
--- a/tools/zipalign/Android.mk
+++ b/tools/zipalign/Android.mk
@@ -26,7 +26,7 @@
 LOCAL_LDLIBS += -lrt
 endif
 
-ifneq ($(strip $(USE_MINGW)),)
+ifdef USE_MINGW
 LOCAL_STATIC_LIBRARIES += libz
 else
 LOCAL_LDLIBS += -lz
diff --git a/tools/zipalign/README.txt b/tools/zipalign/README.txt
index 9c7d07e..0b80b35 100644
--- a/tools/zipalign/README.txt
+++ b/tools/zipalign/README.txt
@@ -5,6 +5,7 @@
 
   -c : check alignment only (does not modify file)
   -f : overwrite existing outfile.zip
+  -p : page align stored shared object files
   -v : verbose output
   <align> is in bytes, e.g. "4" provides 32-bit alignment
   infile.zip is an existing Zip archive
@@ -33,3 +34,7 @@
 
 You can use the "-c" flag to test whether a zip archive is properly aligned.
 
+The "-p" flag aligns any file with a ".so" extension, and which is stored
+uncompressed in the zip archive, to a 4096-byte page boundary.  This
+facilitates directly loading shared libraries from inside a zip archive.
+
diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index dc2826b..a2dfd02 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -32,20 +32,39 @@
     fprintf(stderr, "Zip alignment utility\n");
     fprintf(stderr, "Copyright (C) 2009 The Android Open Source Project\n\n");
     fprintf(stderr,
-        "Usage: zipalign [-f] [-v] [-z] <align> infile.zip outfile.zip\n"
+        "Usage: zipalign [-f] [-p] [-v] [-z] <align> infile.zip outfile.zip\n"
         "       zipalign -c [-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, "  -v: verbose output\n");
     fprintf(stderr, "  -z: recompress using Zopfli\n");
 }
 
+static int getAlignment(bool pageAlignSharedLibs, int defaultAlignment,
+    ZipEntry* pEntry) {
+
+    static const int kPageAlignment = 4096;
+
+    if (!pageAlignSharedLibs) {
+        return defaultAlignment;
+    }
+
+    const char* ext = strrchr(pEntry->getFileName(), '.');
+    if (ext && strcmp(ext, ".so") == 0) {
+        return kPageAlignment;
+    }
+
+    return defaultAlignment;
+}
+
 /*
  * Copy all entries from "pZin" to "pZout", aligning as needed.
  */
-static int copyAndAlign(ZipFile* pZin, ZipFile* pZout, int alignment, bool zopfli)
+static int copyAndAlign(ZipFile* pZin, ZipFile* pZout, int alignment, bool zopfli,
+    bool pageAlignSharedLibs)
 {
     int numEntries = pZin->getNumEntries();
     ZipEntry* pEntry;
@@ -75,13 +94,15 @@
                 status = pZout->add(pZin, pEntry, padding, &pNewEntry);
             }
         } else {
+            const int alignTo = getAlignment(pageAlignSharedLibs, alignment, pEntry);
+
             /*
              * Copy the entry, adjusting as required.  We assume that the
              * file position in the new file will be equal to the file
              * position in the original.
              */
             long newOffset = pEntry->getFileOffset() + bias;
-            padding = (alignment - (newOffset % alignment)) % alignment;
+            padding = (alignTo - (newOffset % alignTo)) % alignTo;
 
             //printf("--- %s: orig at %ld(+%d) len=%ld, adding pad=%d\n",
             //    pEntry->getFileName(), (long) pEntry->getFileOffset(),
@@ -105,7 +126,7 @@
  * output file exists and "force" wasn't specified.
  */
 static int process(const char* inFileName, const char* outFileName,
-    int alignment, bool force, bool zopfli)
+    int alignment, bool force, bool zopfli, bool pageAlignSharedLibs)
 {
     ZipFile zin, zout;
 
@@ -136,7 +157,7 @@
         return 1;
     }
 
-    int result = copyAndAlign(&zin, &zout, alignment, zopfli);
+    int result = copyAndAlign(&zin, &zout, alignment, zopfli, pageAlignSharedLibs);
     if (result != 0) {
         printf("zipalign: failed rewriting '%s' to '%s'\n",
             inFileName, outFileName);
@@ -147,7 +168,8 @@
 /*
  * Verify the alignment of a zip archive.
  */
-static int verify(const char* fileName, int alignment, bool verbose)
+static int verify(const char* fileName, int alignment, bool verbose,
+    bool pageAlignSharedLibs)
 {
     ZipFile zipFile;
     bool foundBad = false;
@@ -172,11 +194,12 @@
             }
         } else {
             long offset = pEntry->getFileOffset();
-            if ((offset % alignment) != 0) {
+            const int alignTo = getAlignment(pageAlignSharedLibs, alignment, pEntry);
+            if ((offset % alignTo) != 0) {
                 if (verbose) {
                     printf("%8ld %s (BAD - %ld)\n",
                         (long) offset, pEntry->getFileName(),
-                        offset % alignment);
+                        offset % alignTo);
                 }
                 foundBad = true;
             } else {
@@ -204,6 +227,7 @@
     bool force = false;
     bool verbose = false;
     bool zopfli = false;
+    bool pageAlignSharedLibs = false;
     int result = 1;
     int alignment;
     char* endp;
@@ -233,6 +257,9 @@
             case 'z':
                 zopfli = true;
                 break;
+            case 'p':
+                pageAlignSharedLibs = true;
+                break;
             default:
                 fprintf(stderr, "ERROR: unknown flag -%c\n", *cp);
                 wantUsage = true;
@@ -260,14 +287,15 @@
 
     if (check) {
         /* check existing archive for correct alignment */
-        result = verify(argv[1], alignment, verbose);
+        result = verify(argv[1], alignment, verbose, pageAlignSharedLibs);
     } else {
         /* create the new archive */
-        result = process(argv[1], argv[2], alignment, force, zopfli);
+        result = process(argv[1], argv[2], alignment, force, zopfli, pageAlignSharedLibs);
 
         /* trust, but verify */
-        if (result == 0)
-            result = verify(argv[2], alignment, verbose);
+        if (result == 0) {
+            result = verify(argv[2], alignment, verbose, pageAlignSharedLibs);
+        }
     }
 
 bail:
diff --git a/tools/zipalign/ZipEntry.cpp b/tools/zipalign/ZipEntry.cpp
index d4d366d..b2270cb 100644
--- a/tools/zipalign/ZipEntry.cpp
+++ b/tools/zipalign/ZipEntry.cpp
@@ -356,7 +356,7 @@
  */
 void ZipEntry::setModWhen(time_t when)
 {
-#ifdef HAVE_LOCALTIME_R
+#if !defined(_WIN32)
     struct tm tmResult;
 #endif
     time_t even;
@@ -368,7 +368,7 @@
     even = (time_t)(((unsigned long)(when) + 1) & (~1));
 
     /* expand */
-#ifdef HAVE_LOCALTIME_R
+#if !defined(_WIN32)
     ptm = localtime_r(&even, &tmResult);
 #else
     ptm = localtime(&even);