auto import from //branches/cupcake/...@126645
diff --git a/core/Makefile b/core/Makefile
index 84fa2e2..0d82299 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -112,6 +112,7 @@
 			BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \
 			TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \
 			BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \
+			TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \
 	        bash $(BUILDINFO_SH) > $@
 	$(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \
 	          cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \
@@ -399,6 +400,7 @@
 
 target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt
 target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html
+target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz
 tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt
 tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html
 
@@ -418,15 +420,17 @@
 			$(HOST_OUT_NOTICE_FILES), \
 			$(ALL_DEFAULT_INSTALLED_MODULES)))
 
-# Install the html file at /system/NOTICE.html.
+# Install the html file at /system/etc/NOTICE.html.gz.
 # This is not ideal, but this is very late in the game, after a lot of
 # the module processing has already been done -- in fact, we used the
 # fact that all that has been done to get the list of modules that we
 # need notice files for.
-installed_notice_html := $(TARGET_OUT)/etc/NOTICE.html
-$(installed_notice_html): $(target_notice_file_html) | $(ACP)
+$(target_notice_file_html_gz): $(target_notice_file_html)
+	gzip -c $< > $@
+installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz
+$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP)
 	$(copy-file-to-target)
-ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html)
+ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz)
 
 # The kernel isn't really a module, so to get its module file in there, we
 # make the target NOTICE files depend on this particular file too, which will
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 2c442f6..ba89c40 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -57,8 +57,8 @@
 
 LOCAL_MODULE_TAGS := $(sort $(LOCAL_MODULE_TAGS))
 ifeq (,$(LOCAL_MODULE_TAGS))
-# Modules without tags fall back to the default set
-LOCAL_MODULE_TAGS := eng user development
+# Modules without tags fall back to user (which is changed to user eng below)
+LOCAL_MODULE_TAGS := user
 #$(warning default tags: $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))))
 endif
 
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 768a0ac..f090507 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -81,6 +81,8 @@
 LOCAL_DX_FLAGS:=
 LOCAL_CERTIFICATE:=
 LOCAL_SDK_VERSION:=
+LOCAL_NO_EMMA_INSTRUMENT:=
+LOCAL_NO_EMMA_COMPILE:=
 
 # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
 # iterate over thousands of entries every time.
diff --git a/core/config.mk b/core/config.mk
index 81063b5..90e5362 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -16,6 +16,7 @@
 SRC_HEADERS := \
 	$(TOPDIR)system/core/include \
 	$(TOPDIR)hardware/libhardware/include \
+	$(TOPDIR)hardware/libhardware_legacy/include \
 	$(TOPDIR)hardware/ril/include \
 	$(TOPDIR)dalvik/libnativehelper/include \
 	$(TOPDIR)frameworks/base/include \
@@ -171,6 +172,7 @@
 ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign$(HOST_EXECUTABLE_SUFFIX)
 FINDBUGS := prebuilt/common/findbugs/bin/findbugs
 LOCALIZE := $(HOST_OUT_EXECUTABLES)/localize$(HOST_EXECUTABLE_SUFFIX)
+EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
 
 # Binary prelinker/compressor tools
 APRIORI := $(HOST_OUT_EXECUTABLES)/apriori$(HOST_EXECUTABLE_SUFFIX)
@@ -292,3 +294,4 @@
 INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.xml
 
 
+
diff --git a/core/definitions.mk b/core/definitions.mk
index a24837b..780d8fb 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -243,9 +243,15 @@
 ###########################################################
 
 define find-subdir-assets
-$(if $(1),$(patsubst ./%,%, \
-	$(shell if [ -d $(1) ] ; then cd $(1) ; find ./ -type f -and -not -type l ; fi)), \
-	$(warning Empty argument supplied to find-subdir-assets) \
+$(if $(1),\
+  $(patsubst ./%,%, $(foreach dir,$(1),\
+    $(shell if [ -d $(dir) ] ; then\
+	 cd $(dir) ; find ./ -type f -and -not -type l ;\
+      fi \
+    ) \
+  )) \
+, \
+  $(warning Empty argument supplied to find-subdir-assets) \
 )
 endef
 
@@ -1135,7 +1141,7 @@
 $(hide) $(TARGET_JAVAC) -encoding ascii $(PRIVATE_BOOTCLASSPATH) \
     $(addprefix -classpath ,$(strip \
         $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
-    -g $(xlint_unchecked) \
+    $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) $(xlint_unchecked) \
     -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
     \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
     || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 )
@@ -1147,6 +1153,11 @@
 @rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
 endef
 
+define transform-classes.jar-to-emma
+$(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \
+    $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR)
+endef
+
 #TODO: use a smaller -Xmx value for most libraries;
 #      only core.jar and framework.jar need a heap this big.
 define transform-classes.jar-to-dex
@@ -1477,3 +1488,4 @@
 #	  sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
 #	      -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
 #	  rm -f $*.d
+
diff --git a/core/java.mk b/core/java.mk
index 25baf41..65c525d 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -66,24 +66,70 @@
 # variable definitions.
 full_classes_jar := $(intermediates.COMMON)/classes.jar
 
+# Emma source code coverage
+ifneq ($(EMMA_INSTRUMENT),true) 
+LOCAL_NO_EMMA_INSTRUMENT := true
+LOCAL_NO_EMMA_COMPILE := true
+endif
+
+ifneq ($(LOCAL_NO_EMMA_COMPILE),true) 
+# If you instrument class files that have local variable debug information in
+# them emma does not correctly maintain the local variable table.
+# This will cause an error when you try to convert the class files for Android.
+# The workaround for this to compile the java classes with only
+# line and source debug information, not local information.
+full_classes_compiled_name_jar := classes-no-debug-var.jar
+$(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g:{lines,source}
+else
+# when emma is off, compile with the default flags, which contain full debug 
+# info
+full_classes_compiled_name_jar := classes-full-debug.jar
+$(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g
+endif
+
 # Compile the java files to a .jar file.
 # This intentionally depends on java_sources, not all_java_sources.
 # Deps for generated source files must be handled separately,
 # via deps on the target that generates the sources.
-full_classes_compiled_jar := $(intermediates.COMMON)/classes-compiled.jar
+full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_name_jar)
 $(full_classes_compiled_jar): $(java_sources) $(full_java_lib_deps)
 	$(transform-java-to-classes.jar)
 
+emma_intermediates_dir := $(intermediates.COMMON)/emma_out
+# the 'lib/$(full_classes_compiled_name_jar)' portion of this path is fixed in 
+# the emma tool
+full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(full_classes_compiled_name_jar)
+
+ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
+# Skip adding emma instrumentation to class files if this is a static library,
+# since it will be instrumented by the package that includes it
+LOCAL_NO_EMMA_INSTRUMENT:= true
+endif
+
+ifneq ($(LOCAL_NO_EMMA_INSTRUMENT),true)
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
+$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
+# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
+# $(full_classes_emma_jar)
+$(full_classes_emma_jar): $(full_classes_compiled_jar)
+	$(transform-classes.jar-to-emma)
+$(PRIVATE_EMMA_COVERAGE_FILE): $(full_classes_emma_jar)
+else
+$(full_classes_emma_jar): $(full_classes_compiled_jar) | $(ACP)
+	@echo Copying $<
+	$(copy-file-to-target)
+endif
+
 # Run jarjar if necessary, otherwise just copy the file.  This is the last
 # part of this step, so the output of this command is full_classes_jar.
 full_classes_jarjar_jar := $(full_classes_jar)
 ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
 $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | jarjar
+$(full_classes_jarjar_jar): $(full_classes_emma_jar) | jarjar
 	@echo JarJar: $@
 	$(hide) $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
 else
-$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+$(full_classes_jarjar_jar): $(full_classes_emma_jar) | $(ACP)
 	@echo Copying: $@
 	$(hide) $(ACP) $< $@
 endif
diff --git a/core/main.mk b/core/main.mk
index 4a1519c..4f97b33 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -165,7 +165,7 @@
 ifneq ($(words $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))),1)
 $(error The 'sdk' target may not be specified with any other targets)
 endif
-override_build_tags := development
+override_build_tags := user
 ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
 ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
 else # !sdk
@@ -488,35 +488,12 @@
 debug_MODULES := $(sort $(call get-tagged-modules,debug,restricted))
 tests_MODULES := $(sort $(call get-tagged-modules,tests,restricted))
 
-# Don't include any GNU targets in the SDK.  It's ok (and necessary)
-# to build the host tools, but nothing that's going to be installed
-# on the target (including static libraries).
-all_development_MODULES := \
-	$(sort $(call get-tagged-modules,development,restricted))
-target_gnu_MODULES := \
-	$(filter \
-		$(TARGET_OUT_INTERMEDIATES)/% \
-		$(TARGET_OUT)/% \
-		$(TARGET_OUT_DATA)/%, \
-	    $(sort $(call get-tagged-modules,gnu)))
-#$(info Removing from development:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
-development_MODULES := \
-	$(filter-out $(target_gnu_MODULES),$(all_development_MODULES))
-
 droid_MODULES := $(sort $(Default_MODULES) \
 			$(eng_MODULES) \
 			$(debug_MODULES) \
 			$(user_MODULES) \
 			$(all_development_MODULES))
 
-# The list of everything that's not on droid_MODULES.
-# Also skip modules tagged as "restricted", which are
-# never installed unless explicitly mentioned in
-# CUSTOM_MODULES.
-nonDroid_MODULES := $(sort $(call get-tagged-modules,\
-			  $(ALL_MODULE_TAGS),\
-			  eng debug user development restricted))
-
 # THIS IS A TOTAL HACK AND SHOULD NOT BE USED AS AN EXAMPLE
 modules_to_build := $(droid_MODULES)
 ifneq ($(override_build_tags),)
@@ -536,6 +513,22 @@
 endif
 #$(error filtered out $(filter-out $(modules_to_build),$(old_modules_to_build)))
 
+# Don't include any GNU targets in the SDK.  It's ok (and necessary)
+# to build the host tools, but nothing that's going to be installed
+# on the target (including static libraries).
+ifneq ($(filter sdk,$(MAKECMDGOALS)),)
+  target_gnu_MODULES := \
+              $(filter \
+                      $(TARGET_OUT_INTERMEDIATES)/% \
+                      $(TARGET_OUT)/% \
+                      $(TARGET_OUT_DATA)/%, \
+                              $(sort $(call get-tagged-modules,gnu)))
+  $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
+  modules_to_build := \
+              $(filter-out $(target_gnu_MODULES),$(modules_to_build))
+endif
+
+
 # config/Makefile contains extra stuff that we don't want to pollute this
 # top-level makefile with.  It expects that ALL_DEFAULT_INSTALLED_MODULES
 # contains everything that's built during the current make, but it also further
diff --git a/core/package.mk b/core/package.mk
index 07690ad..ba41495 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -65,7 +65,8 @@
 endif
 
 ifeq (,$(LOCAL_RESOURCE_DIR))
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+LOCAL_RESOURCE_DIR := $(wildcard $(addsuffix /$(LOCAL_PATH)/res, $(PRODUCT_PACKAGE_OVERLAYS))) \
+  $(LOCAL_PATH)/res
 endif
 
 # this is an app, so add the system libraries to the search path
diff --git a/core/pathmap.mk b/core/pathmap.mk
index 5498898..13cb80d 100644
--- a/core/pathmap.mk
+++ b/core/pathmap.mk
@@ -39,6 +39,7 @@
     libdrm1:frameworks/base/media/libdrm/mobile1/include \
     libdrm2:frameworks/base/media/libdrm/mobile2/include \
     libhardware:hardware/libhardware/include \
+    libhardware_legacy:hardware/libhardware_legacy/include \
     libhost:build/libs/host/include \
     libm:bionic/libm/include \
     libnativehelper:dalvik/libnativehelper/include \
diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
index 2e90322..413dcc4 100644
--- a/core/prelink-linux-arm.map
+++ b/core/prelink-linux-arm.map
@@ -75,7 +75,8 @@
 libwebcore.so           0xAA000000
 libutils.so             0xA9D00000
 libcameraservice.so     0xA9C80000
-libhardware.so          0xA9C00000
+libhardware.so          0xA9C70000
+libhardware_legacy.so   0xA9C00000
 libapp_process.so       0xA9B00000
 libsystem_server.so     0xA9A00000
 libime.so               0xA9800000
diff --git a/core/product.mk b/core/product.mk
index 2406b06..08019e8 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -66,7 +66,8 @@
     PRODUCT_PROPERTY_OVERRIDES \
     PRODUCT_COPY_FILES \
     PRODUCT_OTA_PUBLIC_KEYS \
-    PRODUCT_POLICY
+    PRODUCT_POLICY \
+    PRODUCT_PACKAGE_OVERLAYS
 
 define dump-product
 $(info ==== $(1) ====)\
diff --git a/core/product_config.mk b/core/product_config.mk
index 1031fa1..436f9f6 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -186,6 +186,10 @@
 PRODUCT_PROPERTY_OVERRIDES := \
 	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
 
+# Should we use the default resources or add any product specific overlays
+PRODUCT_PACKAGE_OVERLAYS := \
+	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
+
 # Add the product-defined properties to the build properties.
 ADDITIONAL_BUILD_PROPERTIES := \
 	$(ADDITIONAL_BUILD_PROPERTIES) \