auto import from //depot/cupcake/@137055
diff --git a/buildspec.mk.default b/buildspec.mk.default
index 0f75f31..861bb0d 100644
--- a/buildspec.mk.default
+++ b/buildspec.mk.default
@@ -88,6 +88,11 @@
 #NO_FALLBACK_FONT:=true
 endif
 
+# To enabled instrumentation in webcore based apps like gmail and
+# the browser, define WEBCORE_INSTRUMENTATION:=true
+#WEBCORE_INSTRUMENTATION:=true
+#endif
+
 # when the build system changes such that this file must be updated, this
 # variable will be changed.  After you have modified this file with the new
 # changes (see buildspec.mk.default), update this to the new value from
diff --git a/core/Makefile b/core/Makefile
index 2983628..9ba117a 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -899,6 +899,7 @@
 
 .PHONY: installed-file-list
 installed-file-list: $(INSTALLED_FILES_FILE)
+$(call dist-for-goals, sdk, $(INSTALLED_FILES_FILE))
 
 # -----------------------------------------------------------------
 # A zip of the tests that are built when running "make tests".
diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk
index 01bf9a5..50b56f9 100644
--- a/core/cleanbuild.mk
+++ b/core/cleanbuild.mk
@@ -123,7 +123,11 @@
 ifdef PREVIOUS_BUILD_CONFIG
   ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)"
     $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)")
-    force_installclean := true
+    ifneq ($(DISABLE_AUTO_INSTALLCLEAN),true)
+      force_installclean := true
+    else
+      $(info DISABLE_AUTO_INSTALLCLEAN is set; skipping auto-clean. Your tree may be in an inconsistent state.)
+    endif
   endif
 endif  # else, this is the first build, so no need to clean.
 PREVIOUS_BUILD_CONFIG :=
diff --git a/core/definitions.mk b/core/definitions.mk
index 67f7166..3efef8d 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -558,7 +558,7 @@
 else
 define pretty
 endef
-hide := 
+hide :=
 endif
 
 ###########################################################
@@ -984,7 +984,7 @@
 ###########################################################
 ## Commands for running gcc to link a statically linked
 ## executable.  In practice, we only use this on arm, so
-## the other platforms don't have the 
+## the other platforms don't have the
 ## transform-o-to-static-executable defined
 ###########################################################
 
@@ -1033,7 +1033,7 @@
 
 
 ###########################################################
-## Commands for running javac to make .class files 
+## Commands for running javac to make .class files
 ###########################################################
 
 #@echo "Source intermediates dir: $(PRIVATE_SOURCE_INTERMEDIATES_DIR)"
@@ -1064,9 +1064,9 @@
 endef
 
 ifeq ($(HOST_OS),windows)
-xlint_unchecked := 
+xlint_unchecked :=
 else
-#xlint_unchecked := -Xlint:unchecked 
+#xlint_unchecked := -Xlint:unchecked
 endif
 
 # emit-line, <word list>, <output file>
@@ -1102,7 +1102,7 @@
 
 # For a list of jar files, unzip them to a specified directory,
 # but make sure that no META-INF files come along for the ride.
-# 
+#
 # $(1): files to unzip
 # $(2): destination directory
 define unzip-jar-files
@@ -1250,7 +1250,7 @@
 endef
 
 # TODO(joeo): If we can ever upgrade to post 3.81 make and get the
-# new prebuilt rules to work, we should change this to copy the 
+# new prebuilt rules to work, we should change this to copy the
 # resources to the out directory and then copy the resources.
 
 # Note: not using aapt tool for this because we aren't making
@@ -1263,11 +1263,15 @@
 @mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
 $(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES), \
     $(PRIVATE_CLASS_INTERMEDIATES_DIR))
+$(call dump-words-to-file,$(sort\
+	$(PRIVATE_JAVA_SOURCES)),\
+	$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq)
 $(hide) $(HOST_JAVAC) -encoding ascii -g \
 	$(xlint_unchecked) \
 	$(addprefix -classpath ,$(strip \
 		$(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
-	-extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) $(PRIVATE_JAVA_SOURCES) || \
+	-extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR)\
+        \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq || \
 	( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 )
 $(hide) jar $(if $(strip $(PRIVATE_JAR_MANIFEST)),-cfm,-cf) \
     $@ $(PRIVATE_JAR_MANIFEST) $(PRIVATE_EXTRA_JAR_ARGS) \
@@ -1482,4 +1486,3 @@
 #	  sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
 #	      -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
 #	  rm -f $*.d
-
diff --git a/core/main.mk b/core/main.mk
index 1369944..1f3412f 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -136,11 +136,17 @@
   ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
     WITH_DEXPREOPT := true
   endif
+  
+  # Disallow mock locations by default for user builds
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
+  
 else # !user_variant
   # Turn on checkjni for non-user builds.
   ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
   # Set device insecure for non-user builds.
   ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
+  # Allow mock locations by default for non user builds
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
 endif # !user_variant
 
 ifeq (true,$(strip $(enable_target_debugging)))
diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
index 3ac09a4..429ae1a 100644
--- a/core/prelink-linux-arm.map
+++ b/core/prelink-linux-arm.map
@@ -91,6 +91,7 @@
 libqcamera.so           0xA9400000
 
 # pv libraries
+libopencorenet_support.so     0xA7D20000
 libpvasf.so                   0xA7BC0000
 libpvasfreg.so                0xA7B70000
 libopencoredownload.so        0xA7B40000
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index c9df6c4..9ef99db 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -15,22 +15,7 @@
 cts_dir := $(HOST_OUT)/cts
 cts_tools_src_dir := cts/tools
 
-# Build a name that looks like:
-#
-#     linux-x86   --> android-cts_linux-x86
-#     darwin-x86  --> android-cts_mac-x86
-#     windows-x86 --> android-cts_windows
-#
 cts_name := android-cts
-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)
@@ -48,13 +33,13 @@
 	CtsDatabaseTestCases \
 	CtsGraphicsTestCases \
 	CtsLocationTestCases \
-	CtsNetTestCases \
 	CtsOsTestCases \
 	CtsProviderTestCases \
 	CtsTextTestCases \
 	CtsUtilTestCases \
 	CtsViewTestCases \
 	CtsWidgetTestCases \
+	CtsNetTestCases \
 	SignatureTest
 
 DEFAULT_TEST_PLAN := $(PRIVATE_DIR)/resource/plans
@@ -85,6 +70,9 @@
      $(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)
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
index e6254f4..e8109e5 100644
--- a/target/product/sdk.mk
+++ b/target/product/sdk.mk
@@ -15,8 +15,10 @@
 	Mms \
 	Settings \
 	SdkSetup \
+	CustomLocale \
 	gpstest \
-	sqlite3
+	sqlite3 \
+	SoftKeyboard
 
 
 $(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index a9a1e21..b425da0 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -40,8 +40,8 @@
 
 <?cs if:sdk.not_latest_version ?>
   <div class="special">
-    <p><strong>This is NOT the latest version of the Android SDK</strong>.</p>
-    <p>Go to the <a href="<?cs var:toroot ?>sdk/index.html">SDK home page</a> to be directed to the latest version.</p>
+    <p><strong>This is NOT the current Android SDK release.</strong></p>
+    <p>Use the links under <strong>Current SDK Release</strong>, on the left, to be directed to the current SDK.</p>
   </div>
 <?cs /if ?>
   
diff --git a/tools/droiddoc/templates/assets/android-developer-core.css b/tools/droiddoc/templates/assets/android-developer-core.css
index 5b31558..eaa1176 100644
--- a/tools/droiddoc/templates/assets/android-developer-core.css
+++ b/tools/droiddoc/templates/assets/android-developer-core.css
@@ -682,6 +682,32 @@
   height:1.8em;
 }
 
+/* search result tabs */
+
+#doc-content .gsc-control {
+  position:relative;
+}
+
+#doc-content .gsc-tabsArea {
+  position:relative;
+}
+
+#doc-content .gsc-tabHeader {
+  padding: 3px 6px;
+  position:relative;
+}
+
+#doc-content .gsc-tabHeader.gsc-tabhActive {
+  border-top: 2px solid #94B922;
+}
+
+#doc-content h2#searchTitle {
+  padding:0;
+}
+
+#doc-content .gsc-resultsbox-visible {
+  padding:1em 0 0 6px;
+}
 
 /* CAROUSEL */
 
diff --git a/tools/droiddoc/templates/assets/android-developer-docs.js b/tools/droiddoc/templates/assets/android-developer-docs.js
index cd9c0b3..a84d5a6 100644
--- a/tools/droiddoc/templates/assets/android-developer-docs.js
+++ b/tools/droiddoc/templates/assets/android-developer-docs.js
@@ -102,7 +102,7 @@
   var cookieHeight = getCookie(cookiePath+'height');
   if (cookieWidth) {
     restoreWidth(cookieWidth);
-  } else {
+  } else if ($(".side-nav-resizable").length) {
     resizeWidth();
   }
   if (cookieHeight) {
@@ -127,7 +127,8 @@
   var htmlPos = fullPageName.lastIndexOf(".html", fullPageName.length);
   var pathPageName = fullPageName.slice(firstSlashPos, htmlPos + 5);
   var link = $("#devdoc-nav a[href$='"+ pathPageName+"']");
-  if ((link.length == 0) && (fullPageName.indexOf("/guide/") != -1)) { // if there's no match, then let's backstep through the directory until we find an index.html page that matches our ancestor directories (only for dev guide)
+  if ((link.length == 0) && ((fullPageName.indexOf("/guide/") != -1) || (fullPageName.indexOf("/sdk/") != -1))) { 
+// if there's no match, then let's backstep through the directory until we find an index.html page that matches our ancestor directories (only for dev guide and sdk)
     lastBackstep = pathPageName.lastIndexOf("/");
     while (link.length == 0) {
       backstepDirectory = pathPageName.lastIndexOf("/", lastBackstep);
@@ -175,7 +176,9 @@
 
 function resizeAll() {
   resizeHeight();
-  resizeWidth();
+  if ($(".side-nav-resizable").length) {
+    resizeWidth();
+  }
 }
 
 function loadLast(cookiePath) {
diff --git a/tools/droiddoc/templates/assets/jquery-history.js b/tools/droiddoc/templates/assets/jquery-history.js
new file mode 100644
index 0000000..ef96ec3
--- /dev/null
+++ b/tools/droiddoc/templates/assets/jquery-history.js
@@ -0,0 +1,78 @@
+/**
+ * jQuery history event v0.1
+ * Copyright (c) 2008 Tom Rodenberg <tarodenberg gmail com>
+ * Licensed under the GPL (http://www.gnu.org/licenses/gpl.html) license.
+ */
+(function($) {
+    var currentHash, previousNav, timer, hashTrim = /^.*#/;
+
+    var msie = {
+        iframe: null,
+        getDoc: function() {
+            return msie.iframe.contentWindow.document;
+        },
+        getHash: function() {
+            return msie.getDoc().location.hash;
+        },
+        setHash: function(hash) {
+            var d = msie.getDoc();
+            d.open();
+            d.close();
+            d.location.hash = hash;
+        }
+    };
+
+    var historycheck = function() {
+        var hash = msie.iframe ? msie.getHash() : location.hash;
+        if (hash != currentHash) {
+            currentHash = hash;
+            if (msie.iframe) {
+                location.hash = currentHash;
+            }
+            var current = $.history.getCurrent();
+            $.event.trigger('history', [current, previousNav]);
+            previousNav = current;
+        }
+    };
+
+    $.history = {
+        add: function(hash) {
+            hash = '#' + hash.replace(hashTrim, '');
+            if (currentHash != hash) {
+                var previous = $.history.getCurrent();
+                location.hash = currentHash = hash;
+                if (msie.iframe) {
+                    msie.setHash(currentHash);
+                }
+                $.event.trigger('historyadd', [$.history.getCurrent(), previous]);
+            }
+            if (!timer) {
+                timer = setInterval(historycheck, 100);
+            }
+        },
+        getCurrent: function() {
+            if (currentHash) {
+              return currentHash.replace(hashTrim, '');
+            } else { 
+              return ""; 
+            }
+        }
+    };
+
+    $.fn.history = function(fn) {
+        $(this).bind('history', fn);
+    };
+
+    $.fn.historyadd = function(fn) {
+        $(this).bind('historyadd', fn);
+    };
+
+    $(function() {
+        currentHash = location.hash;
+        if ($.browser.msie) {
+            msie.iframe = $('<iframe style="display:none" src="javascript:false;"></iframe>').prependTo('body')[0];
+            msie.setHash(currentHash);
+            currentHash = msie.getHash();
+        }
+    });
+})(jQuery);
diff --git a/tools/droiddoc/templates/assets/search_autocomplete.js b/tools/droiddoc/templates/assets/search_autocomplete.js
index c9b6ff6..2e12e0f 100644
--- a/tools/droiddoc/templates/assets/search_autocomplete.js
+++ b/tools/droiddoc/templates/assets/search_autocomplete.js
@@ -107,7 +107,8 @@
     var text = search.value;
 
     // 13 = enter
-    if (kd && (e.keyCode == 13)) {
+    if (!kd && (e.keyCode == 13)) {
+        document.getElementById("search_filtered_div").className = "no-display";
         if (gSelectedIndex >= 0) {
             window.location = toroot + gMatches[gSelectedIndex].link;
             return false;
@@ -145,6 +146,7 @@
             }
         }
         sync_selection_table(toroot);
+        return true; // allow the event to bubble up to the search api
     }
 }
 
diff --git a/tools/fileslist.py b/tools/fileslist.py
index ae105e6..ae1b4b6 100755
--- a/tools/fileslist.py
+++ b/tools/fileslist.py
@@ -17,6 +17,10 @@
 
 import os, sys
 
+def get_file_size(path):
+  st = os.lstat(path)
+  return st.st_size;
+
 def main(argv):
   output = []
   roots = argv[1:]
@@ -27,7 +31,7 @@
       for f in files:
         try:
           row = (
-              os.path.getsize(os.path.sep.join((dir, f))),
+              get_file_size(os.path.sep.join((dir, f))),
               os.path.sep.join((relative, f)),
             )
           output.append(row)