Merge commit 'd54f8c2d1b4d88db84465fee93aa29103ca32078' into HEAD

Change-Id: I3cf53f083dee277a450dac36b011bc83180f6294
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 783524d..ca61f88 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -393,8 +393,8 @@
 #                 to guarantee that the files in full_java_libs will
 #                 be up-to-date.
 ifdef LOCAL_IS_HOST_MODULE
-ifeq ($(LOCAL_BUILD_HOST_DEX),true)
-$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-hostdex,$(LOCAL_IS_HOST_MODULE))
+ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-deps,core-hostdex,$(LOCAL_IS_HOST_MODULE))
 
 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
diff --git a/core/build_id.mk b/core/build_id.mk
index 64ad133..aaf4185 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -18,6 +18,6 @@
 # (like "CRB01").  It must be a single word, and is
 # capitalized by convention.
 
-BUILD_ID := KK
+BUILD_ID := OPENMASTER
 
 DISPLAY_BUILD_NUMBER := true
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index 6fbb778..64957bf 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -205,8 +205,9 @@
 else
     KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
     KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
+    KERNEL_HEADERS_AUX    := $(libc_root)/kernel/uapi # for kexec.h
 endif
-KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH) $(KERNEL_HEADERS_AUX)
 
 TARGET_C_INCLUDES := \
 	$(libc_root)/arch-arm/include \
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
index ba6e8cd..a482cc4 100644
--- a/core/combo/TARGET_linux-mips.mk
+++ b/core/combo/TARGET_linux-mips.mk
@@ -35,7 +35,7 @@
 endif
 
 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-TARGET_GCC_VERSION := 4.7
+TARGET_GCC_VERSION := 4.8
 else
 TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
 endif
@@ -99,7 +99,7 @@
 # This warning causes dalvik not to build with gcc 4.6+ and -Werror.
 # We cannot turn it off blindly since the option is not available
 # in gcc-4.4.x.
-ifneq ($(filter 4.6 4.6.% 4.7 4.7.%, $(TARGET_GCC_VERSION)),)
+ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8, $(TARGET_GCC_VERSION)),)
 TARGET_GLOBAL_CFLAGS += -Wno-unused-but-set-variable \
                         -fno-strict-volatile-bitfields
 endif
@@ -194,8 +194,8 @@
     KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
     KERNEL_HEADERS_ARCH   := $(CUSTOM_KERNEL_HEADERS)
 else
-    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
-    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
+    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
 endif
 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
 
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 4a0bf98..90f44bd 100755
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -23,7 +23,7 @@
 endif
 
 ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
-TARGET_GCC_VERSION := 4.7
+TARGET_GCC_VERSION := 4.8
 else
 TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
 endif
@@ -110,8 +110,8 @@
     KERNEL_HEADERS_COMMON := $(CUSTOM_KERNEL_HEADERS)
     KERNEL_HEADERS_ARCH   := $(CUSTOM_KERNEL_HEADERS)
 else
-    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/common
-    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/arch-$(TARGET_ARCH)
+    KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+    KERNEL_HEADERS_ARCH   := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
 endif
 KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
 
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index f8c99fb..74490fd 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -6,13 +6,21 @@
 #
 # Outputs:
 #   COMMON_JAVAC -- Java compiler command with common arguments
+#
+
+ifeq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
+common_flags := -target 1.5 -Xmaxerrs 9999999
+else
+common_flags := -Xmaxerrs 9999999
+endif
+
 
 # Whatever compiler is on this system.
 ifeq ($(BUILD_OS), windows)
     COMMON_JAVAC := development/host/windows/prebuilt/javawrap.exe -J-Xmx256m \
-        -target 1.5 -Xmaxerrs 9999999
+        $(common_flags)
 else
-    COMMON_JAVAC := javac -J-Xmx512M -target 1.5 -Xmaxerrs 9999999
+    COMMON_JAVAC := javac -J-Xmx512M $(common_flags)
 endif
 
 # Eclipse.
@@ -22,14 +30,6 @@
     $(info CUSTOM_JAVA_COMPILER=eclipse)
 endif
 
-# OpenJDK.
-ifeq ($(CUSTOM_JAVA_COMPILER), openjdk)
-    # We set the VM options (like -Xmx) in the javac script.
-    COMMON_JAVAC := prebuilt/common/openjdk/bin/javac -target 1.5 \
-        -Xmaxerrs 9999999
-    $(info CUSTOM_JAVA_COMPILER=openjdk)
-endif
-   
 HOST_JAVAC ?= $(COMMON_JAVAC)
 TARGET_JAVAC ?= $(COMMON_JAVAC)
     
diff --git a/core/combo/select.mk b/core/combo/select.mk
index e485d00..7638bc4 100644
--- a/core/combo/select.mk
+++ b/core/combo/select.mk
@@ -49,7 +49,7 @@
 $(combo_target)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
 $(combo_target)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
 $(combo_target)GLOBAL_LDFLAGS :=
-$(combo_target)GLOBAL_ARFLAGS := crsP
+$(combo_target)GLOBAL_ARFLAGS := crsPD
 
 $(combo_target)EXECUTABLE_SUFFIX :=
 $(combo_target)SHLIB_SUFFIX := .so
diff --git a/core/config.mk b/core/config.mk
index 67ca243..b7c0e10 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -79,6 +79,9 @@
 BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
 BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
 BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk
+BUILD_HOST_DALVIK_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_java_library.mk
+BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
+
 
 -include cts/build/config.mk
 
diff --git a/core/definitions.mk b/core/definitions.mk
index 290bb2f..e1eb9f1 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -342,6 +342,22 @@
 endef
 
 ###########################################################
+# Use utility find to find given files in the given subdirs.
+# This function uses $(1), instead of LOCAL_PATH as the base.
+# $(1): the base dir, relative to the root of the source tree.
+# $(2): the file name pattern to be passed to find as "-name".
+# $(3): a list of subdirs of the base dir.
+# Returns: a list of paths relative to the base dir.
+###########################################################
+
+define find-files-in-subdirs
+$(patsubst ./%,%, \
+  $(shell cd $(1) ; \
+          find -L $(3) -name $(2) -and -not -name ".*") \
+ )
+endef
+
+###########################################################
 ## Scan through each directory of $(1) looking for files
 ## that match $(2) using $(wildcard).  Useful for seeing if
 ## a given directory or one of its parents contains
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index e2e76b8..34150ff 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -82,3 +82,8 @@
 endef
 
 $(eval $(call _build-dexpreopt-boot-jar-dependency))
+
+DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
+ifeq ($(TARGET_CPU_VARIANT),$(filter $(TARGET_CPU_VARIANT),cortex-a15 krait))
+DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := div
+endif
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
new file mode 100644
index 0000000..a79d64d
--- /dev/null
+++ b/core/host_dalvik_java_library.mk
@@ -0,0 +1,106 @@
+#
+# 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.
+#
+
+#
+# Rules for building a host dalvik java library. These libraries
+# are meant to be used by a dalvik VM instance running on the host.
+# They will be compiled against libcore and not the host JRE.
+#
+
+USE_CORE_LIB_BOOTCLASSPATH := true
+
+#######################################
+include $(BUILD_SYSTEM)/host_java_library_common.mk
+#######################################
+
+ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+  LOCAL_JAVA_LIBRARIES +=  core-hostdex
+endif
+
+full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
+full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
+full_classes_jar := $(intermediates.COMMON)/classes.jar
+built_dex := $(intermediates.COMMON)/classes.dex
+
+LOCAL_INTERMEDIATE_TARGETS += \
+    $(full_classes_compiled_jar) \
+    $(full_classes_jarjar_jar) \
+    $(full_classes_jar) \
+    $(built_dex)
+
+# See comment in java.mk
+java_alternative_checked_module := $(full_classes_compiled_jar)
+
+#######################################
+include $(BUILD_SYSTEM)/base_rules.mk
+#######################################
+
+$(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g
+
+java_alternative_checked_module :=
+
+# The layers file allows you to enforce a layering between java packages.
+# Run build/tools/java-layers.py for more details.
+layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
+
+$(LOCAL_INTERMEDIATE_TARGETS): \
+	PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
+$(LOCAL_INTERMEDIATE_TARGETS): \
+	PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+
+$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
+
+$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
+$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
+$(full_classes_compiled_jar): PRIVATE_JAR_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)
+	$(transform-host-java-to-package)
+
+# Run jarjar if necessary, otherwise just copy the file.
+ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
+$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+	@echo JarJar: $@
+	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+else
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+	@echo Copying: $@
+	$(hide) $(ACP) -fp $< $@
+endif
+
+$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
+	@echo Copying: $@
+	$(hide) $(ACP) -fp $< $@
+
+$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
+$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
+$(built_dex): $(full_classes_jar) $(DX)
+	$(transform-classes.jar-to-dex)
+
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
+	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
+	$(create-empty-package)
+	$(add-dex-to-package)
+	$(add-carried-java-resources)
+ifneq ($(extra_jar_args),)
+	$(add-java-resources-to-package)
+endif
+
+USE_CORE_LIB_BOOTCLASSPATH :=
diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk
new file mode 100644
index 0000000..05c4b16
--- /dev/null
+++ b/core/host_dalvik_static_java_library.mk
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+#
+# Rules for building a host dalvik static java library.
+# These libraries will be compiled against libcore and not the host
+# JRE.
+#
+
+USE_CORE_LIB_BOOTCLASSPATH := true
+LOCAL_JAVA_LIBRARIES += core-hostdex
+
+include $(BUILD_SYSTEM)/host_java_library.mk
+
+USE_CORE_LIB_BOOTCLASSPATH :=
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index 391050c..e5ebb11 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -18,55 +18,8 @@
 # Standard rules for building a host java library.
 #
 
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
-LOCAL_IS_HOST_MODULE := true
-LOCAL_BUILT_MODULE_STEM := javalib.jar
-
-# base_rules.mk looks at this
-all_res_assets :=
-
-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
-else
-  ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
-    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-nano
-  else
-    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-lite
-  endif
-endif
-endif
-
-intermediates := $(call local-intermediates-dir)
-intermediates.COMMON := $(call local-intermediates-dir,COMMON)
-
-LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
-
-ifeq ($(LOCAL_BUILD_HOST_DEX),true)
-ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
-  LOCAL_JAVA_LIBRARIES +=  core-hostdex
-endif
-
-full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
-full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
-full_classes_jar := $(intermediates.COMMON)/classes.jar
-built_dex := $(intermediates.COMMON)/classes.dex
-
-LOCAL_INTERMEDIATE_TARGETS += \
-    $(full_classes_compiled_jar) \
-    $(full_classes_jarjar_jar) \
-    $(full_classes_jar) \
-    $(built_dex)
-
-# See comment in java.mk
-java_alternative_checked_module := $(full_classes_compiled_jar)
-endif # LOCAL_BUILD_HOST_DEX
-
-LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
-
 #######################################
+include $(BUILD_SYSTEM)/host_java_library_common.mk
 include $(BUILD_SYSTEM)/base_rules.mk
 #######################################
 
@@ -78,57 +31,10 @@
 # Run build/tools/java-layers.py for more details.
 layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
 
-ifeq ($(LOCAL_BUILD_HOST_DEX),true)
-$(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
-$(LOCAL_INTERMEDIATE_TARGETS): \
-	PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
-
-$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
-
-$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
-$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
-$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
-$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
-        $(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
-	$(transform-host-java-to-package)
-
-# Run jarjar if necessary, otherwise just copy the file.
-ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
-$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
-	@echo JarJar: $@
-	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
-else
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
-endif
-
-$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
-	@echo Copying: $@
-	$(hide) $(ACP) -fp $< $@
-
-$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
-$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
-$(built_dex): $(full_classes_jar) $(DX)
-	$(transform-classes.jar-to-dex)
-
-$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
-$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
-	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
-	$(create-empty-package)
-	$(add-dex-to-package)
-	$(add-carried-java-resources)
-ifneq ($(extra_jar_args),)
-	$(add-java-resources-to-package)
-endif
-
-else
+$(LOCAL_BUILT_MODULE): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
 $(LOCAL_BUILT_MODULE): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS)
 $(LOCAL_BUILT_MODULE): PRIVATE_JAR_EXCLUDE_FILES :=
 $(LOCAL_BUILT_MODULE): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
 $(LOCAL_BUILT_MODULE): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \
 		$(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES)
 	$(transform-host-java-to-package)
-endif  # LOCAL_BUILD_HOST_DEX
diff --git a/core/host_java_library_common.mk b/core/host_java_library_common.mk
new file mode 100644
index 0000000..973afa0
--- /dev/null
+++ b/core/host_java_library_common.mk
@@ -0,0 +1,47 @@
+#
+# 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 rules for building a host java library.
+#
+
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_BUILT_MODULE_STEM := javalib.jar
+
+# base_rules.mk looks at this
+all_res_assets :=
+
+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
+else
+  ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
+    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-nano
+  else
+    LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-2.3.0-lite
+  endif
+endif
+endif
+
+intermediates := $(call local-intermediates-dir)
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
+LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
+
diff --git a/core/java.mk b/core/java.mk
index f237965..9a5404e 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -195,7 +195,7 @@
 
 # We don't need the .so files in bundled branches
 # Prevent these from showing up on the device
-ifneq (,$(TARGET_BUILD_APPS))
+ifneq (,$(TARGET_BUILD_APPS)$(FORCE_BUILD_RS_COMPAT))
 
 rs_compatibility_jni_libs := $(addprefix \
     $(renderscript_intermediate)/librs., \
diff --git a/core/main.mk b/core/main.mk
index eac2a01..511d19e 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -40,17 +40,15 @@
 # Check for broken versions of make.
 # (Allow any version under Cygwin since we don't actually build the platform there.)
 ifeq (,$(findstring CYGWIN,$(shell uname -sm)))
-ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.81))
-ifeq (0,$(shell expr $$(echo $(MAKE_VERSION) | sed "s/[^0-9\.].*//") = 3.82))
+ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
 $(warning ********************************************************************************)
 $(warning *  You are using version $(MAKE_VERSION) of make.)
-$(warning *  Android can only be built by versions 3.81 and 3.82.)
+$(warning *  Android can only be built by versions 3.81 and higher.)
 $(warning *  see https://source.android.com/source/download.html)
 $(warning ********************************************************************************)
 $(error stopping)
 endif
 endif
-endif
 
 # Absolute path of the present working direcotry.
 # This overrides the shell variable $PWD, which does not necessarily points to
@@ -140,7 +138,18 @@
 $(error Directory names containing spaces not supported)
 endif
 
-# Check for the corrent jdk
+# Check for the current jdk
+ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
+# The user asked for java7 openjdk, so check that the host
+# java version is really openjdk
+ifeq ($(shell java -version 2>&1 | grep -i openjdk),)
+$(info ************************************************************)
+$(info You asked for an OpenJDK 7 build but your version is)
+$(info $(shell java -version 2>&1 | head -n 2).)
+$(info ************************************************************)
+$(error stop)
+endif # java version is not OpenJdk
+else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
 ifneq ($(shell java -version 2>&1 | grep -i openjdk),)
 $(info ************************************************************)
 $(info You are attempting to build with an unsupported JDK.)
@@ -150,17 +159,30 @@
 $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
 $(info ************************************************************)
 $(error stop)
-endif
+endif # java version is not Sun Oracle JDK
+endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
 
-# Check for the correct version of java
+# Check for the correct version of java, should be 1.7 if
+# EXPERIMENTAL_USE_JAVA7_OPENJDK is set, 1.6 otherwise.
+ifneq ($(EXPERIMENTAL_USE_JAVA7_OPENJDK),)
+required_version := "OpenJDK 1.7"
+required_javac_version := "1.7"
+java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.7[\. "$$]')
+javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.7[\. "$$]')
+else # if EXPERIMENTAL_USE_JAVA7_OPENJDK
+required_version := "JavaSE 1.6"
+required_javac_version := "1.6"
 java_version := $(shell java -version 2>&1 | head -n 1 | grep '^java .*[ "]1\.6[\. "$$]')
+javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
+endif # if EXPERIMENTAL_USE_JAVA7_OPENJDK
+
 ifeq ($(strip $(java_version)),)
 $(info ************************************************************)
 $(info You are attempting to build with the incorrect version)
 $(info of java.)
 $(info $(space))
 $(info Your version is: $(shell java -version 2>&1 | head -n 1).)
-$(info The correct version is: Java SE 1.6.)
+$(info The required version is: $(required_version))
 $(info $(space))
 $(info Please follow the machine setup instructions at)
 $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
@@ -169,14 +191,13 @@
 endif
 
 # Check for the correct version of javac
-javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')
 ifeq ($(strip $(javac_version)),)
 $(info ************************************************************)
 $(info You are attempting to build with the incorrect version)
 $(info of javac.)
 $(info $(space))
 $(info Your version is: $(shell javac -version 2>&1 | head -n 1).)
-$(info The correct version is: 1.6.)
+$(info The required version is: $(required_javac_version))
 $(info $(space))
 $(info Please follow the machine setup instructions at)
 $(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 9ed75c9..40248fc 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -41,7 +41,7 @@
   # which is the version that we reveal to the end user.
   # Update this value when the platform version changes (rather
   # than overriding it somewhere else).  Can be an arbitrary string.
-  PLATFORM_VERSION := 4.4.1
+  PLATFORM_VERSION := 4.4.3.2.1.000.000
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
diff --git a/target/board/emulator/AndroidBoard.mk b/target/board/emulator/AndroidBoard.mk
deleted file mode 100644
index 7911f61..0000000
--- a/target/board/emulator/AndroidBoard.mk
+++ /dev/null
@@ -1 +0,0 @@
-LOCAL_PATH := $(call my-dir)
diff --git a/target/board/emulator/BoardConfig.mk b/target/board/emulator/BoardConfig.mk
deleted file mode 100644
index 9ab607a..0000000
--- a/target/board/emulator/BoardConfig.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-# config.mk
-# 
-# Product-specific compile-time definitions.
-#
-
-# The generic product target doesn't have any hardware-specific pieces.
-TARGET_NO_BOOTLOADER := true
-TARGET_NO_KERNEL := true
-HAVE_HTC_AUDIO_DRIVER := true
-
-# no hardware camera
-USE_CAMERA_STUB := true
diff --git a/target/board/emulator/README.txt b/target/board/emulator/README.txt
deleted file mode 100644
index 6a1ec89..0000000
--- a/target/board/emulator/README.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-The "emulator" product defines an almost non-hardware-specific target
-without a kernel or bootloader, except that it defines the
-HAVE_HTC_AUDIO_DRIVER constant, since that is what the emulator
-emulates currently.
-
-It can be used to build the entire user-level system, and
-will work with the emulator.
-
-It is not a product "base class"; no other products inherit
-from it or use it in any way.
diff --git a/target/product/base.mk b/target/product/base.mk
index 0959fb4..6725c0d 100644
--- a/target/product/base.mk
+++ b/target/product/base.mk
@@ -78,7 +78,6 @@
     libutils \
     libvisualizer \
     libvorbisidec \
-    libwpa_client \
     media \
     media_cmd \
     mediaserver \
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
index 1155b4e..5197166 100644
--- a/target/product/generic_no_telephony.mk
+++ b/target/product/generic_no_telephony.mk
@@ -45,8 +45,6 @@
     TeleService \
     CalendarProvider \
     bluetooth-health \
-    hostapd \
-    wpa_supplicant.conf \
     WallpaperCropper
 
 PRODUCT_PACKAGES += \
@@ -57,8 +55,7 @@
     network \
     pand \
     pppd \
-    sdptool \
-    wpa_supplicant
+    sdptool
 
 PRODUCT_PACKAGES += \
     librs_jni \