Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.provider; |
| 18 | |
Fabrice Di Meglio | 27e1334 | 2015-03-09 16:49:00 -0700 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 20 | import android.content.ContentResolver; |
| 21 | |
| 22 | /** |
| 23 | * Describe the contract for an Indexable data. |
| 24 | * |
| 25 | * @hide |
| 26 | */ |
Fabrice Di Meglio | 27e1334 | 2015-03-09 16:49:00 -0700 | [diff] [blame] | 27 | @SystemApi |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 28 | public 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 Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 40 | * Indexable reference names. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 41 | */ |
| 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 Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 50 | * Indexable raw data names. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 51 | */ |
| 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 Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 60 | * Non indexable data keys. |
| 61 | */ |
| 62 | public static final String NON_INDEXABLES_KEYS = "non_indexables_key"; |
| 63 | |
| 64 | /** |
Fan Zhang | 9a0f6fe | 2017-11-27 12:39:52 -0800 | [diff] [blame] | 65 | * 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 Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 72 | * ContentProvider path for non indexable data keys. |
| 73 | */ |
| 74 | public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS; |
| 75 | |
| 76 | /** |
Fan Zhang | 9a0f6fe | 2017-11-27 12:39:52 -0800 | [diff] [blame] | 77 | * 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 Fritze | 5159860 | 2018-02-21 17:04:04 -0800 | [diff] [blame] | 84 | * 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 Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 99 | * Indexable xml resources columns. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 100 | */ |
| 101 | public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] { |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 102 | 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 Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
| 111 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 112 | * Indexable xml resources columns indices. |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 113 | */ |
| 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 Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 123 | * Indexable raw data columns. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 124 | */ |
| 125 | public static final String[] INDEXABLES_RAW_COLUMNS = new String[] { |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 126 | 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 Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 139 | RawData.COLUMN_USER_ID, // 13 |
Matthew Fritze | af534b1 | 2016-12-05 18:13:46 -0800 | [diff] [blame] | 140 | RawData.PAYLOAD_TYPE, // 14 |
| 141 | RawData.PAYLOAD // 15 |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | /** |
Fan Zhang | 9a0f6fe | 2017-11-27 12:39:52 -0800 | [diff] [blame] | 145 | * 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 Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 157 | * Indexable raw data columns indices. |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 158 | */ |
| 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 Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 172 | public static final int COLUMN_INDEX_RAW_USER_ID = 13; |
Matthew Fritze | af534b1 | 2016-12-05 18:13:46 -0800 | [diff] [blame] | 173 | /** |
| 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 Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 181 | |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 182 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 183 | * Indexable raw data columns. |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 184 | */ |
| 185 | public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] { |
| 186 | NonIndexableKey.COLUMN_KEY_VALUE // 0 |
| 187 | }; |
| 188 | |
| 189 | /** |
Fabrice Di Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 190 | * Non indexable data keys columns indices. |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 191 | */ |
| 192 | public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0; |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 193 | |
| 194 | /** |
Matthew Fritze | 5159860 | 2018-02-21 17:04:04 -0800 | [diff] [blame] | 195 | * 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 Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 219 | * 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 Zhang | 9a0f6fe | 2017-11-27 12:39:52 -0800 | [diff] [blame] | 237 | * @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 Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 247 | * 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 Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 253 | */ |
| 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 Meglio | 98274a9 | 2014-03-31 19:45:04 -0700 | [diff] [blame] | 267 | * Summary's raw data when the data is "ON". |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 268 | */ |
Fabrice Di Meglio | 98274a9 | 2014-03-31 19:45:04 -0700 | [diff] [blame] | 269 | 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 Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 275 | |
| 276 | /** |
Fabrice Di Meglio | a8e8f3f | 2014-04-11 17:24:02 -0700 | [diff] [blame] | 277 | * Entries associated with the raw data (when the data can have several values). |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 278 | */ |
| 279 | public static final String COLUMN_ENTRIES = "entries"; |
| 280 | |
| 281 | /** |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 282 | * Keywords' raw data. |
| 283 | */ |
| 284 | public static final String COLUMN_KEYWORDS = "keywords"; |
| 285 | |
| 286 | /** |
Fabrice Di Meglio | a8e8f3f | 2014-04-11 17:24:02 -0700 | [diff] [blame] | 287 | * Fragment or Activity title associated with the raw data. |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 288 | */ |
| 289 | public static final String COLUMN_SCREEN_TITLE = "screenTitle"; |
Fabrice Di Meglio | 1ecde22 | 2014-04-09 13:17:42 -0700 | [diff] [blame] | 290 | |
| 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 Meglio | 83c0fdd | 2014-07-10 12:11:47 -0700 | [diff] [blame] | 295 | |
| 296 | /** |
| 297 | * UserId associated with the raw data. |
| 298 | */ |
| 299 | public static final String COLUMN_USER_ID = "user_id"; |
Matthew Fritze | af534b1 | 2016-12-05 18:13:46 -0800 | [diff] [blame] | 300 | |
| 301 | /** |
| 302 | * Identifier for the Payload object type. |
Matthew Fritze | 5159860 | 2018-02-21 17:04:04 -0800 | [diff] [blame] | 303 | * |
Matthew Fritze | af534b1 | 2016-12-05 18:13:46 -0800 | [diff] [blame] | 304 | * @hide |
| 305 | */ |
| 306 | public static final String PAYLOAD_TYPE = "payload_type"; |
| 307 | |
| 308 | /** |
| 309 | * Generic payload for improving Search result expressiveness. |
Matthew Fritze | 5159860 | 2018-02-21 17:04:04 -0800 | [diff] [blame] | 310 | * |
Matthew Fritze | af534b1 | 2016-12-05 18:13:46 -0800 | [diff] [blame] | 311 | * @hide |
| 312 | */ |
| 313 | public static final String PAYLOAD = "payload"; |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /** |
Fabrice Di Meglio | 97babb1 | 2014-04-11 18:45:44 -0700 | [diff] [blame] | 317 | * 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 Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 335 | * The base columns. |
| 336 | */ |
Ying Wang | b67cd46 | 2015-03-30 15:46:30 -0700 | [diff] [blame] | 337 | public static class BaseColumns { |
Fabrice Di Meglio | b49995d | 2014-03-14 19:06:20 -0700 | [diff] [blame] | 338 | 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 | } |