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.SystemApi;
     20 import android.content.ContentResolver;
     21 
     22 /**
     23  * Describe the contract for an Indexable data.
     24  *
     25  * @hide
     26  */
     27 @SystemApi
     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     /**
     40      * Indexable reference names.
     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     /**
     50      * Indexable raw data names.
     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     /**
     60      * Non indexable data keys.
     61      */
     62     public static final String NON_INDEXABLES_KEYS = "non_indexables_key";
     63 
     64     /**
     65      * Site map pairs data key
     66      *
     67      * @hide
     68      */
     69     public static final String SITE_MAP_PAIRS_KEYS = "site_map_pairs";
     70 
     71     /**
     72      * ContentProvider path for non indexable data keys.
     73      */
     74     public static final String NON_INDEXABLES_KEYS_PATH = SETTINGS + "/" + NON_INDEXABLES_KEYS;
     75 
     76     /**
     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     /**
     84      * Indexable xml resources columns.
     85      */
     86     public static final String[] INDEXABLES_XML_RES_COLUMNS = new String[] {
     87             XmlResource.COLUMN_RANK,                    // 0
     88             XmlResource.COLUMN_XML_RESID,               // 1
     89             XmlResource.COLUMN_CLASS_NAME,              // 2
     90             XmlResource.COLUMN_ICON_RESID,              // 3
     91             XmlResource.COLUMN_INTENT_ACTION,           // 4
     92             XmlResource.COLUMN_INTENT_TARGET_PACKAGE,   // 5
     93             XmlResource.COLUMN_INTENT_TARGET_CLASS      // 6
     94     };
     95 
     96     /**
     97      * Indexable xml resources columns indices.
     98      */
     99     public static final int COLUMN_INDEX_XML_RES_RANK = 0;
    100     public static final int COLUMN_INDEX_XML_RES_RESID = 1;
    101     public static final int COLUMN_INDEX_XML_RES_CLASS_NAME = 2;
    102     public static final int COLUMN_INDEX_XML_RES_ICON_RESID = 3;
    103     public static final int COLUMN_INDEX_XML_RES_INTENT_ACTION = 4;
    104     public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_PACKAGE = 5;
    105     public static final int COLUMN_INDEX_XML_RES_INTENT_TARGET_CLASS = 6;
    106 
    107     /**
    108      * Indexable raw data columns.
    109      */
    110     public static final String[] INDEXABLES_RAW_COLUMNS = new String[] {
    111             RawData.COLUMN_RANK,                    // 0
    112             RawData.COLUMN_TITLE,                   // 1
    113             RawData.COLUMN_SUMMARY_ON,              // 2
    114             RawData.COLUMN_SUMMARY_OFF,             // 3
    115             RawData.COLUMN_ENTRIES,                 // 4
    116             RawData.COLUMN_KEYWORDS,                // 5
    117             RawData.COLUMN_SCREEN_TITLE,            // 6
    118             RawData.COLUMN_CLASS_NAME,              // 7
    119             RawData.COLUMN_ICON_RESID,              // 8
    120             RawData.COLUMN_INTENT_ACTION,           // 9
    121             RawData.COLUMN_INTENT_TARGET_PACKAGE,   // 10
    122             RawData.COLUMN_INTENT_TARGET_CLASS,     // 11
    123             RawData.COLUMN_KEY,                     // 12
    124             RawData.COLUMN_USER_ID,                 // 13
    125             RawData.PAYLOAD_TYPE,                   // 14
    126             RawData.PAYLOAD                         // 15
    127     };
    128 
    129     /**
    130      * Columns for site map queries.
    131      *
    132      * @hide
    133      */
    134     public static final String[] SITE_MAP_COLUMNS = new String[] {
    135             SiteMapColumns.PARENT_CLASS,
    136             SiteMapColumns.PARENT_TITLE,
    137             SiteMapColumns.CHILD_CLASS,
    138             SiteMapColumns.CHILD_TITLE,
    139     };
    140 
    141     /**
    142      * Indexable raw data columns indices.
    143      */
    144     public static final int COLUMN_INDEX_RAW_RANK = 0;
    145     public static final int COLUMN_INDEX_RAW_TITLE = 1;
    146     public static final int COLUMN_INDEX_RAW_SUMMARY_ON = 2;
    147     public static final int COLUMN_INDEX_RAW_SUMMARY_OFF = 3;
    148     public static final int COLUMN_INDEX_RAW_ENTRIES = 4;
    149     public static final int COLUMN_INDEX_RAW_KEYWORDS = 5;
    150     public static final int COLUMN_INDEX_RAW_SCREEN_TITLE = 6;
    151     public static final int COLUMN_INDEX_RAW_CLASS_NAME = 7;
    152     public static final int COLUMN_INDEX_RAW_ICON_RESID = 8;
    153     public static final int COLUMN_INDEX_RAW_INTENT_ACTION = 9;
    154     public static final int COLUMN_INDEX_RAW_INTENT_TARGET_PACKAGE = 10;
    155     public static final int COLUMN_INDEX_RAW_INTENT_TARGET_CLASS = 11;
    156     public static final int COLUMN_INDEX_RAW_KEY = 12;
    157     public static final int COLUMN_INDEX_RAW_USER_ID = 13;
    158     /**
    159      * @hide
    160      */
    161     public static final int COLUMN_INDEX_RAW_PAYLOAD_TYPE = 14;
    162     /**
    163      * @hide
    164      */
    165     public static final int COLUMN_INDEX_RAW_PAYLOAD = 15;
    166 
    167     /**
    168      * Indexable raw data columns.
    169      */
    170     public static final String[] NON_INDEXABLES_KEYS_COLUMNS = new String[] {
    171             NonIndexableKey.COLUMN_KEY_VALUE      // 0
    172     };
    173 
    174     /**
    175      * Non indexable data keys columns indices.
    176      */
    177     public static final int COLUMN_INDEX_NON_INDEXABLE_KEYS_KEY_VALUE = 0;
    178 
    179     /**
    180      * Constants related to a {@link SearchIndexableResource}.
    181      *
    182      * This is a description of
    183      */
    184     public static final class XmlResource extends BaseColumns {
    185         private XmlResource() {
    186         }
    187 
    188         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    189                 "/" + INDEXABLES_XML_RES;
    190 
    191         /**
    192          * XML resource ID for the {@link android.preference.PreferenceScreen} to load and index.
    193          */
    194         public static final String COLUMN_XML_RESID = "xmlResId";
    195     }
    196 
    197     /**
    198      * @hide
    199      */
    200     public static final class SiteMapColumns {
    201         public static final String PARENT_CLASS = "parent_class";
    202         public static final String CHILD_CLASS = "child_class";
    203         public static final String PARENT_TITLE = "parent_title";
    204         public static final String CHILD_TITLE = "child_title";
    205     }
    206 
    207     /**
    208      * Constants related to a {@link SearchIndexableData}.
    209      *
    210      * This is the raw data that is stored into an Index. This is related to
    211      * {@link android.preference.Preference} and its attributes like
    212      * {@link android.preference.Preference#getTitle()},
    213      * {@link android.preference.Preference#getSummary()}, etc.
    214      *
    215      */
    216     public static final class RawData extends BaseColumns {
    217         private RawData() {
    218         }
    219 
    220         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    221                 "/" + INDEXABLES_RAW;
    222 
    223         /**
    224          * Title's raw data.
    225          */
    226         public static final String COLUMN_TITLE = "title";
    227 
    228         /**
    229          * Summary's raw data when the data is "ON".
    230          */
    231         public static final String COLUMN_SUMMARY_ON = "summaryOn";
    232 
    233         /**
    234          * Summary's raw data when the data is "OFF".
    235          */
    236         public static final String COLUMN_SUMMARY_OFF = "summaryOff";
    237 
    238         /**
    239          * Entries associated with the raw data (when the data can have several values).
    240          */
    241         public static final String COLUMN_ENTRIES = "entries";
    242 
    243         /**
    244          * Keywords' raw data.
    245          */
    246         public static final String COLUMN_KEYWORDS = "keywords";
    247 
    248         /**
    249          * Fragment or Activity title associated with the raw data.
    250          */
    251         public static final String COLUMN_SCREEN_TITLE = "screenTitle";
    252 
    253         /**
    254          * Key associated with the raw data. The key needs to be unique.
    255          */
    256         public static final String COLUMN_KEY = "key";
    257 
    258         /**
    259          * UserId associated with the raw data.
    260          */
    261         public static final String COLUMN_USER_ID = "user_id";
    262 
    263         /**
    264          * Identifier for the Payload object type.
    265          * @hide
    266          */
    267         public static final String PAYLOAD_TYPE = "payload_type";
    268 
    269         /**
    270          * Generic payload for improving Search result expressiveness.
    271          * @hide
    272          */
    273         public static final String PAYLOAD = "payload";
    274     }
    275 
    276     /**
    277      * Constants related to a {@link SearchIndexableResource} and {@link SearchIndexableData}.
    278      *
    279      * This is a description of a data (thru its unique key) that cannot be indexed.
    280      */
    281     public static final class NonIndexableKey extends BaseColumns {
    282         private NonIndexableKey() {
    283         }
    284 
    285         public static final String MIME_TYPE = ContentResolver.CURSOR_DIR_BASE_TYPE +
    286                 "/" + NON_INDEXABLES_KEYS;
    287 
    288         /**
    289          * Key for the non indexable data.
    290          */
    291         public static final String COLUMN_KEY_VALUE = "key";
    292     }
    293 
    294     /**
    295      * The base columns.
    296      */
    297     public static class BaseColumns {
    298         private BaseColumns() {
    299         }
    300 
    301         /**
    302          * Rank of the data. This is an integer used for ranking the search results. This is
    303          * application specific.
    304          */
    305         public static final String COLUMN_RANK = "rank";
    306 
    307         /**
    308          * Class name associated with the data (usually a Fragment class name).
    309          */
    310         public static final String COLUMN_CLASS_NAME = "className";
    311 
    312         /**
    313          * Icon resource ID for the data.
    314          */
    315         public static final String COLUMN_ICON_RESID = "iconResId";
    316 
    317         /**
    318          * Intent action associated with the data.
    319          */
    320         public static final String COLUMN_INTENT_ACTION = "intentAction";
    321 
    322         /**
    323          * Intent target package associated with the data.
    324          */
    325         public static final String COLUMN_INTENT_TARGET_PACKAGE = "intentTargetPackage";
    326 
    327         /**
    328          * Intent target class associated with the data.
    329          */
    330         public static final String COLUMN_INTENT_TARGET_CLASS = "intentTargetClass";
    331     }
    332 }
    333