diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-11 18:45:44 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-11 18:45:44 -0700 |
commit | 97babb1e9a2b859ff01a633edad8e2ac5b02ab8a (patch) | |
tree | 8b6bc278e7cdf2d0fbc64fa7f85352c0684c0116 /core/java/android/provider | |
parent | a8e8f3f647d6d55052d0faef53fc1eeb432f5bd6 (diff) | |
download | frameworks_base-97babb1e9a2b859ff01a633edad8e2ac5b02ab8a.zip frameworks_base-97babb1e9a2b859ff01a633edad8e2ac5b02ab8a.tar.gz frameworks_base-97babb1e9a2b859ff01a633edad8e2ac5b02ab8a.tar.bz2 |
SearchIndexablesProvider - support for querying for non indexable data keys
SearchIndexablesProvider should be able to send a list of data keys that
should not be indexed (mainly depending on some condition/state from the
device)
- update the contract by adding a new query named queryNonIndexableKeys(...)
Change-Id: Ie720825050acb600dca8ac8fed96fa4f59c3af71
Diffstat (limited to 'core/java/android/provider')
-rw-r--r-- | core/java/android/provider/SearchIndexablesContract.java | 43 | ||||
-rw-r--r-- | core/java/android/provider/SearchIndexablesProvider.java | 31 |
2 files changed, 64 insertions, 10 deletions
diff --git a/core/java/android/provider/SearchIndexablesContract.java b/core/java/android/provider/SearchIndexablesContract.java index 307ac39..a8b4cfb 100644 --- a/core/java/android/provider/SearchIndexablesContract.java +++ b/core/java/android/provider/SearchIndexablesContract.java @@ -35,7 +35,7 @@ public class SearchIndexablesContract { private static final String SETTINGS = "settings"; /** - * Indexable references name. + * Indexable reference names. */ public static final String INDEXABLES_XML_RES = "indexables_xml_res"; @@ -45,7 +45,7 @@ public class SearchIndexablesContract { public static final String INDEXABLES_XML_RES_PATH = SETTINGS + "/" + INDEXABLES_XML_RES; /** - * Indexable raw data name. + * Indexable raw data names. */ public static final String INDEXABLES_RAW = "indexables_raw"; @@ -55,6 +55,16 @@ public class SearchIndexablesContract { public static final String INDEXABLES_RAW_PATH = SETTINGS + "/" + INDEXABLES_RAW; /** + * Non indexable data keys. + */ + public static final String NON_INDEXABLES_KEYS = "non_indexables_key"; + + /** + * ContentProvider path for non indexable data keys. + */ + public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS; + + /** * Indexable xml resources colums. */ public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] { @@ -114,6 +124,17 @@ public class SearchIndexablesContract { public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11; public static final int COLUMN_INDEX_RAW_KEY = 12; + /** + * Indexable raw data colums. + */ + public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] { + NonIndexableKey.COLUMN_KEY_VALUE // 0 + }; + + /** + * Non indexable data keys colums indices. + */ + public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0; /** * Constants related to a {@link SearchIndexableResource}. @@ -186,6 +207,24 @@ public class SearchIndexablesContract { } /** + * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}. + * + * This is a description of a data (thru its unique key) that cannot be indexed. + */ + public static final class NonIndexableKey extends BaseColumns { + private NonIndexableKey() { + } + + public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + + "/" + NON_INDEXABLES_KEYS; + + /** + * Key for the non indexable data. + */ + public static final String COLUMN_KEY_VALUE = "key"; + } + + /** * The base columns. */ private static class BaseColumns { diff --git a/core/java/android/provider/SearchIndexablesProvider.java b/core/java/android/provider/SearchIndexablesProvider.java index 2e358e4..9c8f6d0 100644 --- a/core/java/android/provider/SearchIndexablesProvider.java +++ b/core/java/android/provider/SearchIndexablesProvider.java @@ -69,6 +69,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider { private static final int MATCH_RES_CODE = 1; private static final int MATCH_RAW_CODE = 2; + private static final int MATCH_NON_INDEXABLE_KEYS_CODE = 3; /** * Implementation is provided by the parent class. @@ -82,6 +83,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider { MATCH_RES_CODE); mMatcher.addURI(mAuthority, SearchIndexablesContract.INDEXABLES_RAW_PATH, MATCH_RAW_CODE); + mMatcher.addURI(mAuthority, SearchIndexablesContract.NON_INDEXABLES_KEYS_PATH, + MATCH_NON_INDEXABLE_KEYS_CODE); // Sanity check our setup if (!info.exported) { @@ -105,6 +108,8 @@ public abstract class SearchIndexablesProvider extends ContentProvider { return queryXmlResources(null); case MATCH_RAW_CODE: return queryRawData(null); + case MATCH_NON_INDEXABLE_KEYS_CODE: + return queryNonIndexableKeys(null); default: throw new UnsupportedOperationException("Unknown Uri " + uri); } @@ -113,7 +118,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider { /** * Returns all {@link android.provider.SearchIndexablesContract.XmlResource}. * - * Those are usually xml resource ID to some {@link android.preference.PreferenceScreen}. + * Those are Xml resource IDs to some {@link android.preference.PreferenceScreen}. * * @param projection list of {@link android.provider.SearchIndexablesContract.XmlResource} * columns to put into the cursor. If {@code null} all supported columns @@ -124,7 +129,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider { /** * Returns all {@link android.provider.SearchIndexablesContract.RawData}. * - * Those are raw indexable data. + * Those are the raw indexable data. * * @param projection list of {@link android.provider.SearchIndexablesContract.RawData} columns * to put into the cursor. If {@code null} all supported columns should be @@ -132,6 +137,17 @@ public abstract class SearchIndexablesProvider extends ContentProvider { */ public abstract Cursor queryRawData(String[] projection); + /** + * Returns all {@link android.provider.SearchIndexablesContract.NonIndexableKey}. + * + * Those are the non indexable data keys. + * + * @param projection list of {@link android.provider.SearchIndexablesContract.NonIndexableKey} + * columns to put into the cursor. If {@code null} all supported columns + * should be included. + */ + public abstract Cursor queryNonIndexableKeys(String[] projection); + @Override public String getType(Uri uri) { switch (mMatcher.match(uri)) { @@ -139,14 +155,15 @@ public abstract class SearchIndexablesProvider extends ContentProvider { return SearchIndexablesContract.XmlResource.MIME_TYPE; case MATCH_RAW_CODE: return SearchIndexablesContract.RawData.MIME_TYPE; + case MATCH_NON_INDEXABLE_KEYS_CODE: + return SearchIndexablesContract.NonIndexableKey.MIME_TYPE; default: throw new IllegalArgumentException("Unknown URI " + uri); } } /** - * Implementation is provided by the parent class. Throws by default, and - * cannot be overriden. + * Implementation is provided by the parent class. Throws by default, and cannot be overriden. */ @Override public final Uri insert(Uri uri, ContentValues values) { @@ -154,8 +171,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider { } /** - * Implementation is provided by the parent class. Throws by default, and - * cannot be overriden. + * Implementation is provided by the parent class. Throws by default, and cannot be overriden. */ @Override public final int delete(Uri uri, String selection, String[] selectionArgs) { @@ -163,8 +179,7 @@ public abstract class SearchIndexablesProvider extends ContentProvider { } /** - * Implementation is provided by the parent class. Throws by default, and - * cannot be overriden. + * Implementation is provided by the parent class. Throws by default, and cannot be overriden. */ @Override public final int update( |