Merge "Fix issue 2317760: Change the priority between wired headset and A2DP."
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index adec5a4..eaa34c8 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -110,6 +110,9 @@
     dump_file("KERNEL WAKELOCKS", "/proc/wakelocks");
     dump_file("KERNEL CPUFREQ", "/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
 
+    run_command("SECURE CONTAINERS", 10, "vdc", "asec", "list", NULL);
+    run_command("MOUNTED FILESYSTEMS", 10, "df", NULL);
+
     run_command("PROCESSES", 10, "ps", "-P", NULL);
     run_command("PROCESSES AND THREADS", 10, "ps", "-t", "-p", "-P", NULL);
     run_command("LIBRANK", 10, "librank", NULL);
@@ -208,7 +211,7 @@
     }
 
     /* switch to non-root user and group */
-    gid_t groups[] = { AID_LOG, AID_SDCARD_RW };
+    gid_t groups[] = { AID_LOG, AID_SDCARD_RW, AID_MOUNT };
     setgroups(sizeof(groups)/sizeof(groups[0]), groups);
     setuid(AID_SHELL);
 
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 1d28731..379b425 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -216,9 +216,6 @@
             diff = cookie2.domain.length() - cookie1.domain.length();
             if (diff != 0) return diff;
 
-            diff = cookie2.name.hashCode() - cookie1.name.hashCode();
-            if (diff != 0) return diff;
-
             // If cookie2 has a null value, it should come later in
             // the list.
             if (cookie2.value == null) {
@@ -229,6 +226,9 @@
                 return 1;
             }
 
+            diff = cookie2.name.hashCode() - cookie1.name.hashCode();
+            if (diff != 0) return diff;
+
             // cookie1 and cookie2 both have non-null values so we emit a
             // warning and treat them as the same.
             Log.w(LOGTAG, "Found two cookies with the same value."
@@ -804,9 +804,13 @@
             cookie = new Cookie(host, path);
 
             // Cookies like "testcookie; path=/;" are valid and used
-            // (lovefilm.se). Check for equal as in the string "testcookie"
-            // Check for equalIndex == -1 as in the string "testcookie;"
-            if (semicolonIndex <= equalIndex || equalIndex == -1) {
+            // (lovefilm.se).
+            // Look for 2 cases:
+            // 1. "foo" or "foo;" where equalIndex is -1
+            // 2. "foo; path=..." where the first semicolon is before an equal
+            //    and a semicolon exists.
+            if ((semicolonIndex != -1 && (semicolonIndex < equalIndex)) ||
+                    equalIndex == -1) {
                 // Fix up the index in case we have a string like "testcookie"
                 if (semicolonIndex == -1) {
                     semicolonIndex = length;
@@ -815,7 +819,10 @@
                 cookie.value = null;
             } else {
                 cookie.name = cookieString.substring(index, equalIndex);
-                if (cookieString.charAt(equalIndex + 1) == QUOTATION) {
+                // Make sure we do not throw an exception if the cookie is like
+                // "foo="
+                if ((equalIndex < length - 1) &&
+                        (cookieString.charAt(equalIndex + 1) == QUOTATION)) {
                     index = cookieString.indexOf(QUOTATION, equalIndex + 2);
                     if (index == -1) {
                         // bad format, force return
@@ -834,7 +841,7 @@
                             equalIndex + 1 + MAX_COOKIE_LENGTH);
                 } else if (equalIndex + 1 == semicolonIndex
                         || semicolonIndex < equalIndex) {
-                    // this is an unusual case like foo=;
+                    // this is an unusual case like "foo=;" or "foo="
                     cookie.value = "";
                 } else {
                     cookie.value = cookieString.substring(equalIndex + 1,
diff --git a/core/java/android/webkit/FrameLoader.java b/core/java/android/webkit/FrameLoader.java
index dacb33f..303e417 100644
--- a/core/java/android/webkit/FrameLoader.java
+++ b/core/java/android/webkit/FrameLoader.java
@@ -111,11 +111,10 @@
             }
             mNetwork = Network.getInstance(mListener.getContext());
             if (mListener.isSynchronous()) {
-                handleHTTPLoad();
-            } else {
-                WebViewWorker.getHandler().obtainMessage(
-                        WebViewWorker.MSG_ADD_HTTPLOADER, this).sendToTarget();
+                return handleHTTPLoad();
             }
+            WebViewWorker.getHandler().obtainMessage(
+                    WebViewWorker.MSG_ADD_HTTPLOADER, this).sendToTarget();
             return true;
         } else if (handleLocalFile(url, mListener, mSettings)) {
             return true;
@@ -147,34 +146,53 @@
             return true;
         }
         if (URLUtil.isAssetUrl(url)) {
-            // load asset in a separate thread as it involves IO
-            WebViewWorker.getHandler().obtainMessage(
-                    WebViewWorker.MSG_ADD_STREAMLOADER,
-                    new FileLoader(url, loadListener, FileLoader.TYPE_ASSET,
-                            true)).sendToTarget();
+            if (loadListener.isSynchronous()) {
+                new FileLoader(url, loadListener, FileLoader.TYPE_ASSET,
+                        true).load();
+            } else {
+                // load asset in a separate thread as it involves IO
+                WebViewWorker.getHandler().obtainMessage(
+                        WebViewWorker.MSG_ADD_STREAMLOADER,
+                        new FileLoader(url, loadListener, FileLoader.TYPE_ASSET,
+                                true)).sendToTarget();
+            }
             return true;
         } else if (URLUtil.isResourceUrl(url)) {
-            // load resource in a separate thread as it involves IO
-            WebViewWorker.getHandler().obtainMessage(
-                    WebViewWorker.MSG_ADD_STREAMLOADER,
-                    new FileLoader(url, loadListener, FileLoader.TYPE_RES,
-                            true)).sendToTarget();
+            if (loadListener.isSynchronous()) {
+                new FileLoader(url, loadListener, FileLoader.TYPE_RES,
+                        true).load();
+            } else {
+                // load resource in a separate thread as it involves IO
+                WebViewWorker.getHandler().obtainMessage(
+                        WebViewWorker.MSG_ADD_STREAMLOADER,
+                        new FileLoader(url, loadListener, FileLoader.TYPE_RES,
+                                true)).sendToTarget();
+            }
             return true;
         } else if (URLUtil.isFileUrl(url)) {
-            // load file in a separate thread as it involves IO
-            WebViewWorker.getHandler().obtainMessage(
-                    WebViewWorker.MSG_ADD_STREAMLOADER,
-                    new FileLoader(url, loadListener, FileLoader.TYPE_FILE,
-                            settings.getAllowFileAccess())).sendToTarget();
+            if (loadListener.isSynchronous()) {
+                new FileLoader(url, loadListener, FileLoader.TYPE_FILE,
+                        settings.getAllowFileAccess()).load();
+            } else {
+                // load file in a separate thread as it involves IO
+                WebViewWorker.getHandler().obtainMessage(
+                        WebViewWorker.MSG_ADD_STREAMLOADER,
+                        new FileLoader(url, loadListener, FileLoader.TYPE_FILE,
+                                settings.getAllowFileAccess())).sendToTarget();
+            }
             return true;
         } else if (URLUtil.isContentUrl(url)) {
             // Send the raw url to the ContentLoader because it will do a
             // permission check and the url has to match.
-            // load content in a separate thread as it involves IO
-            WebViewWorker.getHandler().obtainMessage(
-                    WebViewWorker.MSG_ADD_STREAMLOADER,
-                    new ContentLoader(loadListener.url(), loadListener))
-                    .sendToTarget();
+            if (loadListener.isSynchronous()) {
+                new ContentLoader(loadListener.url(), loadListener).load();
+            } else {
+                // load content in a separate thread as it involves IO
+                WebViewWorker.getHandler().obtainMessage(
+                        WebViewWorker.MSG_ADD_STREAMLOADER,
+                        new ContentLoader(loadListener.url(), loadListener))
+                        .sendToTarget();
+            }
             return true;
         } else if (URLUtil.isDataUrl(url)) {
             // load data in the current thread to reduce the latency
diff --git a/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png b/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png
index 44668b3..eda6e16 100644
--- a/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png
+++ b/core/res/res/drawable-hdpi/btn_search_dialog_voice_default.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png b/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png
index 3a4571e..4158ac4 100644
--- a/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png
+++ b/core/res/res/drawable-hdpi/btn_search_dialog_voice_pressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png b/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png
index 60dc632..6f68f25 100644
--- a/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png
+++ b/core/res/res/drawable-hdpi/btn_search_dialog_voice_selected.9.png
Binary files differ
diff --git a/core/tests/coretests/src/android/provider/SettingsProviderTest.java b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
index f82d79a..370ae78 100644
--- a/core/tests/coretests/src/android/provider/SettingsProviderTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
@@ -59,7 +59,7 @@
 
         assertEquals("content://settings/system/test_setting",
                 Settings.System.getUriFor("test_setting").toString());
-        assertEquals("content://settings/gservices/test_service",
+        assertEquals("content://settings/secure/test_service",
                 Settings.Secure.getUriFor("test_service").toString());
 
         // These tables use the row name (not ID) as their content URI.