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 19 import android.annotation.NonNull; 20 import android.annotation.SystemApi; 21 import android.content.ContentResolver; 22 23 /** 24 * Describe the contract for an Indexable data. 25 * 26 * @hide 27 */ 28 @SystemApi 29 public class SearchIndexablesContract { 30 31 /** 32 * Intent action used to identify {@link SearchIndexablesProvider} 33 * instances. This is used in the {@code <intent-filter>} of a {@code <provider>}. 34 */ 35 public static final String PROVIDER_INTERFACE = 36 "android.content.action.SEARCH_INDEXABLES_PROVIDER"; 37 38 private static final String SETTINGS = "settings"; 39 40 /** 41 * Indexable reference names. 42 */ 43 public static final String INDEXABLES_XML_RES = "indexables_xml_res"; 44 45 /** 46 * ContentProvider path for indexable xml resources. 47 */ 48 public static final String INDEXABLES_XML_RES_PATH = SETTINGS + "/" + INDEXABLES_XML_RES; 49 50 /** 51 * Indexable raw data names. 52 */ 53 public static final String INDEXABLES_RAW = "indexables_raw"; 54 55 /** 56 * ContentProvider path for indexable raw data. 57 */ 58 public static final String INDEXABLES_RAW_PATH = SETTINGS + "/" + INDEXABLES_RAW; 59 60 /** 61 * Non indexable data keys. 62 */ 63 public static final String NON_INDEXABLES_KEYS = "non_indexables_key"; 64 65 /** 66 * Site map pairs data key 67 * 68 * @hide 69 */ 70 public static final String SITE_MAP_PAIRS_KEYS = "site_map_pairs"; 71 72 /** 73 * ContentProvider path for non indexable data keys. 74 */ 75 public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS; 76 77 /** 78 * ContentProvider path for sitemap keys. 79 * 80 * @hide 81 */ 82 public static final String SITE_MAP_PAIRS_PATH = SETTINGS + "/" + SITE_MAP_PAIRS_KEYS; 83 84 /** 85 * Last path segment for Preference Key, Slice Uri pair. 86 * <p> 87 * The (Key, Slice Uri) pairs are a mapping between the primary key of the search result and 88 * a Uri for a Slice that represents the same data. Thus, an app can specify a list of Uris 89 * for Slices that replace regular intent-based search results with inline content. 90 * </p> 91 */ 92 public static final String SLICE_URI_PAIRS = "slice_uri_pairs"; 93 94 /** 95 * ContentProvider path for Slice Uri pairs. 96 */ 97 public static final String SLICE_URI_PAIRS_PATH = SETTINGS + "/" + SLICE_URI_PAIRS; 98 99 100 /** 101 * The raw data name of dynamic index. This is used to compose the index path of provider 102 * for dynamic index. 103 */ 104 public static final String DYNAMIC_INDEXABLES_RAW = "dynamic_indexables_raw"; 105 106 /** 107 * ContentProvider path for dynamic index. This is used to get the raw data of dynamic index 108 * from provider. 109 */ 110 public static final String DYNAMIC_INDEXABLES_RAW_PATH = 111 SETTINGS + "/" + DYNAMIC_INDEXABLES_RAW; 112 113 /** 114 * Indexable xml resources columns. 115 */ 116 public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] { 117 XmlResource.COLUMN_RANK, // 0 118 XmlResource.COLUMN_XML_RESID, // 1 119 XmlResource.COLUMN_CLASS_NAME, // 2 120 XmlResource.COLUMN_ICON_RESID, // 3 121 XmlResource.COLUMN_INTENT_ACTION, // 4 122 XmlResource.COLUMN_INTENT_TARGET_PACKAGE, // 5 123 XmlResource.COLUMN_INTENT_TARGET_CLASS // 6 124 }; 125 126 /** 127 * Indexable xml resources columns indices. 128 */ 129 public static final int COLUMN_INDEX_XML_RES_RANK = 0; 130 public static final int COLUMN_INDEX_XML_RES_RESID = 1; 131 public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2; 132 public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3; 133 public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4; 134 public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5; 135 public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6; 136 137 /** 138 * Indexable raw data columns. 139 */ 140 public static final String[] INDEXABLES_RAW_COLUMNS = new String[] { 141 RawData.COLUMN_RANK, // 0 142 RawData.COLUMN_TITLE, // 1 143 RawData.COLUMN_SUMMARY_ON, // 2 144 RawData.COLUMN_SUMMARY_OFF, // 3 145 RawData.COLUMN_ENTRIES, // 4 146 RawData.COLUMN_KEYWORDS, // 5 147 RawData.COLUMN_SCREEN_TITLE, // 6 148 RawData.COLUMN_CLASS_NAME, // 7 149 RawData.COLUMN_ICON_RESID, // 8 150 RawData.COLUMN_INTENT_ACTION, // 9 151 RawData.COLUMN_INTENT_TARGET_PACKAGE, // 10 152 RawData.COLUMN_INTENT_TARGET_CLASS, // 11 153 RawData.COLUMN_KEY, // 12 154 RawData.COLUMN_USER_ID, // 13 155 RawData.PAYLOAD_TYPE, // 14 156 RawData.PAYLOAD // 15 157 }; 158 159 /** 160 * Columns for site map queries. 161 * 162 * @hide 163 */ 164 public static final String[] SITE_MAP_COLUMNS = new String[] { 165 SiteMapColumns.PARENT_CLASS, 166 SiteMapColumns.PARENT_TITLE, 167 SiteMapColumns.CHILD_CLASS, 168 SiteMapColumns.CHILD_TITLE, 169 }; 170 171 /** 172 * Indexable raw data columns indices. 173 */ 174 public static final int COLUMN_INDEX_RAW_RANK = 0; 175 public static final int COLUMN_INDEX_RAW_TITLE = 1; 176 public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2; 177 public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3; 178 public static final int COLUMN_INDEX_RAW_ENTRIES = 4; 179 public static final int COLUMN_INDEX_RAW_KEYWORDS = 5; 180 public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6; 181 public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7; 182 public static final int COLUMN_INDEX_RAW_ICON_RESID = 8; 183 public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9; 184 public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10; 185 public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11; 186 public static final int COLUMN_INDEX_RAW_KEY = 12; 187 public static final int COLUMN_INDEX_RAW_USER_ID = 13; 188 /** 189 * @hide 190 */ 191 public static final int COLUMN_INDEX_RAW_PAYLOAD_TYPE = 14; 192 /** 193 * @hide 194 */ 195 public static final int COLUMN_INDEX_RAW_PAYLOAD = 15; 196 197 /** 198 * Indexable raw data columns. 199 */ 200 public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] { 201 NonIndexableKey.COLUMN_KEY_VALUE // 0 202 }; 203 204 /** 205 * Non indexable data keys columns indices. 206 */ 207 public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0; 208 209 /** 210 * Columns for the SliceUri and Preference Key pairs. 211 */ 212 public static final class SliceUriPairColumns { SliceUriPairColumns()213 private SliceUriPairColumns() {} 214 215 /** 216 * The preference key for the Setting. 217 */ 218 public static final String KEY = "key"; 219 /** 220 * The Slice Uri corresponding to the Setting key. 221 */ 222 public static final String SLICE_URI = "slice_uri"; 223 } 224 225 /** 226 * Cursor schema for SliceUriPairs. 227 */ 228 @NonNull 229 public static final String[] SLICE_URI_PAIRS_COLUMNS = new String[] { 230 SliceUriPairColumns.KEY, 231 SliceUriPairColumns.SLICE_URI 232 }; 233 234 /** 235 * Constants related to a {@link SearchIndexableResource}. 236 * 237 * This is a description of 238 */ 239 public static final class XmlResource extends BaseColumns { XmlResource()240 private XmlResource() { 241 } 242 243 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + 244 "/" + INDEXABLES_XML_RES; 245 246 /** 247 * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index. 248 */ 249 public static final String COLUMN_XML_RESID = "xmlResId"; 250 } 251 252 /** 253 * @hide 254 */ 255 public static final class SiteMapColumns { 256 public static final String PARENT_CLASS = "parent_class"; 257 public static final String CHILD_CLASS = "child_class"; 258 public static final String PARENT_TITLE = "parent_title"; 259 public static final String CHILD_TITLE = "child_title"; 260 } 261 262 /** 263 * Constants related to a {@link SearchIndexableData}. 264 * 265 * This is the raw data that is stored into an Index. This is related to 266 * {@link android.preference.Preference} and its attributes like 267 * {@link android.preference.Preference#getTitle()}, 268 * {@link android.preference.Preference#getSummary()}, etc. 269 */ 270 public static final class RawData extends BaseColumns { RawData()271 private RawData() { 272 } 273 274 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + 275 "/" + INDEXABLES_RAW; 276 277 /** 278 * Title's raw data. 279 */ 280 public static final String COLUMN_TITLE = "title"; 281 282 /** 283 * Summary's raw data when the data is "ON". 284 */ 285 public static final String COLUMN_SUMMARY_ON = "summaryOn"; 286 287 /** 288 * Summary's raw data when the data is "OFF". 289 */ 290 public static final String COLUMN_SUMMARY_OFF = "summaryOff"; 291 292 /** 293 * Entries associated with the raw data (when the data can have several values). 294 */ 295 public static final String COLUMN_ENTRIES = "entries"; 296 297 /** 298 * Keywords' raw data. 299 */ 300 public static final String COLUMN_KEYWORDS = "keywords"; 301 302 /** 303 * Fragment or Activity title associated with the raw data. 304 */ 305 public static final String COLUMN_SCREEN_TITLE = "screenTitle"; 306 307 /** 308 * Key associated with the raw data. The key needs to be unique. 309 */ 310 public static final String COLUMN_KEY = "key"; 311 312 /** 313 * UserId associated with the raw data. 314 */ 315 public static final String COLUMN_USER_ID = "user_id"; 316 317 /** 318 * Identifier for the Payload object type. 319 * 320 * @hide 321 */ 322 public static final String PAYLOAD_TYPE = "payload_type"; 323 324 /** 325 * Generic payload for improving Search result expressiveness. 326 * 327 * @hide 328 */ 329 public static final String PAYLOAD = "payload"; 330 } 331 332 /** 333 * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}. 334 * 335 * This is a description of a data (thru its unique key) that cannot be indexed. 336 */ 337 public static final class NonIndexableKey extends BaseColumns { NonIndexableKey()338 private NonIndexableKey() { 339 } 340 341 public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE + 342 "/" + NON_INDEXABLES_KEYS; 343 344 /** 345 * Key for the non indexable data. 346 */ 347 public static final String COLUMN_KEY_VALUE = "key"; 348 } 349 350 /** 351 * The base columns. 352 */ 353 public static class BaseColumns { BaseColumns()354 private BaseColumns() { 355 } 356 357 /** 358 * Rank of the data. This is an integer used for ranking the search results. This is 359 * application specific. 360 */ 361 public static final String COLUMN_RANK = "rank"; 362 363 /** 364 * Class name associated with the data (usually a Fragment class name). 365 */ 366 public static final String COLUMN_CLASS_NAME = "className"; 367 368 /** 369 * Icon resource ID for the data. 370 */ 371 public static final String COLUMN_ICON_RESID = "iconResId"; 372 373 /** 374 * Intent action associated with the data. 375 */ 376 public static final String COLUMN_INTENT_ACTION = "intentAction"; 377 378 /** 379 * Intent target package associated with the data. 380 */ 381 public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage"; 382 383 /** 384 * Intent target class associated with the data. 385 */ 386 public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass"; 387 } 388 } 389