Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Revert "Remove global search support."
Browse files Browse the repository at this point in the history
The global search API is not being deprecated in this release, so we
want to keep the support for it.
  • Loading branch information
mathewinwood committed Sep 30, 2013
1 parent f2adf6e commit ec987e5
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 2 deletions.
9 changes: 9 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
android:exported="true"
android:readPermission="android.permission.READ_CONTACTS"
android:writePermission="android.permission.WRITE_CONTACTS">
<path-permission
android:pathPrefix="/search_suggest_query"
android:readPermission="android.permission.GLOBAL_SEARCH" />
<path-permission
android:pathPrefix="/search_suggest_shortcut"
android:readPermission="android.permission.GLOBAL_SEARCH" />
<path-permission
android:pathPattern="/contacts/.*/photo"
android:readPermission="android.permission.GLOBAL_SEARCH" />
<grant-uri-permission android:pathPattern=".*" />
</provider>

Expand Down
32 changes: 31 additions & 1 deletion src/com/android/providers/contacts/ContactsProvider2.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ public class ContactsProvider2 extends AbstractContactsProvider
private static final int PROFILE_SYNCSTATE = 11002;
private static final int PROFILE_SYNCSTATE_ID = 11003;

private static final int SEARCH_SUGGESTIONS = 12001;
private static final int SEARCH_SHORTCUT = 12002;

private static final int RAW_CONTACT_ENTITIES = 15001;

private static final int PROVIDER_STATUS = 16001;
Expand Down Expand Up @@ -1222,6 +1225,13 @@ interface RawContactsQuery {
matcher.addURI(ContactsContract.AUTHORITY, "status_updates", STATUS_UPDATES);
matcher.addURI(ContactsContract.AUTHORITY, "status_updates/#", STATUS_UPDATES_ID);

matcher.addURI(ContactsContract.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY,
SEARCH_SUGGESTIONS);
matcher.addURI(ContactsContract.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*",
SEARCH_SUGGESTIONS);
matcher.addURI(ContactsContract.AUTHORITY, SearchManager.SUGGEST_URI_PATH_SHORTCUT + "/*",
SEARCH_SHORTCUT);

matcher.addURI(ContactsContract.AUTHORITY, "provider_status", PROVIDER_STATUS);

matcher.addURI(ContactsContract.AUTHORITY, "directories", DIRECTORIES);
Expand Down Expand Up @@ -1367,6 +1377,7 @@ public static class GroupIdCacheEntry {
private final SecureRandom mRandom = new SecureRandom();

private LegacyApiSupport mLegacyApiSupport;
private GlobalSearchSupport mGlobalSearchSupport;
private CommonNicknameCache mCommonNicknameCache;
private SearchIndexManager mSearchIndexManager;

Expand Down Expand Up @@ -1442,6 +1453,7 @@ private boolean initialize() {
setDbHelperToSerializeOn(mContactsHelper, CONTACTS_DB_TAG, this);

mContactDirectoryManager = new ContactDirectoryManager(this);
mGlobalSearchSupport = new GlobalSearchSupport(this);

// The provider is closed for business until fully initialized
mReadAccessLatch = new CountDownLatch(1);
Expand Down Expand Up @@ -1486,7 +1498,8 @@ public void handleMessage(Message msg) {
*/
private void initForDefaultLocale() {
Context context = getContext();
mLegacyApiSupport = new LegacyApiSupport(context, mContactsHelper, this);
mLegacyApiSupport = new LegacyApiSupport(context, mContactsHelper, this,
mGlobalSearchSupport);
mCurrentLocale = getLocale();
mNameSplitter = mContactsHelper.createNameSplitter(mCurrentLocale);
mNameLookupBuilder = new StructuredNameLookupBuilder(mNameSplitter);
Expand Down Expand Up @@ -6291,6 +6304,19 @@ protected Cursor queryLocal(final Uri uri, final String[] projection, String sel
break;
}

case SEARCH_SUGGESTIONS: {
return mGlobalSearchSupport.handleSearchSuggestionsQuery(
db, uri, projection, limit, cancellationSignal);
}

case SEARCH_SHORTCUT: {
String lookupKey = uri.getLastPathSegment();
String filter = getQueryParameter(
uri, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
return mGlobalSearchSupport.handleSearchShortcutRefresh(
db, projection, lookupKey, filter, cancellationSignal);
}

case RAW_CONTACT_ENTITIES:
case PROFILE_RAW_CONTACT_ENTITIES: {
setTablesAndProjectionMapForRawEntities(qb, uri);
Expand Down Expand Up @@ -8068,6 +8094,10 @@ public String getType(Uri uri) {
return Settings.CONTENT_TYPE;
case AGGREGATION_SUGGESTIONS:
return Contacts.CONTENT_TYPE;
case SEARCH_SUGGESTIONS:
return SearchManager.SUGGEST_MIME_TYPE;
case SEARCH_SHORTCUT:
return SearchManager.SHORTCUT_MIME_TYPE;
case DIRECTORIES:
return Directory.CONTENT_TYPE;
case DIRECTORIES_ID:
Expand Down
Loading

0 comments on commit ec987e5

Please sign in to comment.