blob: 42c2d5ced806937cecc021ebcd1aea1c952691ef [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 /**
Fan Zhang9a0f6fe2017-11-27 12:39:52 -080065 * Site map pairs data key
66 *
67 * @hide
68 */
69 public static final String SITE_MAP_PAIRS_KEYS = "site_map_pairs";
70
71 /**
Fabrice Di Meglio97babb12014-04-11 18:45:44 -070072 * ContentProvider path for non indexable data keys.
73 */
74 public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS;
75
76 /**
Fan Zhang9a0f6fe2017-11-27 12:39:52 -080077 * ContentProvider path for sitemap keys.
78 *
79 * @hide
80 */
81 public static final String SITE_MAP_PAIRS_PATH = SETTINGS + "/" + SITE_MAP_PAIRS_KEYS;
82
83 /**
Matthew Fritze51598602018-02-21 17:04:04 -080084 * Last path segment for Preference Key, Slice Uri pair.
85 * <p>
86 * The (Key, Slice Uri) pairs are a mapping between the primary key of the search result and
87 * a Uri for a Slice that represents the same data. Thus, an app can specify a list of Uris
88 * for Slices that replace regular intent-based search results with inline content.
89 * </p>
90 */
91 public static final String SLICE_URI_PAIRS = "slice_uri_pairs";
92
93 /**
94 * ContentProvider path for Slice Uri pairs.
95 */
96 public static final String SLICE_URI_PAIRS_PATH = SETTINGS + "/" + SLICE_URI_PAIRS;
97
98 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -070099 * Indexable xml resources columns.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700100 */
101 public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] {
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700102 XmlResource.COLUMN_RANK, // 0
103 XmlResource.COLUMN_XML_RESID, // 1
104 XmlResource.COLUMN_CLASS_NAME, // 2
105 XmlResource.COLUMN_ICON_RESID, // 3
106 XmlResource.COLUMN_INTENT_ACTION, // 4
107 XmlResource.COLUMN_INTENT_TARGET_PACKAGE, // 5
108 XmlResource.COLUMN_INTENT_TARGET_CLASS // 6
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700109 };
110
111 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700112 * Indexable xml resources columns indices.
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700113 */
114 public static final int COLUMN_INDEX_XML_RES_RANK = 0;
115 public static final int COLUMN_INDEX_XML_RES_RESID = 1;
116 public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2;
117 public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3;
118 public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4;
119 public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5;
120 public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6;
121
122 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700123 * Indexable raw data columns.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700124 */
125 public static final String[] INDEXABLES_RAW_COLUMNS = new String[] {
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700126 RawData.COLUMN_RANK, // 0
127 RawData.COLUMN_TITLE, // 1
128 RawData.COLUMN_SUMMARY_ON, // 2
129 RawData.COLUMN_SUMMARY_OFF, // 3
130 RawData.COLUMN_ENTRIES, // 4
131 RawData.COLUMN_KEYWORDS, // 5
132 RawData.COLUMN_SCREEN_TITLE, // 6
133 RawData.COLUMN_CLASS_NAME, // 7
134 RawData.COLUMN_ICON_RESID, // 8
135 RawData.COLUMN_INTENT_ACTION, // 9
136 RawData.COLUMN_INTENT_TARGET_PACKAGE, // 10
137 RawData.COLUMN_INTENT_TARGET_CLASS, // 11
138 RawData.COLUMN_KEY, // 12
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700139 RawData.COLUMN_USER_ID, // 13
Matthew Fritzeaf534b12016-12-05 18:13:46 -0800140 RawData.PAYLOAD_TYPE, // 14
141 RawData.PAYLOAD // 15
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700142 };
143
144 /**
Fan Zhang9a0f6fe2017-11-27 12:39:52 -0800145 * Columns for site map queries.
146 *
147 * @hide
148 */
149 public static final String[] SITE_MAP_COLUMNS = new String[] {
150 SiteMapColumns.PARENT_CLASS,
151 SiteMapColumns.PARENT_TITLE,
152 SiteMapColumns.CHILD_CLASS,
153 SiteMapColumns.CHILD_TITLE,
154 };
155
156 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700157 * Indexable raw data columns indices.
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700158 */
159 public static final int COLUMN_INDEX_RAW_RANK = 0;
160 public static final int COLUMN_INDEX_RAW_TITLE = 1;
161 public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2;
162 public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3;
163 public static final int COLUMN_INDEX_RAW_ENTRIES = 4;
164 public static final int COLUMN_INDEX_RAW_KEYWORDS = 5;
165 public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6;
166 public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7;
167 public static final int COLUMN_INDEX_RAW_ICON_RESID = 8;
168 public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9;
169 public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10;
170 public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11;
171 public static final int COLUMN_INDEX_RAW_KEY = 12;
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700172 public static final int COLUMN_INDEX_RAW_USER_ID = 13;
Matthew Fritzeaf534b12016-12-05 18:13:46 -0800173 /**
174 * @hide
175 */
176 public static final int COLUMN_INDEX_RAW_PAYLOAD_TYPE = 14;
177 /**
178 * @hide
179 */
180 public static final int COLUMN_INDEX_RAW_PAYLOAD = 15;
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700181
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700182 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700183 * Indexable raw data columns.
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700184 */
185 public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] {
186 NonIndexableKey.COLUMN_KEY_VALUE // 0
187 };
188
189 /**
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700190 * Non indexable data keys columns indices.
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700191 */
192 public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0;
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700193
194 /**
Matthew Fritze51598602018-02-21 17:04:04 -0800195 * Columns for the SliceUri and Preference Key pairs.
196 */
197 public static final class SliceUriPairColumns {
198 private SliceUriPairColumns() {}
199
200 /**
201 * The preference key for the Setting.
202 */
203 public static final String KEY = "key";
204 /**
205 * The Slice Uri corresponding to the Setting key.
206 */
207 public static final String SLICE_URI = "slice_uri";
208 }
209
210 /**
211 * Cursor schema for SliceUriPairs.
212 */
213 public static final String[] SLICE_URI_PAIRS_COLUMNS = new String[]{
214 SliceUriPairColumns.KEY,
215 SliceUriPairColumns.SLICE_URI
216 };
217
218 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700219 * Constants related to a {@link SearchIndexableResource}.
220 *
221 * This is a description of
222 */
223 public static final class XmlResource extends BaseColumns {
224 private XmlResource() {
225 }
226
227 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
228 "/" + INDEXABLES_XML_RES;
229
230 /**
231 * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
232 */
233 public static final String COLUMN_XML_RESID = "xmlResId";
234 }
235
236 /**
Fan Zhang9a0f6fe2017-11-27 12:39:52 -0800237 * @hide
238 */
239 public static final class SiteMapColumns {
240 public static final String PARENT_CLASS = "parent_class";
241 public static final String CHILD_CLASS = "child_class";
242 public static final String PARENT_TITLE = "parent_title";
243 public static final String CHILD_TITLE = "child_title";
244 }
245
246 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700247 * Constants related to a {@link SearchIndexableData}.
248 *
249 * This is the raw data that is stored into an Index. This is related to
250 * {@link android.preference.Preference} and its attributes like
251 * {@link android.preference.Preference#getTitle()},
252 * {@link android.preference.Preference#getSummary()}, etc.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700253 */
254 public static final class RawData extends BaseColumns {
255 private RawData() {
256 }
257
258 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
259 "/" + INDEXABLES_RAW;
260
261 /**
262 * Title's raw data.
263 */
264 public static final String COLUMN_TITLE = "title";
265
266 /**
Fabrice Di Meglio98274a92014-03-31 19:45:04 -0700267 * Summary's raw data when the data is "ON".
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700268 */
Fabrice Di Meglio98274a92014-03-31 19:45:04 -0700269 public static final String COLUMN_SUMMARY_ON = "summaryOn";
270
271 /**
272 * Summary's raw data when the data is "OFF".
273 */
274 public static final String COLUMN_SUMMARY_OFF = "summaryOff";
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700275
276 /**
Fabrice Di Meglioa8e8f3f2014-04-11 17:24:02 -0700277 * Entries associated with the raw data (when the data can have several values).
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700278 */
279 public static final String COLUMN_ENTRIES = "entries";
280
281 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700282 * Keywords' raw data.
283 */
284 public static final String COLUMN_KEYWORDS = "keywords";
285
286 /**
Fabrice Di Meglioa8e8f3f2014-04-11 17:24:02 -0700287 * Fragment or Activity title associated with the raw data.
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700288 */
289 public static final String COLUMN_SCREEN_TITLE = "screenTitle";
Fabrice Di Meglio1ecde222014-04-09 13:17:42 -0700290
291 /**
292 * Key associated with the raw data. The key needs to be unique.
293 */
294 public static final String COLUMN_KEY = "key";
Fabrice Di Meglio83c0fdd2014-07-10 12:11:47 -0700295
296 /**
297 * UserId associated with the raw data.
298 */
299 public static final String COLUMN_USER_ID = "user_id";
Matthew Fritzeaf534b12016-12-05 18:13:46 -0800300
301 /**
302 * Identifier for the Payload object type.
Matthew Fritze51598602018-02-21 17:04:04 -0800303 *
Matthew Fritzeaf534b12016-12-05 18:13:46 -0800304 * @hide
305 */
306 public static final String PAYLOAD_TYPE = "payload_type";
307
308 /**
309 * Generic payload for improving Search result expressiveness.
Matthew Fritze51598602018-02-21 17:04:04 -0800310 *
Matthew Fritzeaf534b12016-12-05 18:13:46 -0800311 * @hide
312 */
313 public static final String PAYLOAD = "payload";
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700314 }
315
316 /**
Fabrice Di Meglio97babb12014-04-11 18:45:44 -0700317 * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}.
318 *
319 * This is a description of a data (thru its unique key) that cannot be indexed.
320 */
321 public static final class NonIndexableKey extends BaseColumns {
322 private NonIndexableKey() {
323 }
324
325 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
326 "/" + NON_INDEXABLES_KEYS;
327
328 /**
329 * Key for the non indexable data.
330 */
331 public static final String COLUMN_KEY_VALUE = "key";
332 }
333
334 /**
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700335 * The base columns.
336 */
Ying Wangb67cd462015-03-30 15:46:30 -0700337 public static class BaseColumns {
Fabrice Di Megliob49995d2014-03-14 19:06:20 -0700338 private BaseColumns() {
339 }
340
341 /**
342 * Rank of the data. This is an integer used for ranking the search results. This is
343 * application specific.
344 */
345 public static final String COLUMN_RANK = "rank";
346
347 /**
348 * Class name associated with the data (usually a Fragment class name).
349 */
350 public static final String COLUMN_CLASS_NAME = "className";
351
352 /**
353 * Icon resource ID for the data.
354 */
355 public static final String COLUMN_ICON_RESID = "iconResId";
356
357 /**
358 * Intent action associated with the data.
359 */
360 public static final String COLUMN_INTENT_ACTION = "intentAction";
361
362 /**
363 * Intent target package associated with the data.
364 */
365 public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
366
367 /**
368 * Intent target class associated with the data.
369 */
370 public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
371 }
372}