Merge "Group needed libraries together to solve the cyclic dependence between libc, libc_nomalloc and libgcc. When building with upcoming arm-linux-androideabi toolchain, Symbol raise is needed by libgcc.a and defined by libc.a or libc_nomalloc.a.which."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index b84e1b6..af90039 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -44,6 +44,10 @@
 #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
 #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
 
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/Makefile b/core/Makefile
index a5e91d9..b6e4ecd 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -95,6 +95,14 @@
   BUILD_DISPLAY_ID := $(build_desc)
 endif
 
+# Whether there is default locale set in PRODUCT_PROPERTY_OVERRIDES
+product_property_override_locale_language := $(strip \
+    $(patsubst ro.product.locale.language=%,%,\
+    $(filter ro.product.locale.language=%,$(PRODUCT_PROPERTY_OVERRIDES))))
+product_property_overrides_locale_region := $(strip \
+    $(patsubst ro.product.locale.region=%,%,\
+    $(filter ro.product.locale.region=%,$(PRODUCT_PROPERTY_OVERRIDES))))
+
 # Selects the first locale in the list given as the argument,
 # and splits it into language and region, which each may be
 # empty.
@@ -103,12 +111,13 @@
 endef
 
 # Selects the first locale in the list given as the argument
-# and returns the language (or the region)
+# and returns the language (or the region), if it's not set in PRODUCT_PROPERTY_OVERRIDES;
+# Return empty string if it's already set in PRODUCT_PROPERTY_OVERRIDES.
 define default-locale-language
-$(word 2, 2, $(call default-locale, $(1)))
+$(if $(product_property_override_locale_language),,$(word 1, $(call default-locale, $(1))))
 endef
 define default-locale-region
-$(word 3, 3, $(call default-locale, $(1)))
+$(if $(product_property_overrides_locale_region),,$(word 2, $(call default-locale, $(1))))
 endef
 
 BUILDINFO_SH := build/tools/buildinfo.sh
diff --git a/core/binary.mk b/core/binary.mk
index b8688bb..e8f1d80 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -9,6 +9,10 @@
 ## Sanity check for LOCAL_NDK_VERSION
 ######################################
 my_ndk_version_root :=
+ifeq ($(TARGET_SIMULATOR),true)
+  # NDK does not support sim build.
+  LOCAL_NDK_VERSION :=
+endif
 ifdef LOCAL_NDK_VERSION
   ifdef LOCAL_IS_HOST_MODULE
     $(error $(LOCAL_PATH): LOCAL_NDK_VERSION can not be used in host module)
@@ -346,6 +350,10 @@
 
 LOCAL_C_INCLUDES += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(base_intermediates)
 
+ifndef LOCAL_NDK_VERSION
+  LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+endif
+
 $(all_objects) : | $(LOCAL_GENERATED_SOURCES)
 ALL_C_CPP_ETC_OBJECTS += $(all_objects)
 
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index b9b0eda..69ed4f5 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -96,6 +96,8 @@
 LOCAL_PROGUARD_ENABLED:= # '',optonly,full,custom
 LOCAL_PROGUARD_FLAGS:=
 LOCAL_EMMA_COVERAGE_FILTER:=
+LOCAL_WARNINGS_ENABLE:=
+LOCAL_MANIFEST_FILE:=
 
 # 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 e6295d8..a2173dd 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -70,6 +70,8 @@
 BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
 BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
 BUILD_KEY_CHAR_MAP := $(BUILD_SYSTEM)/key_char_map.mk
+BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
+BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
 
 # ###############################################################
 # Parse out any modifier targets.
diff --git a/core/definitions.mk b/core/definitions.mk
index 5e1df45..1feb5ec 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1291,7 +1291,7 @@
 ifeq ($(HOST_OS),windows)
 xlint_unchecked :=
 else
-#xlint_unchecked := -Xlint:unchecked
+xlint_unchecked := -Xlint:unchecked
 endif
 
 # emit-line, <word list>, <output file>
@@ -1366,7 +1366,8 @@
 $(hide) $(TARGET_JAVAC) -encoding ascii $(PRIVATE_BOOTCLASSPATH) \
     $(addprefix -classpath ,$(strip \
         $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
-    $(PRIVATE_JAVACFLAGS) $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) $(xlint_unchecked) \
+    $(PRIVATE_JAVACFLAGS) $(strip $(PRIVATE_JAVAC_DEBUG_FLAGS)) \
+	$(if $(findstring true,$(LOCAL_WARNINGS_ENABLE)),$(xlint_unchecked),) \
     -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
     \@$(dir $(PRIVATE_CLASS_INTERMEDIATES_DIR))/java-source-list-uniq \
     || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 )
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 87ac2f6..da9dd28 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -237,6 +237,7 @@
 TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
 TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
 TARGET_OUT_DATA_STATIC_LIBRARIES:= $(TARGET_OUT_STATIC_LIBRARIES)
+TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
 
 TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
 TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
diff --git a/core/host_native_test.mk b/core/host_native_test.mk
new file mode 100644
index 0000000..2a77f1e
--- /dev/null
+++ b/core/host_native_test.mk
@@ -0,0 +1,14 @@
+################################################
+## A thin wrapper around BUILD_HOST_EXECUTABLE
+## Common flags for host native tests are added.
+################################################
+
+LOCAL_CFLAGS += -DGTEST_OS_LINUX -DGTEST_HAS_STD_STRING -O0 -g
+LOCAL_C_INCLUDES +=  \
+                    bionic/libstdc++/include \
+                    external/gtest/include \
+                    external/astl/include
+LOCAL_STATIC_LIBRARIES += libgtest_host libgtest_main_host libastl_host
+LOCAL_SHARED_LIBRARIES +=
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/core/main.mk b/core/main.mk
index 60d561b..da66c36 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -287,7 +287,6 @@
   ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.dexopt-flags=m=y
 endif
 
-ifeq (,$(TARGET_BUILD_APPS))
 # Install an apns-conf.xml file if one's not already being installed.
 ifeq (,$(filter %:system/etc/apns-conf.xml, $(PRODUCT_COPY_FILES)))
   PRODUCT_COPY_FILES += \
@@ -308,7 +307,6 @@
     endif
   endif
 endif
-endif # !TARGET_BUILD_APPS
 
 ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
 
@@ -763,6 +761,10 @@
 .PHONY: droid tests
 tests: droidcore
 
+# phony target that include any targets in $(ALL_MODULES)
+.PHONY: all_modules
+all_modules: $(ALL_MODULES)
+
 .PHONY: docs
 docs: $(ALL_DOCS)
 
diff --git a/core/native_test.mk b/core/native_test.mk
new file mode 100644
index 0000000..3253a5e
--- /dev/null
+++ b/core/native_test.mk
@@ -0,0 +1,18 @@
+###########################################
+## A thin wrapper around BUILD_EXECUTABLE
+## Common flags for native tests are added.
+###########################################
+
+LOCAL_CFLAGS += -DGTEST_OS_LINUX -DGTEST_HAS_STD_STRING
+LOCAL_C_INCLUDES += bionic \
+                    bionic/libstdc++/include \
+                    external/gtest/include \
+                    external/stlport/stlport
+LOCAL_STATIC_LIBRARIES += libgtest libgtest_main
+LOCAL_SHARED_LIBRARIES += libstlport
+
+ifndef LOCAL_MODULE_PATH
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/core/package.mk b/core/package.mk
index c14e660..b634824 100644
--- a/core/package.mk
+++ b/core/package.mk
@@ -61,6 +61,10 @@
 $(error $(LOCAL_PATH): Package modules may not set LOCAL_JAVA_RESOURCE_FILES)
 endif
 
+ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
+LOCAL_MANIFEST_FILE := AndroidManifest.xml
+endif
+
 ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
 $(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
 endif
@@ -160,7 +164,7 @@
 DONT_INSTALL_DEX_FILES := $(old_DONT_INSTALL_DEX_FILES)
 old_DONT_INSTALL_DEX_FILES =
 
-full_android_manifest := $(LOCAL_PATH)/AndroidManifest.xml
+full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
 $(LOCAL_INTERMEDIATE_TARGETS): \
 	PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
 
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index 46c168b..c5e7966 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -37,59 +37,8 @@
 	android.core.tests.xml \
 	android.core.tests.runner
 
-CTS_SECURITY_APPS_LIST := \
-	CtsAppAccessData \
-	CtsAppWithData \
-	CtsInstrumentationAppDiffCert \
-	CtsPermissionDeclareApp \
-	CtsSharedUidInstall \
-	CtsSharedUidInstallDiffCert \
-	CtsSimpleAppInstall \
-	CtsSimpleAppInstallDiffCert \
-	CtsTargetInstrumentationApp \
-	CtsUsePermissionDiffCert
-
-CTS_CASE_LIST := \
-	TestDeviceSetup \
-	CtsTestStubs \
-	CtsAccessibilityServiceTestCases \
-	CtsAccountManagerTestCases \
-	CtsAppTestCases \
-	CtsBluetoothTestCases \
-	CtsContentTestCases \
-	CtsDatabaseTestCases \
-	CtsDelegatingAccessibilityService \
-	CtsDpiTestCases \
-	CtsDpiTestCases2 \
-	CtsExampleTestCases \
-	CtsGestureTestCases \
-	CtsGraphicsTestCases \
-	CtsHardwareTestCases \
-	CtsJniTestCases \
-	CtsLocationTestCases \
-	CtsMediaTestCases \
-	CtsOsTestCases \
-	CtsPermissionTestCases \
-	CtsPermission2TestCases \
-	CtsProviderTestCases \
-	CtsSpeechTestCases \
-	CtsTelephonyTestCases \
-	CtsTextTestCases \
-	CtsUtilTestCases \
-	CtsViewTestCases \
-	CtsWebkitTestCases \
-	CtsWidgetTestCases \
-	CtsNetTestCases \
-	SignatureTest \
-	CtsPerformanceTestCases \
-	CtsPerformance2TestCases \
-	CtsPerformance3TestCases \
-	CtsPerformance4TestCases \
-	CtsPerformance5TestCases \
-	ApiDemos \
-	ApiDemosReferenceTest \
-	$(CTS_CORE_CASE_LIST) \
-	$(CTS_SECURITY_APPS_LIST)
+-include cts/CtsTestCaseList.mk
+CTS_CASE_LIST := $(CTS_CORE_CASE_LIST) $(CTS_TEST_CASE_LIST)
 
 DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
 
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index 8a2c21b..af00479 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 := Honeycomb
+  PLATFORM_VERSION := Froyo
 endif
 
 ifeq "" "$(PLATFORM_SDK_VERSION)"
@@ -59,7 +59,7 @@
 ifeq "" "$(PLATFORM_VERSION_CODENAME)"
   # This is the current development code-name, if the build is not a final
   # release build.  If this is a final release build, it is simply "REL".
-  PLATFORM_VERSION_CODENAME := Honeycomb
+  PLATFORM_VERSION_CODENAME := Froyo
 endif
 
 ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
diff --git a/envsetup.sh b/envsetup.sh
index 28033f2..df7bfc1 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -650,7 +650,7 @@
         elif [ ! "$M" ]; then
             echo "Couldn't locate a makefile from the current directory."
         else
-            ONE_SHOT_MAKEFILE=$M make -C $T files $@
+            ONE_SHOT_MAKEFILE=$M make -C $T all_modules $@
         fi
     fi
 }
@@ -682,13 +682,15 @@
                     ARGS="$ARGS snod"
                 elif [ "$DIR" = showcommands ]; then
                     ARGS="$ARGS showcommands"
+                elif [ "$DIR" = dist ]; then
+                    ARGS="$ARGS dist"
                 else
                     echo "No Android.mk in $DIR."
                     return 1
                 fi
             fi
         done
-        ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS files $ARGS
+        ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS all_modules $ARGS
     else
         echo "Couldn't locate the top of the tree.  Try setting TOP."
     fi
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index 50e2539..aa5170a 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -18,6 +18,7 @@
 PRODUCT_PROPERTY_OVERRIDES :=
 
 PRODUCT_PACKAGES := \
+	SystemUI \
 	AccountAndSyncSettings \
 	Camera \
 	Calculator \
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
index 6c85149..ce3ee81 100755
--- a/tools/buildinfo.sh
+++ b/tools/buildinfo.sh
@@ -25,8 +25,12 @@
   echo "ro.product.cpu.abi2=$TARGET_CPU_ABI2"
 fi
 echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER"
-echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"
-echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION"
+if [ -n "$PRODUCT_DEFAULT_LANGUAGE" ] ; then
+  echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"
+fi
+if [ -n "$PRODUCT_DEFAULT_REGION" ] ; then
+  echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION"
+fi
 echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"
 echo "ro.board.platform=$TARGET_BOARD_PLATFORM"