Loading core/java/android/app/SearchManager.java +32 −7 Original line number Diff line number Diff line Loading @@ -27,9 +27,9 @@ import android.os.Handler; import android.os.RemoteException; import android.os.ServiceManager; import android.server.search.SearchableInfo; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.text.TextUtils; import java.util.List; Loading Loading @@ -1590,6 +1590,13 @@ public class SearchManager */ public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1"; /** * Query parameter added to suggestion queries to limit the number of suggestions returned. * * @hide Pending API council approval */ public final static String SUGGEST_PARAMETER_LIMIT = "limit"; /** * If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION}, * the search dialog will switch to a different suggestion source when the Loading Loading @@ -1980,6 +1987,21 @@ public class SearchManager * @hide because SearchableInfo is not part of the API. */ public Cursor getSuggestions(SearchableInfo searchable, String query) { return getSuggestions(searchable, query, -1); } /** * Gets a cursor with search suggestions. * * @param searchable Information about how to get the suggestions. * @param query The search text entered (so far). * @param limit The query limit to pass to the suggestion provider. This is advisory, * the returned cursor may contain more rows. Pass {@code -1} for no limit. * @return a cursor with suggestions, or <code>null</null> the suggestion query failed. * * @hide because SearchableInfo is not part of the API. */ public Cursor getSuggestions(SearchableInfo searchable, String query, int limit) { if (searchable == null) { return null; } Loading @@ -1991,7 +2013,9 @@ public class SearchManager Uri.Builder uriBuilder = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(authority); .authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel() // if content path provided, insert it now final String contentPath = searchable.getSuggestPath(); Loading @@ -2012,10 +2036,11 @@ public class SearchManager uriBuilder.appendPath(query); } Uri uri = uriBuilder .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .build(); if (limit > 0) { uriBuilder.appendQueryParameter(SUGGEST_PARAMETER_LIMIT, String.valueOf(limit)); } Uri uri = uriBuilder.build(); // finally, make the query return mContext.getContentResolver().query(uri, null, selection, selArgs, null); Loading core/java/android/app/SuggestionsAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private static final boolean DBG = false; private static final String LOG_TAG = "SuggestionsAdapter"; private static final int QUERY_LIMIT = 50; private SearchManager mSearchManager; private SearchDialog mSearchDialog; Loading Loading @@ -186,7 +187,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mSearchDialog.getWindow().getDecorView().post(mStartSpinnerRunnable); } try { final Cursor cursor = mSearchManager.getSuggestions(mSearchable, query); final Cursor cursor = mSearchManager.getSuggestions(mSearchable, query, QUERY_LIMIT); // trigger fill window so the spinner stays up until the results are copied over and // closer to being ready if (!mGlobalSearchMode && cursor != null) cursor.getCount(); Loading Loading
core/java/android/app/SearchManager.java +32 −7 Original line number Diff line number Diff line Loading @@ -27,9 +27,9 @@ import android.os.Handler; import android.os.RemoteException; import android.os.ServiceManager; import android.server.search.SearchableInfo; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.text.TextUtils; import java.util.List; Loading Loading @@ -1590,6 +1590,13 @@ public class SearchManager */ public final static String SUGGEST_NEVER_MAKE_SHORTCUT = "_-1"; /** * Query parameter added to suggestion queries to limit the number of suggestions returned. * * @hide Pending API council approval */ public final static String SUGGEST_PARAMETER_LIMIT = "limit"; /** * If a suggestion has this value in {@link #SUGGEST_COLUMN_INTENT_ACTION}, * the search dialog will switch to a different suggestion source when the Loading Loading @@ -1980,6 +1987,21 @@ public class SearchManager * @hide because SearchableInfo is not part of the API. */ public Cursor getSuggestions(SearchableInfo searchable, String query) { return getSuggestions(searchable, query, -1); } /** * Gets a cursor with search suggestions. * * @param searchable Information about how to get the suggestions. * @param query The search text entered (so far). * @param limit The query limit to pass to the suggestion provider. This is advisory, * the returned cursor may contain more rows. Pass {@code -1} for no limit. * @return a cursor with suggestions, or <code>null</null> the suggestion query failed. * * @hide because SearchableInfo is not part of the API. */ public Cursor getSuggestions(SearchableInfo searchable, String query, int limit) { if (searchable == null) { return null; } Loading @@ -1991,7 +2013,9 @@ public class SearchManager Uri.Builder uriBuilder = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(authority); .authority(authority) .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment(""); // TODO: Remove, workaround for a bug in Uri.writeToParcel() // if content path provided, insert it now final String contentPath = searchable.getSuggestPath(); Loading @@ -2012,10 +2036,11 @@ public class SearchManager uriBuilder.appendPath(query); } Uri uri = uriBuilder .query("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .fragment("") // TODO: Remove, workaround for a bug in Uri.writeToParcel() .build(); if (limit > 0) { uriBuilder.appendQueryParameter(SUGGEST_PARAMETER_LIMIT, String.valueOf(limit)); } Uri uri = uriBuilder.build(); // finally, make the query return mContext.getContentResolver().query(uri, null, selection, selArgs, null); Loading
core/java/android/app/SuggestionsAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private static final boolean DBG = false; private static final String LOG_TAG = "SuggestionsAdapter"; private static final int QUERY_LIMIT = 50; private SearchManager mSearchManager; private SearchDialog mSearchDialog; Loading Loading @@ -186,7 +187,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mSearchDialog.getWindow().getDecorView().post(mStartSpinnerRunnable); } try { final Cursor cursor = mSearchManager.getSuggestions(mSearchable, query); final Cursor cursor = mSearchManager.getSuggestions(mSearchable, query, QUERY_LIMIT); // trigger fill window so the spinner stays up until the results are copied over and // closer to being ready if (!mGlobalSearchMode && cursor != null) cursor.getCount(); Loading