summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Bringert <bringert@android.com>2009-06-04 15:35:27 +0100
committerBjorn Bringert <bringert@android.com>2009-06-04 16:12:59 +0100
commite6c2fdbc4ea2ece95f6c921f8dea6d7778d02bce (patch)
treec264fbb8d99af4d5adbebe4841daef7915485291
parent28cbadc80d908da1d91f814e98e1f70aa11b77bb (diff)
downloadApplicationsProvider-e6c2fdbc4ea2ece95f6c921f8dea6d7778d02bce.tar.gz
Remove duplicates from application search suggestions.
Fixes http://b/issue?id=1897530
-rw-r--r--src/com/android/providers/applications/ApplicationsProvider.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/com/android/providers/applications/ApplicationsProvider.java b/src/com/android/providers/applications/ApplicationsProvider.java
index f7f2666..5be044b 100644
--- a/src/com/android/providers/applications/ApplicationsProvider.java
+++ b/src/com/android/providers/applications/ApplicationsProvider.java
@@ -206,13 +206,15 @@ public class ApplicationsProvider extends ContentProvider {
+ " applicationsLookup.source = " + APPLICATIONS_TABLE + "." + _ID);
qb.setProjectionMap(sSearchSuggestionsProjectionMap);
qb.appendWhere(buildTokenFilter(query));
+ // don't return duplicates when there are two matching tokens for an app
+ String groupBy = APPLICATIONS_TABLE + "." + _ID;
// order first by whether it a full prefix match, then by name
- // token_index != 0 is true for non-full prefix matches,
+ // MIN(token_index) != 0 is true for non-full prefix matches,
// and since false (0) < true(1), this expression makes sure
// that full prefix matches come first.
- String order = "token_index != 0, " + NAME;
+ String order = "MIN(token_index) != 0, " + NAME;
Cursor cursor = qb.query(mDb, projectionIn, selection, selectionArgs,
- null, null, order);
+ groupBy, null, order);
return cursor;
}