merge in master-release history after reset to ce43185343d360947553c14af41d0113bd36f616
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 985a933..9354764 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -594,8 +594,12 @@
     $(ALL_MODULES.$(my_register_name).CHECKED) $(LOCAL_CHECKED_MODULE)
 ALL_MODULES.$(my_register_name).BUILT := \
     $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
+ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
 ALL_MODULES.$(my_register_name).INSTALLED := \
     $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) $(LOCAL_INSTALLED_MODULE))
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
+    $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED)$(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE))
+endif
 ifdef LOCAL_PICKUP_FILES
 # Files or directories ready to pick up by the build system
 # when $(LOCAL_BUILT_MODULE) is done.
diff --git a/core/build_id.mk b/core/build_id.mk
index c8f2452..221a2f3 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=AAV49B
+BUILD_ID := MASTER
+
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 723d222..f30e170 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -122,7 +122,7 @@
 LOCAL_RENDERSCRIPT_TARGET_API:=
 LOCAL_BUILD_HOST_DEX:=
 LOCAL_DEX_PREOPT:= # '',true,false,nostripping
-LOCAL_DEX_PREOPT_IMAGE:=
+LOCAL_DEX_PREOPT_IMAGE_LOCATION:=
 LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full
 LOCAL_PROTOC_FLAGS:=
 LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
diff --git a/core/config.mk b/core/config.mk
index 12aff6c..cc0e19f 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -536,22 +536,19 @@
 DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
 DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_CPU_VARIANT)
 DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
-
-# If for a 64bit build we have a 2nd architecture but the zygote isn't 64bit,
-# assume DEX2OAT should DEXPREOPT for the 2nd architecture.
-ifdef TARGET_2ND_ARCH
-  ifeq (true,$(TARGET_IS_64_BIT))
-    ifeq ($(filter ro.zygote=zygote64,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)),)
-      DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
-      DEX2OAT_TARGET_CPU_VARIANT := $(TARGET_2ND_CPU_VARIANT)
-    endif
-  endif
-endif
-
 ifneq (,$(filter $(DEX2OAT_TARGET_CPU_VARIANT),cortex-a7 cortex-a15 krait denver))
   DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div
 endif
 
+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
 include $(BUILD_SYSTEM)/clang/config.mk
 
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 46a6479..ab970f9 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -49,25 +49,26 @@
 include $(BUILD_SYSTEM)/dex_preopt_libart.mk
 
 # Define dexpreopt-one-file based on current default runtime.
-# $(1): the boot image to use (unused for libdvm)
-# $(2): the input .jar or .apk file
-# $(3): the input .jar or .apk target location (unused for libdvm)
-# $(4): the output .odex file
+# $(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,$(2),$(4))
+$(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),$(3),$(4))
+$(call dex2oat-one-file,$(1),$(2))
 endef
 
 DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OATD_DEPENDENCY)
-DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE)
-endif
+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
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 7f3285c..7d8cee0 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -23,20 +23,6 @@
 
 PRELOADED_CLASSES := frameworks/base/preloaded-classes
 
-LIBART_BOOT_IMAGE := /$(DEXPREOPT_BOOT_JAR_DIR)/boot-$(DEX2OAT_TARGET_ARCH).art
-
-DEFAULT_DEX_PREOPT_BUILT_IMAGE := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot-$(DEX2OAT_TARGET_ARCH).art
-
-DEFAULT_DEX_PREOPT_INSTALLED_IMAGE :=
-ifneq ($(PRODUCT_DEX_PREOPT_IMAGE_IN_DATA),true)
-DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$(LIBART_BOOT_IMAGE)
-
-# The rule to install boot.art and boot.oat
-$(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) | $(ACP)
-	$(call copy-file-to-target)
-	$(hide) $(ACP) -fp $(patsubst %.art,%.oat,$<) $(patsubst %.art,%.oat,$@)
-endif
-
 # start of image reserved address space
 LIBART_IMG_HOST_BASE_ADDRESS   := 0x60000000
 
@@ -49,48 +35,50 @@
 ########################################################################
 # The full system boot classpath
 
+# Returns the path to the .odex file
+# $(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
+endef
+
+# Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
+# $(1): the arch name (such as "arm")
+# $(2): the image location (such as "/system/framework/boot.art")
+define get-image-file-path
+$(dir $(2))$(1)/$(notdir $(2))
+endef
+
 # note we use core-libart.jar in place of core.jar for ART.
 LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
 LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
 LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
 
-# The .oat with symbols
-LIBART_TARGET_BOOT_OAT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)$(patsubst %.art,%.oat,$(LIBART_BOOT_IMAGE))
+my_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
 
-# Use dex2oat debug version for better error reporting
-$(DEFAULT_DEX_PREOPT_BUILT_IMAGE): $(LIBART_TARGET_BOOT_DEX_FILES) $(DEX2OATD_DEPENDENCY)
-	@echo "target dex2oat: $@ ($?)"
-	@mkdir -p $(dir $@)
-	@mkdir -p $(dir $(LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
-	$(hide) $(DEX2OATD) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) \
-		$(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
-		$(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
-		--oat-symbols=$(LIBART_TARGET_BOOT_OAT_UNSTRIPPED) \
-		--oat-file=$(patsubst %.art,%.oat,$@) \
-		--oat-location=$(patsubst %.art,%.oat,$(LIBART_BOOT_IMAGE)) \
-		--image=$@ --base=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
-		--instruction-set=$(DEX2OAT_TARGET_ARCH) \
-		--instruction-set-features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-		--android-root=$(PRODUCT_OUT)/system
+ifdef TARGET_2ND_ARCH
+my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
+my_2nd_arch_prefix :=
+endif
 
 
 ########################################################################
 # For a single jar or APK
 
-# $(1): the boot image to use
-# $(2): the input .jar or .apk file
-# $(3): the input .jar or .apk target location
-# $(4): the output .odex file
+# $(1): the input .jar or .apk file
+# $(2): the output .odex file
 define dex2oat-one-file
-$(hide) rm -f $(4)
-$(hide) mkdir -p $(dir $(4))
+$(hide) rm -f $(2)
+$(hide) mkdir -p $(dir $(2))
 $(hide) $(DEX2OATD) \
 	--runtime-arg -Xms64m --runtime-arg -Xmx64m \
-	--boot-image=$(1) \
-	--dex-file=$(2) \
-	--dex-location=$(3) \
-	--oat-file=$(4) \
+	--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
+	--dex-file=$(1) \
+	--dex-location=$(PRIVATE_DEX_LOCATION) \
+	--oat-file=$(2) \
 	--android-root=$(PRODUCT_OUT)/system \
-	--instruction-set=$(DEX2OAT_TARGET_ARCH) \
-	--instruction-set-features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+	--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
+	--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
 endef
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
new file mode 100644
index 0000000..70130b6
--- /dev/null
+++ b/core/dex_preopt_libart_boot.mk
@@ -0,0 +1,55 @@
+# Rules to build boot.art
+# Input variables:
+#   my_2nd_arch_prefix: indicates if this is to build for the 2nd arch.
+
+# The image "location" is a symbolic path that with multiarchitecture
+# support doesn't really exist on the device. Typically it is
+# /system/framework/boot.art and should be the same for all supported
+# architectures on the device. The concrete architecture specific
+# content actually ends up in a "filename" that contains an
+# architecture specific directory name such as arm, arm64, mips,
+# mips64, x86, x86_64.
+#
+# Here are some example values for an x86_64 / x86 configuration:
+#
+# DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION=out/target/product/generic_x86_64/dex_bootjars/system/framework/boot.art
+# DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME=out/target/product/generic_x86_64/dex_bootjars/system/framework/x86_64/boot.art
+# LIBART_BOOT_IMAGE=/system/framework/x86_64/boot.art
+#
+# 2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION=out/target/product/generic_x86_64/dex_bootjars/system/framework/boot.art
+# 2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME=out/target/product/generic_x86_64/dex_bootjars/system/framework/x86/boot.art
+# 2ND_LIBART_BOOT_IMAGE=/system/framework/x86/boot.art
+
+$(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.art
+$(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH)/boot.art
+$(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME := /$(DEXPREOPT_BOOT_JAR_DIR)/$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH)/boot.art
+
+# 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
+
+# The rule to install boot.art and boot.oat
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) | $(ACP)
+	$(call copy-file-to-target)
+	$(hide) $(ACP) -fp $(patsubst %.art,%.oat,$<) $(patsubst %.art,%.oat,$@)
+
+$($(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)
+	@echo "target dex2oat: $@ ($?)"
+	@mkdir -p $(dir $@)
+	@mkdir -p $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
+	$(hide) $(DEX2OATD) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) \
+		$(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
+		$(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
+		--oat-symbols=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED) \
+		--oat-file=$(patsubst %.art,%.oat,$@) \
+		--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-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
+		--android-root=$(PRODUCT_OUT)/system
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index b0b73af..acba378 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -33,38 +33,110 @@
 
 built_odex :=
 installed_odex :=
+built_installed_odex :=
 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)
 
-ifneq ($(DALVIK_VM_LIB),libdvm.so) # libart
-ifndef LOCAL_DEX_PREOPT_IMAGE
-LOCAL_DEX_PREOPT_IMAGE := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE)
+$(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.
+# #################################################
+# Odex for the 1st arch
+built_odex := $(call get-odex-file-path,$(DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE))
+ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION
+my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION)
+else
+my_dex_preopt_image_location := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)
 endif
+my_dex_preopt_image_filename := $(call get-image-file-path,$(DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location))
+$(built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX :=
+$(built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location)
+$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
+                $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
+                $(my_dex_preopt_image_filename)
+installed_odex := $(call get-odex-file-path,$(DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
+built_installed_odex := $(built_odex):$(installed_odex)
+# #################################################
+# Odex for the 2nd arch
+ifdef TARGET_2ND_ARCH
+built_odex2 := $(call get-odex-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE))
+ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION
+my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION)
+else
+my_dex_preopt_image_location := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)
+endif
+my_dex_preopt_image_filename := $(call get-image-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location))
+$(built_odex2): PRIVATE_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+$(built_odex2): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(built_odex2): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location)
+$(built_odex2) : $($(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
+                 $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
+                 $(my_dex_preopt_image_filename)
+
+installed_odex2 := $(call get-odex-file-path,$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
+built_odex += $(built_odex2)
+installed_odex += $(installed_odex2)
+built_installed_odex += $(built_odex2):$(installed_odex2)
+endif  # TARGET_2ND_ARCH
+# #################################################
+else  # must be APPS
+# For an app, we build for the multilib arch it's targeted for.
+built_odex := $(call get-odex-file-path,$($(LOCAL_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE))
+ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION
+my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION)
+else
+my_dex_preopt_image_location := $($(LOCAL_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)
+endif
+my_dex_preopt_image_filename := $(call get-image-file-path,$($(LOCAL_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location))
+# $(built_odex) is byproduct of $(LOCAL_BUILT_MODULE)
+$(LOCAL_BUILT_MODULE) $(built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
+$(LOCAL_BUILT_MODULE) $(built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(LOCAL_BUILT_MODULE) $(built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location)
+$(LOCAL_BUILT_MODULE) $(built_odex) : $($(LOCAL_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
+                $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
+                $(my_dex_preopt_image_filename)
+installed_odex := $(call get-odex-file-path,$($(LOCAL_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
+built_installed_odex := $(built_odex):$(installed_odex)
+endif  # LOCAL_MODULE_CLASS
 endif # libart
 endif # boot jar
 
 ifdef built_odex
 # We need $(LOCAL_BUILT_MODULE) in the deps to enforce reinstallation
 # even if $(built_odex) is byproduct of $(LOCAL_BUILT_MODULE), such as in package.mk.
-$(installed_odex) : $(built_odex) $(LOCAL_BUILT_MODULE) | $(ACP)
+# Use pattern rule - we may have multiple installed odex files.
+# Ugly syntax - See the definition get-odex-file-path.
+$(installed_odex) : $(dir $(LOCAL_INSTALLED_MODULE))%/$(notdir $(word 1,$(installed_odex))) \
+                  : $(dir $(LOCAL_BUILT_MODULE))%/$(notdir $(word 1,$(built_odex))) \
+    $(LOCAL_BUILT_MODULE) | $(ACP)
 	@echo "Install: $@"
 	$(copy-file-to-target)
 endif
 
 # Add the installed_odex to the list of installed files for this module.
-ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(installed_odex)
+ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
+
 # Make sure to install the .odex when you run "make <module_name>"
 $(my_register_name): $(installed_odex)
 
diff --git a/core/java_library.mk b/core/java_library.mk
index 343b27e..dffc7d9 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -93,15 +93,10 @@
 
 else # ! boot jar
 $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
-$(built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
-$(built_odex): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
-# Make sure the boot jars get dex-preopt-ed first
-$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
-$(built_odex) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-$(built_odex) : $(LOCAL_DEX_PREOPT_IMAGE)
-$(built_odex) : $(common_javalib.jar)
+# Use pattern rule - we may have multiple built odex files.
+$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar)
 	@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
-	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$<,$(PRIVATE_DEX_LOCATION),$@)
+	$(call dexpreopt-one-file,$<,$@)
 
 $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
 	$(call copy-file-to-target)
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 598c065..d72933a 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -345,13 +345,7 @@
 # Define the rule to build the actual package.
 $(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN)
 ifdef LOCAL_DEX_PREOPT
-$(LOCAL_BUILT_MODULE): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
 $(LOCAL_BUILT_MODULE): PRIVATE_BUILT_ODEX := $(built_odex)
-$(LOCAL_BUILT_MODULE): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
-# Make sure the boot jars get dexpreopt-ed first
-$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
-$(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-$(LOCAL_BUILT_MODULE) : $(LOCAL_DEX_PREOPT_IMAGE)
 
 # built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
 $(built_odex) : $(LOCAL_BUILT_MODULE)
@@ -385,7 +379,7 @@
 endif
 	$(sign-package)
 ifdef LOCAL_DEX_PREOPT
-	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
+	$(call dexpreopt-one-file,$@,$(PRIVATE_BUILT_ODEX))
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 9507121..184ebb0 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -160,13 +160,7 @@
 include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
 #######################################
 ifdef LOCAL_DEX_PREOPT
-$(built_module): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE)
-$(built_module): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
 $(built_module): PRIVATE_BUILT_ODEX := $(built_odex)
-# Make sure the boot jars get dexpreopt-ed first
-$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT)
-$(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS)
-(built_module) : $(LOCAL_DEX_PREOPT_IMAGE)
 # built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe.
 $(built_odex) : $(LOCAL_BUILT_MODULE)
 endif # LOCAL_DEX_PREOPT
@@ -180,7 +174,7 @@
 	$(sign-package)
 endif
 ifdef LOCAL_DEX_PREOPT
-	$(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX))
+	$(call dexpreopt-one-file,$@,$(PRIVATE_BUILT_ODEX))
 endif
 	$(align-package)
 
diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk
index 890d26a..83d5984 100644
--- a/core/tasks/tools/package-modules.mk
+++ b/core/tasks/tools/package-modules.mk
@@ -14,27 +14,23 @@
 my_copy_pairs :=
 my_pickup_files :=
 
-# Search for modules' built files and installed files;
+# Iterate over modules' built files and installed files;
 # Calculate the dest files in the output zip file.
-# If for 1 module name we found multiple installed files,
-# we use suffix matching to find the corresponding built file.
+
 $(foreach m,$(my_modules),\
-  $(if $(ALL_MODULES.$(m).INSTALLED),,\
+  $(if $(ALL_MODULES.$(m).BUILT_INSTALLED),,\
     $(warning Unknown installed file for module '$(m)'))\
   $(eval my_pickup_files += $(ALL_MODULES.$(m).PICKUP_FILES))\
-  $(foreach i,$(filter $(TARGET_OUT_ROOT)/%,$(ALL_MODULES.$(m).INSTALLED)),\
-    $(eval my_suffix := $(suffix $(i))) \
-    $(if $(my_suffix),\
-      $(eval my_patt := $(TARGET_OUT_ROOT)/%$(my_suffix)),\
-      $(eval my_patt := $(TARGET_OUT_ROOT)/%$(notdir $(i))))\
-    $(eval b := $(filter $(my_patt),$(ALL_MODULES.$(m).BUILT)))\
-    $(if $(filter 1,$(words $(b))),\
-      $(eval my_built_modules += $(b))\
+  $(foreach i, $(ALL_MODULES.$(m).BUILT_INSTALLED),\
+    $(eval bui_ins := $(subst :,$(space),$(i)))\
+    $(eval ins := $(word 2,$(bui_ins)))\
+    $(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
+      $(eval bui := $(word 1,$(bui_ins)))\
+      $(eval my_built_modules += $(bui))\
       $(eval my_copy_dest := $(patsubst data/%,DATA/%,\
                                $(patsubst system/%,DATA/%,\
-                                 $(patsubst $(PRODUCT_OUT)/%,%,$(i)))))\
-      $(eval my_copy_pairs += $(b):$(my_staging_dir)/$(my_copy_dest)),\
-      $(warning Unexpected module built file '$(b)' for module '$(m)'))\
+                                 $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
+      $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
   ))
 
 my_package_zip := $(my_staging_dir)/$(my_package_name).zip
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
index c30cc75..6d58b1c 100644
--- a/target/board/generic/BoardConfig.mk
+++ b/target/board/generic/BoardConfig.mk
@@ -78,6 +78,7 @@
 BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
 BOARD_SEPOLICY_UNION += \
         adbd.te \
+        app.te \
         bootanim.te \
         device.te \
         domain.te \
@@ -88,4 +89,5 @@
         rild.te \
         shell.te \
         surfaceflinger.te \
-        system_server.te
+        system_server.te \
+        zygote.te
diff --git a/target/board/generic/sepolicy/app.te b/target/board/generic/sepolicy/app.te
new file mode 100644
index 0000000..fd33453
--- /dev/null
+++ b/target/board/generic/sepolicy/app.te
@@ -0,0 +1 @@
+allow appdomain qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/bootanim.te b/target/board/generic/sepolicy/bootanim.te
index d6506e1..a5a84f9 100644
--- a/target/board/generic/sepolicy/bootanim.te
+++ b/target/board/generic/sepolicy/bootanim.te
@@ -1,2 +1,3 @@
 allow bootanim self:process execmem;
 allow bootanim ashmem_device:chr_file execute;
+allow bootanim qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/surfaceflinger.te b/target/board/generic/sepolicy/surfaceflinger.te
index 4c35469..6712789 100644
--- a/target/board/generic/sepolicy/surfaceflinger.te
+++ b/target/board/generic/sepolicy/surfaceflinger.te
@@ -1,2 +1,3 @@
 allow surfaceflinger self:process execmem;
 allow surfaceflinger ashmem_device:chr_file execute;
+allow surfaceflinger qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/zygote.te b/target/board/generic/sepolicy/zygote.te
new file mode 100644
index 0000000..a5da574
--- /dev/null
+++ b/target/board/generic/sepolicy/zygote.te
@@ -0,0 +1 @@
+allow zygote qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
index faf8600..727d3db 100644
--- a/target/board/generic_x86/BoardConfig.mk
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -44,7 +44,9 @@
 
 BOARD_SEPOLICY_DIRS += build/target/board/generic_x86/sepolicy
 BOARD_SEPOLICY_UNION += \
+        app.te \
         adbd.te \
+        bootanim.te \
         device.te \
         domain.te \
         file.te \
@@ -55,5 +57,6 @@
         qemud.te \
         rild.te \
         shell.te \
+        surfaceflinger.te \
         system_server.te \
         zygote.te
diff --git a/target/board/generic_x86/sepolicy/app.te b/target/board/generic_x86/sepolicy/app.te
new file mode 100644
index 0000000..fd33453
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/app.te
@@ -0,0 +1 @@
+allow appdomain qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/sepolicy/bootanim.te b/target/board/generic_x86/sepolicy/bootanim.te
new file mode 100644
index 0000000..762a573
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/bootanim.te
@@ -0,0 +1 @@
+allow bootanim qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/sepolicy/surfaceflinger.te b/target/board/generic_x86/sepolicy/surfaceflinger.te
new file mode 100644
index 0000000..865405c
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/surfaceflinger.te
@@ -0,0 +1 @@
+allow surfaceflinger qemu_device:chr_file rw_file_perms;
diff --git a/target/board/generic_x86/sepolicy/zygote.te b/target/board/generic_x86/sepolicy/zygote.te
index 93993a4..d34c4a1 100644
--- a/target/board/generic_x86/sepolicy/zygote.te
+++ b/target/board/generic_x86/sepolicy/zygote.te
@@ -1,2 +1,3 @@
 allow zygote self:process execmem;
 allow zygote self:capability sys_nice;
+allow zygote qemu_device:chr_file rw_file_perms;
diff --git a/target/product/core.mk b/target/product/core.mk
index 5fe5754..875d08c 100644
--- a/target/product/core.mk
+++ b/target/product/core.mk
@@ -50,6 +50,7 @@
     SharedStorageBackup \
     Telecomm \
     TeleService \
-    VpnDialogs
+    VpnDialogs \
+    MmsService
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core_base.mk)
diff --git a/target/product/core_64_bit.mk b/target/product/core_64_bit.mk
index e2fc1a6..971b6bd 100644
--- a/target/product/core_64_bit.mk
+++ b/target/product/core_64_bit.mk
@@ -31,6 +31,3 @@
 
 TARGET_SUPPORTS_32_BIT_APPS := true
 TARGET_SUPPORTS_64_BIT_APPS := true
-
-# Disable DEXPREOPT until we have multilib support (bug 14694978).
-WITH_DEXPREOPT := false
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index 4b99ca1..522b237 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -713,6 +713,7 @@
     color: #33b5e5;
     border-bottom-color: #33b5e5; } }
 
+h1:target,
 h2:target,
 h3:target {
     -webkit-animation-name: glowheader;
@@ -1131,7 +1132,7 @@
 h3, h4 {
     color:#333;
     line-height: 20px;
-    margin: 10px 0;
+    margin: 10px 0 14px 0;
 }
 h4 {
   font-size: 16px;
@@ -5137,10 +5138,12 @@
   margin-bottom: 0px;
   font-size: 20px;
   color: #363636;
+  padding-top: 70px;
+  margin-top:-60px;
 }
 .headerLine hr {
   overflow: hidden;
-  margin: 42px 0 0 0;
+  margin: 30px 0 0 0;
 }
 
 .article-detail #body-content {
@@ -5365,11 +5368,11 @@
 .resource-flow-layout:after {
   content: ".";
   display: block;
-  height: 0;
+  height: 10;
+  position:relative;
   clear: both;
   visibility: hidden;
 }
-
 .resource-card:hover {
   cursor: pointer;
 }
@@ -6383,4 +6386,12 @@
 div.jd-descr > .resource-widget[data-section=distribute\/tools]
 .section-card-menu .card-info ul li {
   border-top-color: #7e3794 !important;
+}
+
+div.jd-descr > h2:before, h3:before {
+display:block;
+content: "   ";
+margin-top:-60px;
+height: 70px;
+visibility:hidden;
 }
\ No newline at end of file
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index e6befe3..d8d5732 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -884,103 +884,99 @@
 /* #########     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) {
+
+  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;
+  }
+
+  // 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
+});
+
+/*
+ * 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();
@@ -1827,6 +1823,11 @@
     }
     // Stop here if Google results are showing
     else if ($("#searchResults").is(":visible")) {
+        //If search_results is scrolled out of view, scroll to top on input
+        if ((sticky ) && (search.value != "")) {
+          $('body,html').animate({scrollTop:0}, '500', 'swing');
+        }
+        // if results aren't showing (and text not empty), return true to allow search to execute
         return true;
     }
     // 38 UP ARROW
@@ -2505,8 +2506,6 @@
     if (!$("#searchResults").is(":hidden")) {
       hideResults();
     }
-    // Adjust the scroll position to account for sticky header
-    $(window).scrollTop($(window).scrollTop() - 60);
     return;
   }
 
@@ -3517,7 +3516,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") ||