blob: 93ac7f686127eeb976f4d8fb10de1c3e6504229e [file] [log] [blame]
Fabrice Di Megliob49995d2014-03-14 19:06:20 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.provider;
18
Fabrice Di Meglio27e13342015-03-09 16:49:00 -070019import android.annotation.SystemApi;
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070020import android.content.ContentResolver;
21
22/**
23 * Describe the contract for an Indexable data.
24 *
25 * @hide
26 */
Fabrice Di Meglio27e13342015-03-09 16:49:00 -070027@SystemApi
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070028public class SearchIndexablesContract {
29
30 /**
31 * Intent action used to identify {@link SearchIndexablesProvider}
32 * instances. This is used in the {@code <intent-filter>} of a {@code <provider>}.
33 */
34 public static final String PROVIDER_INTERFACE =
35 "android.content.action.SEARCH_INDEXABLES_PROVIDER";
36
37 private static final String SETTINGS = "settings";
38
39 /**
Fabrice Di Meglio97babb12014-04-11 18:45:44 -070040 * Indexable reference names.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070041 */
42 public static final String INDEXABLES_XML_RES = "indexables_xml_res";
43
44 /**
45 * ContentProvider path for indexable xml resources.
46 */
47 public static final String INDEXABLES_XML_RES_PATH = SETTINGS + "/" + INDEXABLES_XML_RES;
48
49 /**
Fabrice Di Meglio97babb12014-04-11 18:45:44 -070050 * Indexable raw data names.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070051 */
52 public static final String INDEXABLES_RAW = "indexables_raw";
53
54 /**
55 * ContentProvider path for indexable raw data.
56 */
57 public static final String INDEXABLES_RAW_PATH = SETTINGS + "/" + INDEXABLES_RAW;
58
59 /**
Fabrice Di Meglio97babb12014-04-11 18:45:44 -070060 * Non indexable data keys.
61 */
62 public static final String NON_INDEXABLES_KEYS = "non_indexables_key";
63
64 /**
65 * ContentProvider path for non indexable data keys.
66 */
67 public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS;
68
69 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -070070 * Indexable xml resources columns.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070071 */
72 public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] {
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -070073 XmlResource.COLUMN_RANK, // 0
74 XmlResource.COLUMN_XML_RESID, // 1
75 XmlResource.COLUMN_CLASS_NAME, // 2
76 XmlResource.COLUMN_ICON_RESID, // 3
77 XmlResource.COLUMN_INTENT_ACTION, // 4
78 XmlResource.COLUMN_INTENT_TARGET_PACKAGE, // 5
79 XmlResource.COLUMN_INTENT_TARGET_CLASS // 6
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070080 };
81
82 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -070083 * Indexable xml resources columns indices.
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -070084 */
85 public static final int COLUMN_INDEX_XML_RES_RANK = 0;
86 public static final int COLUMN_INDEX_XML_RES_RESID = 1;
87 public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2;
88 public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3;
89 public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4;
90 public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5;
91 public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6;
92
93 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -070094 * Indexable raw data columns.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -070095 */
96 public static final String[] INDEXABLES_RAW_COLUMNS = new String[] {
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -070097 RawData.COLUMN_RANK, // 0
98 RawData.COLUMN_TITLE, // 1
99 RawData.COLUMN_SUMMARY_ON, // 2
100 RawData.COLUMN_SUMMARY_OFF, // 3
101 RawData.COLUMN_ENTRIES, // 4
102 RawData.COLUMN_KEYWORDS, // 5
103 RawData.COLUMN_SCREEN_TITLE, // 6
104 RawData.COLUMN_CLASS_NAME, // 7
105 RawData.COLUMN_ICON_RESID, // 8
106 RawData.COLUMN_INTENT_ACTION, // 9
107 RawData.COLUMN_INTENT_TARGET_PACKAGE, // 10
108 RawData.COLUMN_INTENT_TARGET_CLASS, // 11
109 RawData.COLUMN_KEY, // 12
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700110 RawData.COLUMN_USER_ID, // 13
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700111 };
112
113 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700114 * Indexable raw data columns indices.
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700115 */
116 public static final int COLUMN_INDEX_RAW_RANK = 0;
117 public static final int COLUMN_INDEX_RAW_TITLE = 1;
118 public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2;
119 public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3;
120 public static final int COLUMN_INDEX_RAW_ENTRIES = 4;
121 public static final int COLUMN_INDEX_RAW_KEYWORDS = 5;
122 public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6;
123 public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7;
124 public static final int COLUMN_INDEX_RAW_ICON_RESID = 8;
125 public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9;
126 public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10;
127 public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11;
128 public static final int COLUMN_INDEX_RAW_KEY = 12;
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700129 public static final int COLUMN_INDEX_RAW_USER_ID = 13;
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700130
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700131 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700132 * Indexable raw data columns.
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700133 */
134 public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] {
135 NonIndexableKey.COLUMN_KEY_VALUE // 0
136 };
137
138 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700139 * Non indexable data keys columns indices.
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700140 */
141 public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0;
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700142
143 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700144 * Constants related to a {@link SearchIndexableResource}.
145 *
146 * This is a description of
147 */
148 public static final class XmlResource extends BaseColumns {
149 private XmlResource() {
150 }
151
152 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
153 "/" + INDEXABLES_XML_RES;
154
155 /**
156 * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
157 */
158 public static final String COLUMN_XML_RESID = "xmlResId";
159 }
160
161 /**
162 * Constants related to a {@link SearchIndexableData}.
163 *
164 * This is the raw data that is stored into an Index. This is related to
165 * {@link android.preference.Preference} and its attributes like
166 * {@link android.preference.Preference#getTitle()},
167 * {@link android.preference.Preference#getSummary()}, etc.
168 *
169 */
170 public static final class RawData extends BaseColumns {
171 private RawData() {
172 }
173
174 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
175 "/" + INDEXABLES_RAW;
176
177 /**
178 * Title's raw data.
179 */
180 public static final String COLUMN_TITLE = "title";
181
182 /**
Fabrice Di Meglio98274a92014-03-31 19:45:04 -0700183 * Summary's raw data when the data is "ON".
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700184 */
Fabrice Di Meglio98274a92014-03-31 19:45:04 -0700185 public static final String COLUMN_SUMMARY_ON = "summaryOn";
186
187 /**
188 * Summary's raw data when the data is "OFF".
189 */
190 public static final String COLUMN_SUMMARY_OFF = "summaryOff";
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700191
192 /**
Fabrice Di Meglioa8e8f3f2014-04-11 17:24:02 -0700193 * Entries associated with the raw data (when the data can have several values).
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700194 */
195 public static final String COLUMN_ENTRIES = "entries";
196
197 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700198 * Keywords' raw data.
199 */
200 public static final String COLUMN_KEYWORDS = "keywords";
201
202 /**
Fabrice Di Meglioa8e8f3f2014-04-11 17:24:02 -0700203 * Fragment or Activity title associated with the raw data.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700204 */
205 public static final String COLUMN_SCREEN_TITLE = "screenTitle";
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700206
207 /**
208 * Key associated with the raw data. The key needs to be unique.
209 */
210 public static final String COLUMN_KEY = "key";
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700211
212 /**
213 * UserId associated with the raw data.
214 */
215 public static final String COLUMN_USER_ID = "user_id";
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700216 }
217
218 /**
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700219 * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}.
220 *
221 * This is a description of a data (thru its unique key) that cannot be indexed.
222 */
223 public static final class NonIndexableKey extends BaseColumns {
224 private NonIndexableKey() {
225 }
226
227 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
228 "/" + NON_INDEXABLES_KEYS;
229
230 /**
231 * Key for the non indexable data.
232 */
233 public static final String COLUMN_KEY_VALUE = "key";
234 }
235
236 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700237 * The base columns.
238 */
Ying Wangb67cd462015-03-30 15:46:30 -0700239 public static class BaseColumns {
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700240 private BaseColumns() {
241 }
242
243 /**
244 * Rank of the data. This is an integer used for ranking the search results. This is
245 * application specific.
246 */
247 public static final String COLUMN_RANK = "rank";
248
249 /**
250 * Class name associated with the data (usually a Fragment class name).
251 */
252 public static final String COLUMN_CLASS_NAME = "className";
253
254 /**
255 * Icon resource ID for the data.
256 */
257 public static final String COLUMN_ICON_RESID = "iconResId";
258
259 /**
260 * Intent action associated with the data.
261 */
262 public static final String COLUMN_INTENT_ACTION = "intentAction";
263
264 /**
265 * Intent target package associated with the data.
266 */
267 public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
268
269 /**
270 * Intent target class associated with the data.
271 */
272 public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
273 }
274}