auto import from //depot/cupcake/@135843
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
new file mode 100644
index 0000000..044e4af
--- /dev/null
+++ b/core/tasks/apicheck.mk
@@ -0,0 +1,76 @@
+# Copyright (C) 2008 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 running apicheck to confirm that you haven't broken
+# api compatibility or added apis illegally.
+#
+
+ifneq ($(BUILD_TINY_ANDROID), true)
+
+.PHONY: checkapi
+
+# eval this to define a rule that runs apicheck.
+#
+# Args:
+#    $(1)  target
+#    $(2)  stable api xml file
+#    $(3)  api xml file to be tested
+#    $(4)  arguments for apicheck
+#    $(5)  command to run if apicheck failed
+define check-api
+$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(APICHECK)
+	@echo "Checking API:" $(1)
+	$(hide) ( $(APICHECK) $(4) $(2) $(3) || ( $(5) ; exit 38 ) )
+	$(hide) mkdir -p $$(dir $$@)
+	$(hide) touch $$@
+checkapi: $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
+endef
+
+# Run the checkapi rules by default.
+droidcore: checkapi
+
+# INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
+
+# Check that the API we're building hasn't broken the last-released
+# SDK version.
+$(eval $(call check-api, \
+	checkapi-last, \
+	$(SRC_API_DIR)/$(lastword $(TARGET_AVAILABLE_SDK_VERSIONS)).xml, \
+	$(INTERNAL_PLATFORM_API_FILE), \
+	-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 \
+	-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+	-error 16 -error 17 -error 18 , \
+	cat $(BUILD_SYSTEM)/apicheck_msg_last.txt \
+	))
+
+# Check that the API we're building hasn't changed from the not-yet-released
+# SDK version.
+$(eval $(call check-api, \
+	checkapi-current, \
+	$(SRC_API_DIR)/current.xml, \
+	$(INTERNAL_PLATFORM_API_FILE), \
+	-error 2 -error 3 -error 4 -error 5 -error 6 \
+	-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+	-error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
+	-error 25 , \
+	cat $(BUILD_SYSTEM)/apicheck_msg_current.txt \
+	))
+
+.PHONY: update-api
+update-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
+	@echo Copying current.xml
+	$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.xml
+
+endif
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
new file mode 100644
index 0000000..9ef99db
--- /dev/null
+++ b/core/tasks/cts.mk
@@ -0,0 +1,95 @@
+# Copyright (C) 2008 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.
+
+cts_dir := $(HOST_OUT)/cts
+cts_tools_src_dir := cts/tools
+
+cts_name := android-cts
+
+CTS_EXECUTABLE := cts
+ifeq ($(HOST_OS),windows)
+    CTS_EXECUTABLE_PATH := $(cts_tools_src_dir)/host/etc/cts.bat
+else
+    CTS_EXECUTABLE_PATH := $(HOST_OUT_EXECUTABLES)/$(CTS_EXECUTABLE)
+endif
+CTS_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/cts.jar
+
+CTS_CASE_LIST := \
+	DeviceInfoCollector \
+	CtsTestStubs \
+	CtsAppTestCases \
+	CtsContentTestCases \
+	CtsDatabaseTestCases \
+	CtsGraphicsTestCases \
+	CtsLocationTestCases \
+	CtsOsTestCases \
+	CtsProviderTestCases \
+	CtsTextTestCases \
+	CtsUtilTestCases \
+	CtsViewTestCases \
+	CtsWidgetTestCases \
+	CtsNetTestCases \
+	SignatureTest
+
+DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans
+
+$(cts_dir)/all_cts_files_stamp: $(CTS_CASE_LIST) | $(ACP)
+# Make necessary directory for CTS
+	@rm -rf $(PRIVATE_CTS_DIR)
+	@mkdir -p $(TMP_DIR)
+	@mkdir -p $(PRIVATE_DIR)/docs
+	@mkdir -p $(PRIVATE_DIR)/tools
+	@mkdir -p $(PRIVATE_DIR)/repository/testcases
+	@mkdir -p $(PRIVATE_DIR)/repository/plans
+# Copy executable to CTS directory
+	$(hide) $(ACP) -fp $(CTS_HOST_JAR) $(PRIVATE_DIR)/tools
+	$(hide) $(ACP) -fp $(CTS_EXECUTABLE_PATH) $(PRIVATE_DIR)/tools
+# Change mode of the executables
+	$(hide) chmod ug+rwX $(PRIVATE_DIR)/tools/$(notdir $(CTS_EXECUTABLE_PATH))
+	$(foreach apk,$(CTS_CASE_LIST), \
+			$(call copy-testcase-apk,$(apk)))
+# Copy CTS host config and start script to CTS directory
+	$(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/host_config.xml $(PRIVATE_DIR)/repository/
+	$(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/startcts $(PRIVATE_DIR)/tools/
+	$(hide) touch $@
+
+# Generate the default test plan for User.
+$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_tools_src_dir)/utils/genDefaultTestPlan.sh
+	$(hide) bash $(cts_tools_src_dir)/utils/genDefaultTestPlan.sh cts/tests/tests/ \
+     $(PRIVATE_DIR) $(TMP_DIR) $(TOP) $(TARGET_COMMON_OUT_ROOT) $(OUT_DIR)
+
+# Package CTS and clean up.
+#
+# TODO:
+#   Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details
+INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
+$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
+$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
+$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
+$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
+$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
+	@echo "Package CTS: $@"
+	$(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
+
+.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
+
+endef
+
diff --git a/core/tasks/localize.mk b/core/tasks/localize.mk
new file mode 100644
index 0000000..12e7b5c
--- /dev/null
+++ b/core/tasks/localize.mk
@@ -0,0 +1,47 @@
+# Copyright (C) 2008 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 the xlb files for export for translation.
+# 
+
+# Gather all of the resource files for the default locale -- that is,
+# all resources in directories called values or values-something, where
+# one of the - separated segments is not two characters long -- those are the
+# language directories, and we don't want those.
+all_resource_files := $(foreach pkg, \
+        $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
+        $(PACKAGES.$(pkg).RESOURCE_FILES))
+values_resource_files := $(shell echo $(all_resource_files) | \
+		tr -s / | \
+		tr " " "\n" | \
+		grep -E "\/values[^/]*/(strings.xml|arrays.xml)$$" | \
+		grep -v -E -e "-[a-zA-Z]{2}[/\-]")
+
+xlb_target := $(PRODUCT_OUT)/strings.xlb
+
+$(xlb_target): $(values_resource_files) | $(LOCALIZE)
+	@echo XLB: $@
+	$(hide) mkdir -p $(dir $@)
+	$(hide) rm -f $@
+	$(hide) $(LOCALIZE) xlb $@ $^
+
+# Add a phony target so typing make xlb is convenient
+.PHONY: xlb
+xlb: $(xlb_target)
+
+# We want this on the build-server builds, but no reason to inflict it on
+# everyone
+$(call dist-for-goals, droid, $(xlb_target))
+