diff options
| -rw-r--r-- | core/java/android/app/SearchDialog.java | 5 | ||||
| -rw-r--r-- | core/java/android/app/SearchManager.java | 8 | ||||
| -rw-r--r-- | core/java/android/app/SuggestionsAdapter.java | 19 |
3 files changed, 31 insertions, 1 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index f474f06c973e..75e4669575f9 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -1137,6 +1137,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS String action = mGlobalSearchMode ? Intent.ACTION_WEB_SEARCH : Intent.ACTION_SEARCH; Intent intent = createIntent(action, null, null, query, null, actionKey, actionMsg); + // Allow GlobalSearch to log and create shortcut for searches launched by + // the search button, enter key or an action key. + if (mGlobalSearchMode) { + mSuggestionsAdapter.reportSearch(query); + } launchIntent(intent); } diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index 267d86a9c607..3a14f6f17c8e 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -1350,6 +1350,14 @@ public class SearchManager * When the threshold received in {@link #POST_REFRESH_RECEIVE_DISPLAY_NOTIFY} is displayed. */ public final static int THRESH_HIT = 3; + + /** + * When a search is started without using a suggestion. + */ + public final static int SEARCH = 4; + public final static String SEARCH_SEND_MAX_DISPLAY_POS + = "DialogCursorProtocol.SEARCH.sendDisplayPosition"; + public final static String SEARCH_SEND_QUERY = "DialogCursorProtocol.SEARCH.query"; } /** diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index 90f8c503607b..8730288b97a4 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -290,7 +290,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { */ void callCursorOnClick(Cursor cursor, int position) { if (!mGlobalSearchMode) return; - final Bundle request = new Bundle(1); + final Bundle request = new Bundle(3); request.putInt(DialogCursorProtocol.METHOD, DialogCursorProtocol.CLICK); request.putInt(DialogCursorProtocol.CLICK_SEND_POSITION, position); request.putInt(DialogCursorProtocol.CLICK_SEND_MAX_DISPLAY_POS, mMaxDisplayed); @@ -301,6 +301,23 @@ class SuggestionsAdapter extends ResourceCursorAdapter { } /** + * Tell the cursor that a search was started without using a suggestion. + * + * @param query The search query. + */ + void reportSearch(String query) { + if (!mGlobalSearchMode) return; + Cursor cursor = getCursor(); + if (cursor == null) return; + final Bundle request = new Bundle(3); + request.putInt(DialogCursorProtocol.METHOD, DialogCursorProtocol.SEARCH); + request.putString(DialogCursorProtocol.SEARCH_SEND_QUERY, query); + request.putInt(DialogCursorProtocol.SEARCH_SEND_MAX_DISPLAY_POS, mMaxDisplayed); + // the response is always empty + cursor.respond(request); + } + + /** * Tags the view with cached child view look-ups. */ @Override |