auto import from //branches/cupcake/...@130745
diff --git a/core/Makefile b/core/Makefile
index d8af02c..ca2b143 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -109,6 +109,7 @@
 			PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \
 			PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \
 			BUILD_ID="$(BUILD_ID)" \
+			BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \
 			BUILD_NUMBER="$(BUILD_NUMBER)" \
 			PLATFORM_VERSION="$(PLATFORM_VERSION)" \
 			PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \
@@ -559,6 +560,7 @@
 ## Generate an ext2 image
 define build-userdataimage-target
     $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
+    @mkdir -p $(TARGET_OUT_DATA)
     $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,)
     $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
 endef
@@ -568,6 +570,7 @@
 ## Generate a yaffs2 image
 define build-userdataimage-target
     $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
+    @mkdir -p $(TARGET_OUT_DATA)
     $(hide) $(MKYAFFS2) -f $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET)
     $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE))
 endef
diff --git a/core/build_id.mk b/core/build_id.mk
index 9899dd4..cb18bc4 100644
--- a/core/build_id.mk
+++ b/core/build_id.mk
@@ -23,4 +23,10 @@
 # (like "TC1-RC5").  It must be a single word, and is
 # capitalized by convention.
 #
-BUILD_ID := MAIN
+BUILD_ID := CUPCAKE
+
+# DISPLAY_BUILD_NUMBER should only be set for development branches,
+# If set, the BUILD_NUMBER (cl) is appended to the BUILD_ID for
+# a more descriptive BUILD_ID_DISPLAY, otherwise BUILD_ID_DISPLAY
+# is the same as BUILD_ID
+DISPLAY_BUILD_NUMBER := true
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index b2e04a7..0b292bf 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -84,3 +84,111 @@
 clean_steps_file :=
 INTERNAL_CLEAN_STEPS :=
 INTERNAL_CLEAN_BUILD_VERSION :=
+
+
+# Since products and build variants (unfortunately) share the same
+# PRODUCT_OUT staging directory, things can get out of sync if different
+# build configurations are built in the same tree.  The following logic
+# will notice when the configuration has changed and remove the files
+# necessary to keep things consistent.
+
+previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk
+
+# TODO: this special case for the sdk is only necessary while "sdk"
+# is a valid make target.  Eventually, it will just be a product, at
+# which point TARGET_PRODUCT will handle it and we can avoid this check
+# of MAKECMDGOALS.  The "addprefix" is just to keep things pretty.
+ifneq ($(TARGET_PRODUCT),sdk)
+  building_sdk := $(addprefix -,$(filter sdk,$(MAKECMDGOALS)))
+else
+  # Don't bother with this extra part when explicitly building the sdk product.
+  building_sdk :=
+endif
+current_build_config := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)$(building_sdk)
+building_sdk :=
+force_installclean := false
+
+# Read the current state from the file, if present.
+# Will set PREVIOUS_BUILD_CONFIG.
+#
+PREVIOUS_BUILD_CONFIG :=
+-include $(previous_build_config_file)
+PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG))
+ifdef PREVIOUS_BUILD_CONFIG
+  ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)"
+    $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)")
+    force_installclean := true
+  endif
+endif  # else, this is the first build, so no need to clean.
+PREVIOUS_BUILD_CONFIG :=
+
+# Write the new state to the file.
+#
+$(shell \
+  mkdir -p $(dir $(previous_build_config_file)) && \
+  echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \
+      $(previous_build_config_file) \
+ )
+previous_build_config_file :=
+current_build_config :=
+
+#
+# installclean logic
+#
+
+# The files/dirs to delete during an installclean.  This includes the
+# non-common APPS directory, which may contain the wrong resources.
+# Use "./" in front of the paths to avoid accidentally deleting random
+# parts of the filesystem if any of the *_OUT vars resolve to blank.
+#
+# Deletes all of the files that change between different build types,
+# like "make user" vs. "make sdk".  This lets you work with different
+# build types without having to do a full clean each time.  E.g.:
+#
+#     $ make -j8 all
+#     $ make installclean
+#     $ make -j8 user
+#     $ make installclean
+#     $ make -j8 sdk
+#
+installclean_files := \
+	./$(HOST_OUT)/obj/NOTICE_FILES \
+	./$(HOST_OUT)/sdk \
+	./$(PRODUCT_OUT)/*.img \
+	./$(PRODUCT_OUT)/*.txt \
+	./$(PRODUCT_OUT)/*.xlb \
+	./$(PRODUCT_OUT)/*.zip \
+	./$(PRODUCT_OUT)/data \
+	./$(PRODUCT_OUT)/obj/APPS \
+	./$(PRODUCT_OUT)/obj/NOTICE_FILES \
+	./$(PRODUCT_OUT)/obj/PACKAGING \
+	./$(PRODUCT_OUT)/recovery \
+	./$(PRODUCT_OUT)/root \
+	./$(PRODUCT_OUT)/system
+
+# The files/dirs to delete during a dataclean, which removes any files
+# in the staging and emulator data partitions.
+dataclean_files := \
+	./$(PRODUCT_OUT)/data/* \
+	./$(PRODUCT_OUT)/data-qemu/* \
+	./$(PRODUCT_OUT)/userdata-qemu.img
+
+# Define the rules for commandline invocation.
+.PHONY: dataclean
+dataclean: FILES := $(dataclean_files)
+dataclean:
+	$(hide) rm -rf $(FILES)
+	@echo "Deleted emulator userdata images."
+
+.PHONY: installclean
+installclean: FILES := $(installclean_files)
+installclean: dataclean
+	$(hide) rm -rf $(FILES)
+	@echo "Deleted images and staging directories."
+
+ifeq "$(force_installclean)" "true"
+  $(info *** Forcing "make installclean"...)
+  $(shell rm -rf $(dataclean_files) $(installclean_files))
+  $(info *** Done with the cleaning, now starting the real build.)
+endif
+force_installclean :=
diff --git a/core/config.mk b/core/config.mk
index 90e5362..90a40a7 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -20,6 +20,7 @@
 	$(TOPDIR)hardware/ril/include \
 	$(TOPDIR)dalvik/libnativehelper/include \
 	$(TOPDIR)frameworks/base/include \
+	$(TOPDIR)frameworks/base/opengl/include \
 	$(TOPDIR)external/skia/include
 SRC_HOST_HEADERS:=$(TOPDIR)tools/include
 SRC_LIBRARIES:= $(TOPDIR)libs
@@ -87,6 +88,8 @@
 COMMON_JAVA_PACKAGE_SUFFIX := .jar
 COMMON_ANDROID_PACKAGE_SUFFIX := .apk
 
+# list of flags to turn specific warnings in to errors
+TARGET_ERROR_FLAGS := -Werror=return-type
 
 # ###############################################################
 # Include sub-configuration files
@@ -245,6 +248,16 @@
 HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
 TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS)
 
+# Many host compilers don't support these flags, so we have to make
+# sure to only specify them for the target compilers checked in to
+# the source tree. The simulator uses the target flags but the
+# host compiler, so only set them for the target when the target
+# is not the simulator.
+ifneq ($(TARGET_SIMULATOR),true)
+TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
+TARGET_GLOBAL_CPPFLAGS += $(TARGET_ERROR_FLAGS)
+endif
+
 ifeq ($(HOST_BUILD_TYPE),release)
 HOST_GLOBAL_CFLAGS+= $(HOST_RELEASE_CFLAGS)
 HOST_GLOBAL_CPPFLAGS+= $(HOST_RELEASE_CPPFLAGS)
diff --git a/core/distdir.mk b/core/distdir.mk
index 777242b..e04938b 100644
--- a/core/distdir.mk
+++ b/core/distdir.mk
@@ -46,13 +46,20 @@
 # and "dist" is specified, the marked files will be copied to DIST_DIR.
 #
 # $(1): a list of goals  (e.g. droid, sdk, pdk, ndk)
-# $(2): the dist files to add to those goals
+# $(2): the dist files to add to those goals.  If the file contains ':',
+#       the text following the colon is the name that the file is copied
+#       to under the dist directory.  Subdirs are ok, and will be created
+#       at copy time if necessary.
 define dist-for-goals
 $(foreach file,$(2), \
+  $(eval fw := $(subst :,$(space),$(file))) \
+  $(eval src := $(word 1,$(fw))) \
+  $(eval dst := $(word 2,$(fw))) \
+  $(eval dst := $(if $(dst),$(dst),$(notdir $(src)))) \
   $(eval \
       $(call copy-one-dist-file, \
-          $(file), \
-          $(DIST_DIR)/$(notdir $(file)), \
+          $(src), \
+          $(DIST_DIR)/$(dst), \
 	  $(1) \
        ) \
    ) \
diff --git a/core/main.mk b/core/main.mk
index 216225b..a1374a2 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -325,10 +325,6 @@
 #
 INTERNAL_DEFAULT_DOCS_TARGETS := offline-sdk-docs
 subdirs := $(TOP)
-# Only include Android.mk files directly under vendor/*, not
-# *all* Android.mk files under vendor (which is what would happen
-# if we didn't prune vendor in the findleaves call).
-subdir_makefiles += $(wildcard vendor/*/Android.mk)
 
 FULL_BUILD := true
 
@@ -339,8 +335,7 @@
 # Can't use first-makefiles-under here because
 # --mindepth=2 makes the prunes not work.
 subdir_makefiles += \
-	$(shell build/tools/findleaves.sh \
-	    --prune="./vendor" --prune="./out" $(subdirs) Android.mk)
+	$(shell build/tools/findleaves.sh --prune="./out" $(subdirs) Android.mk)
 
 # Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
 # or under vendor/*/$(TARGET_DEVICE).  Search in both places, but
@@ -632,40 +627,7 @@
 	@rm -rf $(OUT_DIR)
 	@echo "Entire build directory removed."
 
-.PHONY: dataclean
-dataclean:
-	@rm -rf $(PRODUCT_OUT)/data/*
-	@rm -rf $(PRODUCT_OUT)/data-qemu/*
-	@rm -rf $(PRODUCT_OUT)/userdata-qemu.img
-	@echo "Deleted emulator userdata images."
-
-.PHONY: installclean
-# Deletes all of the files that change between different build types,
-# like "make user" vs. "make sdk".  This lets you work with different
-# build types without having to do a full clean each time.  E.g.:
-#
-#     $ make -j8 all
-#     $ make installclean
-#     $ make -j8 user
-#     $ make installclean
-#     $ make -j8 sdk
-#
-installclean: dataclean
-	$(hide) rm -rf ./$(PRODUCT_OUT)/system
-	$(hide) rm -rf ./$(PRODUCT_OUT)/recovery
-	$(hide) rm -rf ./$(PRODUCT_OUT)/data
-	$(hide) rm -rf ./$(PRODUCT_OUT)/root
-	$(hide) rm -rf ./$(PRODUCT_OUT)/obj/NOTICE_FILES
-	@# Remove APPS because they may contain the wrong resources.
-	$(hide) rm -rf ./$(PRODUCT_OUT)/obj/APPS
-	$(hide) rm -rf ./$(HOST_OUT)/obj/NOTICE_FILES
-	$(hide) rm -rf ./$(HOST_OUT)/sdk
-	$(hide) rm -rf ./$(PRODUCT_OUT)/obj/PACKAGING
-	$(hide) rm -f ./$(PRODUCT_OUT)/*.img
-	$(hide) rm -f ./$(PRODUCT_OUT)/*.zip
-	$(hide) rm -f ./$(PRODUCT_OUT)/*.txt
-	$(hide) rm -f ./$(PRODUCT_OUT)/*.xlb
-	@echo "Deleted images and staging directories."
+# The rules for dataclean and installclean are defined in cleanbuild.mk.
 
 #xxx scrape this from ALL_MODULE_NAME_TAGS
 .PHONY: modules
diff --git a/core/package.mk b/core/package.mk
index 32f394f..a212553 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -69,6 +69,7 @@
 endif
 LOCAL_RESOURCE_DIR := \
   $(wildcard $(addsuffix /$(LOCAL_RESOURCE_DIR), $(PRODUCT_PACKAGE_OVERLAYS))) \
+  $(wildcard $(addsuffix /$(LOCAL_RESOURCE_DIR), $(DEVICE_PACKAGE_OVERLAYS))) \
   $(LOCAL_RESOURCE_DIR)
 
 # this is an app, so add the system libraries to the search path
diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
index 413dcc4..3ac09a4 100644
--- a/core/prelink-linux-arm.map
+++ b/core/prelink-linux-arm.map
@@ -52,7 +52,13 @@
 libcorecg.so            0xACE00000
 libsurfaceflinger.so    0xACD00000
 libagl.so               0xACC00000
-libGLES_CM.so           0xACB00000
+
+libGLESv1_CM.so         0xACB00000
+libGLESv2.so            0xACA00000
+libOpenVG_CM.so         0xAC900000
+libOpenVGU_CM.so        0xAC800000
+libEGL.so               0xAC700000
+
 libexif.so              0xAC500000
 libui.so                0xAC400000
 libsgl.so               0xAC000000
@@ -98,6 +104,14 @@
 libopencoremp4reg.so          0xA7300000
 libopencoreplayer.so          0xA7000000
 
+# opencore hardware support
+libmm-adspsvc.so              0xA6FFD000
+libOmxCore.so                 0xA6FF0000
+libOmxMpeg4Dec.so             0xA6FC0000
+libOmxH264Dec.so              0xA6F90000
+libOmxVidEnc.so               0xA6F60000
+libopencorehw.so              0xA6F50000
+
 # libraries for specific apps or temporary libraries
 libcam_ipl.so           0x9F000000
 libwbxml.so             0x9E800000
diff --git a/core/product.mk b/core/product.mk
index 08019e8..8f5dc7b 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -23,14 +23,8 @@
 # $(call ) isn't necessary.
 #
 define _find-android-products-files
-$(foreach vendor,$(wildcard vendor/*), \
-  $(if $(wildcard $(vendor)/AndroidProducts.mk), \
-    $(vendor)/AndroidProducts.mk \
-   , \
-    $(wildcard $(vendor)/*/AndroidProducts.mk) \
-   ) \
- ) \
- $(wildcard $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
+$(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk) \
+  $(SRC_TARGET_DIR)/product/AndroidProducts.mk
 endef
 
 #
@@ -67,7 +61,10 @@
     PRODUCT_COPY_FILES \
     PRODUCT_OTA_PUBLIC_KEYS \
     PRODUCT_POLICY \
-    PRODUCT_PACKAGE_OVERLAYS
+    PRODUCT_PACKAGE_OVERLAYS \
+    DEVICE_PACKAGE_OVERLAYS \
+    PRODUCT_CONTRIBUTORS_FILE \
+    PRODUCT_TAGS
 
 define dump-product
 $(info ==== $(1) ====)\
diff --git a/core/product_config.mk b/core/product_config.mk
index 436f9f6..a9021cc 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -181,6 +181,10 @@
 PRODUCT_COPY_FILES := \
 	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))
 
+# The HTML file containing the contributors to the project.
+PRODUCT_CONTRIBUTORS_FILE := \
+	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CONTRIBUTORS_FILE))
+
 # A list of property assignments, like "key = value", with zero or more
 # whitespace characters on either side of the '='.
 PRODUCT_PROPERTY_OVERRIDES := \
@@ -189,6 +193,11 @@
 # Should we use the default resources or add any product specific overlays
 PRODUCT_PACKAGE_OVERLAYS := \
 	$(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
+DEVICE_PACKAGE_OVERLAYS := \
+        $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))
+
+# An list of whitespace-separated words.
+PRODUCT_TAGS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_TAGS))
 
 # Add the product-defined properties to the build properties.
 ADDITIONAL_BUILD_PROPERTIES := \
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 6f1b94a..fe54d04 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -43,9 +43,18 @@
 CTS_CASE_LIST := \
 	DeviceInfoCollector \
 	CtsTestStubs \
-	CtsTextTestCases \
-	CtsViewTestCases \
+	CtsAppTestCases \
+	CtsContentTestCases \
+	CtsDatabaseTestCases \
 	CtsGraphicsTestCases \
+	CtsLocationTestCases \
+	CtsNetTestCases \
+	CtsOsTestCases \
+	CtsProviderTestCases \
+	CtsTextTestCases \
+	CtsUtilTestCases \
+	CtsViewTestCases \
+	CtsWidgetTestCases \
 	SignatureTest
 
 DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans
@@ -84,11 +93,12 @@
 	@echo "Package CTS: $@"
 	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
 
-.PHONY: cts 
+.PHONY: cts
 cts: $(INTERNAL_CTS_TARGET) adb
 $(call dist-for-goals,cts,$(INTERNAL_CTS_TARGET))
 
 define copy-testcase-apk
+
 $(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,$(1))/package.apk \
 	$(PRIVATE_DIR)/repository/testcases/$(1).apk
 
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 7a3c682..e38a803 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -71,3 +71,14 @@
   # anyone trying to parse it as an integer will probably get "0".
   BUILD_NUMBER := eng.$(USER).$(shell date +%Y%m%d.%H%M%S)
 endif
+
+ifeq "true" "$(DISPLAY_BUILD_NUMBER)"
+  # if the build_id.mk has this defined, then BUILD_ID is updated with
+  # the BUILD_NUMBER as well.  For development branches, this will be 
+  # set, but release branches this will not be set.
+  BUILD_DISPLAY_ID := "$(BUILD_ID).$(BUILD_NUMBER)"
+else
+  BUILD_DISPLAY_ID := "$(BUILD_ID)"
+endif
+
+