Adding search_client_id which includes the "ms-" or "tablet-" client-id prefix, set in GooglePartnerSetup.
Retaining client-id (which does not include the client-id prefix) for legacy purposes, if Browser is used with an older version of GooglePartnerSetup.

Bug #3483276

Change-Id: Ice4788ef78f4b58c5d981b50d5248aa51a53733d
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6eb13e3..28fe407 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -817,10 +817,10 @@
             user signs up the device with a Google sites account, the site's
             domain will be appended. -->
     <string name="homepage_base" translatable="false">
-        http://www.google.com/webhp?client=ms-{CID}&amp;source=android-home</string>
+        http://www.google.com/webhp?client={CID}&amp;source=android-home</string>
     <!-- The default url for the instant_base_page. -->
     <string name="instant_base" translatable="false">
-        http://www.google.com/webhp?client=ms-{CID}&amp;source=android-omnibox-instant&amp;ion=1</string>
+        http://www.google.com/webhp?client={CID}&amp;source=android-omnibox-instant&amp;ion=1</string>
 
     <!-- Bookmarks -->
     <string-array name="bookmarks" translatable="false">
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index cba16a0..f69665c 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -181,18 +181,30 @@
     // its content provider. http://b/issue?id=2425179
     static String getClientId(ContentResolver cr) {
         String ret = "android-google";
-        Cursor c = null;
+        Cursor legacyClientIdCursor = null;
+        Cursor searchClientIdCursor = null;
+
+        // search_client_id includes search prefix, legacy client_id does not include prefix
         try {
-            c = cr.query(Uri.parse("content://com.google.settings/partner"),
+            searchClientIdCursor = cr.query(Uri.parse("content://com.google.settings/partner"),
+               new String[] { "value" }, "name='search_client_id'", null, null);
+            if (searchClientIdCursor != null && searchClientIdCursor.moveToNext()) {
+                ret = searchClientIdCursor.getString(0);
+            } else {
+                legacyClientIdCursor = cr.query(Uri.parse("content://com.google.settings/partner"),
                     new String[] { "value" }, "name='client_id'", null, null);
-            if (c != null && c.moveToNext()) {
-                ret = c.getString(0);
+                if (legacyClientIdCursor != null && legacyClientIdCursor.moveToNext()) {
+                    ret = "ms-" + legacyClientIdCursor.getString(0);
+                }
             }
         } catch (RuntimeException ex) {
             // fall through to return the default
         } finally {
-            if (c != null) {
-                c.close();
+            if (legacyClientIdCursor != null) {
+                legacyClientIdCursor.close();
+            }
+            if (searchClientIdCursor != null) {
+                searchClientIdCursor.close();
             }
         }
         return ret;
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index c6b1bc7..e632fca 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -1263,11 +1263,11 @@
         }
     }
 
-    // Filters out the client=ms- param for search urls
+    // Filters out the client= param for search urls
     private String filterSearchClient(String url) {
         // remove "client" before updating it to the history so that it wont
         // show up in the auto-complete list.
-        int index = url.indexOf("client=ms-");
+        int index = url.indexOf("client=");
         if (index > 0 && url.contains(".google.")) {
             int end = url.indexOf('&', index);
             if (end > 0) {