Home | History | Annotate | Download | only in provider
      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      * Indexable xml resources columns.
    101      */
    102     public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] {
    103             XmlResource.COLUMN_RANK,                    // 0
    104             XmlResource.COLUMN_XML_RESID,               // 1
    105             XmlResource.COLUMN_CLASS_NAME,              // 2
    106             XmlResource.COLUMN_ICON_RESID,              // 3
    107             XmlResource.COLUMN_INTENT_ACTION,           // 4
    108             XmlResource.COLUMN_INTENT_TARGET_PACKAGE,   // 5
    109             XmlResource.COLUMN_INTENT_TARGET_CLASS      // 6
    110     };
    111 
    112     /**
    113      * Indexable xml resources columns indices.
    114      */
    115     public static final int COLUMN_INDEX_XML_RES_RANK = 0;
    116     public static final int COLUMN_INDEX_XML_RES_RESID = 1;
    117     public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2;
    118     public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3;
    119     public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4;
    120     public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5;
    121     public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6;
    122 
    123     /**
    124      * Indexable raw data columns.
    125      */
    126     public static final String[] INDEXABLES_RAW_COLUMNS = new String[] {
    127             RawData.COLUMN_RANK,                    // 0
    128             RawData.COLUMN_TITLE,                   // 1
    129             RawData.COLUMN_SUMMARY_ON,              // 2
    130             RawData.COLUMN_SUMMARY_OFF,             // 3
    131             RawData.COLUMN_ENTRIES,                 // 4
    132             RawData.COLUMN_KEYWORDS,                // 5
    133             RawData.COLUMN_SCREEN_TITLE,            // 6
    134             RawData.COLUMN_CLASS_NAME,              // 7
    135             RawData.COLUMN_ICON_RESID,              // 8
    136             RawData.COLUMN_INTENT_ACTION,           // 9
    137             RawData.COLUMN_INTENT_TARGET_PACKAGE,   // 10
    138             RawData.COLUMN_INTENT_TARGET_CLASS,     // 11
    139             RawData.COLUMN_KEY,                     // 12
    140             RawData.COLUMN_USER_ID,                 // 13
    141             RawData.PAYLOAD_TYPE,                   // 14
    142             RawData.PAYLOAD                         // 15
    143     };
    144 
    145     /**
    146      * Columns for site map queries.
    147      *
    148      * @hide
    149      */
    150     public static final String[] SITE_MAP_COLUMNS = new String[] {
    151             SiteMapColumns.PARENT_CLASS,
    152             SiteMapColumns.PARENT_TITLE,
    153             SiteMapColumns.CHILD_CLASS,
    154             SiteMapColumns.CHILD_TITLE,
    155     };
    156 
    157     /**
    158      * Indexable raw data columns indices.
    159      */
    160     public static final int COLUMN_INDEX_RAW_RANK = 0;
    161     public static final int COLUMN_INDEX_RAW_TITLE = 1;
    162     public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2;
    163     public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3;
    164     public static final int COLUMN_INDEX_RAW_ENTRIES = 4;
    165     public static final int COLUMN_INDEX_RAW_KEYWORDS = 5;
    166     public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6;
    167     public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7;
    168     public static final int COLUMN_INDEX_RAW_ICON_RESID = 8;
    169     public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9;
    170     public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10;
    171     public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11;
    172     public static final int COLUMN_INDEX_RAW_KEY = 12;
    173     public static final int COLUMN_INDEX_RAW_USER_ID = 13;
    174     /**
    175      * @hide
    176      */
    177     public static final int COLUMN_INDEX_RAW_PAYLOAD_TYPE = 14;
    178     /**
    179      * @hide
    180      */
    181     public static final int COLUMN_INDEX_RAW_PAYLOAD = 15;
    182 
    183     /**
    184      * Indexable raw data columns.
    185      */
    186     public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] {
    187             NonIndexableKey.COLUMN_KEY_VALUE      // 0
    188     };
    189 
    190     /**
    191      * Non indexable data keys columns indices.
    192      */
    193     public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0;
    194 
    195     /**
    196      * Columns for the SliceUri and Preference Key pairs.
    197      */
    198     public static final class SliceUriPairColumns {
    199         private SliceUriPairColumns() {}
    200 
    201         /**
    202          * The preference key for the Setting.
    203          */
    204         public static final String KEY = "key";
    205         /**
    206          * The Slice Uri corresponding to the Setting key.
    207          */
    208         public static final String SLICE_URI = "slice_uri";
    209     }
    210 
    211     /**
    212      * Cursor schema for SliceUriPairs.
    213      */
    214     @NonNull
    215     public static final String[] SLICE_URI_PAIRS_COLUMNS = new String[]{
    216             SliceUriPairColumns.KEY,
    217             SliceUriPairColumns.SLICE_URI
    218     };
    219 
    220     /**
    221      * Constants related to a {@link SearchIndexableResource}.
    222      *
    223      * This is a description of
    224      */
    225     public static final class XmlResource extends BaseColumns {
    226         private XmlResource() {
    227         }
    228 
    229         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    230                 "/" + INDEXABLES_XML_RES;
    231 
    232         /**
    233          * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
    234          */
    235         public static final String COLUMN_XML_RESID = "xmlResId";
    236     }
    237 
    238     /**
    239      * @hide
    240      */
    241     public static final class SiteMapColumns {
    242         public static final String PARENT_CLASS = "parent_class";
    243         public static final String CHILD_CLASS = "child_class";
    244         public static final String PARENT_TITLE = "parent_title";
    245         public static final String CHILD_TITLE = "child_title";
    246     }
    247 
    248     /**
    249      * Constants related to a {@link SearchIndexableData}.
    250      *
    251      * This is the raw data that is stored into an Index. This is related to
    252      * {@link android.preference.Preference} and its attributes like
    253      * {@link android.preference.Preference#getTitle()},
    254      * {@link android.preference.Preference#getSummary()}, etc.
    255      */
    256     public static final class RawData extends BaseColumns {
    257         private RawData() {
    258         }
    259 
    260         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    261                 "/" + INDEXABLES_RAW;
    262 
    263         /**
    264          * Title's raw data.
    265          */
    266         public static final String COLUMN_TITLE = "title";
    267 
    268         /**
    269          * Summary's raw data when the data is "ON".
    270          */
    271         public static final String COLUMN_SUMMARY_ON = "summaryOn";
    272 
    273         /**
    274          * Summary's raw data when the data is "OFF".
    275          */
    276         public static final String COLUMN_SUMMARY_OFF = "summaryOff";
    277 
    278         /**
    279          * Entries associated with the raw data (when the data can have several values).
    280          */
    281         public static final String COLUMN_ENTRIES = "entries";
    282 
    283         /**
    284          * Keywords' raw data.
    285          */
    286         public static final String COLUMN_KEYWORDS = "keywords";
    287 
    288         /**
    289          * Fragment or Activity title associated with the raw data.
    290          */
    291         public static final String COLUMN_SCREEN_TITLE = "screenTitle";
    292 
    293         /**
    294          * Key associated with the raw data. The key needs to be unique.
    295          */
    296         public static final String COLUMN_KEY = "key";
    297 
    298         /**
    299          * UserId associated with the raw data.
    300          */
    301         public static final String COLUMN_USER_ID = "user_id";
    302 
    303         /**
    304          * Identifier for the Payload object type.
    305          *
    306          * @hide
    307          */
    308         public static final String PAYLOAD_TYPE = "payload_type";
    309 
    310         /**
    311          * Generic payload for improving Search result expressiveness.
    312          *
    313          * @hide
    314          */
    315         public static final String PAYLOAD = "payload";
    316     }
    317 
    318     /**
    319      * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}.
    320      *
    321      * This is a description of a data (thru its unique key) that cannot be indexed.
    322      */
    323     public static final class NonIndexableKey extends BaseColumns {
    324         private NonIndexableKey() {
    325         }
    326 
    327         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    328                 "/" + NON_INDEXABLES_KEYS;
    329 
    330         /**
    331          * Key for the non indexable data.
    332          */
    333         public static final String COLUMN_KEY_VALUE = "key";
    334     }
    335 
    336     /**
    337      * The base columns.
    338      */
    339     public static class BaseColumns {
    340         private BaseColumns() {
    341         }
    342 
    343         /**
    344          * Rank of the data. This is an integer used for ranking the search results. This is
    345          * application specific.
    346          */
    347         public static final String COLUMN_RANK = "rank";
    348 
    349         /**
    350          * Class name associated with the data (usually a Fragment class name).
    351          */
    352         public static final String COLUMN_CLASS_NAME = "className";
    353 
    354         /**
    355          * Icon resource ID for the data.
    356          */
    357         public static final String COLUMN_ICON_RESID = "iconResId";
    358 
    359         /**
    360          * Intent action associated with the data.
    361          */
    362         public static final String COLUMN_INTENT_ACTION = "intentAction";
    363 
    364         /**
    365          * Intent target package associated with the data.
    366          */
    367         public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
    368 
    369         /**
    370          * Intent target class associated with the data.
    371          */
    372         public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
    373     }
    374 }
    375