Add searchSuggestThreshold to searchable meta-data.

This lets the searchable activity specify the number of
characters needed to trigger suggestions. Before, this was
hard-coded at 0. This caused unnecessary querying of the
suggestion provider in cases where the provider does not
return suggestions for empty or short queries.

The attribute is not yet public, pending API council approval.
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 2d2e710..d7ef103 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -472,7 +472,7 @@
         closeSuggestionsAdapter();
         
         mSearchAutoComplete.setDropDownAnimationStyle(0); // no animation
-        mSearchAutoComplete.setThreshold(0);  // always allow zero-query suggestions
+        mSearchAutoComplete.setThreshold(mSearchable.getSuggestThreshold());
 
         if (mGlobalSearchMode) {
             mSearchAutoComplete.setDropDownAlwaysVisible(true);  // fill space until results come in
diff --git a/core/java/android/server/search/SearchableInfo.java b/core/java/android/server/search/SearchableInfo.java
index 22abd1b..a4a7827 100644
--- a/core/java/android/server/search/SearchableInfo.java
+++ b/core/java/android/server/search/SearchableInfo.java
@@ -71,6 +71,7 @@
     private String mSuggestSelection = null;
     private String mSuggestIntentAction = null;
     private String mSuggestIntentData = null;
+    private int mSuggestThreshold = 0;
     private ActionKeyInfo mActionKeyList = null;
     private String mSuggestProviderPackage = null;
     
@@ -140,6 +141,16 @@
     }
     
     /**
+     * Gets the suggestion threshold for use with these suggestions. 
+     * 
+     * @return The value of the <code>searchSuggestThreshold</code> attribute, 
+     *         or 0 if the attribute is not set.
+     */
+    public int getSuggestThreshold() {
+        return mSuggestThreshold;
+    }
+    
+    /**
      * Get the context for the searchable activity.  
      * 
      * This is fairly expensive so do it on the original scan, or when an app is
@@ -238,6 +249,8 @@
                     com.android.internal.R.styleable.Searchable_searchSuggestIntentAction);
             mSuggestIntentData = a.getString(
                     com.android.internal.R.styleable.Searchable_searchSuggestIntentData);
+            mSuggestThreshold = a.getInt(
+                    com.android.internal.R.styleable.Searchable_searchSuggestThreshold, 0);
         }
         mVoiceSearchMode = 
             a.getInt(com.android.internal.R.styleable.Searchable_voiceSearchMode, 0);
@@ -600,6 +613,7 @@
         mSuggestSelection = in.readString();
         mSuggestIntentAction = in.readString();
         mSuggestIntentData = in.readString();
+        mSuggestThreshold = in.readInt();
 
         mActionKeyList = null;
         int count = in.readInt();
@@ -636,6 +650,7 @@
         dest.writeString(mSuggestSelection);
         dest.writeString(mSuggestIntentAction);
         dest.writeString(mSuggestIntentData);
+        dest.writeInt(mSuggestThreshold);
 
         // This is usually a very short linked list so we'll just pre-count it
         ActionKeyInfo nextKeyInfo = mActionKeyList;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 972953b..922dd32 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2781,6 +2781,10 @@
             when the user clicks a suggestion.  <i>Optional attribute.</i> -->
         <attr name="searchSuggestIntentData" format="string" />
         
+        <!-- If provided, this is the minimun number of characters needed to trigger
+             search suggestions. The default value is 0. <i>Optional attribute.</i> -->
+        <attr name="searchSuggestThreshold" format="integer" />
+        
     </declare-styleable>
 
     <!-- In order to process special action keys during search, you must define them using