Code drop from //branches/cupcake/...@124589
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
index 3ba5fb7..8e766bb 100644
--- a/core/tasks/apicheck.mk
+++ b/core/tasks/apicheck.mk
@@ -45,9 +45,9 @@
 # SDK version.
 $(eval $(call check-api, \
 	checkapi-last, \
-	$(BUILD_SYSTEM)/api/$(lastword $(TARGET_AVAILABLE_SDK_VERSIONS)).xml, \
+	$(SRC_API_DIR)/$(lastword $(TARGET_AVAILABLE_SDK_VERSIONS)).xml, \
 	$(INTERNAL_PLATFORM_API_FILE), \
-	-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 \
+	-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 \
 	-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 \
@@ -57,16 +57,16 @@
 # SDK version.
 $(eval $(call check-api, \
 	checkapi-current, \
-	$(BUILD_SYSTEM)/api/current.xml, \
+	$(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 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 , \
 	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) $(BUILD_SYSTEM)/api/current.xml
+	$(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) $(SRC_API_DIR)/current.xml
 
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
new file mode 100644
index 0000000..6f1b94a
--- /dev/null
+++ b/core/tasks/cts.mk
@@ -0,0 +1,96 @@
+# 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
+
+# Build a name that looks like:
+#
+#     linux-x86   --> android-cts_12345_linux-x86
+#     darwin-x86  --> android-cts_12345_mac-x86
+#     windows-x86 --> android-cts_12345_windows
+#
+cts_name := android-cts_$(FILE_NAME_TAG)
+ifeq ($(HOST_OS),darwin)
+    cts_host_os := mac
+else
+    cts_host_os := $(HOST_OS)
+endif
+ifneq ($(HOST_OS),windows)
+    cts_host_os := $(cts_host_os)-$(HOST_ARCH)
+endif
+cts_name := $(cts_name)_$(cts_host_os)
+
+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 \
+	CtsTextTestCases \
+	CtsViewTestCases \
+	CtsGraphicsTestCases \
+	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 to CTS directory
+	$(hide) $(ACP) -fp $(cts_tools_src_dir)/utils/host_config.xml $(PRIVATE_DIR)/repository/
+	$(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.
+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
index ee0ec9a..12e7b5c 100644
--- a/core/tasks/localize.mk
+++ b/core/tasks/localize.mk
@@ -43,5 +43,5 @@
 
 # We want this on the build-server builds, but no reason to inflict it on
 # everyone
-$(call dist-for-goals, user droid, $(xlb_target))
+$(call dist-for-goals, droid, $(xlb_target))