Home | History | Annotate | Download | only in provider
      1 /*
      2  * Copyright (C) 2009 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.accounts.Account;
     20 import android.annotation.SystemApi;
     21 import android.app.Activity;
     22 import android.app.admin.DevicePolicyManager;
     23 import android.content.ActivityNotFoundException;
     24 import android.content.ContentProviderClient;
     25 import android.content.ContentProviderOperation;
     26 import android.content.ContentResolver;
     27 import android.content.ContentUris;
     28 import android.content.ContentValues;
     29 import android.content.Context;
     30 import android.content.ContextWrapper;
     31 import android.content.CursorEntityIterator;
     32 import android.content.Entity;
     33 import android.content.EntityIterator;
     34 import android.content.Intent;
     35 import android.content.res.AssetFileDescriptor;
     36 import android.content.res.Resources;
     37 import android.database.Cursor;
     38 import android.database.CursorWrapper;
     39 import android.database.DatabaseUtils;
     40 import android.graphics.Rect;
     41 import android.net.Uri;
     42 import android.os.RemoteException;
     43 import android.text.TextUtils;
     44 import android.util.DisplayMetrics;
     45 import android.util.Pair;
     46 import android.view.View;
     47 import android.widget.Toast;
     48 
     49 import java.io.ByteArrayInputStream;
     50 import java.io.IOException;
     51 import java.io.InputStream;
     52 import java.util.ArrayList;
     53 
     54 /**
     55  * <p>
     56  * The contract between the contacts provider and applications. Contains
     57  * definitions for the supported URIs and columns. These APIs supersede
     58  * {@link Contacts}.
     59  * </p>
     60  * <h3>Overview</h3>
     61  * <p>
     62  * ContactsContract defines an extensible database of contact-related
     63  * information. Contact information is stored in a three-tier data model:
     64  * </p>
     65  * <ul>
     66  * <li>
     67  * A row in the {@link Data} table can store any kind of personal data, such
     68  * as a phone number or email addresses.  The set of data kinds that can be
     69  * stored in this table is open-ended. There is a predefined set of common
     70  * kinds, but any application can add its own data kinds.
     71  * </li>
     72  * <li>
     73  * A row in the {@link RawContacts} table represents a set of data describing a
     74  * person and associated with a single account (for example, one of the user's
     75  * Gmail accounts).
     76  * </li>
     77  * <li>
     78  * A row in the {@link Contacts} table represents an aggregate of one or more
     79  * RawContacts presumably describing the same person.  When data in or associated with
     80  * the RawContacts table is changed, the affected aggregate contacts are updated as
     81  * necessary.
     82  * </li>
     83  * </ul>
     84  * <p>
     85  * Other tables include:
     86  * </p>
     87  * <ul>
     88  * <li>
     89  * {@link Groups}, which contains information about raw contact groups
     90  * such as Gmail contact groups.  The
     91  * current API does not support the notion of groups spanning multiple accounts.
     92  * </li>
     93  * <li>
     94  * {@link StatusUpdates}, which contains social status updates including IM
     95  * availability.
     96  * </li>
     97  * <li>
     98  * {@link AggregationExceptions}, which is used for manual aggregation and
     99  * disaggregation of raw contacts
    100  * </li>
    101  * <li>
    102  * {@link Settings}, which contains visibility and sync settings for accounts
    103  * and groups.
    104  * </li>
    105  * <li>
    106  * {@link SyncState}, which contains free-form data maintained on behalf of sync
    107  * adapters
    108  * </li>
    109  * <li>
    110  * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
    111  * </ul>
    112  */
    113 @SuppressWarnings("unused")
    114 public final class ContactsContract {
    115     /** The authority for the contacts provider */
    116     public static final String AUTHORITY = "com.android.contacts";
    117     /** A content:// style uri to the authority for the contacts provider */
    118     public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
    119 
    120     /**
    121      * An optional URI parameter for insert, update, or delete queries
    122      * that allows the caller
    123      * to specify that it is a sync adapter. The default value is false. If true
    124      * {@link RawContacts#DIRTY} is not automatically set and the
    125      * "syncToNetwork" parameter is set to false when calling
    126      * {@link
    127      * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
    128      * This prevents an unnecessary extra synchronization, see the discussion of
    129      * the delete operation in {@link RawContacts}.
    130      */
    131     public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
    132 
    133     /**
    134      * Query parameter that should be used by the client to access a specific
    135      * {@link Directory}. The parameter value should be the _ID of the corresponding
    136      * directory, e.g.
    137      * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
    138      */
    139     public static final String DIRECTORY_PARAM_KEY = "directory";
    140 
    141     /**
    142      * A query parameter that limits the number of results returned for supported URIs. The
    143      * parameter value should be an integer.
    144      *
    145      * <p>This parameter is not supported by all URIs.  Supported URIs include, but not limited to,
    146      * {@link Contacts#CONTENT_URI},
    147      * {@link RawContacts#CONTENT_URI},
    148      * {@link Data#CONTENT_URI},
    149      * {@link CommonDataKinds.Phone#CONTENT_URI},
    150      * {@link CommonDataKinds.Callable#CONTENT_URI},
    151      * {@link CommonDataKinds.Email#CONTENT_URI},
    152      * {@link CommonDataKinds.Contactables#CONTENT_URI},
    153      *
    154      * <p>In order to limit the number of rows returned by a non-supported URI, you can implement a
    155      * {@link CursorWrapper} and override the {@link CursorWrapper#getCount()} methods.
    156      */
    157     public static final String LIMIT_PARAM_KEY = "limit";
    158 
    159     /**
    160      * A query parameter specifing a primary account. This parameter should be used with
    161      * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on
    162      * this information to optimize its query results.
    163      *
    164      * For example, in an email composition screen, its implementation can specify an account when
    165      * obtaining possible recipients, letting the provider know which account is selected during
    166      * the composition. The provider may use the "primary account" information to optimize
    167      * the search result.
    168      */
    169     public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account";
    170 
    171     /**
    172      * A query parameter specifing a primary account. This parameter should be used with
    173      * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}.
    174      */
    175     public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account";
    176 
    177     /**
    178      * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
    179      * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
    180      * return only phone-related results. For example, frequently contacted person list should
    181      * include persons contacted via phone (not email, sms, etc.)
    182      */
    183     public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
    184 
    185     /**
    186      * A key to a boolean in the "extras" bundle of the cursor.
    187      * The boolean indicates that the provider did not create a snippet and that the client asking
    188      * for the snippet should do it (true means the snippeting was deferred to the client).
    189      *
    190      * @see SearchSnippets
    191      */
    192     public static final String DEFERRED_SNIPPETING = "deferred_snippeting";
    193 
    194     /**
    195      * Key to retrieve the original deferred snippeting from the cursor on the client side.
    196      *
    197      * @see SearchSnippets
    198      * @see #DEFERRED_SNIPPETING
    199      */
    200     public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query";
    201 
    202     /**
    203      * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI},
    204      * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and
    205      * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}.
    206      * This enables a content provider to remove duplicate entries in results.
    207      */
    208     public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries";
    209 
    210     /**
    211      * <p>
    212      * API for obtaining a pre-authorized version of a URI that normally requires special
    213      * permission (beyond READ_CONTACTS) to read.  The caller obtaining the pre-authorized URI
    214      * must already have the necessary permissions to access the URI; otherwise a
    215      * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission},
    216      * this can be used to grant permissions that aren't explicitly required for the URI inside
    217      * AndroidManifest.xml. For example, permissions that are only required when reading URIs
    218      * that refer to the user's profile.
    219      * </p>
    220      * <p>
    221      * The authorized URI returned in the bundle contains an expiring token that allows the
    222      * caller to execute the query without having the special permissions that would normally
    223      * be required. The token expires in five minutes.
    224      * </p>
    225      * <p>
    226      * This API does not access disk, and should be safe to invoke from the UI thread.
    227      * </p>
    228      * <p>
    229      * Example usage:
    230      * <pre>
    231      * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
    232      * Bundle uriBundle = new Bundle();
    233      * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
    234      * Bundle authResponse = getContext().getContentResolver().call(
    235      *         ContactsContract.AUTHORITY_URI,
    236      *         ContactsContract.Authorization.AUTHORIZATION_METHOD,
    237      *         null, // String arg, not used.
    238      *         uriBundle);
    239      * if (authResponse != null) {
    240      *     Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
    241      *             ContactsContract.Authorization.KEY_AUTHORIZED_URI);
    242      *     // This pre-authorized URI can be queried by a caller without READ_PROFILE
    243      *     // permission.
    244      * }
    245      * </pre>
    246      * </p>
    247      *
    248      * @hide
    249      */
    250     public static final class Authorization {
    251         /**
    252          * The method to invoke to create a pre-authorized URI out of the input argument.
    253          */
    254         public static final String AUTHORIZATION_METHOD = "authorize";
    255 
    256         /**
    257          * The key to set in the outbound Bundle with the URI that should be authorized.
    258          */
    259         public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize";
    260 
    261         /**
    262          * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
    263          */
    264         public static final String KEY_AUTHORIZED_URI = "authorized_uri";
    265     }
    266 
    267     /**
    268      * A Directory represents a contacts corpus, e.g. Local contacts,
    269      * Google Apps Global Address List or Corporate Global Address List.
    270      * <p>
    271      * A Directory is implemented as a content provider with its unique authority and
    272      * the same API as the main Contacts Provider.  However, there is no expectation that
    273      * every directory provider will implement this Contract in its entirety.  If a
    274      * directory provider does not have an implementation for a specific request, it
    275      * should throw an UnsupportedOperationException.
    276      * </p>
    277      * <p>
    278      * The most important use case for Directories is search.  A Directory provider is
    279      * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI
    280      * Contacts.CONTENT_FILTER_URI}.  If a Directory provider wants to participate
    281      * in email and phone lookup functionalities, it should also implement
    282      * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
    283      * and
    284      * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
    285      * </p>
    286      * <p>
    287      * A directory provider should return NULL for every projection field it does not
    288      * recognize, rather than throwing an exception.  This way it will not be broken
    289      * if ContactsContract is extended with new fields in the future.
    290      * </p>
    291      * <p>
    292      * The client interacts with a directory via Contacts Provider by supplying an
    293      * optional {@code directory=} query parameter.
    294      * <p>
    295      * <p>
    296      * When the Contacts Provider receives the request, it transforms the URI and forwards
    297      * the request to the corresponding directory content provider.
    298      * The URI is transformed in the following fashion:
    299      * <ul>
    300      * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
    301      * <li>The {@code accountName=} and {@code accountType=} parameters are added or
    302      * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
    303      * </ul>
    304      * </p>
    305      * <p>
    306      * Clients should send directory requests to Contacts Provider and let it
    307      * forward them to the respective providers rather than constructing
    308      * directory provider URIs by themselves. This level of indirection allows
    309      * Contacts Provider to implement additional system-level features and
    310      * optimizations. Access to Contacts Provider is protected by the
    311      * READ_CONTACTS permission, but access to the directory provider is protected by
    312      * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous
    313      * platform versions the provider should perform the following check to make sure the call
    314      * is coming from the ContactsProvider:
    315      * <pre>
    316      * private boolean isCallerAllowed() {
    317      *   PackageManager pm = getContext().getPackageManager();
    318      *   for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
    319      *     if (packageName.equals("com.android.providers.contacts")) {
    320      *       return true;
    321      *     }
    322      *   }
    323      *   return false;
    324      * }
    325      * </pre>
    326      * </p>
    327      * <p>
    328      * The Directory table is read-only and is maintained by the Contacts Provider
    329      * automatically.
    330      * </p>
    331      * <p>It always has at least these two rows:
    332      * <ul>
    333      * <li>
    334      * The local directory. It has {@link Directory#_ID Directory._ID} =
    335      * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
    336      * stored contacts. The same can be achieved by omitting the {@code directory=}
    337      * parameter altogether.
    338      * </li>
    339      * <li>
    340      * The local invisible contacts. The corresponding directory ID is
    341      * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
    342      * </li>
    343      * </ul>
    344      * </p>
    345      * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
    346      * <ul>
    347      * <li>It finds all installed content providers with meta data identifying them
    348      * as directory providers in AndroidManifest.xml:
    349      * <code>
    350      * &lt;meta-data android:name="android.content.ContactDirectory"
    351      *               android:value="true" /&gt;
    352      * </code>
    353      * <p>
    354      * This tag should be placed inside the corresponding content provider declaration.
    355      * </p>
    356      * </li>
    357      * <li>
    358      * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
    359      * query to each of the directory authorities.  A directory provider must implement
    360      * this query and return a list of directories.  Each directory returned by
    361      * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
    362      * {@link #ACCOUNT_TYPE} columns (nulls are allowed).  Since directory IDs are assigned
    363      * automatically, the _ID field will not be part of the query projection.
    364      * </li>
    365      * <li>Contacts Provider compiles directory lists received from all directory
    366      * providers into one, assigns each individual directory a globally unique ID and
    367      * stores all directory records in the Directory table.
    368      * </li>
    369      * </ul>
    370      * </p>
    371      * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
    372      * Thus simply installing a package containing a directory provider is sufficient
    373      * to have that provider registered.  A package supplying a directory provider does
    374      * not have to contain launchable activities.
    375      * </p>
    376      * <p>
    377      * Every row in the Directory table is automatically associated with the corresponding package
    378      * (apk).  If the package is later uninstalled, all corresponding directory rows
    379      * are automatically removed from the Contacts Provider.
    380      * </p>
    381      * <p>
    382      * When the list of directories handled by a directory provider changes
    383      * (for instance when the user adds a new Directory account), the directory provider
    384      * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
    385      * In response, the Contacts Provider will requery the directory provider to obtain the
    386      * new list of directories.
    387      * </p>
    388      * <p>
    389      * A directory row can be optionally associated with an existing account
    390      * (see {@link android.accounts.AccountManager}). If the account is later removed,
    391      * the corresponding directory rows are automatically removed from the Contacts Provider.
    392      * </p>
    393      */
    394     public static final class Directory implements BaseColumns {
    395 
    396         /**
    397          * Not instantiable.
    398          */
    399         private Directory() {
    400         }
    401 
    402         /**
    403          * The content:// style URI for this table.  Requests to this URI can be
    404          * performed on the UI thread because they are always unblocking.
    405          */
    406         public static final Uri CONTENT_URI =
    407                 Uri.withAppendedPath(AUTHORITY_URI, "directories");
    408 
    409         /**
    410          * URI used for getting all directories from primary and managed profile.
    411          * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns.
    412          * If the device has no managed profile that is linked to the current profile, it behaves
    413          * in the exact same way as {@link #CONTENT_URI}.
    414          * If there is a managed profile linked to the current profile, it will merge
    415          * managed profile and current profile's results and return.
    416          *
    417          * Note: this query returns primary profile results before managed profile results,
    418          * and this order is not affected by sorting parameter.
    419          *
    420          */
    421         public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
    422                 "directories_enterprise");
    423 
    424         /**
    425          * Access file provided by remote directory. It allows both personal and work remote
    426          * directory, but not local and invisible diretory.
    427          *
    428          * It's supported only by a few specific places for referring to contact pictures in the
    429          * remote directory. Contact picture URIs, e.g.
    430          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}, may contain this kind of URI.
    431          *
    432          * @hide
    433          */
    434         public static final Uri ENTERPRISE_FILE_URI = Uri.withAppendedPath(AUTHORITY_URI,
    435                 "directory_file_enterprise");
    436 
    437 
    438         /**
    439          * The MIME-type of {@link #CONTENT_URI} providing a directory of
    440          * contact directories.
    441          */
    442         public static final String CONTENT_TYPE =
    443                 "vnd.android.cursor.dir/contact_directories";
    444 
    445         /**
    446          * The MIME type of a {@link #CONTENT_URI} item.
    447          */
    448         public static final String CONTENT_ITEM_TYPE =
    449                 "vnd.android.cursor.item/contact_directory";
    450 
    451         /**
    452          * _ID of the default directory, which represents locally stored contacts.
    453          * <b>This is only supported by {@link ContactsContract.Contacts#CONTENT_URI} and
    454          * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}.
    455          * Other URLs do not support the concept of "visible" or "invisible" contacts.
    456          */
    457         public static final long DEFAULT = 0;
    458 
    459         /**
    460          * _ID of the directory that represents locally stored invisible contacts.
    461          */
    462         public static final long LOCAL_INVISIBLE = 1;
    463 
    464         /**
    465          * _ID of the work profile default directory, which represents locally stored contacts.
    466          */
    467         public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE
    468                 + DEFAULT;
    469 
    470         /**
    471          * _ID of the work profile directory that represents locally stored invisible contacts.
    472          */
    473         public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE
    474                 + LOCAL_INVISIBLE;
    475 
    476         /**
    477          * The name of the package that owns this directory. Contacts Provider
    478          * fill it in with the name of the package containing the directory provider.
    479          * If the package is later uninstalled, the directories it owns are
    480          * automatically removed from this table.
    481          *
    482          * <p>TYPE: TEXT</p>
    483          */
    484         public static final String PACKAGE_NAME = "packageName";
    485 
    486         /**
    487          * The type of directory captured as a resource ID in the context of the
    488          * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
    489          *
    490          * <p>TYPE: INTEGER</p>
    491          */
    492         public static final String TYPE_RESOURCE_ID = "typeResourceId";
    493 
    494         /**
    495          * An optional name that can be used in the UI to represent this directory,
    496          * e.g. "Acme Corp"
    497          * <p>TYPE: text</p>
    498          */
    499         public static final String DISPLAY_NAME = "displayName";
    500 
    501         /**
    502          * <p>
    503          * The authority of the Directory Provider. Contacts Provider will
    504          * use this authority to forward requests to the directory provider.
    505          * A directory provider can leave this column empty - Contacts Provider will fill it in.
    506          * </p>
    507          * <p>
    508          * Clients of this API should not send requests directly to this authority.
    509          * All directory requests must be routed through Contacts Provider.
    510          * </p>
    511          *
    512          * <p>TYPE: text</p>
    513          */
    514         public static final String DIRECTORY_AUTHORITY = "authority";
    515 
    516         /**
    517          * The account type which this directory is associated.
    518          *
    519          * <p>TYPE: text</p>
    520          */
    521         public static final String ACCOUNT_TYPE = "accountType";
    522 
    523         /**
    524          * The account with which this directory is associated. If the account is later
    525          * removed, the directories it owns are automatically removed from this table.
    526          *
    527          * <p>TYPE: text</p>
    528          */
    529         public static final String ACCOUNT_NAME = "accountName";
    530 
    531         /**
    532          * Mimimal ID for corp directory returned from
    533          * {@link Directory#CORP_CONTENT_URI}.
    534          *
    535          * @hide
    536          */
    537         // slightly smaller than 2 ** 30
    538         public static final long ENTERPRISE_DIRECTORY_ID_BASE = 1000000000;
    539 
    540         /**
    541          * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
    542          * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
    543          * directory has for data exported from it.  Clients must obey this setting.
    544          */
    545         public static final String EXPORT_SUPPORT = "exportSupport";
    546 
    547         /**
    548          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
    549          * does not allow any data to be copied out of it.
    550          */
    551         public static final int EXPORT_SUPPORT_NONE = 0;
    552 
    553         /**
    554          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
    555          * allow its data copied only to the account specified by
    556          * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
    557          */
    558         public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
    559 
    560         /**
    561          * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
    562          * allow its data copied to any contacts account.
    563          */
    564         public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
    565 
    566         /**
    567          * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
    568          * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory
    569          * has for shortcuts created for its elements. Clients must obey this setting.
    570          */
    571         public static final String SHORTCUT_SUPPORT = "shortcutSupport";
    572 
    573         /**
    574          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
    575          * does not allow any shortcuts created for its contacts.
    576          */
    577         public static final int SHORTCUT_SUPPORT_NONE = 0;
    578 
    579         /**
    580          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
    581          * allow creation of shortcuts for data items like email, phone or postal address,
    582          * but not the entire contact.
    583          */
    584         public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
    585 
    586         /**
    587          * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
    588          * allow creation of shortcuts for contact as well as their constituent elements.
    589          */
    590         public static final int SHORTCUT_SUPPORT_FULL = 2;
    591 
    592         /**
    593          * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY},
    594          * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent
    595          * to which the directory supports contact photos.
    596          */
    597         public static final String PHOTO_SUPPORT = "photoSupport";
    598 
    599         /**
    600          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    601          * does not provide any photos.
    602          */
    603         public static final int PHOTO_SUPPORT_NONE = 0;
    604 
    605         /**
    606          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    607          * can only produce small size thumbnails of contact photos.
    608          */
    609         public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1;
    610 
    611         /**
    612          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    613          * has full-size contact photos, but cannot provide scaled thumbnails.
    614          */
    615         public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2;
    616 
    617         /**
    618          * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
    619          * can produce thumbnails as well as full-size contact photos.
    620          */
    621         public static final int PHOTO_SUPPORT_FULL = 3;
    622 
    623         /**
    624          * Return TRUE if it is a remote stored directory.
    625          */
    626         public static boolean isRemoteDirectoryId(long directoryId) {
    627             return directoryId != Directory.DEFAULT
    628                     && directoryId != Directory.LOCAL_INVISIBLE
    629                     && directoryId != Directory.ENTERPRISE_DEFAULT
    630                     && directoryId != Directory.ENTERPRISE_LOCAL_INVISIBLE;
    631         }
    632 
    633         /**
    634          * Return TRUE if it is a remote stored directory. TODO: Remove this method once all
    635          * internal apps are not using this API.
    636          *
    637          * @hide
    638          */
    639         public static boolean isRemoteDirectory(long directoryId) {
    640             return isRemoteDirectoryId(directoryId);
    641         }
    642 
    643         /**
    644          * Return TRUE if a directory ID is from the contacts provider on the enterprise profile.
    645          *
    646          */
    647         public static boolean isEnterpriseDirectoryId(long directoryId) {
    648             return directoryId >= ENTERPRISE_DIRECTORY_ID_BASE;
    649         }
    650 
    651         /**
    652          * Notifies the system of a change in the list of directories handled by
    653          * a particular directory provider. The Contacts provider will turn around
    654          * and send a query to the directory provider for the full list of directories,
    655          * which will replace the previous list.
    656          */
    657         public static void notifyDirectoryChange(ContentResolver resolver) {
    658             // This is done to trigger a query by Contacts Provider back to the directory provider.
    659             // No data needs to be sent back, because the provider can infer the calling
    660             // package from binder.
    661             ContentValues contentValues = new ContentValues();
    662             resolver.update(Directory.CONTENT_URI, contentValues, null, null);
    663         }
    664     }
    665 
    666     /**
    667      * @hide should be removed when users are updated to refer to SyncState
    668      * @deprecated use SyncState instead
    669      */
    670     @Deprecated
    671     public interface SyncStateColumns extends SyncStateContract.Columns {
    672     }
    673 
    674     /**
    675      * A table provided for sync adapters to use for storing private sync state data for contacts.
    676      *
    677      * @see SyncStateContract
    678      */
    679     public static final class SyncState implements SyncStateContract.Columns {
    680         /**
    681          * This utility class cannot be instantiated
    682          */
    683         private SyncState() {}
    684 
    685         public static final String CONTENT_DIRECTORY =
    686                 SyncStateContract.Constants.CONTENT_DIRECTORY;
    687 
    688         /**
    689          * The content:// style URI for this table
    690          */
    691         public static final Uri CONTENT_URI =
    692                 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
    693 
    694         /**
    695          * @see android.provider.SyncStateContract.Helpers#get
    696          */
    697         public static byte[] get(ContentProviderClient provider, Account account)
    698                 throws RemoteException {
    699             return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
    700         }
    701 
    702         /**
    703          * @see android.provider.SyncStateContract.Helpers#get
    704          */
    705         public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
    706                 throws RemoteException {
    707             return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
    708         }
    709 
    710         /**
    711          * @see android.provider.SyncStateContract.Helpers#set
    712          */
    713         public static void set(ContentProviderClient provider, Account account, byte[] data)
    714                 throws RemoteException {
    715             SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
    716         }
    717 
    718         /**
    719          * @see android.provider.SyncStateContract.Helpers#newSetOperation
    720          */
    721         public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
    722             return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
    723         }
    724     }
    725 
    726 
    727     /**
    728      * A table provided for sync adapters to use for storing private sync state data for the
    729      * user's personal profile.
    730      *
    731      * @see SyncStateContract
    732      */
    733     public static final class ProfileSyncState implements SyncStateContract.Columns {
    734         /**
    735          * This utility class cannot be instantiated
    736          */
    737         private ProfileSyncState() {}
    738 
    739         public static final String CONTENT_DIRECTORY =
    740                 SyncStateContract.Constants.CONTENT_DIRECTORY;
    741 
    742         /**
    743          * The content:// style URI for this table
    744          */
    745         public static final Uri CONTENT_URI =
    746                 Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY);
    747 
    748         /**
    749          * @see android.provider.SyncStateContract.Helpers#get
    750          */
    751         public static byte[] get(ContentProviderClient provider, Account account)
    752                 throws RemoteException {
    753             return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
    754         }
    755 
    756         /**
    757          * @see android.provider.SyncStateContract.Helpers#get
    758          */
    759         public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
    760                 throws RemoteException {
    761             return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
    762         }
    763 
    764         /**
    765          * @see android.provider.SyncStateContract.Helpers#set
    766          */
    767         public static void set(ContentProviderClient provider, Account account, byte[] data)
    768                 throws RemoteException {
    769             SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
    770         }
    771 
    772         /**
    773          * @see android.provider.SyncStateContract.Helpers#newSetOperation
    774          */
    775         public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
    776             return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
    777         }
    778     }
    779 
    780     /**
    781      * Generic columns for use by sync adapters. The specific functions of
    782      * these columns are private to the sync adapter. Other clients of the API
    783      * should not attempt to either read or write this column.
    784      *
    785      * @see RawContacts
    786      * @see Groups
    787      */
    788     protected interface BaseSyncColumns {
    789 
    790         /** Generic column for use by sync adapters. */
    791         public static final String SYNC1 = "sync1";
    792         /** Generic column for use by sync adapters. */
    793         public static final String SYNC2 = "sync2";
    794         /** Generic column for use by sync adapters. */
    795         public static final String SYNC3 = "sync3";
    796         /** Generic column for use by sync adapters. */
    797         public static final String SYNC4 = "sync4";
    798     }
    799 
    800     /**
    801      * Columns that appear when each row of a table belongs to a specific
    802      * account, including sync information that an account may need.
    803      *
    804      * @see RawContacts
    805      * @see Groups
    806      */
    807     protected interface SyncColumns extends BaseSyncColumns {
    808         /**
    809          * The name of the account instance to which this row belongs, which when paired with
    810          * {@link #ACCOUNT_TYPE} identifies a specific account.
    811          * <P>Type: TEXT</P>
    812          */
    813         public static final String ACCOUNT_NAME = "account_name";
    814 
    815         /**
    816          * The type of account to which this row belongs, which when paired with
    817          * {@link #ACCOUNT_NAME} identifies a specific account.
    818          * <P>Type: TEXT</P>
    819          */
    820         public static final String ACCOUNT_TYPE = "account_type";
    821 
    822         /**
    823          * String that uniquely identifies this row to its source account.
    824          * <P>Type: TEXT</P>
    825          */
    826         public static final String SOURCE_ID = "sourceid";
    827 
    828         /**
    829          * Version number that is updated whenever this row or its related data
    830          * changes.
    831          * <P>Type: INTEGER</P>
    832          */
    833         public static final String VERSION = "version";
    834 
    835         /**
    836          * Flag indicating that {@link #VERSION} has changed, and this row needs
    837          * to be synchronized by its owning account.
    838          * <P>Type: INTEGER (boolean)</P>
    839          */
    840         public static final String DIRTY = "dirty";
    841     }
    842 
    843     /**
    844      * Columns of {@link ContactsContract.Contacts} that track the user's
    845      * preferences for, or interactions with, the contact.
    846      *
    847      * @see Contacts
    848      * @see RawContacts
    849      * @see ContactsContract.Data
    850      * @see PhoneLookup
    851      * @see ContactsContract.Contacts.AggregationSuggestions
    852      */
    853     protected interface ContactOptionsColumns {
    854         /**
    855          * The number of times a contact has been contacted
    856          * <P>Type: INTEGER</P>
    857          */
    858         public static final String TIMES_CONTACTED = "times_contacted";
    859 
    860         /**
    861          * The last time a contact was contacted.
    862          * <P>Type: INTEGER</P>
    863          */
    864         public static final String LAST_TIME_CONTACTED = "last_time_contacted";
    865 
    866         /**
    867          * Is the contact starred?
    868          * <P>Type: INTEGER (boolean)</P>
    869          */
    870         public static final String STARRED = "starred";
    871 
    872         /**
    873          * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED},
    874          * the contact is not pinned. Also see {@link PinnedPositions}.
    875          * <P>Type: INTEGER </P>
    876          */
    877         public static final String PINNED = "pinned";
    878 
    879         /**
    880          * URI for a custom ringtone associated with the contact. If null or missing,
    881          * the default ringtone is used.
    882          * <P>Type: TEXT (URI to the ringtone)</P>
    883          */
    884         public static final String CUSTOM_RINGTONE = "custom_ringtone";
    885 
    886         /**
    887          * Whether the contact should always be sent to voicemail. If missing,
    888          * defaults to false.
    889          * <P>Type: INTEGER (0 for false, 1 for true)</P>
    890          */
    891         public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
    892     }
    893 
    894     /**
    895      * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
    896      * properties of the contact, as opposed to the user-specified options
    897      * found in {@link ContactOptionsColumns}.
    898      *
    899      * @see Contacts
    900      * @see ContactsContract.Data
    901      * @see PhoneLookup
    902      * @see ContactsContract.Contacts.AggregationSuggestions
    903      */
    904     protected interface ContactsColumns {
    905         /**
    906          * The display name for the contact.
    907          * <P>Type: TEXT</P>
    908          */
    909         public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
    910 
    911         /**
    912          * Reference to the row in the RawContacts table holding the contact name.
    913          * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
    914          */
    915         public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
    916 
    917         /**
    918          * Reference to the row in the data table holding the photo.  A photo can
    919          * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
    920          * and {@link #PHOTO_URI}).
    921          * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
    922          * which is a more generic mechanism for referencing the contact photo, especially for
    923          * contacts returned by non-local directories (see {@link Directory}).
    924          *
    925          * <P>Type: INTEGER REFERENCES data(_id)</P>
    926          */
    927         public static final String PHOTO_ID = "photo_id";
    928 
    929         /**
    930          * Photo file ID of the full-size photo.  If present, this will be used to populate
    931          * {@link #PHOTO_URI}.  The ID can also be used with
    932          * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
    933          * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
    934          *
    935          * <P>Type: INTEGER</P>
    936          */
    937         public static final String PHOTO_FILE_ID = "photo_file_id";
    938 
    939         /**
    940          * A URI that can be used to retrieve the contact's full-size photo.
    941          * If PHOTO_FILE_ID is not null, this will be populated with a URI based off
    942          * {@link ContactsContract.DisplayPhoto#CONTENT_URI}.  Otherwise, this will
    943          * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
    944          * A photo can be referred to either by a URI (this field) or by ID
    945          * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
    946          * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
    947          * vice versa).  Thus using PHOTO_URI is a more robust method of retrieving
    948          * contact photos.
    949          *
    950          * <P>Type: TEXT</P>
    951          */
    952         public static final String PHOTO_URI = "photo_uri";
    953 
    954         /**
    955          * A URI that can be used to retrieve a thumbnail of the contact's photo.
    956          * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
    957          * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
    958          * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
    959          * If the content provider does not differentiate between full-size photos
    960          * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
    961          * the same value, but either both shall be null or both not null.
    962          *
    963          * <P>Type: TEXT</P>
    964          */
    965         public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
    966 
    967         /**
    968          * Flag that reflects whether the contact exists inside the default directory.
    969          * Ie, whether the contact is designed to only be visible outside search.
    970          */
    971         public static final String IN_DEFAULT_DIRECTORY = "in_default_directory";
    972 
    973         /**
    974          * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any
    975          * {@link CommonDataKinds.GroupMembership} for this contact.
    976          */
    977         public static final String IN_VISIBLE_GROUP = "in_visible_group";
    978 
    979         /**
    980          * Flag that reflects whether this contact represents the user's
    981          * personal profile entry.
    982          */
    983         public static final String IS_USER_PROFILE = "is_user_profile";
    984 
    985         /**
    986          * An indicator of whether this contact has at least one phone number. "1" if there is
    987          * at least one phone number, "0" otherwise.
    988          * <P>Type: INTEGER</P>
    989          */
    990         public static final String HAS_PHONE_NUMBER = "has_phone_number";
    991 
    992         /**
    993          * An opaque value that contains hints on how to find the contact if
    994          * its row id changed as a result of a sync or aggregation.
    995          */
    996         public static final String LOOKUP_KEY = "lookup";
    997 
    998         /**
    999          * Timestamp (milliseconds since epoch) of when this contact was last updated.  This
   1000          * includes updates to all data associated with this contact including raw contacts.  Any
   1001          * modification (including deletes and inserts) of underlying contact data are also
   1002          * reflected in this timestamp.
   1003          */
   1004         public static final String CONTACT_LAST_UPDATED_TIMESTAMP =
   1005                 "contact_last_updated_timestamp";
   1006     }
   1007 
   1008     /**
   1009      * @see Contacts
   1010      */
   1011     protected interface ContactStatusColumns {
   1012         /**
   1013          * Contact presence status. See {@link StatusUpdates} for individual status
   1014          * definitions.
   1015          * <p>Type: NUMBER</p>
   1016          */
   1017         public static final String CONTACT_PRESENCE = "contact_presence";
   1018 
   1019         /**
   1020          * Contact Chat Capabilities. See {@link StatusUpdates} for individual
   1021          * definitions.
   1022          * <p>Type: NUMBER</p>
   1023          */
   1024         public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
   1025 
   1026         /**
   1027          * Contact's latest status update.
   1028          * <p>Type: TEXT</p>
   1029          */
   1030         public static final String CONTACT_STATUS = "contact_status";
   1031 
   1032         /**
   1033          * The absolute time in milliseconds when the latest status was
   1034          * inserted/updated.
   1035          * <p>Type: NUMBER</p>
   1036          */
   1037         public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
   1038 
   1039         /**
   1040          * The package containing resources for this status: label and icon.
   1041          * <p>Type: TEXT</p>
   1042          */
   1043         public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
   1044 
   1045         /**
   1046          * The resource ID of the label describing the source of contact
   1047          * status, e.g. "Google Talk". This resource is scoped by the
   1048          * {@link #CONTACT_STATUS_RES_PACKAGE}.
   1049          * <p>Type: NUMBER</p>
   1050          */
   1051         public static final String CONTACT_STATUS_LABEL = "contact_status_label";
   1052 
   1053         /**
   1054          * The resource ID of the icon for the source of contact status. This
   1055          * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
   1056          * <p>Type: NUMBER</p>
   1057          */
   1058         public static final String CONTACT_STATUS_ICON = "contact_status_icon";
   1059     }
   1060 
   1061     /**
   1062      * Constants for various styles of combining given name, family name etc into
   1063      * a full name.  For example, the western tradition follows the pattern
   1064      * 'given name' 'middle name' 'family name' with the alternative pattern being
   1065      * 'family name', 'given name' 'middle name'.  The CJK tradition is
   1066      * 'family name' 'middle name' 'given name', with Japanese favoring a space between
   1067      * the names and Chinese omitting the space.
   1068      */
   1069     public interface FullNameStyle {
   1070         public static final int UNDEFINED = 0;
   1071         public static final int WESTERN = 1;
   1072 
   1073         /**
   1074          * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
   1075          * which specific language it belongs to: Chinese, Japanese or Korean.
   1076          */
   1077         public static final int CJK = 2;
   1078 
   1079         public static final int CHINESE = 3;
   1080         public static final int JAPANESE = 4;
   1081         public static final int KOREAN = 5;
   1082     }
   1083 
   1084     /**
   1085      * Constants for various styles of capturing the pronunciation of a person's name.
   1086      */
   1087     public interface PhoneticNameStyle {
   1088         public static final int UNDEFINED = 0;
   1089 
   1090         /**
   1091          * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
   1092          * shown in UIs, but used for searches and sorting.
   1093          */
   1094         public static final int PINYIN = 3;
   1095 
   1096         /**
   1097          * Hiragana and Katakana are two common styles of writing out the pronunciation
   1098          * of a Japanese names.
   1099          */
   1100         public static final int JAPANESE = 4;
   1101 
   1102         /**
   1103          * Hangul is the Korean phonetic alphabet.
   1104          */
   1105         public static final int KOREAN = 5;
   1106     }
   1107 
   1108     /**
   1109      * Types of data used to produce the display name for a contact. In the order
   1110      * of increasing priority: {@link #EMAIL}, {@link #PHONE},
   1111      * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME},
   1112      * {@link #STRUCTURED_NAME}.
   1113      */
   1114     public interface DisplayNameSources {
   1115         public static final int UNDEFINED = 0;
   1116         public static final int EMAIL = 10;
   1117         public static final int PHONE = 20;
   1118         public static final int ORGANIZATION = 30;
   1119         public static final int NICKNAME = 35;
   1120         /** Display name comes from a structured name that only has phonetic components. */
   1121         public static final int STRUCTURED_PHONETIC_NAME = 37;
   1122         public static final int STRUCTURED_NAME = 40;
   1123     }
   1124 
   1125     /**
   1126      * Contact name and contact name metadata columns in the RawContacts table.
   1127      *
   1128      * @see Contacts
   1129      * @see RawContacts
   1130      */
   1131     protected interface ContactNameColumns {
   1132 
   1133         /**
   1134          * The kind of data that is used as the display name for the contact, such as
   1135          * structured name or email address.  See {@link DisplayNameSources}.
   1136          */
   1137         public static final String DISPLAY_NAME_SOURCE = "display_name_source";
   1138 
   1139         /**
   1140          * <p>
   1141          * The standard text shown as the contact's display name, based on the best
   1142          * available information for the contact (for example, it might be the email address
   1143          * if the name is not available).
   1144          * The information actually used to compute the name is stored in
   1145          * {@link #DISPLAY_NAME_SOURCE}.
   1146          * </p>
   1147          * <p>
   1148          * A contacts provider is free to choose whatever representation makes most
   1149          * sense for its target market.
   1150          * For example in the default Android Open Source Project implementation,
   1151          * if the display name is
   1152          * based on the structured name and the structured name follows
   1153          * the Western full-name style, then this field contains the "given name first"
   1154          * version of the full name.
   1155          * <p>
   1156          *
   1157          * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
   1158          */
   1159         public static final String DISPLAY_NAME_PRIMARY = "display_name";
   1160 
   1161         /**
   1162          * <p>
   1163          * An alternative representation of the display name, such as "family name first"
   1164          * instead of "given name first" for Western names.  If an alternative is not
   1165          * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
   1166          * </p>
   1167          * <p>
   1168          * A contacts provider is free to provide alternatives as necessary for
   1169          * its target market.
   1170          * For example the default Android Open Source Project contacts provider
   1171          * currently provides an
   1172          * alternative in a single case:  if the display name is
   1173          * based on the structured name and the structured name follows
   1174          * the Western full name style, then the field contains the "family name first"
   1175          * version of the full name.
   1176          * Other cases may be added later.
   1177          * </p>
   1178          */
   1179         public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
   1180 
   1181         /**
   1182          * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}.  See
   1183          * {@link PhoneticNameStyle}.
   1184          */
   1185         public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
   1186 
   1187         /**
   1188          * <p>
   1189          * Pronunciation of the full name in the phonetic alphabet specified by
   1190          * {@link #PHONETIC_NAME_STYLE}.
   1191          * </p>
   1192          * <p>
   1193          * The value may be set manually by the user. This capability is of
   1194          * interest only in countries with commonly used phonetic alphabets,
   1195          * such as Japan and Korea. See {@link PhoneticNameStyle}.
   1196          * </p>
   1197          */
   1198         public static final String PHONETIC_NAME = "phonetic_name";
   1199 
   1200         /**
   1201          * Sort key that takes into account locale-based traditions for sorting
   1202          * names in address books.  The default
   1203          * sort key is {@link #DISPLAY_NAME_PRIMARY}.  For Chinese names
   1204          * the sort key is the name's Pinyin spelling, and for Japanese names
   1205          * it is the Hiragana version of the phonetic name.
   1206          */
   1207         public static final String SORT_KEY_PRIMARY = "sort_key";
   1208 
   1209         /**
   1210          * Sort key based on the alternative representation of the full name,
   1211          * {@link #DISPLAY_NAME_ALTERNATIVE}.  Thus for Western names,
   1212          * it is the one using the "family name first" format.
   1213          */
   1214         public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
   1215     }
   1216 
   1217     interface ContactCounts {
   1218 
   1219         /**
   1220          * Add this query parameter to a URI to get back row counts grouped by the address book
   1221          * index as cursor extras. For most languages it is the first letter of the sort key. This
   1222          * parameter does not affect the main content of the cursor.
   1223          *
   1224          * <p>
   1225          * <pre>
   1226          * Example:
   1227          *
   1228          * import android.provider.ContactsContract.Contacts;
   1229          *
   1230          * Uri uri = Contacts.CONTENT_URI.buildUpon()
   1231          *          .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true")
   1232          *          .build();
   1233          * Cursor cursor = getContentResolver().query(uri,
   1234          *          new String[] {Contacts.DISPLAY_NAME},
   1235          *          null, null, null);
   1236          * Bundle bundle = cursor.getExtras();
   1237          * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
   1238          *         bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
   1239          *     String sections[] =
   1240          *             bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
   1241          *     int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
   1242          * }
   1243          * </pre>
   1244          * </p>
   1245          */
   1246         public static final String EXTRA_ADDRESS_BOOK_INDEX =
   1247                 "android.provider.extra.ADDRESS_BOOK_INDEX";
   1248 
   1249         /**
   1250          * The array of address book index titles, which are returned in the
   1251          * same order as the data in the cursor.
   1252          * <p>TYPE: String[]</p>
   1253          */
   1254         public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES =
   1255                 "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
   1256 
   1257         /**
   1258          * The array of group counts for the corresponding group.  Contains the same number
   1259          * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
   1260          * <p>TYPE: int[]</p>
   1261          */
   1262         public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS =
   1263                 "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
   1264     }
   1265 
   1266     /**
   1267      * Constants for the contacts table, which contains a record per aggregate
   1268      * of raw contacts representing the same person.
   1269      * <h3>Operations</h3>
   1270      * <dl>
   1271      * <dt><b>Insert</b></dt>
   1272      * <dd>A Contact cannot be created explicitly. When a raw contact is
   1273      * inserted, the provider will first try to find a Contact representing the
   1274      * same person. If one is found, the raw contact's
   1275      * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
   1276      * Contact. If no match is found, the provider automatically inserts a new
   1277      * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
   1278      * of the newly inserted raw contact.</dd>
   1279      * <dt><b>Update</b></dt>
   1280      * <dd>Only certain columns of Contact are modifiable:
   1281      * {@link #TIMES_CONTACTED}, {@link #LAST_TIME_CONTACTED}, {@link #STARRED},
   1282      * {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
   1283      * these columns on the Contact also changes them on all constituent raw
   1284      * contacts.</dd>
   1285      * <dt><b>Delete</b></dt>
   1286      * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
   1287      * deletes all constituent raw contacts. The corresponding sync adapters
   1288      * will notice the deletions of their respective raw contacts and remove
   1289      * them from their back end storage.</dd>
   1290      * <dt><b>Query</b></dt>
   1291      * <dd>
   1292      * <ul>
   1293      * <li>If you need to read an individual contact, consider using
   1294      * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
   1295      * <li>If you need to look up a contact by the phone number, use
   1296      * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
   1297      * which is optimized for this purpose.</li>
   1298      * <li>If you need to look up a contact by partial name, e.g. to produce
   1299      * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
   1300      * <li>If you need to look up a contact by some data element like email
   1301      * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
   1302      * The result will contain contact ID, name etc.
   1303      * </ul>
   1304      * </dd>
   1305      * </dl>
   1306      * <h2>Columns</h2>
   1307      * <table class="jd-sumtable">
   1308      * <tr>
   1309      * <th colspan='4'>Contacts</th>
   1310      * </tr>
   1311      * <tr>
   1312      * <td>long</td>
   1313      * <td>{@link #_ID}</td>
   1314      * <td>read-only</td>
   1315      * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
   1316      * </tr>
   1317      * <tr>
   1318      * <td>String</td>
   1319      * <td>{@link #LOOKUP_KEY}</td>
   1320      * <td>read-only</td>
   1321      * <td>An opaque value that contains hints on how to find the contact if its
   1322      * row id changed as a result of a sync or aggregation.</td>
   1323      * </tr>
   1324      * <tr>
   1325      * <td>long</td>
   1326      * <td>NAME_RAW_CONTACT_ID</td>
   1327      * <td>read-only</td>
   1328      * <td>The ID of the raw contact that contributes the display name
   1329      * to the aggregate contact. During aggregation one of the constituent
   1330      * raw contacts is chosen using a heuristic: a longer name or a name
   1331      * with more diacritic marks or more upper case characters is chosen.</td>
   1332      * </tr>
   1333      * <tr>
   1334      * <td>String</td>
   1335      * <td>DISPLAY_NAME_PRIMARY</td>
   1336      * <td>read-only</td>
   1337      * <td>The display name for the contact. It is the display name
   1338      * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
   1339      * column.</td>
   1340      * </tr>
   1341      * <tr>
   1342      * <td>long</td>
   1343      * <td>{@link #PHOTO_ID}</td>
   1344      * <td>read-only</td>
   1345      * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
   1346      * That row has the mime type
   1347      * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
   1348      * is computed automatically based on the
   1349      * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
   1350      * that mime type.</td>
   1351      * </tr>
   1352      * <tr>
   1353      * <td>long</td>
   1354      * <td>{@link #PHOTO_URI}</td>
   1355      * <td>read-only</td>
   1356      * <td>A URI that can be used to retrieve the contact's full-size photo. This
   1357      * column is the preferred method of retrieving the contact photo.</td>
   1358      * </tr>
   1359      * <tr>
   1360      * <td>long</td>
   1361      * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
   1362      * <td>read-only</td>
   1363      * <td>A URI that can be used to retrieve the thumbnail of contact's photo.  This
   1364      * column is the preferred method of retrieving the contact photo.</td>
   1365      * </tr>
   1366      * <tr>
   1367      * <td>int</td>
   1368      * <td>{@link #IN_VISIBLE_GROUP}</td>
   1369      * <td>read-only</td>
   1370      * <td>An indicator of whether this contact is supposed to be visible in the
   1371      * UI. "1" if the contact has at least one raw contact that belongs to a
   1372      * visible group; "0" otherwise.</td>
   1373      * </tr>
   1374      * <tr>
   1375      * <td>int</td>
   1376      * <td>{@link #HAS_PHONE_NUMBER}</td>
   1377      * <td>read-only</td>
   1378      * <td>An indicator of whether this contact has at least one phone number.
   1379      * "1" if there is at least one phone number, "0" otherwise.</td>
   1380      * </tr>
   1381      * <tr>
   1382      * <td>int</td>
   1383      * <td>{@link #TIMES_CONTACTED}</td>
   1384      * <td>read/write</td>
   1385      * <td>The number of times the contact has been contacted. See
   1386      * {@link #markAsContacted}. When raw contacts are aggregated, this field is
   1387      * computed automatically as the maximum number of times contacted among all
   1388      * constituent raw contacts. Setting this field automatically changes the
   1389      * corresponding field on all constituent raw contacts.</td>
   1390      * </tr>
   1391      * <tr>
   1392      * <td>long</td>
   1393      * <td>{@link #LAST_TIME_CONTACTED}</td>
   1394      * <td>read/write</td>
   1395      * <td>The timestamp of the last time the contact was contacted. See
   1396      * {@link #markAsContacted}. Setting this field also automatically
   1397      * increments {@link #TIMES_CONTACTED}. When raw contacts are aggregated,
   1398      * this field is computed automatically as the latest time contacted of all
   1399      * constituent raw contacts. Setting this field automatically changes the
   1400      * corresponding field on all constituent raw contacts.</td>
   1401      * </tr>
   1402      * <tr>
   1403      * <td>int</td>
   1404      * <td>{@link #STARRED}</td>
   1405      * <td>read/write</td>
   1406      * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
   1407      * When raw contacts are aggregated, this field is automatically computed:
   1408      * if any constituent raw contacts are starred, then this field is set to
   1409      * '1'. Setting this field automatically changes the corresponding field on
   1410      * all constituent raw contacts.</td>
   1411      * </tr>
   1412      * <tr>
   1413      * <td>String</td>
   1414      * <td>{@link #CUSTOM_RINGTONE}</td>
   1415      * <td>read/write</td>
   1416      * <td>A custom ringtone associated with a contact. Typically this is the
   1417      * URI returned by an activity launched with the
   1418      * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
   1419      * </tr>
   1420      * <tr>
   1421      * <td>int</td>
   1422      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   1423      * <td>read/write</td>
   1424      * <td>An indicator of whether calls from this contact should be forwarded
   1425      * directly to voice mail ('1') or not ('0'). When raw contacts are
   1426      * aggregated, this field is automatically computed: if <i>all</i>
   1427      * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
   1428      * to '1'. Setting this field automatically changes the corresponding field
   1429      * on all constituent raw contacts.</td>
   1430      * </tr>
   1431      * <tr>
   1432      * <td>int</td>
   1433      * <td>{@link #CONTACT_PRESENCE}</td>
   1434      * <td>read-only</td>
   1435      * <td>Contact IM presence status. See {@link StatusUpdates} for individual
   1436      * status definitions. Automatically computed as the highest presence of all
   1437      * constituent raw contacts. The provider may choose not to store this value
   1438      * in persistent storage. The expectation is that presence status will be
   1439      * updated on a regular basis.</td>
   1440      * </tr>
   1441      * <tr>
   1442      * <td>String</td>
   1443      * <td>{@link #CONTACT_STATUS}</td>
   1444      * <td>read-only</td>
   1445      * <td>Contact's latest status update. Automatically computed as the latest
   1446      * of all constituent raw contacts' status updates.</td>
   1447      * </tr>
   1448      * <tr>
   1449      * <td>long</td>
   1450      * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
   1451      * <td>read-only</td>
   1452      * <td>The absolute time in milliseconds when the latest status was
   1453      * inserted/updated.</td>
   1454      * </tr>
   1455      * <tr>
   1456      * <td>String</td>
   1457      * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
   1458      * <td>read-only</td>
   1459      * <td> The package containing resources for this status: label and icon.</td>
   1460      * </tr>
   1461      * <tr>
   1462      * <td>long</td>
   1463      * <td>{@link #CONTACT_STATUS_LABEL}</td>
   1464      * <td>read-only</td>
   1465      * <td>The resource ID of the label describing the source of contact status,
   1466      * e.g. "Google Talk". This resource is scoped by the
   1467      * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
   1468      * </tr>
   1469      * <tr>
   1470      * <td>long</td>
   1471      * <td>{@link #CONTACT_STATUS_ICON}</td>
   1472      * <td>read-only</td>
   1473      * <td>The resource ID of the icon for the source of contact status. This
   1474      * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
   1475      * </tr>
   1476      * </table>
   1477      */
   1478     public static class Contacts implements BaseColumns, ContactsColumns,
   1479             ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
   1480         /**
   1481          * This utility class cannot be instantiated
   1482          */
   1483         private Contacts()  {}
   1484 
   1485         /**
   1486          * The content:// style URI for this table
   1487          */
   1488         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
   1489 
   1490         /**
   1491          * Special contacts URI to refer to contacts on the corp profile from the personal
   1492          * profile.
   1493          *
   1494          * It's supported only by a few specific places for referring to contact pictures that
   1495          * are in the corp provider for enterprise caller-ID.  Contact picture URIs returned from
   1496          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
   1497          *
   1498          * @hide
   1499          */
   1500         public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
   1501                 "contacts_corp");
   1502 
   1503         /**
   1504          * A content:// style URI for this table that should be used to create
   1505          * shortcuts or otherwise create long-term links to contacts. This URI
   1506          * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
   1507          * It can optionally also have a "/" and last known contact ID appended after
   1508          * that. This "complete" format is an important optimization and is highly recommended.
   1509          * <p>
   1510          * As long as the contact's row ID remains the same, this URI is
   1511          * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
   1512          * as a result of a sync or aggregation, this URI will look up the
   1513          * contact using indirect information (sync IDs or constituent raw
   1514          * contacts).
   1515          * <p>
   1516          * Lookup key should be appended unencoded - it is stored in the encoded
   1517          * form, ready for use in a URI.
   1518          */
   1519         public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
   1520                 "lookup");
   1521 
   1522         /**
   1523          * Base {@link Uri} for referencing a single {@link Contacts} entry,
   1524          * created by appending {@link #LOOKUP_KEY} using
   1525          * {@link Uri#withAppendedPath(Uri, String)}. Provides
   1526          * {@link OpenableColumns} columns when queried, or returns the
   1527          * referenced contact formatted as a vCard when opened through
   1528          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
   1529          */
   1530         public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
   1531                 "as_vcard");
   1532 
   1533        /**
   1534         * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
   1535         * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
   1536         * vcard should not contain a photo.
   1537         *
   1538         * This is useful for obtaining a space efficient vcard.
   1539         */
   1540         public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo";
   1541 
   1542         /**
   1543          * Base {@link Uri} for referencing multiple {@link Contacts} entry,
   1544          * created by appending {@link #LOOKUP_KEY} using
   1545          * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
   1546          * joined with the colon (":") separator, and the resulting string encoded.
   1547          *
   1548          * Provides {@link OpenableColumns} columns when queried, or returns the
   1549          * referenced contact formatted as a vCard when opened through
   1550          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
   1551          *
   1552          * <p>
   1553          * Usage example:
   1554          * <dl>
   1555          * <dt>The following code snippet creates a multi-vcard URI that references all the
   1556          * contacts in a user's database.</dt>
   1557          * <dd>
   1558          *
   1559          * <pre>
   1560          * public Uri getAllContactsVcardUri() {
   1561          *     Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
   1562          *         new String[] {Contacts.LOOKUP_KEY}, null, null, null);
   1563          *     if (cursor == null) {
   1564          *         return null;
   1565          *     }
   1566          *     try {
   1567          *         StringBuilder uriListBuilder = new StringBuilder();
   1568          *         int index = 0;
   1569          *         while (cursor.moveToNext()) {
   1570          *             if (index != 0) uriListBuilder.append(':');
   1571          *             uriListBuilder.append(cursor.getString(0));
   1572          *             index++;
   1573          *         }
   1574          *         return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
   1575          *                 Uri.encode(uriListBuilder.toString()));
   1576          *     } finally {
   1577          *         cursor.close();
   1578          *     }
   1579          * }
   1580          * </pre>
   1581          *
   1582          * </p>
   1583          */
   1584         public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
   1585                 "as_multi_vcard");
   1586 
   1587         /**
   1588          * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
   1589          * requested {@link Contacts} entry.
   1590          *
   1591          * @param contactUri A {@link #CONTENT_URI} row, or an existing
   1592          *            {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
   1593          */
   1594         public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
   1595             final Cursor c = resolver.query(contactUri, new String[] {
   1596                     Contacts.LOOKUP_KEY, Contacts._ID
   1597             }, null, null, null);
   1598             if (c == null) {
   1599                 return null;
   1600             }
   1601 
   1602             try {
   1603                 if (c.moveToFirst()) {
   1604                     final String lookupKey = c.getString(0);
   1605                     final long contactId = c.getLong(1);
   1606                     return getLookupUri(contactId, lookupKey);
   1607                 }
   1608             } finally {
   1609                 c.close();
   1610             }
   1611             return null;
   1612         }
   1613 
   1614         /**
   1615          * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
   1616          * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
   1617          * <p>
   1618          * Returns null if unable to construct a valid lookup URI from the
   1619          * provided parameters.
   1620          */
   1621         public static Uri getLookupUri(long contactId, String lookupKey) {
   1622             if (TextUtils.isEmpty(lookupKey)) {
   1623                 return null;
   1624             }
   1625             return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
   1626                     lookupKey), contactId);
   1627         }
   1628 
   1629         /**
   1630          * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
   1631          * <p>
   1632          * Returns null if the contact cannot be found.
   1633          */
   1634         public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
   1635             if (lookupUri == null) {
   1636                 return null;
   1637             }
   1638 
   1639             Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
   1640             if (c == null) {
   1641                 return null;
   1642             }
   1643 
   1644             try {
   1645                 if (c.moveToFirst()) {
   1646                     long contactId = c.getLong(0);
   1647                     return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
   1648                 }
   1649             } finally {
   1650                 c.close();
   1651             }
   1652             return null;
   1653         }
   1654 
   1655         /**
   1656          * Mark a contact as having been contacted. Updates two fields:
   1657          * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
   1658          * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
   1659          * field is populated with the current system time.
   1660          *
   1661          * @param resolver the ContentResolver to use
   1662          * @param contactId the person who was contacted
   1663          *
   1664          * @deprecated The class DataUsageStatUpdater of the Android support library should
   1665          *     be used instead.
   1666          */
   1667         @Deprecated
   1668         public static void markAsContacted(ContentResolver resolver, long contactId) {
   1669             Uri uri = ContentUris.withAppendedId(CONTENT_URI, contactId);
   1670             ContentValues values = new ContentValues();
   1671             // TIMES_CONTACTED will be incremented when LAST_TIME_CONTACTED is modified.
   1672             values.put(LAST_TIME_CONTACTED, System.currentTimeMillis());
   1673             resolver.update(uri, values, null, null);
   1674         }
   1675 
   1676         /**
   1677          * The content:// style URI used for "type-to-filter" functionality on the
   1678          * {@link #CONTENT_URI} URI. The filter string will be used to match
   1679          * various parts of the contact name. The filter argument should be passed
   1680          * as an additional path segment after this URI.
   1681          */
   1682         public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
   1683                 CONTENT_URI, "filter");
   1684 
   1685         /**
   1686          * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
   1687          * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters,
   1688          * otherwise it will throw IllegalArgumentException.
   1689          */
   1690         public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
   1691                 CONTENT_URI, "filter_enterprise");
   1692 
   1693         /**
   1694          * The content:// style URI for this table joined with useful data from
   1695          * {@link ContactsContract.Data}, filtered to include only starred contacts
   1696          * and the most frequently contacted contacts.
   1697          */
   1698         public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
   1699                 CONTENT_URI, "strequent");
   1700 
   1701         /**
   1702          * The content:// style URI for showing a list of frequently contacted people.
   1703          */
   1704         public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
   1705                 CONTENT_URI, "frequent");
   1706 
   1707         /**
   1708          * The content:// style URI used for "type-to-filter" functionality on the
   1709          * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
   1710          * various parts of the contact name. The filter argument should be passed
   1711          * as an additional path segment after this URI.
   1712          */
   1713         public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
   1714                 CONTENT_STREQUENT_URI, "filter");
   1715 
   1716         public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
   1717                 CONTENT_URI, "group");
   1718 
   1719         /**
   1720          * The MIME type of {@link #CONTENT_URI} providing a directory of
   1721          * people.
   1722          */
   1723         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
   1724 
   1725         /**
   1726          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
   1727          * person.
   1728          */
   1729         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
   1730 
   1731         /**
   1732          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
   1733          * person.
   1734          */
   1735         public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
   1736 
   1737         /**
   1738          * Mimimal ID for corp contacts returned from
   1739          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   1740          *
   1741          * @hide
   1742          */
   1743         public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
   1744 
   1745         /**
   1746          * Prefix for corp contacts returned from
   1747          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   1748          *
   1749          * @hide
   1750          */
   1751         public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-";
   1752 
   1753         /**
   1754          * Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
   1755          *
   1756          * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
   1757          */
   1758         public static boolean isEnterpriseContactId(long contactId) {
   1759             return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
   1760         }
   1761 
   1762         /**
   1763          * A sub-directory of a single contact that contains all of the constituent raw contact
   1764          * {@link ContactsContract.Data} rows.  This directory can be used either
   1765          * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
   1766          */
   1767         public static final class Data implements BaseColumns, DataColumns {
   1768             /**
   1769              * no public constructor since this is a utility class
   1770              */
   1771             private Data() {}
   1772 
   1773             /**
   1774              * The directory twig for this sub-table
   1775              */
   1776             public static final String CONTENT_DIRECTORY = "data";
   1777         }
   1778 
   1779         /**
   1780          * <p>
   1781          * A sub-directory of a contact that contains all of its
   1782          * {@link ContactsContract.RawContacts} as well as
   1783          * {@link ContactsContract.Data} rows. To access this directory append
   1784          * {@link #CONTENT_DIRECTORY} to the contact URI.
   1785          * </p>
   1786          * <p>
   1787          * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
   1788          * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
   1789          * the data rows. Entity always contains at least one row per
   1790          * constituent raw contact, even if there are no actual data rows. In
   1791          * this case the {@link #DATA_ID} field will be null.
   1792          * </p>
   1793          * <p>
   1794          * Entity reads all data for the entire contact in one transaction, to
   1795          * guarantee consistency.  There is significant data duplication
   1796          * in the Entity (each row repeats all Contact columns and all RawContact
   1797          * columns), so the benefits of transactional consistency should be weighed
   1798          * against the cost of transferring large amounts of denormalized data
   1799          * from the Provider.
   1800          * </p>
   1801          * <p>
   1802          * To reduce the amount of data duplication the contacts provider and directory
   1803          * providers implementing this protocol are allowed to provide common Contacts
   1804          * and RawContacts fields in the first row returned for each raw contact only and
   1805          * leave them as null in subsequent rows.
   1806          * </p>
   1807          */
   1808         public static final class Entity implements BaseColumns, ContactsColumns,
   1809                 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
   1810                 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
   1811             /**
   1812              * no public constructor since this is a utility class
   1813              */
   1814             private Entity() {
   1815             }
   1816 
   1817             /**
   1818              * The directory twig for this sub-table
   1819              */
   1820             public static final String CONTENT_DIRECTORY = "entities";
   1821 
   1822             /**
   1823              * The ID of the raw contact row.
   1824              * <P>Type: INTEGER</P>
   1825              */
   1826             public static final String RAW_CONTACT_ID = "raw_contact_id";
   1827 
   1828             /**
   1829              * The ID of the data row. The value will be null if this raw contact has no
   1830              * data rows.
   1831              * <P>Type: INTEGER</P>
   1832              */
   1833             public static final String DATA_ID = "data_id";
   1834         }
   1835 
   1836         /**
   1837          * <p>
   1838          * A sub-directory of a single contact that contains all of the constituent raw contact
   1839          * {@link ContactsContract.StreamItems} rows.  This directory can be used either
   1840          * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
   1841          * </p>
   1842          * <p>
   1843          * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
   1844          * permission.
   1845          * </p>
   1846          *
   1847          * @deprecated - Do not use. This will not be supported in the future. In the future,
   1848          * cursors returned from related queries will be empty.
   1849          *
   1850          * @hide
   1851          * @removed
   1852          */
   1853         @Deprecated
   1854         public static final class StreamItems implements StreamItemsColumns {
   1855             /**
   1856              * no public constructor since this is a utility class
   1857              *
   1858              * @deprecated - Do not use. This will not be supported in the future. In the future,
   1859              * cursors returned from related queries will be empty.
   1860              */
   1861             @Deprecated
   1862             private StreamItems() {}
   1863 
   1864             /**
   1865              * The directory twig for this sub-table
   1866              *
   1867              * @deprecated - Do not use. This will not be supported in the future. In the future,
   1868              * cursors returned from related queries will be empty.
   1869              */
   1870             @Deprecated
   1871             public static final String CONTENT_DIRECTORY = "stream_items";
   1872         }
   1873 
   1874         /**
   1875          * <p>
   1876          * A <i>read-only</i> sub-directory of a single contact aggregate that
   1877          * contains all aggregation suggestions (other contacts). The
   1878          * aggregation suggestions are computed based on approximate data
   1879          * matches with this contact.
   1880          * </p>
   1881          * <p>
   1882          * <i>Note: this query may be expensive! If you need to use it in bulk,
   1883          * make sure the user experience is acceptable when the query runs for a
   1884          * long time.</i>
   1885          * <p>
   1886          * Usage example:
   1887          *
   1888          * <pre>
   1889          * Uri uri = Contacts.CONTENT_URI.buildUpon()
   1890          *          .appendEncodedPath(String.valueOf(contactId))
   1891          *          .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
   1892          *          .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
   1893          *          .build()
   1894          * Cursor cursor = getContentResolver().query(suggestionsUri,
   1895          *          new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
   1896          *          null, null, null);
   1897          * </pre>
   1898          *
   1899          * </p>
   1900          * <p>
   1901          * This directory can be used either with a {@link #CONTENT_URI} or
   1902          * {@link #CONTENT_LOOKUP_URI}.
   1903          * </p>
   1904          */
   1905         public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
   1906                 ContactOptionsColumns, ContactStatusColumns {
   1907             /**
   1908              * No public constructor since this is a utility class
   1909              */
   1910             private AggregationSuggestions() {}
   1911 
   1912             /**
   1913              * The directory twig for this sub-table. The URI can be followed by an optional
   1914              * type-to-filter, similar to
   1915              * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
   1916              */
   1917             public static final String CONTENT_DIRECTORY = "suggestions";
   1918 
   1919             /**
   1920              * Used to specify what kind of data is supplied for the suggestion query.
   1921              *
   1922              * @hide
   1923              */
   1924             public static final String PARAMETER_MATCH_NAME = "name";
   1925 
   1926             /**
   1927              * A convenience builder for aggregation suggestion content URIs.
   1928              */
   1929             public static final class Builder {
   1930                 private long mContactId;
   1931                 private final ArrayList<String> mValues = new ArrayList<String>();
   1932                 private int mLimit;
   1933 
   1934                 /**
   1935                  * Optional existing contact ID.  If it is not provided, the search
   1936                  * will be based exclusively on the values supplied with {@link #addNameParameter}.
   1937                  *
   1938                  * @param contactId contact to find aggregation suggestions for
   1939                  * @return This Builder object to allow for chaining of calls to builder methods
   1940                  */
   1941                 public Builder setContactId(long contactId) {
   1942                     this.mContactId = contactId;
   1943                     return this;
   1944                 }
   1945 
   1946                 /**
   1947                  * Add a name to be used when searching for aggregation suggestions.
   1948                  *
   1949                  * @param name name to find aggregation suggestions for
   1950                  * @return This Builder object to allow for chaining of calls to builder methods
   1951                  */
   1952                 public Builder addNameParameter(String name) {
   1953                     mValues.add(name);
   1954                     return this;
   1955                 }
   1956 
   1957                 /**
   1958                  * Sets the Maximum number of suggested aggregations that should be returned.
   1959                  * @param limit The maximum number of suggested aggregations
   1960                  *
   1961                  * @return This Builder object to allow for chaining of calls to builder methods
   1962                  */
   1963                 public Builder setLimit(int limit) {
   1964                     mLimit = limit;
   1965                     return this;
   1966                 }
   1967 
   1968                 /**
   1969                  * Combine all of the options that have been set and return a new {@link Uri}
   1970                  * object for fetching aggregation suggestions.
   1971                  */
   1972                 public Uri build() {
   1973                     android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
   1974                     builder.appendEncodedPath(String.valueOf(mContactId));
   1975                     builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
   1976                     if (mLimit != 0) {
   1977                         builder.appendQueryParameter("limit", String.valueOf(mLimit));
   1978                     }
   1979 
   1980                     int count = mValues.size();
   1981                     for (int i = 0; i < count; i++) {
   1982                         builder.appendQueryParameter("query", PARAMETER_MATCH_NAME
   1983                                 + ":" + mValues.get(i));
   1984                     }
   1985 
   1986                     return builder.build();
   1987                 }
   1988             }
   1989 
   1990             /**
   1991              * @hide
   1992              */
   1993             public static final Builder builder() {
   1994                 return new Builder();
   1995             }
   1996         }
   1997 
   1998         /**
   1999          * A <i>read-only</i> sub-directory of a single contact that contains
   2000          * the contact's primary photo.  The photo may be stored in up to two ways -
   2001          * the default "photo" is a thumbnail-sized image stored directly in the data
   2002          * row, while the "display photo", if present, is a larger version stored as
   2003          * a file.
   2004          * <p>
   2005          * Usage example:
   2006          * <dl>
   2007          * <dt>Retrieving the thumbnail-sized photo</dt>
   2008          * <dd>
   2009          * <pre>
   2010          * public InputStream openPhoto(long contactId) {
   2011          *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
   2012          *     Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
   2013          *     Cursor cursor = getContentResolver().query(photoUri,
   2014          *          new String[] {Contacts.Photo.PHOTO}, null, null, null);
   2015          *     if (cursor == null) {
   2016          *         return null;
   2017          *     }
   2018          *     try {
   2019          *         if (cursor.moveToFirst()) {
   2020          *             byte[] data = cursor.getBlob(0);
   2021          *             if (data != null) {
   2022          *                 return new ByteArrayInputStream(data);
   2023          *             }
   2024          *         }
   2025          *     } finally {
   2026          *         cursor.close();
   2027          *     }
   2028          *     return null;
   2029          * }
   2030          * </pre>
   2031          * </dd>
   2032          * <dt>Retrieving the larger photo version</dt>
   2033          * <dd>
   2034          * <pre>
   2035          * public InputStream openDisplayPhoto(long contactId) {
   2036          *     Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
   2037          *     Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
   2038          *     try {
   2039          *         AssetFileDescriptor fd =
   2040          *             getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
   2041          *         return fd.createInputStream();
   2042          *     } catch (IOException e) {
   2043          *         return null;
   2044          *     }
   2045          * }
   2046          * </pre>
   2047          * </dd>
   2048          * </dl>
   2049          *
   2050          * </p>
   2051          * <p>You may also consider using the convenience method
   2052          * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
   2053          * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
   2054          * </p>
   2055          * <p>
   2056          * This directory can be used either with a {@link #CONTENT_URI} or
   2057          * {@link #CONTENT_LOOKUP_URI}.
   2058          * </p>
   2059          */
   2060         public static final class Photo implements BaseColumns, DataColumnsWithJoins {
   2061             /**
   2062              * no public constructor since this is a utility class
   2063              */
   2064             private Photo() {}
   2065 
   2066             /**
   2067              * The directory twig for this sub-table
   2068              */
   2069             public static final String CONTENT_DIRECTORY = "photo";
   2070 
   2071             /**
   2072              * The directory twig for retrieving the full-size display photo.
   2073              */
   2074             public static final String DISPLAY_PHOTO = "display_photo";
   2075 
   2076             /**
   2077              * Full-size photo file ID of the raw contact.
   2078              * See {@link ContactsContract.DisplayPhoto}.
   2079              * <p>
   2080              * Type: NUMBER
   2081              */
   2082             public static final String PHOTO_FILE_ID = DATA14;
   2083 
   2084             /**
   2085              * Thumbnail photo of the raw contact. This is the raw bytes of an image
   2086              * that could be inflated using {@link android.graphics.BitmapFactory}.
   2087              * <p>
   2088              * Type: BLOB
   2089              */
   2090             public static final String PHOTO = DATA15;
   2091         }
   2092 
   2093         /**
   2094          * Opens an InputStream for the contacts's photo and returns the
   2095          * photo as a byte stream.
   2096          * @param cr The content resolver to use for querying
   2097          * @param contactUri the contact whose photo should be used. This can be used with
   2098          * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
   2099          * @param preferHighres If this is true and the contact has a higher resolution photo
   2100          * available, it is returned. If false, this function always tries to get the thumbnail
   2101          * @return an InputStream of the photo, or null if no photo is present
   2102          */
   2103         public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
   2104                 boolean preferHighres) {
   2105             if (preferHighres) {
   2106                 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
   2107                         Contacts.Photo.DISPLAY_PHOTO);
   2108                 try {
   2109                     AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
   2110                     if (fd != null) {
   2111                         return fd.createInputStream();
   2112                     }
   2113                 } catch (IOException e) {
   2114                     // fallback to the thumbnail code
   2115                 }
   2116            }
   2117 
   2118             Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
   2119             if (photoUri == null) {
   2120                 return null;
   2121             }
   2122             Cursor cursor = cr.query(photoUri,
   2123                     new String[] {
   2124                         ContactsContract.CommonDataKinds.Photo.PHOTO
   2125                     }, null, null, null);
   2126             try {
   2127                 if (cursor == null || !cursor.moveToNext()) {
   2128                     return null;
   2129                 }
   2130                 byte[] data = cursor.getBlob(0);
   2131                 if (data == null) {
   2132                     return null;
   2133                 }
   2134                 return new ByteArrayInputStream(data);
   2135             } finally {
   2136                 if (cursor != null) {
   2137                     cursor.close();
   2138                 }
   2139             }
   2140         }
   2141 
   2142         /**
   2143          * Opens an InputStream for the contacts's thumbnail photo and returns the
   2144          * photo as a byte stream.
   2145          * @param cr The content resolver to use for querying
   2146          * @param contactUri the contact whose photo should be used. This can be used with
   2147          * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
   2148          * @return an InputStream of the photo, or null if no photo is present
   2149          * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
   2150          * of the thumbnail the high-res picture is preferred
   2151          */
   2152         public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
   2153             return openContactPhotoInputStream(cr, contactUri, false);
   2154         }
   2155     }
   2156 
   2157     /**
   2158      * <p>
   2159      * Constants for the user's profile data, which is represented as a single contact on
   2160      * the device that represents the user.  The profile contact is not aggregated
   2161      * together automatically in the same way that normal contacts are; instead, each
   2162      * account (including data set, if applicable) on the device may contribute a single
   2163      * raw contact representing the user's personal profile data from that source.
   2164      * </p>
   2165      * <p>
   2166      * Access to the profile entry through these URIs (or incidental access to parts of
   2167      * the profile if retrieved directly via ID) requires additional permissions beyond
   2168      * the read/write contact permissions required by the provider.  Querying for profile
   2169      * data requires android.permission.READ_PROFILE permission, and inserting or
   2170      * updating profile data requires android.permission.WRITE_PROFILE permission.
   2171      * </p>
   2172      * <h3>Operations</h3>
   2173      * <dl>
   2174      * <dt><b>Insert</b></dt>
   2175      * <dd>The user's profile entry cannot be created explicitly (attempting to do so
   2176      * will throw an exception). When a raw contact is inserted into the profile, the
   2177      * provider will check for the existence of a profile on the device.  If one is
   2178      * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
   2179      * the profile Contact. If no match is found, the profile Contact is created and
   2180      * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
   2181      * inserted raw contact.</dd>
   2182      * <dt><b>Update</b></dt>
   2183      * <dd>The profile Contact has the same update restrictions as Contacts in general,
   2184      * but requires the android.permission.WRITE_PROFILE permission.</dd>
   2185      * <dt><b>Delete</b></dt>
   2186      * <dd>The profile Contact cannot be explicitly deleted.  It will be removed
   2187      * automatically if all of its constituent raw contact entries are deleted.</dd>
   2188      * <dt><b>Query</b></dt>
   2189      * <dd>
   2190      * <ul>
   2191      * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
   2192      * retrieving a contact by ID, except that it will only ever return the user's
   2193      * profile contact.
   2194      * </li>
   2195      * <li>
   2196      * The profile contact supports all of the same sub-paths as an individual contact
   2197      * does - the content of the profile contact can be retrieved as entities or
   2198      * data rows.  Similarly, specific raw contact entries can be retrieved by appending
   2199      * the desired raw contact ID within the profile.
   2200      * </li>
   2201      * </ul>
   2202      * </dd>
   2203      * </dl>
   2204      */
   2205     public static final class Profile implements BaseColumns, ContactsColumns,
   2206             ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
   2207         /**
   2208          * This utility class cannot be instantiated
   2209          */
   2210         private Profile() {
   2211         }
   2212 
   2213         /**
   2214          * The content:// style URI for this table, which requests the contact entry
   2215          * representing the user's personal profile data.
   2216          */
   2217         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
   2218 
   2219         /**
   2220          * {@link Uri} for referencing the user's profile {@link Contacts} entry,
   2221          * Provides {@link OpenableColumns} columns when queried, or returns the
   2222          * user's profile contact formatted as a vCard when opened through
   2223          * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
   2224          */
   2225         public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
   2226                 "as_vcard");
   2227 
   2228         /**
   2229          * {@link Uri} for referencing the raw contacts that make up the user's profile
   2230          * {@link Contacts} entry.  An individual raw contact entry within the profile
   2231          * can be addressed by appending the raw contact ID.  The entities or data within
   2232          * that specific raw contact can be requested by appending the entity or data
   2233          * path as well.
   2234          */
   2235         public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
   2236                 "raw_contacts");
   2237 
   2238         /**
   2239          * The minimum ID for any entity that belongs to the profile.  This essentially
   2240          * defines an ID-space in which profile data is stored, and is used by the provider
   2241          * to determine whether a request via a non-profile-specific URI should be directed
   2242          * to the profile data rather than general contacts data, along with all the special
   2243          * permission checks that entails.
   2244          *
   2245          * Callers may use {@link #isProfileId} to check whether a specific ID falls into
   2246          * the set of data intended for the profile.
   2247          */
   2248         public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
   2249     }
   2250 
   2251     /**
   2252      * This method can be used to identify whether the given ID is associated with profile
   2253      * data.  It does not necessarily indicate that the ID is tied to valid data, merely
   2254      * that accessing data using this ID will result in profile access checks and will only
   2255      * return data from the profile.
   2256      *
   2257      * @param id The ID to check.
   2258      * @return Whether the ID is associated with profile data.
   2259      */
   2260     public static boolean isProfileId(long id) {
   2261         return id >= Profile.MIN_ID;
   2262     }
   2263 
   2264     protected interface DeletedContactsColumns {
   2265 
   2266         /**
   2267          * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
   2268          * <P>Type: INTEGER</P>
   2269          */
   2270         public static final String CONTACT_ID = "contact_id";
   2271 
   2272         /**
   2273          * Time (milliseconds since epoch) that the contact was deleted.
   2274          */
   2275         public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
   2276     }
   2277 
   2278     /**
   2279      * Constants for the deleted contact table.  This table holds a log of deleted contacts.
   2280      * <p>
   2281      * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
   2282      */
   2283     public static final class DeletedContacts implements DeletedContactsColumns {
   2284 
   2285         /**
   2286          * This utility class cannot be instantiated
   2287          */
   2288         private DeletedContacts() {
   2289         }
   2290 
   2291         /**
   2292          * The content:// style URI for this table, which requests a directory of raw contact rows
   2293          * matching the selection criteria.
   2294          */
   2295         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
   2296                 "deleted_contacts");
   2297 
   2298         /**
   2299          * Number of days that the delete log will be kept.  After this time, delete records may be
   2300          * deleted.
   2301          *
   2302          * @hide
   2303          */
   2304         private static final int DAYS_KEPT = 30;
   2305 
   2306         /**
   2307          * Milliseconds that the delete log will be kept.  After this time, delete records may be
   2308          * deleted.
   2309          */
   2310         public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
   2311     }
   2312 
   2313     protected interface RawContactsColumns {
   2314         /**
   2315          * A reference to the {@link ContactsContract.Contacts#_ID} that this
   2316          * data belongs to.
   2317          * <P>Type: INTEGER</P>
   2318          */
   2319         public static final String CONTACT_ID = "contact_id";
   2320 
   2321         /**
   2322          * Persistent unique id for each raw_contact within its account.
   2323          * This id is provided by its own data source, and can be used to backup metadata
   2324          * to the server.
   2325          * This should be unique within each set of account_name/account_type/data_set
   2326          */
   2327         public static final String BACKUP_ID = "backup_id";
   2328 
   2329         /**
   2330          * The data set within the account that this row belongs to.  This allows
   2331          * multiple sync adapters for the same account type to distinguish between
   2332          * each others' data.
   2333          *
   2334          * This is empty by default, and is completely optional.  It only needs to
   2335          * be populated if multiple sync adapters are entering distinct data for
   2336          * the same account type and account name.
   2337          * <P>Type: TEXT</P>
   2338          */
   2339         public static final String DATA_SET = "data_set";
   2340 
   2341         /**
   2342          * A concatenation of the account type and data set (delimited by a forward
   2343          * slash) - if the data set is empty, this will be the same as the account
   2344          * type.  For applications that need to be aware of the data set, this can
   2345          * be used instead of account type to distinguish sets of data.  This is
   2346          * never intended to be used for specifying accounts.
   2347          * <p>
   2348          * This column does *not* escape forward slashes in the account type or the data set.
   2349          * If this is an issue, consider using
   2350          * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
   2351          * {@link ContactsContract.RawContacts#DATA_SET} directly.
   2352          */
   2353         public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
   2354 
   2355         /**
   2356          * The aggregation mode for this contact.
   2357          * <P>Type: INTEGER</P>
   2358          */
   2359         public static final String AGGREGATION_MODE = "aggregation_mode";
   2360 
   2361         /**
   2362          * The "deleted" flag: "0" by default, "1" if the row has been marked
   2363          * for deletion. When {@link android.content.ContentResolver#delete} is
   2364          * called on a raw contact, it is marked for deletion and removed from its
   2365          * aggregate contact. The sync adaptor deletes the raw contact on the server and
   2366          * then calls ContactResolver.delete once more, this time passing the
   2367          * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
   2368          * the data removal.
   2369          * <P>Type: INTEGER</P>
   2370          */
   2371         public static final String DELETED = "deleted";
   2372 
   2373         /**
   2374          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
   2375          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
   2376          * <P>Type: INTEGER</P>
   2377          */
   2378         public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
   2379 
   2380         /**
   2381          * Flag that reflects whether this raw contact belongs to the user's
   2382          * personal profile entry.
   2383          */
   2384         public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
   2385 
   2386         /**
   2387          * Flag indicating that a raw contact's metadata has changed, and its metadata
   2388          * needs to be synchronized by the server.
   2389          * <P>Type: INTEGER (boolean)</P>
   2390          */
   2391         public static final String METADATA_DIRTY = "metadata_dirty";
   2392     }
   2393 
   2394     /**
   2395      * Constants for the raw contacts table, which contains one row of contact
   2396      * information for each person in each synced account. Sync adapters and
   2397      * contact management apps
   2398      * are the primary consumers of this API.
   2399      *
   2400      * <h3>Aggregation</h3>
   2401      * <p>
   2402      * As soon as a raw contact is inserted or whenever its constituent data
   2403      * changes, the provider will check if the raw contact matches other
   2404      * existing raw contacts and if so will aggregate it with those. The
   2405      * aggregation is reflected in the {@link RawContacts} table by the change of the
   2406      * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
   2407      * </p>
   2408      * <p>
   2409      * Changes to the structured name, organization, phone number, email address,
   2410      * or nickname trigger a re-aggregation.
   2411      * </p>
   2412      * <p>
   2413      * See also {@link AggregationExceptions} for a mechanism to control
   2414      * aggregation programmatically.
   2415      * </p>
   2416      *
   2417      * <h3>Operations</h3>
   2418      * <dl>
   2419      * <dt><b>Insert</b></dt>
   2420      * <dd>
   2421      * <p>
   2422      * Raw contacts can be inserted incrementally or in a batch.
   2423      * The incremental method is more traditional but less efficient.
   2424      * It should be used
   2425      * only if no {@link Data} values are available at the time the raw contact is created:
   2426      * <pre>
   2427      * ContentValues values = new ContentValues();
   2428      * values.put(RawContacts.ACCOUNT_TYPE, accountType);
   2429      * values.put(RawContacts.ACCOUNT_NAME, accountName);
   2430      * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
   2431      * long rawContactId = ContentUris.parseId(rawContactUri);
   2432      * </pre>
   2433      * </p>
   2434      * <p>
   2435      * Once {@link Data} values become available, insert those.
   2436      * For example, here's how you would insert a name:
   2437      *
   2438      * <pre>
   2439      * values.clear();
   2440      * values.put(Data.RAW_CONTACT_ID, rawContactId);
   2441      * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
   2442      * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
   2443      * getContentResolver().insert(Data.CONTENT_URI, values);
   2444      * </pre>
   2445      * </p>
   2446      * <p>
   2447      * The batch method is by far preferred.  It inserts the raw contact and its
   2448      * constituent data rows in a single database transaction
   2449      * and causes at most one aggregation pass.
   2450      * <pre>
   2451      * ArrayList&lt;ContentProviderOperation&gt; ops =
   2452      *          new ArrayList&lt;ContentProviderOperation&gt;();
   2453      * ...
   2454      * int rawContactInsertIndex = ops.size();
   2455      * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
   2456      *          .withValue(RawContacts.ACCOUNT_TYPE, accountType)
   2457      *          .withValue(RawContacts.ACCOUNT_NAME, accountName)
   2458      *          .build());
   2459      *
   2460      * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   2461      *          .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
   2462      *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
   2463      *          .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
   2464      *          .build());
   2465      *
   2466      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   2467      * </pre>
   2468      * </p>
   2469      * <p>
   2470      * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
   2471      * to refer to the as-yet-unknown index value of the raw contact inserted in the
   2472      * first operation.
   2473      * </p>
   2474      *
   2475      * <dt><b>Update</b></dt>
   2476      * <dd><p>
   2477      * Raw contacts can be updated incrementally or in a batch.
   2478      * Batch mode should be used whenever possible.
   2479      * The procedures and considerations are analogous to those documented above for inserts.
   2480      * </p></dd>
   2481      * <dt><b>Delete</b></dt>
   2482      * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
   2483      * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
   2484      * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
   2485      * itself is also deleted automatically.
   2486      * </p>
   2487      * <p>
   2488      * The invocation of {@code resolver.delete(...)}, does not immediately delete
   2489      * a raw contacts row.
   2490      * Instead, it sets the {@link #DELETED} flag on the raw contact and
   2491      * removes the raw contact from its aggregate contact.
   2492      * The sync adapter then deletes the raw contact from the server and
   2493      * finalizes phone-side deletion by calling {@code resolver.delete(...)}
   2494      * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
   2495      * <p>Some sync adapters are read-only, meaning that they only sync server-side
   2496      * changes to the phone, but not the reverse.  If one of those raw contacts
   2497      * is marked for deletion, it will remain on the phone.  However it will be
   2498      * effectively invisible, because it will not be part of any aggregate contact.
   2499      * </dd>
   2500      *
   2501      * <dt><b>Query</b></dt>
   2502      * <dd>
   2503      * <p>
   2504      * It is easy to find all raw contacts in a Contact:
   2505      * <pre>
   2506      * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
   2507      *          new String[]{RawContacts._ID},
   2508      *          RawContacts.CONTACT_ID + "=?",
   2509      *          new String[]{String.valueOf(contactId)}, null);
   2510      * </pre>
   2511      * </p>
   2512      * <p>
   2513      * To find raw contacts within a specific account,
   2514      * you can either put the account name and type in the selection or pass them as query
   2515      * parameters.  The latter approach is preferable, especially when you can reuse the
   2516      * URI:
   2517      * <pre>
   2518      * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
   2519      *          .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
   2520      *          .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
   2521      *          .build();
   2522      * Cursor c1 = getContentResolver().query(rawContactUri,
   2523      *          RawContacts.STARRED + "&lt;&gt;0", null, null, null);
   2524      * ...
   2525      * Cursor c2 = getContentResolver().query(rawContactUri,
   2526      *          RawContacts.DELETED + "&lt;&gt;0", null, null, null);
   2527      * </pre>
   2528      * </p>
   2529      * <p>The best way to read a raw contact along with all the data associated with it is
   2530      * by using the {@link Entity} directory. If the raw contact has data rows,
   2531      * the Entity cursor will contain a row for each data row.  If the raw contact has no
   2532      * data rows, the cursor will still contain one row with the raw contact-level information.
   2533      * <pre>
   2534      * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
   2535      * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
   2536      * Cursor c = getContentResolver().query(entityUri,
   2537      *          new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
   2538      *          null, null, null);
   2539      * try {
   2540      *     while (c.moveToNext()) {
   2541      *         String sourceId = c.getString(0);
   2542      *         if (!c.isNull(1)) {
   2543      *             String mimeType = c.getString(2);
   2544      *             String data = c.getString(3);
   2545      *             ...
   2546      *         }
   2547      *     }
   2548      * } finally {
   2549      *     c.close();
   2550      * }
   2551      * </pre>
   2552      * </p>
   2553      * </dd>
   2554      * </dl>
   2555      * <h2>Columns</h2>
   2556      *
   2557      * <table class="jd-sumtable">
   2558      * <tr>
   2559      * <th colspan='4'>RawContacts</th>
   2560      * </tr>
   2561      * <tr>
   2562      * <td>long</td>
   2563      * <td>{@link #_ID}</td>
   2564      * <td>read-only</td>
   2565      * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
   2566      * it is much better for a sync adapter to update a raw contact rather than to delete and
   2567      * re-insert it.</td>
   2568      * </tr>
   2569      * <tr>
   2570      * <td>long</td>
   2571      * <td>{@link #CONTACT_ID}</td>
   2572      * <td>read-only</td>
   2573      * <td>The ID of the row in the {@link ContactsContract.Contacts} table
   2574      * that this raw contact belongs
   2575      * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
   2576      * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
   2577      * </tr>
   2578      * <tr>
   2579      * <td>int</td>
   2580      * <td>{@link #AGGREGATION_MODE}</td>
   2581      * <td>read/write</td>
   2582      * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
   2583      * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
   2584      * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
   2585      * </tr>
   2586      * <tr>
   2587      * <td>int</td>
   2588      * <td>{@link #DELETED}</td>
   2589      * <td>read/write</td>
   2590      * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
   2591      * for deletion. When {@link android.content.ContentResolver#delete} is
   2592      * called on a raw contact, it is marked for deletion and removed from its
   2593      * aggregate contact. The sync adaptor deletes the raw contact on the server and
   2594      * then calls ContactResolver.delete once more, this time passing the
   2595      * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
   2596      * the data removal.</td>
   2597      * </tr>
   2598      * <tr>
   2599      * <td>int</td>
   2600      * <td>{@link #TIMES_CONTACTED}</td>
   2601      * <td>read/write</td>
   2602      * <td>The number of times the contact has been contacted. To have an effect
   2603      * on the corresponding value of the aggregate contact, this field
   2604      * should be set at the time the raw contact is inserted.
   2605      * After that, this value is typically updated via
   2606      * {@link ContactsContract.Contacts#markAsContacted}.</td>
   2607      * </tr>
   2608      * <tr>
   2609      * <td>long</td>
   2610      * <td>{@link #LAST_TIME_CONTACTED}</td>
   2611      * <td>read/write</td>
   2612      * <td>The timestamp of the last time the contact was contacted. To have an effect
   2613      * on the corresponding value of the aggregate contact, this field
   2614      * should be set at the time the raw contact is inserted.
   2615      * After that, this value is typically updated via
   2616      * {@link ContactsContract.Contacts#markAsContacted}.
   2617      * </td>
   2618      * </tr>
   2619      * <tr>
   2620      * <td>int</td>
   2621      * <td>{@link #STARRED}</td>
   2622      * <td>read/write</td>
   2623      * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
   2624      * Changing this field immediately affects the corresponding aggregate contact:
   2625      * if any raw contacts in that aggregate contact are starred, then the contact
   2626      * itself is marked as starred.</td>
   2627      * </tr>
   2628      * <tr>
   2629      * <td>String</td>
   2630      * <td>{@link #CUSTOM_RINGTONE}</td>
   2631      * <td>read/write</td>
   2632      * <td>A custom ringtone associated with a raw contact. Typically this is the
   2633      * URI returned by an activity launched with the
   2634      * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
   2635      * To have an effect on the corresponding value of the aggregate contact, this field
   2636      * should be set at the time the raw contact is inserted. To set a custom
   2637      * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
   2638      * Contacts.CUSTOM_RINGTONE}
   2639      * instead.</td>
   2640      * </tr>
   2641      * <tr>
   2642      * <td>int</td>
   2643      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   2644      * <td>read/write</td>
   2645      * <td>An indicator of whether calls from this raw contact should be forwarded
   2646      * directly to voice mail ('1') or not ('0'). To have an effect
   2647      * on the corresponding value of the aggregate contact, this field
   2648      * should be set at the time the raw contact is inserted.</td>
   2649      * </tr>
   2650      * <tr>
   2651      * <td>String</td>
   2652      * <td>{@link #ACCOUNT_NAME}</td>
   2653      * <td>read/write-once</td>
   2654      * <td>The name of the account instance to which this row belongs, which when paired with
   2655      * {@link #ACCOUNT_TYPE} identifies a specific account.
   2656      * For example, this will be the Gmail address if it is a Google account.
   2657      * It should be set at the time the raw contact is inserted and never
   2658      * changed afterwards.</td>
   2659      * </tr>
   2660      * <tr>
   2661      * <td>String</td>
   2662      * <td>{@link #ACCOUNT_TYPE}</td>
   2663      * <td>read/write-once</td>
   2664      * <td>
   2665      * <p>
   2666      * The type of account to which this row belongs, which when paired with
   2667      * {@link #ACCOUNT_NAME} identifies a specific account.
   2668      * It should be set at the time the raw contact is inserted and never
   2669      * changed afterwards.
   2670      * </p>
   2671      * <p>
   2672      * To ensure uniqueness, new account types should be chosen according to the
   2673      * Java package naming convention.  Thus a Google account is of type "com.google".
   2674      * </p>
   2675      * </td>
   2676      * </tr>
   2677      * <tr>
   2678      * <td>String</td>
   2679      * <td>{@link #DATA_SET}</td>
   2680      * <td>read/write-once</td>
   2681      * <td>
   2682      * <p>
   2683      * The data set within the account that this row belongs to.  This allows
   2684      * multiple sync adapters for the same account type to distinguish between
   2685      * each others' data.  The combination of {@link #ACCOUNT_TYPE},
   2686      * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
   2687      * that is associated with a single sync adapter.
   2688      * </p>
   2689      * <p>
   2690      * This is empty by default, and is completely optional.  It only needs to
   2691      * be populated if multiple sync adapters are entering distinct data for
   2692      * the same account type and account name.
   2693      * </p>
   2694      * <p>
   2695      * It should be set at the time the raw contact is inserted and never
   2696      * changed afterwards.
   2697      * </p>
   2698      * </td>
   2699      * </tr>
   2700      * <tr>
   2701      * <td>String</td>
   2702      * <td>{@link #SOURCE_ID}</td>
   2703      * <td>read/write</td>
   2704      * <td>String that uniquely identifies this row to its source account.
   2705      * Typically it is set at the time the raw contact is inserted and never
   2706      * changed afterwards. The one notable exception is a new raw contact: it
   2707      * will have an account name and type (and possibly a data set), but no
   2708      * source id. This indicates to the sync adapter that a new contact needs
   2709      * to be created server-side and its ID stored in the corresponding
   2710      * SOURCE_ID field on the phone.
   2711      * </td>
   2712      * </tr>
   2713      * <tr>
   2714      * <td>int</td>
   2715      * <td>{@link #VERSION}</td>
   2716      * <td>read-only</td>
   2717      * <td>Version number that is updated whenever this row or its related data
   2718      * changes. This field can be used for optimistic locking of a raw contact.
   2719      * </td>
   2720      * </tr>
   2721      * <tr>
   2722      * <td>int</td>
   2723      * <td>{@link #DIRTY}</td>
   2724      * <td>read/write</td>
   2725      * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
   2726      * to be synchronized by its owning account.  The value is set to "1" automatically
   2727      * whenever the raw contact changes, unless the URI has the
   2728      * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
   2729      * The sync adapter should always supply this query parameter to prevent
   2730      * unnecessary synchronization: user changes some data on the server,
   2731      * the sync adapter updates the contact on the phone (without the
   2732      * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
   2733      * which triggers a sync to bring the changes to the server.
   2734      * </td>
   2735      * </tr>
   2736      * <tr>
   2737      * <td>String</td>
   2738      * <td>{@link #SYNC1}</td>
   2739      * <td>read/write</td>
   2740      * <td>Generic column provided for arbitrary use by sync adapters.
   2741      * The content provider
   2742      * stores this information on behalf of the sync adapter but does not
   2743      * interpret it in any way.
   2744      * </td>
   2745      * </tr>
   2746      * <tr>
   2747      * <td>String</td>
   2748      * <td>{@link #SYNC2}</td>
   2749      * <td>read/write</td>
   2750      * <td>Generic column for use by sync adapters.
   2751      * </td>
   2752      * </tr>
   2753      * <tr>
   2754      * <td>String</td>
   2755      * <td>{@link #SYNC3}</td>
   2756      * <td>read/write</td>
   2757      * <td>Generic column for use by sync adapters.
   2758      * </td>
   2759      * </tr>
   2760      * <tr>
   2761      * <td>String</td>
   2762      * <td>{@link #SYNC4}</td>
   2763      * <td>read/write</td>
   2764      * <td>Generic column for use by sync adapters.
   2765      * </td>
   2766      * </tr>
   2767      * </table>
   2768      */
   2769     public static final class RawContacts implements BaseColumns, RawContactsColumns,
   2770             ContactOptionsColumns, ContactNameColumns, SyncColumns  {
   2771         /**
   2772          * This utility class cannot be instantiated
   2773          */
   2774         private RawContacts() {
   2775         }
   2776 
   2777         /**
   2778          * The content:// style URI for this table, which requests a directory of
   2779          * raw contact rows matching the selection criteria.
   2780          */
   2781         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
   2782 
   2783         /**
   2784          * The MIME type of the results from {@link #CONTENT_URI} when a specific
   2785          * ID value is not provided, and multiple raw contacts may be returned.
   2786          */
   2787         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
   2788 
   2789         /**
   2790          * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
   2791          * yielding a subdirectory of a single person.
   2792          */
   2793         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
   2794 
   2795         /**
   2796          * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
   2797          */
   2798         public static final int AGGREGATION_MODE_DEFAULT = 0;
   2799 
   2800         /**
   2801          * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
   2802          * @deprecated Aggregation is synchronous, this historic value is a no-op
   2803          */
   2804         @Deprecated
   2805         public static final int AGGREGATION_MODE_IMMEDIATE = 1;
   2806 
   2807         /**
   2808          * <p>
   2809          * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
   2810          * Changes to the raw contact will update the associated aggregate contact but will not
   2811          * result in any change in how the contact is aggregated. Similar to
   2812          * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
   2813          * {@link Contacts} aggregate.
   2814          * </p>
   2815          * <p>
   2816          * This can be used to postpone aggregation until after a series of updates, for better
   2817          * performance and/or user experience.
   2818          * </p>
   2819          * <p>
   2820          * Note that changing
   2821          * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
   2822          * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
   2823          * subsequent
   2824          * change to the raw contact's data will.
   2825          * </p>
   2826          */
   2827         public static final int AGGREGATION_MODE_SUSPENDED = 2;
   2828 
   2829         /**
   2830          * <p>
   2831          * Aggregation mode: never aggregate this raw contact.  The raw contact will not
   2832          * have a corresponding {@link Contacts} aggregate and therefore will not be included in
   2833          * {@link Contacts} query results.
   2834          * </p>
   2835          * <p>
   2836          * For example, this mode can be used for a raw contact that is marked for deletion while
   2837          * waiting for the deletion to occur on the server side.
   2838          * </p>
   2839          *
   2840          * @see #AGGREGATION_MODE_SUSPENDED
   2841          */
   2842         public static final int AGGREGATION_MODE_DISABLED = 3;
   2843 
   2844         /**
   2845          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
   2846          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
   2847          * entry of the given {@link RawContacts} entry.
   2848          */
   2849         public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
   2850             // TODO: use a lighter query by joining rawcontacts with contacts in provider
   2851             final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
   2852             final Cursor cursor = resolver.query(dataUri, new String[] {
   2853                     RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
   2854             }, null, null, null);
   2855 
   2856             Uri lookupUri = null;
   2857             try {
   2858                 if (cursor != null && cursor.moveToFirst()) {
   2859                     final long contactId = cursor.getLong(0);
   2860                     final String lookupKey = cursor.getString(1);
   2861                     return Contacts.getLookupUri(contactId, lookupKey);
   2862                 }
   2863             } finally {
   2864                 if (cursor != null) cursor.close();
   2865             }
   2866             return lookupUri;
   2867         }
   2868 
   2869         /**
   2870          * A sub-directory of a single raw contact that contains all of its
   2871          * {@link ContactsContract.Data} rows. To access this directory
   2872          * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
   2873          */
   2874         public static final class Data implements BaseColumns, DataColumns {
   2875             /**
   2876              * no public constructor since this is a utility class
   2877              */
   2878             private Data() {
   2879             }
   2880 
   2881             /**
   2882              * The directory twig for this sub-table
   2883              */
   2884             public static final String CONTENT_DIRECTORY = "data";
   2885         }
   2886 
   2887         /**
   2888          * <p>
   2889          * A sub-directory of a single raw contact that contains all of its
   2890          * {@link ContactsContract.Data} rows. To access this directory append
   2891          * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
   2892          * {@link RawContactsEntity} for a stand-alone table containing the same
   2893          * data.
   2894          * </p>
   2895          * <p>
   2896          * Entity has two ID fields: {@link #_ID} for the raw contact
   2897          * and {@link #DATA_ID} for the data rows.
   2898          * Entity always contains at least one row, even if there are no
   2899          * actual data rows. In this case the {@link #DATA_ID} field will be
   2900          * null.
   2901          * </p>
   2902          * <p>
   2903          * Using Entity should be preferred to using two separate queries:
   2904          * RawContacts followed by Data. The reason is that Entity reads all
   2905          * data for a raw contact in one transaction, so there is no possibility
   2906          * of the data changing between the two queries.
   2907          */
   2908         public static final class Entity implements BaseColumns, DataColumns {
   2909             /**
   2910              * no public constructor since this is a utility class
   2911              */
   2912             private Entity() {
   2913             }
   2914 
   2915             /**
   2916              * The directory twig for this sub-table
   2917              */
   2918             public static final String CONTENT_DIRECTORY = "entity";
   2919 
   2920             /**
   2921              * The ID of the data row. The value will be null if this raw contact has no
   2922              * data rows.
   2923              * <P>Type: INTEGER</P>
   2924              */
   2925             public static final String DATA_ID = "data_id";
   2926         }
   2927 
   2928         /**
   2929          * <p>
   2930          * A sub-directory of a single raw contact that contains all of its
   2931          * {@link ContactsContract.StreamItems} rows. To access this directory append
   2932          * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
   2933          * {@link ContactsContract.StreamItems} for a stand-alone table containing the
   2934          * same data.
   2935          * </p>
   2936          * <p>
   2937          * Access to the social stream through this sub-directory requires additional permissions
   2938          * beyond the read/write contact permissions required by the provider.  Querying for
   2939          * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
   2940          * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
   2941          * permission.
   2942          * </p>
   2943          *
   2944          * @deprecated - Do not use. This will not be supported in the future. In the future,
   2945          * cursors returned from related queries will be empty.
   2946          *
   2947          * @hide
   2948          * @removed
   2949          */
   2950         @Deprecated
   2951         public static final class StreamItems implements BaseColumns, StreamItemsColumns {
   2952             /**
   2953              * No public constructor since this is a utility class
   2954              *
   2955              * @deprecated - Do not use. This will not be supported in the future. In the future,
   2956              * cursors returned from related queries will be empty.
   2957              */
   2958             @Deprecated
   2959             private StreamItems() {
   2960             }
   2961 
   2962             /**
   2963              * The directory twig for this sub-table
   2964              *
   2965              * @deprecated - Do not use. This will not be supported in the future. In the future,
   2966              * cursors returned from related queries will be empty.
   2967              */
   2968             @Deprecated
   2969             public static final String CONTENT_DIRECTORY = "stream_items";
   2970         }
   2971 
   2972         /**
   2973          * <p>
   2974          * A sub-directory of a single raw contact that represents its primary
   2975          * display photo.  To access this directory append
   2976          * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
   2977          * The resulting URI represents an image file, and should be interacted with
   2978          * using ContentResolver.openAssetFileDescriptor.
   2979          * <p>
   2980          * <p>
   2981          * Note that this sub-directory also supports opening the photo as an asset file
   2982          * in write mode.  Callers can create or replace the primary photo associated
   2983          * with this raw contact by opening the asset file and writing the full-size
   2984          * photo contents into it.  When the file is closed, the image will be parsed,
   2985          * sized down if necessary for the full-size display photo and thumbnail
   2986          * dimensions, and stored.
   2987          * </p>
   2988          * <p>
   2989          * Usage example:
   2990          * <pre>
   2991          * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
   2992          *     Uri rawContactPhotoUri = Uri.withAppendedPath(
   2993          *             ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
   2994          *             RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
   2995          *     try {
   2996          *         AssetFileDescriptor fd =
   2997          *             getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
   2998          *         OutputStream os = fd.createOutputStream();
   2999          *         os.write(photo);
   3000          *         os.close();
   3001          *         fd.close();
   3002          *     } catch (IOException e) {
   3003          *         // Handle error cases.
   3004          *     }
   3005          * }
   3006          * </pre>
   3007          * </p>
   3008          */
   3009         public static final class DisplayPhoto {
   3010             /**
   3011              * No public constructor since this is a utility class
   3012              */
   3013             private DisplayPhoto() {
   3014             }
   3015 
   3016             /**
   3017              * The directory twig for this sub-table
   3018              */
   3019             public static final String CONTENT_DIRECTORY = "display_photo";
   3020         }
   3021 
   3022         /**
   3023          * TODO: javadoc
   3024          * @param cursor
   3025          * @return
   3026          */
   3027         public static EntityIterator newEntityIterator(Cursor cursor) {
   3028             return new EntityIteratorImpl(cursor);
   3029         }
   3030 
   3031         private static class EntityIteratorImpl extends CursorEntityIterator {
   3032             private static final String[] DATA_KEYS = new String[]{
   3033                     Data.DATA1,
   3034                     Data.DATA2,
   3035                     Data.DATA3,
   3036                     Data.DATA4,
   3037                     Data.DATA5,
   3038                     Data.DATA6,
   3039                     Data.DATA7,
   3040                     Data.DATA8,
   3041                     Data.DATA9,
   3042                     Data.DATA10,
   3043                     Data.DATA11,
   3044                     Data.DATA12,
   3045                     Data.DATA13,
   3046                     Data.DATA14,
   3047                     Data.DATA15,
   3048                     Data.SYNC1,
   3049                     Data.SYNC2,
   3050                     Data.SYNC3,
   3051                     Data.SYNC4};
   3052 
   3053             public EntityIteratorImpl(Cursor cursor) {
   3054                 super(cursor);
   3055             }
   3056 
   3057             @Override
   3058             public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
   3059                     throws RemoteException {
   3060                 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
   3061                 final long rawContactId = cursor.getLong(columnRawContactId);
   3062 
   3063                 // we expect the cursor is already at the row we need to read from
   3064                 ContentValues cv = new ContentValues();
   3065                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
   3066                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
   3067                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
   3068                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
   3069                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
   3070                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
   3071                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
   3072                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
   3073                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
   3074                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
   3075                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
   3076                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
   3077                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
   3078                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
   3079                 android.content.Entity contact = new android.content.Entity(cv);
   3080 
   3081                 // read data rows until the contact id changes
   3082                 do {
   3083                     if (rawContactId != cursor.getLong(columnRawContactId)) {
   3084                         break;
   3085                     }
   3086                     // add the data to to the contact
   3087                     cv = new ContentValues();
   3088                     cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
   3089                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
   3090                             Data.RES_PACKAGE);
   3091                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
   3092                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
   3093                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
   3094                             Data.IS_SUPER_PRIMARY);
   3095                     DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
   3096                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
   3097                             CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
   3098                     DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
   3099                             Data.DATA_VERSION);
   3100                     for (String key : DATA_KEYS) {
   3101                         final int columnIndex = cursor.getColumnIndexOrThrow(key);
   3102                         switch (cursor.getType(columnIndex)) {
   3103                             case Cursor.FIELD_TYPE_NULL:
   3104                                 // don't put anything
   3105                                 break;
   3106                             case Cursor.FIELD_TYPE_INTEGER:
   3107                             case Cursor.FIELD_TYPE_FLOAT:
   3108                             case Cursor.FIELD_TYPE_STRING:
   3109                                 cv.put(key, cursor.getString(columnIndex));
   3110                                 break;
   3111                             case Cursor.FIELD_TYPE_BLOB:
   3112                                 cv.put(key, cursor.getBlob(columnIndex));
   3113                                 break;
   3114                             default:
   3115                                 throw new IllegalStateException("Invalid or unhandled data type");
   3116                         }
   3117                     }
   3118                     contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
   3119                 } while (cursor.moveToNext());
   3120 
   3121                 return contact;
   3122             }
   3123 
   3124         }
   3125     }
   3126 
   3127     /**
   3128      * Social status update columns.
   3129      *
   3130      * @see StatusUpdates
   3131      * @see ContactsContract.Data
   3132      */
   3133     protected interface StatusColumns {
   3134         /**
   3135          * Contact's latest presence level.
   3136          * <P>Type: INTEGER (one of the values below)</P>
   3137          */
   3138         public static final String PRESENCE = "mode";
   3139 
   3140         /**
   3141          * @deprecated use {@link #PRESENCE}
   3142          */
   3143         @Deprecated
   3144         public static final String PRESENCE_STATUS = PRESENCE;
   3145 
   3146         /**
   3147          * An allowed value of {@link #PRESENCE}.
   3148          */
   3149         int OFFLINE = 0;
   3150 
   3151         /**
   3152          * An allowed value of {@link #PRESENCE}.
   3153          */
   3154         int INVISIBLE = 1;
   3155 
   3156         /**
   3157          * An allowed value of {@link #PRESENCE}.
   3158          */
   3159         int AWAY = 2;
   3160 
   3161         /**
   3162          * An allowed value of {@link #PRESENCE}.
   3163          */
   3164         int IDLE = 3;
   3165 
   3166         /**
   3167          * An allowed value of {@link #PRESENCE}.
   3168          */
   3169         int DO_NOT_DISTURB = 4;
   3170 
   3171         /**
   3172          * An allowed value of {@link #PRESENCE}.
   3173          */
   3174         int AVAILABLE = 5;
   3175 
   3176         /**
   3177          * Contact latest status update.
   3178          * <p>Type: TEXT</p>
   3179          */
   3180         public static final String STATUS = "status";
   3181 
   3182         /**
   3183          * @deprecated use {@link #STATUS}
   3184          */
   3185         @Deprecated
   3186         public static final String PRESENCE_CUSTOM_STATUS = STATUS;
   3187 
   3188         /**
   3189          * The absolute time in milliseconds when the latest status was inserted/updated.
   3190          * <p>Type: NUMBER</p>
   3191          */
   3192         public static final String STATUS_TIMESTAMP = "status_ts";
   3193 
   3194         /**
   3195          * The package containing resources for this status: label and icon.
   3196          * <p>Type: TEXT</p>
   3197          */
   3198         public static final String STATUS_RES_PACKAGE = "status_res_package";
   3199 
   3200         /**
   3201          * The resource ID of the label describing the source of the status update, e.g. "Google
   3202          * Talk".  This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
   3203          * <p>Type: NUMBER</p>
   3204          */
   3205         public static final String STATUS_LABEL = "status_label";
   3206 
   3207         /**
   3208          * The resource ID of the icon for the source of the status update.
   3209          * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
   3210          * <p>Type: NUMBER</p>
   3211          */
   3212         public static final String STATUS_ICON = "status_icon";
   3213 
   3214         /**
   3215          * Contact's audio/video chat capability level.
   3216          * <P>Type: INTEGER (one of the values below)</P>
   3217          */
   3218         public static final String CHAT_CAPABILITY = "chat_capability";
   3219 
   3220         /**
   3221          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
   3222          * and speaker)
   3223          */
   3224         public static final int CAPABILITY_HAS_VOICE = 1;
   3225 
   3226         /**
   3227          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
   3228          * display a video feed.
   3229          */
   3230         public static final int CAPABILITY_HAS_VIDEO = 2;
   3231 
   3232         /**
   3233          * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
   3234          * camera that can be used for video chat (e.g. a front-facing camera on a phone).
   3235          */
   3236         public static final int CAPABILITY_HAS_CAMERA = 4;
   3237     }
   3238 
   3239     /**
   3240      * <p>
   3241      * Constants for the stream_items table, which contains social stream updates from
   3242      * the user's contact list.
   3243      * </p>
   3244      * <p>
   3245      * Only a certain number of stream items will ever be stored under a given raw contact.
   3246      * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
   3247      * determine this limit, and should restrict the number of items inserted in any given
   3248      * transaction correspondingly.  Insertion of more items beyond the limit will
   3249      * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
   3250      * </p>
   3251      * <p>
   3252      * Access to the social stream through these URIs requires additional permissions beyond the
   3253      * read/write contact permissions required by the provider.  Querying for social stream data
   3254      * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
   3255      * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
   3256      * </p>
   3257      * <h3>Account check</h3>
   3258      * <p>
   3259      * The content URIs to the insert, update and delete operations are required to have the account
   3260      * information matching that of the owning raw contact as query parameters, namely
   3261      * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
   3262      * {@link RawContacts#DATA_SET} isn't required.
   3263      * </p>
   3264      * <h3>Operations</h3>
   3265      * <dl>
   3266      * <dt><b>Insert</b></dt>
   3267      * <dd>
   3268      * <p>Social stream updates are always associated with a raw contact.  There are a couple
   3269      * of ways to insert these entries.
   3270      * <dl>
   3271      * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
   3272      * <dd>
   3273      * <pre>
   3274      * ContentValues values = new ContentValues();
   3275      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
   3276      * values.put(StreamItems.TIMESTAMP, timestamp);
   3277      * values.put(StreamItems.COMMENTS, "3 people reshared this");
   3278      * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
   3279      * ContentUris.appendId(builder, rawContactId);
   3280      * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
   3281      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3282      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3283      * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
   3284      * long streamItemId = ContentUris.parseId(streamItemUri);
   3285      * </pre>
   3286      * </dd>
   3287      * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
   3288      * <dd>
   3289      *<pre>
   3290      * ContentValues values = new ContentValues();
   3291      * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
   3292      * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
   3293      * values.put(StreamItems.TIMESTAMP, timestamp);
   3294      * values.put(StreamItems.COMMENTS, "3 people reshared this");
   3295      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3296      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3297      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3298      * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
   3299      * long streamItemId = ContentUris.parseId(streamItemUri);
   3300      *</pre>
   3301      * </dd>
   3302      * </dl>
   3303      * </dd>
   3304      * </p>
   3305      * <p>
   3306      * Once a {@link StreamItems} entry has been inserted, photos associated with that
   3307      * social update can be inserted.  For example, after one of the insertions above,
   3308      * photos could be added to the stream item in one of the following ways:
   3309      * <dl>
   3310      * <dt>Via a URI including the stream item ID:</dt>
   3311      * <dd>
   3312      * <pre>
   3313      * values.clear();
   3314      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3315      * values.put(StreamItemPhotos.PHOTO, photoData);
   3316      * getContentResolver().insert(Uri.withAppendedPath(
   3317      *     ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
   3318      *     StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
   3319      * </pre>
   3320      * </dd>
   3321      * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
   3322      * <dd>
   3323      * <pre>
   3324      * values.clear();
   3325      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
   3326      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3327      * values.put(StreamItemPhotos.PHOTO, photoData);
   3328      * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
   3329      * </pre>
   3330      * <p>Note that this latter form allows the insertion of a stream item and its
   3331      * photos in a single transaction, by using {@link ContentProviderOperation} with
   3332      * back references to populate the stream item ID in the {@link ContentValues}.
   3333      * </dd>
   3334      * </dl>
   3335      * </p>
   3336      * </dd>
   3337      * <dt><b>Update</b></dt>
   3338      * <dd>Updates can be performed by appending the stream item ID to the
   3339      * {@link StreamItems#CONTENT_URI} URI.  Only social stream entries that were
   3340      * created by the calling package can be updated.</dd>
   3341      * <dt><b>Delete</b></dt>
   3342      * <dd>Deletes can be performed by appending the stream item ID to the
   3343      * {@link StreamItems#CONTENT_URI} URI.  Only social stream entries that were
   3344      * created by the calling package can be deleted.</dd>
   3345      * <dt><b>Query</b></dt>
   3346      * <dl>
   3347      * <dt>Finding all social stream updates for a given contact</dt>
   3348      * <dd>By Contact ID:
   3349      * <pre>
   3350      * Cursor c = getContentResolver().query(Uri.withAppendedPath(
   3351      *          ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
   3352      *          Contacts.StreamItems.CONTENT_DIRECTORY),
   3353      *          null, null, null, null);
   3354      * </pre>
   3355      * </dd>
   3356      * <dd>By lookup key:
   3357      * <pre>
   3358      * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
   3359      *          .appendPath(lookupKey)
   3360      *          .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
   3361      *          null, null, null, null);
   3362      * </pre>
   3363      * </dd>
   3364      * <dt>Finding all social stream updates for a given raw contact</dt>
   3365      * <dd>
   3366      * <pre>
   3367      * Cursor c = getContentResolver().query(Uri.withAppendedPath(
   3368      *          ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
   3369      *          RawContacts.StreamItems.CONTENT_DIRECTORY)),
   3370      *          null, null, null, null);
   3371      * </pre>
   3372      * </dd>
   3373      * <dt>Querying for a specific stream item by ID</dt>
   3374      * <dd>
   3375      * <pre>
   3376      * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
   3377      *          StreamItems.CONTENT_URI, streamItemId),
   3378      *          null, null, null, null);
   3379      * </pre>
   3380      * </dd>
   3381      * </dl>
   3382      *
   3383      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3384      * cursors returned from related queries will be empty.
   3385      *
   3386      * @hide
   3387      * @removed
   3388      */
   3389     @Deprecated
   3390     public static final class StreamItems implements BaseColumns, StreamItemsColumns {
   3391         /**
   3392          * This utility class cannot be instantiated
   3393          *
   3394          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3395          * cursors returned from related queries will be empty.
   3396          */
   3397         @Deprecated
   3398         private StreamItems() {
   3399         }
   3400 
   3401         /**
   3402          * The content:// style URI for this table, which handles social network stream
   3403          * updates for the user's contacts.
   3404          *
   3405          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3406          * cursors returned from related queries will be empty.
   3407          */
   3408         @Deprecated
   3409         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
   3410 
   3411         /**
   3412          * <p>
   3413          * A content:// style URI for the photos stored in a sub-table underneath
   3414          * stream items.  This is only used for inserts, and updates - queries and deletes
   3415          * for photos should be performed by appending
   3416          * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
   3417          * specific stream item.
   3418          * </p>
   3419          * <p>
   3420          * When using this URI, the stream item ID for the photo(s) must be identified
   3421          * in the {@link ContentValues} passed in.
   3422          * </p>
   3423          *
   3424          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3425          * cursors returned from related queries will be empty.
   3426          */
   3427         @Deprecated
   3428         public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
   3429 
   3430         /**
   3431          * This URI allows the caller to query for the maximum number of stream items
   3432          * that will be stored under any single raw contact.
   3433          *
   3434          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3435          * cursors returned from related queries will be empty.
   3436          */
   3437         @Deprecated
   3438         public static final Uri CONTENT_LIMIT_URI =
   3439                 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
   3440 
   3441         /**
   3442          * The MIME type of a directory of stream items.
   3443          *
   3444          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3445          * cursors returned from related queries will be empty.
   3446          */
   3447         @Deprecated
   3448         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
   3449 
   3450         /**
   3451          * The MIME type of a single stream item.
   3452          *
   3453          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3454          * cursors returned from related queries will be empty.
   3455          */
   3456         @Deprecated
   3457         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
   3458 
   3459         /**
   3460          * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
   3461          * contain this column, with the value indicating the maximum number of
   3462          * stream items that will be stored under any single raw contact.
   3463          *
   3464          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3465          * cursors returned from related queries will be empty.
   3466          */
   3467         @Deprecated
   3468         public static final String MAX_ITEMS = "max_items";
   3469 
   3470         /**
   3471          * <p>
   3472          * A sub-directory of a single stream item entry that contains all of its
   3473          * photo rows. To access this
   3474          * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
   3475          * an individual stream item URI.
   3476          * </p>
   3477          * <p>
   3478          * Access to social stream photos requires additional permissions beyond the read/write
   3479          * contact permissions required by the provider.  Querying for social stream photos
   3480          * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
   3481          * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
   3482          * </p>
   3483          *
   3484          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3485          * cursors returned from related queries will be empty.
   3486          *
   3487          * @hide
   3488          * @removed
   3489          */
   3490         @Deprecated
   3491         public static final class StreamItemPhotos
   3492                 implements BaseColumns, StreamItemPhotosColumns {
   3493             /**
   3494              * No public constructor since this is a utility class
   3495              *
   3496              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3497              * cursors returned from related queries will be empty.
   3498              */
   3499             @Deprecated
   3500             private StreamItemPhotos() {
   3501             }
   3502 
   3503             /**
   3504              * The directory twig for this sub-table
   3505              *
   3506              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3507              * cursors returned from related queries will be empty.
   3508              */
   3509             @Deprecated
   3510             public static final String CONTENT_DIRECTORY = "photo";
   3511 
   3512             /**
   3513              * The MIME type of a directory of stream item photos.
   3514              *
   3515              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3516              * cursors returned from related queries will be empty.
   3517              */
   3518             @Deprecated
   3519             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
   3520 
   3521             /**
   3522              * The MIME type of a single stream item photo.
   3523              *
   3524              * @deprecated - Do not use. This will not be supported in the future. In the future,
   3525              * cursors returned from related queries will be empty.
   3526              */
   3527             @Deprecated
   3528             public static final String CONTENT_ITEM_TYPE
   3529                     = "vnd.android.cursor.item/stream_item_photo";
   3530         }
   3531     }
   3532 
   3533     /**
   3534      * Columns in the StreamItems table.
   3535      *
   3536      * @see ContactsContract.StreamItems
   3537      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3538      * cursors returned from related queries will be empty.
   3539      *
   3540      * @hide
   3541      * @removed
   3542      */
   3543     @Deprecated
   3544     protected interface StreamItemsColumns {
   3545         /**
   3546          * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
   3547          * that this stream item belongs to.
   3548          *
   3549          * <p>Type: INTEGER</p>
   3550          * <p>read-only</p>
   3551          *
   3552          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3553          * cursors returned from related queries will be empty.
   3554          */
   3555         @Deprecated
   3556         public static final String CONTACT_ID = "contact_id";
   3557 
   3558         /**
   3559          * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
   3560          * that this stream item belongs to.
   3561          *
   3562          * <p>Type: TEXT</p>
   3563          * <p>read-only</p>
   3564          *
   3565          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3566          * cursors returned from related queries will be empty.
   3567          */
   3568         @Deprecated
   3569         public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
   3570 
   3571         /**
   3572          * A reference to the {@link RawContacts#_ID}
   3573          * that this stream item belongs to.
   3574          * <p>Type: INTEGER</p>
   3575          *
   3576          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3577          * cursors returned from related queries will be empty.
   3578          */
   3579         @Deprecated
   3580         public static final String RAW_CONTACT_ID = "raw_contact_id";
   3581 
   3582         /**
   3583          * The package name to use when creating {@link Resources} objects for
   3584          * this stream item. This value is only designed for use when building
   3585          * user interfaces, and should not be used to infer the owner.
   3586          * <P>Type: TEXT</P>
   3587          *
   3588          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3589          * cursors returned from related queries will be empty.
   3590          */
   3591         @Deprecated
   3592         public static final String RES_PACKAGE = "res_package";
   3593 
   3594         /**
   3595          * The account type to which the raw_contact of this item is associated. See
   3596          * {@link RawContacts#ACCOUNT_TYPE}
   3597          *
   3598          * <p>Type: TEXT</p>
   3599          * <p>read-only</p>
   3600          *
   3601          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3602          * cursors returned from related queries will be empty.
   3603          */
   3604         @Deprecated
   3605         public static final String ACCOUNT_TYPE = "account_type";
   3606 
   3607         /**
   3608          * The account name to which the raw_contact of this item is associated. See
   3609          * {@link RawContacts#ACCOUNT_NAME}
   3610          *
   3611          * <p>Type: TEXT</p>
   3612          * <p>read-only</p>
   3613          *
   3614          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3615          * cursors returned from related queries will be empty.
   3616          */
   3617         @Deprecated
   3618         public static final String ACCOUNT_NAME = "account_name";
   3619 
   3620         /**
   3621          * The data set within the account that the raw_contact of this row belongs to. This allows
   3622          * multiple sync adapters for the same account type to distinguish between
   3623          * each others' data.
   3624          * {@link RawContacts#DATA_SET}
   3625          *
   3626          * <P>Type: TEXT</P>
   3627          * <p>read-only</p>
   3628          *
   3629          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3630          * cursors returned from related queries will be empty.
   3631          */
   3632         @Deprecated
   3633         public static final String DATA_SET = "data_set";
   3634 
   3635         /**
   3636          * The source_id of the raw_contact that this row belongs to.
   3637          * {@link RawContacts#SOURCE_ID}
   3638          *
   3639          * <P>Type: TEXT</P>
   3640          * <p>read-only</p>
   3641          *
   3642          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3643          * cursors returned from related queries will be empty.
   3644          */
   3645         @Deprecated
   3646         public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
   3647 
   3648         /**
   3649          * The resource name of the icon for the source of the stream item.
   3650          * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
   3651          * drawables, the "@drawable/" prefix must be omitted.
   3652          * <P>Type: TEXT</P>
   3653          *
   3654          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3655          * cursors returned from related queries will be empty.
   3656          */
   3657         @Deprecated
   3658         public static final String RES_ICON = "icon";
   3659 
   3660         /**
   3661          * The resource name of the label describing the source of the status update, e.g. "Google
   3662          * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
   3663          * reference strings, the "@string/" prefix must be omitted.
   3664          * <p>Type: TEXT</p>
   3665          *
   3666          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3667          * cursors returned from related queries will be empty.
   3668          */
   3669         @Deprecated
   3670         public static final String RES_LABEL = "label";
   3671 
   3672         /**
   3673          * <P>
   3674          * The main textual contents of the item. Typically this is content
   3675          * that was posted by the source of this stream item, but it can also
   3676          * be a textual representation of an action (e.g. Checked in at Joe's).
   3677          * This text is displayed to the user and allows formatting and embedded
   3678          * resource images via HTML (as parseable via
   3679          * {@link android.text.Html#fromHtml}).
   3680          * </P>
   3681          * <P>
   3682          * Long content may be truncated and/or ellipsized - the exact behavior
   3683          * is unspecified, but it should not break tags.
   3684          * </P>
   3685          * <P>Type: TEXT</P>
   3686          *
   3687          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3688          * cursors returned from related queries will be empty.
   3689          */
   3690         @Deprecated
   3691         public static final String TEXT = "text";
   3692 
   3693         /**
   3694          * The absolute time (milliseconds since epoch) when this stream item was
   3695          * inserted/updated.
   3696          * <P>Type: NUMBER</P>
   3697          *
   3698          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3699          * cursors returned from related queries will be empty.
   3700          */
   3701         @Deprecated
   3702         public static final String TIMESTAMP = "timestamp";
   3703 
   3704         /**
   3705          * <P>
   3706          * Summary information about the stream item, for example to indicate how
   3707          * many people have reshared it, how many have liked it, how many thumbs
   3708          * up and/or thumbs down it has, what the original source was, etc.
   3709          * </P>
   3710          * <P>
   3711          * This text is displayed to the user and allows simple formatting via
   3712          * HTML, in the same manner as {@link #TEXT} allows.
   3713          * </P>
   3714          * <P>
   3715          * Long content may be truncated and/or ellipsized - the exact behavior
   3716          * is unspecified, but it should not break tags.
   3717          * </P>
   3718          * <P>Type: TEXT</P>
   3719          *
   3720          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3721          * cursors returned from related queries will be empty.
   3722          */
   3723         @Deprecated
   3724         public static final String COMMENTS = "comments";
   3725 
   3726         /**
   3727          * Generic column for use by sync adapters.
   3728          *
   3729          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3730          * cursors returned from related queries will be empty.
   3731          */
   3732         @Deprecated
   3733         public static final String SYNC1 = "stream_item_sync1";
   3734         /**
   3735          * Generic column for use by sync adapters.
   3736          *
   3737          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3738          * cursors returned from related queries will be empty.
   3739          */
   3740         @Deprecated
   3741         public static final String SYNC2 = "stream_item_sync2";
   3742         /**
   3743          * Generic column for use by sync adapters.
   3744          *
   3745          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3746          * cursors returned from related queries will be empty.
   3747          */
   3748         @Deprecated
   3749         public static final String SYNC3 = "stream_item_sync3";
   3750         /**
   3751          * Generic column for use by sync adapters.
   3752          *
   3753          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3754          * cursors returned from related queries will be empty.
   3755          */
   3756         @Deprecated
   3757         public static final String SYNC4 = "stream_item_sync4";
   3758     }
   3759 
   3760     /**
   3761      * <p>
   3762      * Constants for the stream_item_photos table, which contains photos associated with
   3763      * social stream updates.
   3764      * </p>
   3765      * <p>
   3766      * Access to social stream photos requires additional permissions beyond the read/write
   3767      * contact permissions required by the provider.  Querying for social stream photos
   3768      * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
   3769      * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
   3770      * </p>
   3771      * <h3>Account check</h3>
   3772      * <p>
   3773      * The content URIs to the insert, update and delete operations are required to have the account
   3774      * information matching that of the owning raw contact as query parameters, namely
   3775      * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
   3776      * {@link RawContacts#DATA_SET} isn't required.
   3777      * </p>
   3778      * <h3>Operations</h3>
   3779      * <dl>
   3780      * <dt><b>Insert</b></dt>
   3781      * <dd>
   3782      * <p>Social stream photo entries are associated with a social stream item.  Photos
   3783      * can be inserted into a social stream item in a couple of ways:
   3784      * <dl>
   3785      * <dt>
   3786      * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
   3787      * stream item:
   3788      * </dt>
   3789      * <dd>
   3790      * <pre>
   3791      * ContentValues values = new ContentValues();
   3792      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3793      * values.put(StreamItemPhotos.PHOTO, photoData);
   3794      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3795      * ContentUris.appendId(builder, streamItemId);
   3796      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3797      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3798      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3799      * Uri photoUri = getContentResolver().insert(builder.build(), values);
   3800      * long photoId = ContentUris.parseId(photoUri);
   3801      * </pre>
   3802      * </dd>
   3803      * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
   3804      * <dd>
   3805      * <pre>
   3806      * ContentValues values = new ContentValues();
   3807      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
   3808      * values.put(StreamItemPhotos.SORT_INDEX, 1);
   3809      * values.put(StreamItemPhotos.PHOTO, photoData);
   3810      * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
   3811      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3812      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3813      * Uri photoUri = getContentResolver().insert(builder.build(), values);
   3814      * long photoId = ContentUris.parseId(photoUri);
   3815      * </pre>
   3816      * </dd>
   3817      * </dl>
   3818      * </p>
   3819      * </dd>
   3820      * <dt><b>Update</b></dt>
   3821      * <dd>
   3822      * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
   3823      * identified by both the stream item ID it belongs to and the stream item photo ID.
   3824      * This can be specified in two ways.
   3825      * <dl>
   3826      * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
   3827      * stream item:
   3828      * </dt>
   3829      * <dd>
   3830      * <pre>
   3831      * ContentValues values = new ContentValues();
   3832      * values.put(StreamItemPhotos.PHOTO, newPhotoData);
   3833      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3834      * ContentUris.appendId(builder, streamItemId);
   3835      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3836      * ContentUris.appendId(builder, streamItemPhotoId);
   3837      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3838      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3839      * getContentResolver().update(builder.build(), values, null, null);
   3840      * </pre>
   3841      * </dd>
   3842      * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
   3843      * <dd>
   3844      * <pre>
   3845      * ContentValues values = new ContentValues();
   3846      * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
   3847      * values.put(StreamItemPhotos.PHOTO, newPhotoData);
   3848      * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
   3849      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3850      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3851      * getContentResolver().update(builder.build(), values);
   3852      * </pre>
   3853      * </dd>
   3854      * </dl>
   3855      * </p>
   3856      * </dd>
   3857      * <dt><b>Delete</b></dt>
   3858      * <dd>Deletes can be made against either a specific photo item in a stream item, or
   3859      * against all or a selected subset of photo items under a stream item.
   3860      * For example:
   3861      * <dl>
   3862      * <dt>Deleting a single photo via the
   3863      * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
   3864      * </dt>
   3865      * <dd>
   3866      * <pre>
   3867      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3868      * ContentUris.appendId(builder, streamItemId);
   3869      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3870      * ContentUris.appendId(builder, streamItemPhotoId);
   3871      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3872      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3873      * getContentResolver().delete(builder.build(), null, null);
   3874      * </pre>
   3875      * </dd>
   3876      * <dt>Deleting all photos under a stream item</dt>
   3877      * <dd>
   3878      * <pre>
   3879      * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
   3880      * ContentUris.appendId(builder, streamItemId);
   3881      * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
   3882      * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
   3883      * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
   3884      * getContentResolver().delete(builder.build(), null, null);
   3885      * </pre>
   3886      * </dd>
   3887      * </dl>
   3888      * </dd>
   3889      * <dt><b>Query</b></dt>
   3890      * <dl>
   3891      * <dt>Querying for a specific photo in a stream item</dt>
   3892      * <dd>
   3893      * <pre>
   3894      * Cursor c = getContentResolver().query(
   3895      *     ContentUris.withAppendedId(
   3896      *         Uri.withAppendedPath(
   3897      *             ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
   3898      *             StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
   3899      *         streamItemPhotoId), null, null, null, null);
   3900      * </pre>
   3901      * </dd>
   3902      * <dt>Querying for all photos in a stream item</dt>
   3903      * <dd>
   3904      * <pre>
   3905      * Cursor c = getContentResolver().query(
   3906      *     Uri.withAppendedPath(
   3907      *         ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
   3908      *         StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
   3909      *     null, null, null, StreamItemPhotos.SORT_INDEX);
   3910      * </pre>
   3911      * </dl>
   3912      * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
   3913      * {@link StreamItemPhotos#PHOTO_URI}.  The {@link StreamItemPhotos#PHOTO_FILE_ID}
   3914      * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
   3915      * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
   3916      * an asset file, as follows:
   3917      * <pre>
   3918      * public InputStream openDisplayPhoto(String photoUri) {
   3919      *     try {
   3920      *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
   3921      *         return fd.createInputStream();
   3922      *     } catch (IOException e) {
   3923      *         return null;
   3924      *     }
   3925      * }
   3926      * <pre>
   3927      * </dd>
   3928      * </dl>
   3929      *
   3930      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3931      * cursors returned from related queries will be empty.
   3932      *
   3933      * @hide
   3934      * @removed
   3935      */
   3936     @Deprecated
   3937     public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
   3938         /**
   3939          * No public constructor since this is a utility class
   3940          *
   3941          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3942          * cursors returned from related queries will be empty.
   3943          */
   3944         @Deprecated
   3945         private StreamItemPhotos() {
   3946         }
   3947 
   3948         /**
   3949          * <p>
   3950          * The binary representation of the photo.  Any size photo can be inserted;
   3951          * the provider will resize it appropriately for storage and display.
   3952          * </p>
   3953          * <p>
   3954          * This is only intended for use when inserting or updating a stream item photo.
   3955          * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
   3956          * as an asset file.
   3957          * </p>
   3958          * <P>Type: BLOB</P>
   3959          *
   3960          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3961          * cursors returned from related queries will be empty.
   3962          */
   3963         @Deprecated
   3964         public static final String PHOTO = "photo";
   3965     }
   3966 
   3967     /**
   3968      * Columns in the StreamItemPhotos table.
   3969      *
   3970      * @see ContactsContract.StreamItemPhotos
   3971      * @deprecated - Do not use. This will not be supported in the future. In the future,
   3972      * cursors returned from related queries will be empty.
   3973      *
   3974      * @hide
   3975      * @removed
   3976      */
   3977     @Deprecated
   3978     protected interface StreamItemPhotosColumns {
   3979         /**
   3980          * A reference to the {@link StreamItems#_ID} this photo is associated with.
   3981          * <P>Type: NUMBER</P>
   3982          *
   3983          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3984          * cursors returned from related queries will be empty.
   3985          */
   3986         @Deprecated
   3987         public static final String STREAM_ITEM_ID = "stream_item_id";
   3988 
   3989         /**
   3990          * An integer to use for sort order for photos in the stream item.  If not
   3991          * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
   3992          * <P>Type: NUMBER</P>
   3993          *
   3994          * @deprecated - Do not use. This will not be supported in the future. In the future,
   3995          * cursors returned from related queries will be empty.
   3996          */
   3997         @Deprecated
   3998         public static final String SORT_INDEX = "sort_index";
   3999 
   4000         /**
   4001          * Photo file ID for the photo.
   4002          * See {@link ContactsContract.DisplayPhoto}.
   4003          * <P>Type: NUMBER</P>
   4004          *
   4005          * @deprecated - Do not use. This will not be supported in the future. In the future,
   4006          * cursors returned from related queries will be empty.
   4007          */
   4008         @Deprecated
   4009         public static final String PHOTO_FILE_ID = "photo_file_id";
   4010 
   4011         /**
   4012          * URI for retrieving the photo content, automatically populated.  Callers
   4013          * may retrieve the photo content by opening this URI as an asset file.
   4014          * <P>Type: TEXT</P>
   4015          *
   4016          * @deprecated - Do not use. This will not be supported in the future. In the future,
   4017          * cursors returned from related queries will be empty.
   4018          */
   4019         @Deprecated
   4020         public static final String PHOTO_URI = "photo_uri";
   4021 
   4022         /**
   4023          * Generic column for use by sync adapters.
   4024          *
   4025          * @deprecated - Do not use. This will not be supported in the future. In the future,
   4026          * cursors returned from related queries will be empty.
   4027          */
   4028         @Deprecated
   4029         public static final String SYNC1 = "stream_item_photo_sync1";
   4030         /**
   4031          * Generic column for use by sync adapters.
   4032          *
   4033          * @deprecated - Do not use. This will not be supported in the future. In the future,
   4034          * cursors returned from related queries will be empty.
   4035          */
   4036         @Deprecated
   4037         public static final String SYNC2 = "stream_item_photo_sync2";
   4038         /**
   4039          * Generic column for use by sync adapters.
   4040          *
   4041          * @deprecated - Do not use. This will not be supported in the future. In the future,
   4042          * cursors returned from related queries will be empty.
   4043          */
   4044         @Deprecated
   4045         public static final String SYNC3 = "stream_item_photo_sync3";
   4046         /**
   4047          * Generic column for use by sync adapters.
   4048          *
   4049          * @deprecated - Do not use. This will not be supported in the future. In the future,
   4050          * cursors returned from related queries will be empty.
   4051          */
   4052         @Deprecated
   4053         public static final String SYNC4 = "stream_item_photo_sync4";
   4054     }
   4055 
   4056     /**
   4057      * <p>
   4058      * Constants for the photo files table, which tracks metadata for hi-res photos
   4059      * stored in the file system.
   4060      * </p>
   4061      *
   4062      * @hide
   4063      */
   4064     public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
   4065         /**
   4066          * No public constructor since this is a utility class
   4067          */
   4068         private PhotoFiles() {
   4069         }
   4070     }
   4071 
   4072     /**
   4073      * Columns in the PhotoFiles table.
   4074      *
   4075      * @see ContactsContract.PhotoFiles
   4076      *
   4077      * @hide
   4078      */
   4079     protected interface PhotoFilesColumns {
   4080 
   4081         /**
   4082          * The height, in pixels, of the photo this entry is associated with.
   4083          * <P>Type: NUMBER</P>
   4084          */
   4085         public static final String HEIGHT = "height";
   4086 
   4087         /**
   4088          * The width, in pixels, of the photo this entry is associated with.
   4089          * <P>Type: NUMBER</P>
   4090          */
   4091         public static final String WIDTH = "width";
   4092 
   4093         /**
   4094          * The size, in bytes, of the photo stored on disk.
   4095          * <P>Type: NUMBER</P>
   4096          */
   4097         public static final String FILESIZE = "filesize";
   4098     }
   4099 
   4100     /**
   4101      * Columns in the Data table.
   4102      *
   4103      * @see ContactsContract.Data
   4104      */
   4105     protected interface DataColumns {
   4106         /**
   4107          * The package name to use when creating {@link Resources} objects for
   4108          * this data row. This value is only designed for use when building user
   4109          * interfaces, and should not be used to infer the owner.
   4110          */
   4111         public static final String RES_PACKAGE = "res_package";
   4112 
   4113         /**
   4114          * The MIME type of the item represented by this row.
   4115          */
   4116         public static final String MIMETYPE = "mimetype";
   4117 
   4118         /**
   4119          * Hash id on the data fields, used for backup and restore.
   4120          *
   4121          * @hide
   4122          */
   4123         public static final String HASH_ID = "hash_id";
   4124 
   4125         /**
   4126          * A reference to the {@link RawContacts#_ID}
   4127          * that this data belongs to.
   4128          */
   4129         public static final String RAW_CONTACT_ID = "raw_contact_id";
   4130 
   4131         /**
   4132          * Whether this is the primary entry of its kind for the raw contact it belongs to.
   4133          * <P>Type: INTEGER (if set, non-0 means true)</P>
   4134          */
   4135         public static final String IS_PRIMARY = "is_primary";
   4136 
   4137         /**
   4138          * Whether this is the primary entry of its kind for the aggregate
   4139          * contact it belongs to. Any data record that is "super primary" must
   4140          * also be "primary".
   4141          * <P>Type: INTEGER (if set, non-0 means true)</P>
   4142          */
   4143         public static final String IS_SUPER_PRIMARY = "is_super_primary";
   4144 
   4145         /**
   4146          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
   4147          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
   4148          * <P>Type: INTEGER</P>
   4149          */
   4150         public static final String IS_READ_ONLY = "is_read_only";
   4151 
   4152         /**
   4153          * The version of this data record. This is a read-only value. The data column is
   4154          * guaranteed to not change without the version going up. This value is monotonically
   4155          * increasing.
   4156          * <P>Type: INTEGER</P>
   4157          */
   4158         public static final String DATA_VERSION = "data_version";
   4159 
   4160         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4161         public static final String DATA1 = "data1";
   4162         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4163         public static final String DATA2 = "data2";
   4164         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4165         public static final String DATA3 = "data3";
   4166         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4167         public static final String DATA4 = "data4";
   4168         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4169         public static final String DATA5 = "data5";
   4170         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4171         public static final String DATA6 = "data6";
   4172         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4173         public static final String DATA7 = "data7";
   4174         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4175         public static final String DATA8 = "data8";
   4176         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4177         public static final String DATA9 = "data9";
   4178         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4179         public static final String DATA10 = "data10";
   4180         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4181         public static final String DATA11 = "data11";
   4182         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4183         public static final String DATA12 = "data12";
   4184         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4185         public static final String DATA13 = "data13";
   4186         /** Generic data column, the meaning is {@link #MIMETYPE} specific */
   4187         public static final String DATA14 = "data14";
   4188         /**
   4189          * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
   4190          * this field is used to store BLOBs (binary data).
   4191          */
   4192         public static final String DATA15 = "data15";
   4193 
   4194         /** Generic column for use by sync adapters. */
   4195         public static final String SYNC1 = "data_sync1";
   4196         /** Generic column for use by sync adapters. */
   4197         public static final String SYNC2 = "data_sync2";
   4198         /** Generic column for use by sync adapters. */
   4199         public static final String SYNC3 = "data_sync3";
   4200         /** Generic column for use by sync adapters. */
   4201         public static final String SYNC4 = "data_sync4";
   4202 
   4203         /**
   4204          * Carrier presence information.
   4205          * <P>
   4206          * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields)
   4207          * </P>
   4208          */
   4209         public static final String CARRIER_PRESENCE = "carrier_presence";
   4210 
   4211         /**
   4212          * Indicates that the entry is Video Telephony (VT) capable on the
   4213          * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}.
   4214          */
   4215         public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01;
   4216     }
   4217 
   4218     /**
   4219      * Columns in the Data_Usage_Stat table
   4220      */
   4221     protected interface DataUsageStatColumns {
   4222         /** The last time (in milliseconds) this {@link Data} was used. */
   4223         public static final String LAST_TIME_USED = "last_time_used";
   4224 
   4225         /** The number of times the referenced {@link Data} has been used. */
   4226         public static final String TIMES_USED = "times_used";
   4227     }
   4228 
   4229     /**
   4230      * Combines all columns returned by {@link ContactsContract.Data} table queries.
   4231      *
   4232      * @see ContactsContract.Data
   4233      */
   4234     protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
   4235             RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
   4236             ContactStatusColumns, DataUsageStatColumns {
   4237     }
   4238 
   4239     /**
   4240      * <p>
   4241      * Constants for the data table, which contains data points tied to a raw
   4242      * contact.  Each row of the data table is typically used to store a single
   4243      * piece of contact
   4244      * information (such as a phone number) and its
   4245      * associated metadata (such as whether it is a work or home number).
   4246      * </p>
   4247      * <h3>Data kinds</h3>
   4248      * <p>
   4249      * Data is a generic table that can hold any kind of contact data.
   4250      * The kind of data stored in a given row is specified by the row's
   4251      * {@link #MIMETYPE} value, which determines the meaning of the
   4252      * generic columns {@link #DATA1} through
   4253      * {@link #DATA15}.
   4254      * For example, if the data kind is
   4255      * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
   4256      * {@link #DATA1} stores the
   4257      * phone number, but if the data kind is
   4258      * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
   4259      * stores the email address.
   4260      * Sync adapters and applications can introduce their own data kinds.
   4261      * </p>
   4262      * <p>
   4263      * ContactsContract defines a small number of pre-defined data kinds, e.g.
   4264      * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
   4265      * convenience, these classes define data kind specific aliases for DATA1 etc.
   4266      * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
   4267      * {@link ContactsContract.Data Data.DATA1}.
   4268      * </p>
   4269      * <p>
   4270      * {@link #DATA1} is an indexed column and should be used for the data element that is
   4271      * expected to be most frequently used in query selections. For example, in the
   4272      * case of a row representing email addresses {@link #DATA1} should probably
   4273      * be used for the email address itself, while {@link #DATA2} etc can be
   4274      * used for auxiliary information like type of email address.
   4275      * <p>
   4276      * <p>
   4277      * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
   4278      * </p>
   4279      * <p>
   4280      * The sync adapter for a given account type must correctly handle every data type
   4281      * used in the corresponding raw contacts.  Otherwise it could result in lost or
   4282      * corrupted data.
   4283      * </p>
   4284      * <p>
   4285      * Similarly, you should refrain from introducing new kinds of data for an other
   4286      * party's account types. For example, if you add a data row for
   4287      * "favorite song" to a raw contact owned by a Google account, it will not
   4288      * get synced to the server, because the Google sync adapter does not know
   4289      * how to handle this data kind. Thus new data kinds are typically
   4290      * introduced along with new account types, i.e. new sync adapters.
   4291      * </p>
   4292      * <h3>Batch operations</h3>
   4293      * <p>
   4294      * Data rows can be inserted/updated/deleted using the traditional
   4295      * {@link ContentResolver#insert}, {@link ContentResolver#update} and
   4296      * {@link ContentResolver#delete} methods, however the newer mechanism based
   4297      * on a batch of {@link ContentProviderOperation} will prove to be a better
   4298      * choice in almost all cases. All operations in a batch are executed in a
   4299      * single transaction, which ensures that the phone-side and server-side
   4300      * state of a raw contact are always consistent. Also, the batch-based
   4301      * approach is far more efficient: not only are the database operations
   4302      * faster when executed in a single transaction, but also sending a batch of
   4303      * commands to the content provider saves a lot of time on context switching
   4304      * between your process and the process in which the content provider runs.
   4305      * </p>
   4306      * <p>
   4307      * The flip side of using batched operations is that a large batch may lock
   4308      * up the database for a long time preventing other applications from
   4309      * accessing data and potentially causing ANRs ("Application Not Responding"
   4310      * dialogs.)
   4311      * </p>
   4312      * <p>
   4313      * To avoid such lockups of the database, make sure to insert "yield points"
   4314      * in the batch. A yield point indicates to the content provider that before
   4315      * executing the next operation it can commit the changes that have already
   4316      * been made, yield to other requests, open another transaction and continue
   4317      * processing operations. A yield point will not automatically commit the
   4318      * transaction, but only if there is another request waiting on the
   4319      * database. Normally a sync adapter should insert a yield point at the
   4320      * beginning of each raw contact operation sequence in the batch. See
   4321      * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
   4322      * </p>
   4323      * <h3>Operations</h3>
   4324      * <dl>
   4325      * <dt><b>Insert</b></dt>
   4326      * <dd>
   4327      * <p>
   4328      * An individual data row can be inserted using the traditional
   4329      * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
   4330      * should always be inserted as a batch.
   4331      * </p>
   4332      * <p>
   4333      * An example of a traditional insert:
   4334      * <pre>
   4335      * ContentValues values = new ContentValues();
   4336      * values.put(Data.RAW_CONTACT_ID, rawContactId);
   4337      * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
   4338      * values.put(Phone.NUMBER, "1-800-GOOG-411");
   4339      * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
   4340      * values.put(Phone.LABEL, "free directory assistance");
   4341      * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
   4342      * </pre>
   4343      * <p>
   4344      * The same done using ContentProviderOperations:
   4345      * <pre>
   4346      * ArrayList&lt;ContentProviderOperation&gt; ops =
   4347      *          new ArrayList&lt;ContentProviderOperation&gt;();
   4348      *
   4349      * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   4350      *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
   4351      *          .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
   4352      *          .withValue(Phone.NUMBER, "1-800-GOOG-411")
   4353      *          .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
   4354      *          .withValue(Phone.LABEL, "free directory assistance")
   4355      *          .build());
   4356      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   4357      * </pre>
   4358      * </p>
   4359      * <dt><b>Update</b></dt>
   4360      * <dd>
   4361      * <p>
   4362      * Just as with insert, update can be done incrementally or as a batch,
   4363      * the batch mode being the preferred method:
   4364      * <pre>
   4365      * ArrayList&lt;ContentProviderOperation&gt; ops =
   4366      *          new ArrayList&lt;ContentProviderOperation&gt;();
   4367      *
   4368      * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
   4369      *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
   4370      *          .withValue(Email.DATA, "somebody (at) android.com")
   4371      *          .build());
   4372      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   4373      * </pre>
   4374      * </p>
   4375      * </dd>
   4376      * <dt><b>Delete</b></dt>
   4377      * <dd>
   4378      * <p>
   4379      * Just as with insert and update, deletion can be done either using the
   4380      * {@link ContentResolver#delete} method or using a ContentProviderOperation:
   4381      * <pre>
   4382      * ArrayList&lt;ContentProviderOperation&gt; ops =
   4383      *          new ArrayList&lt;ContentProviderOperation&gt;();
   4384      *
   4385      * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
   4386      *          .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
   4387      *          .build());
   4388      * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   4389      * </pre>
   4390      * </p>
   4391      * </dd>
   4392      * <dt><b>Query</b></dt>
   4393      * <dd>
   4394      * <p>
   4395      * <dl>
   4396      * <dt>Finding all Data of a given type for a given contact</dt>
   4397      * <dd>
   4398      * <pre>
   4399      * Cursor c = getContentResolver().query(Data.CONTENT_URI,
   4400      *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
   4401      *          Data.CONTACT_ID + &quot;=?&quot; + " AND "
   4402      *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
   4403      *          new String[] {String.valueOf(contactId)}, null);
   4404      * </pre>
   4405      * </p>
   4406      * <p>
   4407      * </dd>
   4408      * <dt>Finding all Data of a given type for a given raw contact</dt>
   4409      * <dd>
   4410      * <pre>
   4411      * Cursor c = getContentResolver().query(Data.CONTENT_URI,
   4412      *          new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
   4413      *          Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
   4414      *                  + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
   4415      *          new String[] {String.valueOf(rawContactId)}, null);
   4416      * </pre>
   4417      * </dd>
   4418      * <dt>Finding all Data for a given raw contact</dt>
   4419      * <dd>
   4420      * Most sync adapters will want to read all data rows for a raw contact
   4421      * along with the raw contact itself.  For that you should use the
   4422      * {@link RawContactsEntity}. See also {@link RawContacts}.
   4423      * </dd>
   4424      * </dl>
   4425      * </p>
   4426      * </dd>
   4427      * </dl>
   4428      * <h2>Columns</h2>
   4429      * <p>
   4430      * Many columns are available via a {@link Data#CONTENT_URI} query.  For best performance you
   4431      * should explicitly specify a projection to only those columns that you need.
   4432      * </p>
   4433      * <table class="jd-sumtable">
   4434      * <tr>
   4435      * <th colspan='4'>Data</th>
   4436      * </tr>
   4437      * <tr>
   4438      * <td style="width: 7em;">long</td>
   4439      * <td style="width: 20em;">{@link #_ID}</td>
   4440      * <td style="width: 5em;">read-only</td>
   4441      * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
   4442      * it would be a bad idea to delete and reinsert a data row. A sync adapter should
   4443      * always do an update instead.</td>
   4444      * </tr>
   4445      * <tr>
   4446      * <td>String</td>
   4447      * <td>{@link #MIMETYPE}</td>
   4448      * <td>read/write-once</td>
   4449      * <td>
   4450      * <p>The MIME type of the item represented by this row. Examples of common
   4451      * MIME types are:
   4452      * <ul>
   4453      * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
   4454      * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
   4455      * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
   4456      * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
   4457      * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
   4458      * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
   4459      * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
   4460      * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
   4461      * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
   4462      * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
   4463      * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
   4464      * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
   4465      * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
   4466      * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
   4467      * </ul>
   4468      * </p>
   4469      * </td>
   4470      * </tr>
   4471      * <tr>
   4472      * <td>long</td>
   4473      * <td>{@link #RAW_CONTACT_ID}</td>
   4474      * <td>read/write-once</td>
   4475      * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
   4476      * </tr>
   4477      * <tr>
   4478      * <td>int</td>
   4479      * <td>{@link #IS_PRIMARY}</td>
   4480      * <td>read/write</td>
   4481      * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
   4482      * "1" if true, "0" if false.
   4483      * </td>
   4484      * </tr>
   4485      * <tr>
   4486      * <td>int</td>
   4487      * <td>{@link #IS_SUPER_PRIMARY}</td>
   4488      * <td>read/write</td>
   4489      * <td>Whether this is the primary entry of its kind for the aggregate
   4490      * contact it belongs to. Any data record that is "super primary" must
   4491      * also be "primary".  For example, the super-primary entry may be
   4492      * interpreted as the default contact value of its kind (for example,
   4493      * the default phone number to use for the contact).</td>
   4494      * </tr>
   4495      * <tr>
   4496      * <td>int</td>
   4497      * <td>{@link #DATA_VERSION}</td>
   4498      * <td>read-only</td>
   4499      * <td>The version of this data record. Whenever the data row changes
   4500      * the version goes up. This value is monotonically increasing.</td>
   4501      * </tr>
   4502      * <tr>
   4503      * <td>Any type</td>
   4504      * <td>
   4505      * {@link #DATA1}<br>
   4506      * {@link #DATA2}<br>
   4507      * {@link #DATA3}<br>
   4508      * {@link #DATA4}<br>
   4509      * {@link #DATA5}<br>
   4510      * {@link #DATA6}<br>
   4511      * {@link #DATA7}<br>
   4512      * {@link #DATA8}<br>
   4513      * {@link #DATA9}<br>
   4514      * {@link #DATA10}<br>
   4515      * {@link #DATA11}<br>
   4516      * {@link #DATA12}<br>
   4517      * {@link #DATA13}<br>
   4518      * {@link #DATA14}<br>
   4519      * {@link #DATA15}
   4520      * </td>
   4521      * <td>read/write</td>
   4522      * <td>
   4523      * <p>
   4524      * Generic data columns.  The meaning of each column is determined by the
   4525      * {@link #MIMETYPE}.  By convention, {@link #DATA15} is used for storing
   4526      * BLOBs (binary data).
   4527      * </p>
   4528      * <p>
   4529      * Data columns whose meaning is not explicitly defined for a given MIMETYPE
   4530      * should not be used.  There is no guarantee that any sync adapter will
   4531      * preserve them.  Sync adapters themselves should not use such columns either,
   4532      * but should instead use {@link #SYNC1}-{@link #SYNC4}.
   4533      * </p>
   4534      * </td>
   4535      * </tr>
   4536      * <tr>
   4537      * <td>Any type</td>
   4538      * <td>
   4539      * {@link #SYNC1}<br>
   4540      * {@link #SYNC2}<br>
   4541      * {@link #SYNC3}<br>
   4542      * {@link #SYNC4}
   4543      * </td>
   4544      * <td>read/write</td>
   4545      * <td>Generic columns for use by sync adapters. For example, a Photo row
   4546      * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
   4547      * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
   4548      * </tr>
   4549      * </table>
   4550      *
   4551      * <p>
   4552      * Some columns from the most recent associated status update are also available
   4553      * through an implicit join.
   4554      * </p>
   4555      * <table class="jd-sumtable">
   4556      * <tr>
   4557      * <th colspan='4'>Join with {@link StatusUpdates}</th>
   4558      * </tr>
   4559      * <tr>
   4560      * <td style="width: 7em;">int</td>
   4561      * <td style="width: 20em;">{@link #PRESENCE}</td>
   4562      * <td style="width: 5em;">read-only</td>
   4563      * <td>IM presence status linked to this data row. Compare with
   4564      * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
   4565      * all IM rows. See {@link StatusUpdates} for individual status definitions.
   4566      * The provider may choose not to store this value
   4567      * in persistent storage. The expectation is that presence status will be
   4568      * updated on a regular basis.
   4569      * </td>
   4570      * </tr>
   4571      * <tr>
   4572      * <td>String</td>
   4573      * <td>{@link #STATUS}</td>
   4574      * <td>read-only</td>
   4575      * <td>Latest status update linked with this data row.</td>
   4576      * </tr>
   4577      * <tr>
   4578      * <td>long</td>
   4579      * <td>{@link #STATUS_TIMESTAMP}</td>
   4580      * <td>read-only</td>
   4581      * <td>The absolute time in milliseconds when the latest status was
   4582      * inserted/updated for this data row.</td>
   4583      * </tr>
   4584      * <tr>
   4585      * <td>String</td>
   4586      * <td>{@link #STATUS_RES_PACKAGE}</td>
   4587      * <td>read-only</td>
   4588      * <td>The package containing resources for this status: label and icon.</td>
   4589      * </tr>
   4590      * <tr>
   4591      * <td>long</td>
   4592      * <td>{@link #STATUS_LABEL}</td>
   4593      * <td>read-only</td>
   4594      * <td>The resource ID of the label describing the source of status update linked
   4595      * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
   4596      * </tr>
   4597      * <tr>
   4598      * <td>long</td>
   4599      * <td>{@link #STATUS_ICON}</td>
   4600      * <td>read-only</td>
   4601      * <td>The resource ID of the icon for the source of the status update linked
   4602      * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
   4603      * </tr>
   4604      * </table>
   4605      *
   4606      * <p>
   4607      * Some columns from the associated raw contact are also available through an
   4608      * implicit join.  The other columns are excluded as uninteresting in this
   4609      * context.
   4610      * </p>
   4611      *
   4612      * <table class="jd-sumtable">
   4613      * <tr>
   4614      * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
   4615      * </tr>
   4616      * <tr>
   4617      * <td style="width: 7em;">long</td>
   4618      * <td style="width: 20em;">{@link #CONTACT_ID}</td>
   4619      * <td style="width: 5em;">read-only</td>
   4620      * <td>The id of the row in the {@link Contacts} table that this data belongs
   4621      * to.</td>
   4622      * </tr>
   4623      * <tr>
   4624      * <td>int</td>
   4625      * <td>{@link #AGGREGATION_MODE}</td>
   4626      * <td>read-only</td>
   4627      * <td>See {@link RawContacts}.</td>
   4628      * </tr>
   4629      * <tr>
   4630      * <td>int</td>
   4631      * <td>{@link #DELETED}</td>
   4632      * <td>read-only</td>
   4633      * <td>See {@link RawContacts}.</td>
   4634      * </tr>
   4635      * </table>
   4636      *
   4637      * <p>
   4638      * The ID column for the associated aggregated contact table
   4639      * {@link ContactsContract.Contacts} is available
   4640      * via the implicit join to the {@link RawContacts} table, see above.
   4641      * The remaining columns from this table are also
   4642      * available, through an implicit join.  This
   4643      * facilitates lookup by
   4644      * the value of a single data element, such as the email address.
   4645      * </p>
   4646      *
   4647      * <table class="jd-sumtable">
   4648      * <tr>
   4649      * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
   4650      * </tr>
   4651      * <tr>
   4652      * <td style="width: 7em;">String</td>
   4653      * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
   4654      * <td style="width: 5em;">read-only</td>
   4655      * <td>See {@link ContactsContract.Contacts}</td>
   4656      * </tr>
   4657      * <tr>
   4658      * <td>String</td>
   4659      * <td>{@link #DISPLAY_NAME}</td>
   4660      * <td>read-only</td>
   4661      * <td>See {@link ContactsContract.Contacts}</td>
   4662      * </tr>
   4663      * <tr>
   4664      * <td>long</td>
   4665      * <td>{@link #PHOTO_ID}</td>
   4666      * <td>read-only</td>
   4667      * <td>See {@link ContactsContract.Contacts}.</td>
   4668      * </tr>
   4669      * <tr>
   4670      * <td>int</td>
   4671      * <td>{@link #IN_VISIBLE_GROUP}</td>
   4672      * <td>read-only</td>
   4673      * <td>See {@link ContactsContract.Contacts}.</td>
   4674      * </tr>
   4675      * <tr>
   4676      * <td>int</td>
   4677      * <td>{@link #HAS_PHONE_NUMBER}</td>
   4678      * <td>read-only</td>
   4679      * <td>See {@link ContactsContract.Contacts}.</td>
   4680      * </tr>
   4681      * <tr>
   4682      * <td>int</td>
   4683      * <td>{@link #TIMES_CONTACTED}</td>
   4684      * <td>read-only</td>
   4685      * <td>See {@link ContactsContract.Contacts}.</td>
   4686      * </tr>
   4687      * <tr>
   4688      * <td>long</td>
   4689      * <td>{@link #LAST_TIME_CONTACTED}</td>
   4690      * <td>read-only</td>
   4691      * <td>See {@link ContactsContract.Contacts}.</td>
   4692      * </tr>
   4693      * <tr>
   4694      * <td>int</td>
   4695      * <td>{@link #STARRED}</td>
   4696      * <td>read-only</td>
   4697      * <td>See {@link ContactsContract.Contacts}.</td>
   4698      * </tr>
   4699      * <tr>
   4700      * <td>String</td>
   4701      * <td>{@link #CUSTOM_RINGTONE}</td>
   4702      * <td>read-only</td>
   4703      * <td>See {@link ContactsContract.Contacts}.</td>
   4704      * </tr>
   4705      * <tr>
   4706      * <td>int</td>
   4707      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   4708      * <td>read-only</td>
   4709      * <td>See {@link ContactsContract.Contacts}.</td>
   4710      * </tr>
   4711      * <tr>
   4712      * <td>int</td>
   4713      * <td>{@link #CONTACT_PRESENCE}</td>
   4714      * <td>read-only</td>
   4715      * <td>See {@link ContactsContract.Contacts}.</td>
   4716      * </tr>
   4717      * <tr>
   4718      * <td>String</td>
   4719      * <td>{@link #CONTACT_STATUS}</td>
   4720      * <td>read-only</td>
   4721      * <td>See {@link ContactsContract.Contacts}.</td>
   4722      * </tr>
   4723      * <tr>
   4724      * <td>long</td>
   4725      * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
   4726      * <td>read-only</td>
   4727      * <td>See {@link ContactsContract.Contacts}.</td>
   4728      * </tr>
   4729      * <tr>
   4730      * <td>String</td>
   4731      * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
   4732      * <td>read-only</td>
   4733      * <td>See {@link ContactsContract.Contacts}.</td>
   4734      * </tr>
   4735      * <tr>
   4736      * <td>long</td>
   4737      * <td>{@link #CONTACT_STATUS_LABEL}</td>
   4738      * <td>read-only</td>
   4739      * <td>See {@link ContactsContract.Contacts}.</td>
   4740      * </tr>
   4741      * <tr>
   4742      * <td>long</td>
   4743      * <td>{@link #CONTACT_STATUS_ICON}</td>
   4744      * <td>read-only</td>
   4745      * <td>See {@link ContactsContract.Contacts}.</td>
   4746      * </tr>
   4747      * </table>
   4748      */
   4749     public final static class Data implements DataColumnsWithJoins, ContactCounts {
   4750         /**
   4751          * This utility class cannot be instantiated
   4752          */
   4753         private Data() {}
   4754 
   4755         /**
   4756          * The content:// style URI for this table, which requests a directory
   4757          * of data rows matching the selection criteria.
   4758          */
   4759         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
   4760 
   4761         /**
   4762         * The content:// style URI for this table in managed profile, which requests a directory
   4763         * of data rows matching the selection criteria.
   4764         *
   4765         * @hide
   4766         */
   4767         static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
   4768                 "data_enterprise");
   4769 
   4770         /**
   4771          * A boolean parameter for {@link Data#CONTENT_URI}.
   4772          * This specifies whether or not the returned data items should be filtered to show
   4773          * data items belonging to visible contacts only.
   4774          */
   4775         public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
   4776 
   4777         /**
   4778          * The MIME type of the results from {@link #CONTENT_URI}.
   4779          */
   4780         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
   4781 
   4782         /**
   4783          * <p>
   4784          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
   4785          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
   4786          * entry of the given {@link ContactsContract.Data} entry.
   4787          * </p>
   4788          * <p>
   4789          * Returns the Uri for the contact in the first entry returned by
   4790          * {@link ContentResolver#query(Uri, String[], String, String[], String)}
   4791          * for the provided {@code dataUri}.  If the query returns null or empty
   4792          * results, silently returns null.
   4793          * </p>
   4794          */
   4795         public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
   4796             final Cursor cursor = resolver.query(dataUri, new String[] {
   4797                     RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
   4798             }, null, null, null);
   4799 
   4800             Uri lookupUri = null;
   4801             try {
   4802                 if (cursor != null && cursor.moveToFirst()) {
   4803                     final long contactId = cursor.getLong(0);
   4804                     final String lookupKey = cursor.getString(1);
   4805                     return Contacts.getLookupUri(contactId, lookupKey);
   4806                 }
   4807             } finally {
   4808                 if (cursor != null) cursor.close();
   4809             }
   4810             return lookupUri;
   4811         }
   4812     }
   4813 
   4814     /**
   4815      * <p>
   4816      * Constants for the raw contacts entities table, which can be thought of as
   4817      * an outer join of the raw_contacts table with the data table.  It is a strictly
   4818      * read-only table.
   4819      * </p>
   4820      * <p>
   4821      * If a raw contact has data rows, the RawContactsEntity cursor will contain
   4822      * a one row for each data row. If the raw contact has no data rows, the
   4823      * cursor will still contain one row with the raw contact-level information
   4824      * and nulls for data columns.
   4825      *
   4826      * <pre>
   4827      * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
   4828      * Cursor c = getContentResolver().query(entityUri,
   4829      *          new String[]{
   4830      *              RawContactsEntity.SOURCE_ID,
   4831      *              RawContactsEntity.DATA_ID,
   4832      *              RawContactsEntity.MIMETYPE,
   4833      *              RawContactsEntity.DATA1
   4834      *          }, null, null, null);
   4835      * try {
   4836      *     while (c.moveToNext()) {
   4837      *         String sourceId = c.getString(0);
   4838      *         if (!c.isNull(1)) {
   4839      *             String mimeType = c.getString(2);
   4840      *             String data = c.getString(3);
   4841      *             ...
   4842      *         }
   4843      *     }
   4844      * } finally {
   4845      *     c.close();
   4846      * }
   4847      * </pre>
   4848      *
   4849      * <h3>Columns</h3>
   4850      * RawContactsEntity has a combination of RawContact and Data columns.
   4851      *
   4852      * <table class="jd-sumtable">
   4853      * <tr>
   4854      * <th colspan='4'>RawContacts</th>
   4855      * </tr>
   4856      * <tr>
   4857      * <td style="width: 7em;">long</td>
   4858      * <td style="width: 20em;">{@link #_ID}</td>
   4859      * <td style="width: 5em;">read-only</td>
   4860      * <td>Raw contact row ID. See {@link RawContacts}.</td>
   4861      * </tr>
   4862      * <tr>
   4863      * <td>long</td>
   4864      * <td>{@link #CONTACT_ID}</td>
   4865      * <td>read-only</td>
   4866      * <td>See {@link RawContacts}.</td>
   4867      * </tr>
   4868      * <tr>
   4869      * <td>int</td>
   4870      * <td>{@link #AGGREGATION_MODE}</td>
   4871      * <td>read-only</td>
   4872      * <td>See {@link RawContacts}.</td>
   4873      * </tr>
   4874      * <tr>
   4875      * <td>int</td>
   4876      * <td>{@link #DELETED}</td>
   4877      * <td>read-only</td>
   4878      * <td>See {@link RawContacts}.</td>
   4879      * </tr>
   4880      * </table>
   4881      *
   4882      * <table class="jd-sumtable">
   4883      * <tr>
   4884      * <th colspan='4'>Data</th>
   4885      * </tr>
   4886      * <tr>
   4887      * <td style="width: 7em;">long</td>
   4888      * <td style="width: 20em;">{@link #DATA_ID}</td>
   4889      * <td style="width: 5em;">read-only</td>
   4890      * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
   4891      * </tr>
   4892      * <tr>
   4893      * <td>String</td>
   4894      * <td>{@link #MIMETYPE}</td>
   4895      * <td>read-only</td>
   4896      * <td>See {@link ContactsContract.Data}.</td>
   4897      * </tr>
   4898      * <tr>
   4899      * <td>int</td>
   4900      * <td>{@link #IS_PRIMARY}</td>
   4901      * <td>read-only</td>
   4902      * <td>See {@link ContactsContract.Data}.</td>
   4903      * </tr>
   4904      * <tr>
   4905      * <td>int</td>
   4906      * <td>{@link #IS_SUPER_PRIMARY}</td>
   4907      * <td>read-only</td>
   4908      * <td>See {@link ContactsContract.Data}.</td>
   4909      * </tr>
   4910      * <tr>
   4911      * <td>int</td>
   4912      * <td>{@link #DATA_VERSION}</td>
   4913      * <td>read-only</td>
   4914      * <td>See {@link ContactsContract.Data}.</td>
   4915      * </tr>
   4916      * <tr>
   4917      * <td>Any type</td>
   4918      * <td>
   4919      * {@link #DATA1}<br>
   4920      * {@link #DATA2}<br>
   4921      * {@link #DATA3}<br>
   4922      * {@link #DATA4}<br>
   4923      * {@link #DATA5}<br>
   4924      * {@link #DATA6}<br>
   4925      * {@link #DATA7}<br>
   4926      * {@link #DATA8}<br>
   4927      * {@link #DATA9}<br>
   4928      * {@link #DATA10}<br>
   4929      * {@link #DATA11}<br>
   4930      * {@link #DATA12}<br>
   4931      * {@link #DATA13}<br>
   4932      * {@link #DATA14}<br>
   4933      * {@link #DATA15}
   4934      * </td>
   4935      * <td>read-only</td>
   4936      * <td>See {@link ContactsContract.Data}.</td>
   4937      * </tr>
   4938      * <tr>
   4939      * <td>Any type</td>
   4940      * <td>
   4941      * {@link #SYNC1}<br>
   4942      * {@link #SYNC2}<br>
   4943      * {@link #SYNC3}<br>
   4944      * {@link #SYNC4}
   4945      * </td>
   4946      * <td>read-only</td>
   4947      * <td>See {@link ContactsContract.Data}.</td>
   4948      * </tr>
   4949      * </table>
   4950      */
   4951     public final static class RawContactsEntity
   4952             implements BaseColumns, DataColumns, RawContactsColumns {
   4953         /**
   4954          * This utility class cannot be instantiated
   4955          */
   4956         private RawContactsEntity() {}
   4957 
   4958         /**
   4959          * The content:// style URI for this table
   4960          */
   4961         public static final Uri CONTENT_URI =
   4962                 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
   4963 
   4964         /**
   4965         * The content:// style URI for this table in corp profile
   4966         *
   4967         * @hide
   4968         */
   4969         public static final Uri CORP_CONTENT_URI =
   4970                 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp");
   4971 
   4972         /**
   4973          * The content:// style URI for this table, specific to the user's profile.
   4974          */
   4975         public static final Uri PROFILE_CONTENT_URI =
   4976                 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
   4977 
   4978         /**
   4979          * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
   4980          */
   4981         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
   4982 
   4983         /**
   4984          * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
   4985          * Data.CONTENT_URI contains only exportable data.
   4986          *
   4987          * This flag is useful (currently) only for vCard exporter in Contacts app, which
   4988          * needs to exclude "un-exportable" data from available data to export, while
   4989          * Contacts app itself has priviledge to access all data including "un-expotable"
   4990          * ones and providers return all of them regardless of the callers' intention.
   4991          * <P>Type: INTEGER</p>
   4992          *
   4993          * @hide Maybe available only in Eclair and not really ready for public use.
   4994          * TODO: remove, or implement this feature completely. As of now (Eclair),
   4995          * we only use this flag in queryEntities(), not query().
   4996          */
   4997         public static final String FOR_EXPORT_ONLY = "for_export_only";
   4998 
   4999         /**
   5000          * The ID of the data column. The value will be null if this raw contact has no data rows.
   5001          * <P>Type: INTEGER</P>
   5002          */
   5003         public static final String DATA_ID = "data_id";
   5004     }
   5005 
   5006     /**
   5007      * @see PhoneLookup
   5008      */
   5009     protected interface PhoneLookupColumns {
   5010         /**
   5011          *  The ID of the data row.
   5012          *  <P>Type: INTEGER</P>
   5013          */
   5014         public static final String DATA_ID = "data_id";
   5015         /**
   5016          * A reference to the {@link ContactsContract.Contacts#_ID} that this
   5017          * data belongs to.
   5018          * <P>Type: INTEGER</P>
   5019          */
   5020         public static final String CONTACT_ID = "contact_id";
   5021         /**
   5022          * The phone number as the user entered it.
   5023          * <P>Type: TEXT</P>
   5024          */
   5025         public static final String NUMBER = "number";
   5026 
   5027         /**
   5028          * The type of phone number, for example Home or Work.
   5029          * <P>Type: INTEGER</P>
   5030          */
   5031         public static final String TYPE = "type";
   5032 
   5033         /**
   5034          * The user defined label for the phone number.
   5035          * <P>Type: TEXT</P>
   5036          */
   5037         public static final String LABEL = "label";
   5038 
   5039         /**
   5040          * The phone number's E164 representation.
   5041          * <P>Type: TEXT</P>
   5042          */
   5043         public static final String NORMALIZED_NUMBER = "normalized_number";
   5044     }
   5045 
   5046     /**
   5047      * A table that represents the result of looking up a phone number, for
   5048      * example for caller ID. To perform a lookup you must append the number you
   5049      * want to find to {@link #CONTENT_FILTER_URI}.  This query is highly
   5050      * optimized.
   5051      * <pre>
   5052      * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
   5053      * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
   5054      * </pre>
   5055      *
   5056      * <h3>Columns</h3>
   5057      *
   5058      * <table class="jd-sumtable">
   5059      * <tr>
   5060      * <th colspan='4'>PhoneLookup</th>
   5061      * </tr>
   5062      * <tr>
   5063      * <td>String</td>
   5064      * <td>{@link #NUMBER}</td>
   5065      * <td>read-only</td>
   5066      * <td>Phone number.</td>
   5067      * </tr>
   5068      * <tr>
   5069      * <td>String</td>
   5070      * <td>{@link #TYPE}</td>
   5071      * <td>read-only</td>
   5072      * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
   5073      * </tr>
   5074      * <tr>
   5075      * <td>String</td>
   5076      * <td>{@link #LABEL}</td>
   5077      * <td>read-only</td>
   5078      * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
   5079      * </tr>
   5080      * </table>
   5081      * <p>
   5082      * Columns from the Contacts table are also available through a join.
   5083      * </p>
   5084      * <table class="jd-sumtable">
   5085      * <tr>
   5086      * <th colspan='4'>Join with {@link Contacts}</th>
   5087      * </tr>
   5088      * <tr>
   5089      * <td>long</td>
   5090      * <td>{@link #_ID}</td>
   5091      * <td>read-only</td>
   5092      * <td>Contact ID.</td>
   5093      * </tr>
   5094      * <tr>
   5095      * <td>long</td>
   5096      * <td>{@link #CONTACT_ID}</td>
   5097      * <td>read-only</td>
   5098      * <td>Contact ID.</td>
   5099      * </tr>
   5100      * <tr>
   5101      * <td>long</td>
   5102      * <td>{@link #DATA_ID}</td>
   5103      * <td>read-only</td>
   5104      * <td>Data ID.</td>
   5105      * </tr>
   5106      * <tr>
   5107      * <td>String</td>
   5108      * <td>{@link #LOOKUP_KEY}</td>
   5109      * <td>read-only</td>
   5110      * <td>See {@link ContactsContract.Contacts}</td>
   5111      * </tr>
   5112      * <tr>
   5113      * <td>String</td>
   5114      * <td>{@link #DISPLAY_NAME}</td>
   5115      * <td>read-only</td>
   5116      * <td>See {@link ContactsContract.Contacts}</td>
   5117      * </tr>
   5118      * <tr>
   5119      * <td>long</td>
   5120      * <td>{@link #PHOTO_ID}</td>
   5121      * <td>read-only</td>
   5122      * <td>See {@link ContactsContract.Contacts}.</td>
   5123      * </tr>
   5124      * <tr>
   5125      * <td>int</td>
   5126      * <td>{@link #IN_VISIBLE_GROUP}</td>
   5127      * <td>read-only</td>
   5128      * <td>See {@link ContactsContract.Contacts}.</td>
   5129      * </tr>
   5130      * <tr>
   5131      * <td>int</td>
   5132      * <td>{@link #HAS_PHONE_NUMBER}</td>
   5133      * <td>read-only</td>
   5134      * <td>See {@link ContactsContract.Contacts}.</td>
   5135      * </tr>
   5136      * <tr>
   5137      * <td>int</td>
   5138      * <td>{@link #TIMES_CONTACTED}</td>
   5139      * <td>read-only</td>
   5140      * <td>See {@link ContactsContract.Contacts}.</td>
   5141      * </tr>
   5142      * <tr>
   5143      * <td>long</td>
   5144      * <td>{@link #LAST_TIME_CONTACTED}</td>
   5145      * <td>read-only</td>
   5146      * <td>See {@link ContactsContract.Contacts}.</td>
   5147      * </tr>
   5148      * <tr>
   5149      * <td>int</td>
   5150      * <td>{@link #STARRED}</td>
   5151      * <td>read-only</td>
   5152      * <td>See {@link ContactsContract.Contacts}.</td>
   5153      * </tr>
   5154      * <tr>
   5155      * <td>String</td>
   5156      * <td>{@link #CUSTOM_RINGTONE}</td>
   5157      * <td>read-only</td>
   5158      * <td>See {@link ContactsContract.Contacts}.</td>
   5159      * </tr>
   5160      * <tr>
   5161      * <td>int</td>
   5162      * <td>{@link #SEND_TO_VOICEMAIL}</td>
   5163      * <td>read-only</td>
   5164      * <td>See {@link ContactsContract.Contacts}.</td>
   5165      * </tr>
   5166      * </table>
   5167      */
   5168     public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
   5169             ContactsColumns, ContactOptionsColumns {
   5170         /**
   5171          * This utility class cannot be instantiated
   5172          */
   5173         private PhoneLookup() {}
   5174 
   5175         /**
   5176          * The content:// style URI for this table. Append the phone number you want to lookup
   5177          * to this URI and query it to perform a lookup. For example:
   5178          * <pre>
   5179          * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
   5180          *         Uri.encode(phoneNumber));
   5181          * </pre>
   5182          */
   5183         public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
   5184                 "phone_lookup");
   5185 
   5186         /**
   5187          * <p>URI used for the "enterprise caller-id".</p>
   5188          *
   5189          * <p>
   5190          * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
   5191          * columns.  If the device has no corp profile that is linked to the current profile, it
   5192          * behaves in the exact same way as {@link #CONTENT_FILTER_URI}.  If there is a corp profile
   5193          * linked to the current profile, it first queries against the personal contact database,
   5194          * and if no matching contacts are found there, then queries against the
   5195          * corp contacts database.
   5196          * </p>
   5197          * <p>
   5198          * If a result is from the corp profile, it makes the following changes to the data:
   5199          * <ul>
   5200          *     <li>
   5201          *     {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
   5202          *     URIs.  Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
   5203          *     load pictures from them.
   5204          *     {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null.  Do not use them.
   5205          *     </li>
   5206          *     <li>
   5207          *     Corp contacts will get artificial {@link #_ID}s.  In order to tell whether a contact
   5208          *     is from the corp profile, use
   5209          *     {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
   5210          *     </li>
   5211          *     <li>
   5212          *     Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
   5213          *     </li>
   5214          *     <li>
   5215          *     Returned work contact IDs and lookup keys are not accepted in places that not
   5216          *     explicitly say to accept them.
   5217          *     </li>
   5218          * </ul>
   5219          * <p>
   5220          * A contact lookup URL built by
   5221          * {@link ContactsContract.Contacts#getLookupUri(long, String)}
   5222          * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
   5223          * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
   5224          * corp profile.
   5225          * </p>
   5226          *
   5227          * <pre>
   5228          * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
   5229          *         Uri.encode(phoneNumber));
   5230          * </pre>
   5231          */
   5232         public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
   5233                 "phone_lookup_enterprise");
   5234 
   5235         /**
   5236          * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
   5237          *
   5238          * @hide
   5239          */
   5240         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
   5241 
   5242         /**
   5243          * If this boolean parameter is set to true, then the appended query is treated as a
   5244          * SIP address and the lookup will be performed against SIP addresses in the user's
   5245          * contacts.
   5246          */
   5247         public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
   5248     }
   5249 
   5250     /**
   5251      * Additional data mixed in with {@link StatusColumns} to link
   5252      * back to specific {@link ContactsContract.Data#_ID} entries.
   5253      *
   5254      * @see StatusUpdates
   5255      */
   5256     protected interface PresenceColumns {
   5257 
   5258         /**
   5259          * Reference to the {@link Data#_ID} entry that owns this presence.
   5260          * <P>Type: INTEGER</P>
   5261          */
   5262         public static final String DATA_ID = "presence_data_id";
   5263 
   5264         /**
   5265          * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
   5266          * <p>Type: NUMBER</p>
   5267          */
   5268         public static final String PROTOCOL = "protocol";
   5269 
   5270         /**
   5271          * Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
   5272          * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
   5273          * omitted if {@link #PROTOCOL} value is not
   5274          * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
   5275          *
   5276          * <p>Type: NUMBER</p>
   5277          */
   5278         public static final String CUSTOM_PROTOCOL = "custom_protocol";
   5279 
   5280         /**
   5281          * The IM handle the presence item is for. The handle is scoped to
   5282          * {@link #PROTOCOL}.
   5283          * <P>Type: TEXT</P>
   5284          */
   5285         public static final String IM_HANDLE = "im_handle";
   5286 
   5287         /**
   5288          * The IM account for the local user that the presence data came from.
   5289          * <P>Type: TEXT</P>
   5290          */
   5291         public static final String IM_ACCOUNT = "im_account";
   5292     }
   5293 
   5294     /**
   5295      * <p>
   5296      * A status update is linked to a {@link ContactsContract.Data} row and captures
   5297      * the user's latest status update via the corresponding source, e.g.
   5298      * "Having lunch" via "Google Talk".
   5299      * </p>
   5300      * <p>
   5301      * There are two ways a status update can be inserted: by explicitly linking
   5302      * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
   5303      * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
   5304      * {@link #IM_HANDLE}.  There is no difference between insert and update, you can use
   5305      * either.
   5306      * </p>
   5307      * <p>
   5308      * Inserting or updating a status update for the user's profile requires either using
   5309      * the {@link #DATA_ID} to identify the data row to attach the update to, or
   5310      * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
   5311      * profile.
   5312      * </p>
   5313      * <p>
   5314      * You cannot use {@link ContentResolver#update} to change a status, but
   5315      * {@link ContentResolver#insert} will replace the latests status if it already
   5316      * exists.
   5317      * </p>
   5318      * <p>
   5319      * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
   5320      * for multiple contacts at once.
   5321      * </p>
   5322      *
   5323      * <h3>Columns</h3>
   5324      * <table class="jd-sumtable">
   5325      * <tr>
   5326      * <th colspan='4'>StatusUpdates</th>
   5327      * </tr>
   5328      * <tr>
   5329      * <td>long</td>
   5330      * <td>{@link #DATA_ID}</td>
   5331      * <td>read/write</td>
   5332      * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
   5333      * field is <i>not</i> specified, the provider will attempt to find a data row
   5334      * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
   5335      * {@link #IM_HANDLE} columns.
   5336      * </td>
   5337      * </tr>
   5338      * <tr>
   5339      * <td>long</td>
   5340      * <td>{@link #PROTOCOL}</td>
   5341      * <td>read/write</td>
   5342      * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
   5343      * </tr>
   5344      * <tr>
   5345      * <td>String</td>
   5346      * <td>{@link #CUSTOM_PROTOCOL}</td>
   5347      * <td>read/write</td>
   5348      * <td>Name of the custom protocol.  Should be supplied along with the {@link #PROTOCOL} value
   5349      * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.  Should be null or
   5350      * omitted if {@link #PROTOCOL} value is not
   5351      * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
   5352      * </tr>
   5353      * <tr>
   5354      * <td>String</td>
   5355      * <td>{@link #IM_HANDLE}</td>
   5356      * <td>read/write</td>
   5357      * <td> The IM handle the presence item is for. The handle is scoped to
   5358      * {@link #PROTOCOL}.</td>
   5359      * </tr>
   5360      * <tr>
   5361      * <td>String</td>
   5362      * <td>{@link #IM_ACCOUNT}</td>
   5363      * <td>read/write</td>
   5364      * <td>The IM account for the local user that the presence data came from.</td>
   5365      * </tr>
   5366      * <tr>
   5367      * <td>int</td>
   5368      * <td>{@link #PRESENCE}</td>
   5369      * <td>read/write</td>
   5370      * <td>Contact IM presence status. The allowed values are:
   5371      * <p>
   5372      * <ul>
   5373      * <li>{@link #OFFLINE}</li>
   5374      * <li>{@link #INVISIBLE}</li>
   5375      * <li>{@link #AWAY}</li>
   5376      * <li>{@link #IDLE}</li>
   5377      * <li>{@link #DO_NOT_DISTURB}</li>
   5378      * <li>{@link #AVAILABLE}</li>
   5379      * </ul>
   5380      * </p>
   5381      * <p>
   5382      * Since presence status is inherently volatile, the content provider
   5383      * may choose not to store this field in long-term storage.
   5384      * </p>
   5385      * </td>
   5386      * </tr>
   5387      * <tr>
   5388      * <td>int</td>
   5389      * <td>{@link #CHAT_CAPABILITY}</td>
   5390      * <td>read/write</td>
   5391      * <td>Contact IM chat compatibility value. The allowed values combinations of the following
   5392      * flags. If None of these flags is set, the device can only do text messaging.
   5393      * <p>
   5394      * <ul>
   5395      * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
   5396      * <li>{@link #CAPABILITY_HAS_VOICE}</li>
   5397      * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
   5398      * </ul>
   5399      * </p>
   5400      * <p>
   5401      * Since chat compatibility is inherently volatile as the contact's availability moves from
   5402      * one device to another, the content provider may choose not to store this field in long-term
   5403      * storage.
   5404      * </p>
   5405      * </td>
   5406      * </tr>
   5407      * <tr>
   5408      * <td>String</td>
   5409      * <td>{@link #STATUS}</td>
   5410      * <td>read/write</td>
   5411      * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
   5412      * </tr>
   5413      * <tr>
   5414      * <td>long</td>
   5415      * <td>{@link #STATUS_TIMESTAMP}</td>
   5416      * <td>read/write</td>
   5417      * <td>The absolute time in milliseconds when the status was
   5418      * entered by the user. If this value is not provided, the provider will follow
   5419      * this logic: if there was no prior status update, the value will be left as null.
   5420      * If there was a prior status update, the provider will default this field
   5421      * to the current time.</td>
   5422      * </tr>
   5423      * <tr>
   5424      * <td>String</td>
   5425      * <td>{@link #STATUS_RES_PACKAGE}</td>
   5426      * <td>read/write</td>
   5427      * <td> The package containing resources for this status: label and icon.</td>
   5428      * </tr>
   5429      * <tr>
   5430      * <td>long</td>
   5431      * <td>{@link #STATUS_LABEL}</td>
   5432      * <td>read/write</td>
   5433      * <td>The resource ID of the label describing the source of contact status,
   5434      * e.g. "Google Talk". This resource is scoped by the
   5435      * {@link #STATUS_RES_PACKAGE}.</td>
   5436      * </tr>
   5437      * <tr>
   5438      * <td>long</td>
   5439      * <td>{@link #STATUS_ICON}</td>
   5440      * <td>read/write</td>
   5441      * <td>The resource ID of the icon for the source of contact status. This
   5442      * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
   5443      * </tr>
   5444      * </table>
   5445      */
   5446     public static class StatusUpdates implements StatusColumns, PresenceColumns {
   5447 
   5448         /**
   5449          * This utility class cannot be instantiated
   5450          */
   5451         private StatusUpdates() {}
   5452 
   5453         /**
   5454          * The content:// style URI for this table
   5455          */
   5456         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
   5457 
   5458         /**
   5459          * The content:// style URI for this table, specific to the user's profile.
   5460          */
   5461         public static final Uri PROFILE_CONTENT_URI =
   5462                 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
   5463 
   5464         /**
   5465          * Gets the resource ID for the proper presence icon.
   5466          *
   5467          * @param status the status to get the icon for
   5468          * @return the resource ID for the proper presence icon
   5469          */
   5470         public static final int getPresenceIconResourceId(int status) {
   5471             switch (status) {
   5472                 case AVAILABLE:
   5473                     return android.R.drawable.presence_online;
   5474                 case IDLE:
   5475                 case AWAY:
   5476                     return android.R.drawable.presence_away;
   5477                 case DO_NOT_DISTURB:
   5478                     return android.R.drawable.presence_busy;
   5479                 case INVISIBLE:
   5480                     return android.R.drawable.presence_invisible;
   5481                 case OFFLINE:
   5482                 default:
   5483                     return android.R.drawable.presence_offline;
   5484             }
   5485         }
   5486 
   5487         /**
   5488          * Returns the precedence of the status code the higher number being the higher precedence.
   5489          *
   5490          * @param status The status code.
   5491          * @return An integer representing the precedence, 0 being the lowest.
   5492          */
   5493         public static final int getPresencePrecedence(int status) {
   5494             // Keep this function here incase we want to enforce a different precedence than the
   5495             // natural order of the status constants.
   5496             return status;
   5497         }
   5498 
   5499         /**
   5500          * The MIME type of {@link #CONTENT_URI} providing a directory of
   5501          * status update details.
   5502          */
   5503         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
   5504 
   5505         /**
   5506          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
   5507          * status update detail.
   5508          */
   5509         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
   5510     }
   5511 
   5512     /**
   5513      * @deprecated This old name was never meant to be made public. Do not use.
   5514      */
   5515     @Deprecated
   5516     public static final class Presence extends StatusUpdates {
   5517 
   5518     }
   5519 
   5520     /**
   5521      * Additional column returned by
   5522      * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
   5523      * why the filter matched the contact. This column will contain extracts from the contact's
   5524      * constituent {@link Data Data} items, formatted in a way that indicates the section of the
   5525      * snippet that matched the filter.
   5526      *
   5527      * <p>
   5528      * The following example searches for all contacts that match the query "presi" and requests
   5529      * the snippet column as well.
   5530      * <pre>
   5531      * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
   5532      * builder.appendPath("presi");
   5533      * // Defer snippeting to the client side if possible, for performance reasons.
   5534      * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
   5535      *
   5536      * Cursor cursor = getContentResolver().query(builder.build());
   5537      *
   5538      * Bundle extras = cursor.getExtras();
   5539      * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
   5540      *     // Do our own snippet formatting.
   5541      *     // For a contact with the email address (president (at) organization.com), the snippet
   5542      *     // column will contain the string "president (at) organization.com".
   5543      * } else {
   5544      *     // The snippet has already been pre-formatted, we can display it as is.
   5545      *     // For a contact with the email address (president (at) organization.com), the snippet
   5546      *     // column will contain the string "[presi]dent (at) organization.com".
   5547      * }
   5548      * </pre>
   5549      * </p>
   5550      */
   5551     public static class SearchSnippets {
   5552 
   5553         /**
   5554          * The search snippet constructed by SQLite snippeting functionality.
   5555          * <p>
   5556          * The snippet may contain (parts of) several data elements belonging to the contact,
   5557          * with the matching parts optionally surrounded by special characters that indicate the
   5558          * start and end of matching text.
   5559          *
   5560          * For example, if a contact has an address "123 Main Street", using a filter "mai" would
   5561          * return the formatted snippet "123 [Mai]n street".
   5562          *
   5563          * @see <a href="http://www.sqlite.org/fts3.html#snippet">
   5564          *         http://www.sqlite.org/fts3.html#snippet</a>
   5565          */
   5566         public static final String SNIPPET = "snippet";
   5567 
   5568         /**
   5569          * Comma-separated parameters for the generation of the snippet:
   5570          * <ul>
   5571          * <li>The "start match" text. Default is '['</li>
   5572          * <li>The "end match" text. Default is ']'</li>
   5573          * <li>The "ellipsis" text. Default is "..."</li>
   5574          * <li>Maximum number of tokens to include in the snippet. Can be either
   5575          * a positive or a negative number: A positive number indicates how many
   5576          * tokens can be returned in total. A negative number indicates how many
   5577          * tokens can be returned per occurrence of the search terms.</li>
   5578          * </ul>
   5579          *
   5580          * @hide
   5581          */
   5582         public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
   5583 
   5584         /**
   5585          * The key to ask the provider to defer the formatting of the snippet to the client if
   5586          * possible, for performance reasons.
   5587          * A value of 1 indicates true, 0 indicates false. False is the default.
   5588          * When a cursor is returned to the client, it should check for an extra with the name
   5589          * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
   5590          * should do its own formatting of the snippet. If it doesn't exist, the snippet column
   5591          * in the cursor should already contain a formatted snippet.
   5592          */
   5593         public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
   5594     }
   5595 
   5596     /**
   5597      * Container for definitions of common data types stored in the {@link ContactsContract.Data}
   5598      * table.
   5599      */
   5600     public static final class CommonDataKinds {
   5601         /**
   5602          * This utility class cannot be instantiated
   5603          */
   5604         private CommonDataKinds() {}
   5605 
   5606         /**
   5607          * The {@link Data#RES_PACKAGE} value for common data that should be
   5608          * shown using a default style.
   5609          *
   5610          * @hide RES_PACKAGE is hidden
   5611          */
   5612         public static final String PACKAGE_COMMON = "common";
   5613 
   5614         /**
   5615          * The base types that all "Typed" data kinds support.
   5616          */
   5617         public interface BaseTypes {
   5618             /**
   5619              * A custom type. The custom label should be supplied by user.
   5620              */
   5621             public static int TYPE_CUSTOM = 0;
   5622         }
   5623 
   5624         /**
   5625          * Columns common across the specific types.
   5626          */
   5627         protected interface CommonColumns extends BaseTypes {
   5628             /**
   5629              * The data for the contact method.
   5630              * <P>Type: TEXT</P>
   5631              */
   5632             public static final String DATA = DataColumns.DATA1;
   5633 
   5634             /**
   5635              * The type of data, for example Home or Work.
   5636              * <P>Type: INTEGER</P>
   5637              */
   5638             public static final String TYPE = DataColumns.DATA2;
   5639 
   5640             /**
   5641              * The user defined label for the the contact method.
   5642              * <P>Type: TEXT</P>
   5643              */
   5644             public static final String LABEL = DataColumns.DATA3;
   5645         }
   5646 
   5647         /**
   5648          * A data kind representing the contact's proper name. You can use all
   5649          * columns defined for {@link ContactsContract.Data} as well as the following aliases.
   5650          *
   5651          * <h2>Column aliases</h2>
   5652          * <table class="jd-sumtable">
   5653          * <tr>
   5654          * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
   5655          * </tr>
   5656          * <tr>
   5657          * <td>String</td>
   5658          * <td>{@link #DISPLAY_NAME}</td>
   5659          * <td>{@link #DATA1}</td>
   5660          * <td></td>
   5661          * </tr>
   5662          * <tr>
   5663          * <td>String</td>
   5664          * <td>{@link #GIVEN_NAME}</td>
   5665          * <td>{@link #DATA2}</td>
   5666          * <td></td>
   5667          * </tr>
   5668          * <tr>
   5669          * <td>String</td>
   5670          * <td>{@link #FAMILY_NAME}</td>
   5671          * <td>{@link #DATA3}</td>
   5672          * <td></td>
   5673          * </tr>
   5674          * <tr>
   5675          * <td>String</td>
   5676          * <td>{@link #PREFIX}</td>
   5677          * <td>{@link #DATA4}</td>
   5678          * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
   5679          * </tr>
   5680          * <tr>
   5681          * <td>String</td>
   5682          * <td>{@link #MIDDLE_NAME}</td>
   5683          * <td>{@link #DATA5}</td>
   5684          * <td></td>
   5685          * </tr>
   5686          * <tr>
   5687          * <td>String</td>
   5688          * <td>{@link #SUFFIX}</td>
   5689          * <td>{@link #DATA6}</td>
   5690          * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
   5691          * </tr>
   5692          * <tr>
   5693          * <td>String</td>
   5694          * <td>{@link #PHONETIC_GIVEN_NAME}</td>
   5695          * <td>{@link #DATA7}</td>
   5696          * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
   5697          * </tr>
   5698          * <tr>
   5699          * <td>String</td>
   5700          * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
   5701          * <td>{@link #DATA8}</td>
   5702          * <td></td>
   5703          * </tr>
   5704          * <tr>
   5705          * <td>String</td>
   5706          * <td>{@link #PHONETIC_FAMILY_NAME}</td>
   5707          * <td>{@link #DATA9}</td>
   5708          * <td></td>
   5709          * </tr>
   5710          * </table>
   5711          */
   5712         public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
   5713             /**
   5714              * This utility class cannot be instantiated
   5715              */
   5716             private StructuredName() {}
   5717 
   5718             /** MIME type used when storing this in data table. */
   5719             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
   5720 
   5721             /**
   5722              * The name that should be used to display the contact.
   5723              * <i>Unstructured component of the name should be consistent with
   5724              * its structured representation.</i>
   5725              * <p>
   5726              * Type: TEXT
   5727              */
   5728             public static final String DISPLAY_NAME = DATA1;
   5729 
   5730             /**
   5731              * The given name for the contact.
   5732              * <P>Type: TEXT</P>
   5733              */
   5734             public static final String GIVEN_NAME = DATA2;
   5735 
   5736             /**
   5737              * The family name for the contact.
   5738              * <P>Type: TEXT</P>
   5739              */
   5740             public static final String FAMILY_NAME = DATA3;
   5741 
   5742             /**
   5743              * The contact's honorific prefix, e.g. "Sir"
   5744              * <P>Type: TEXT</P>
   5745              */
   5746             public static final String PREFIX = DATA4;
   5747 
   5748             /**
   5749              * The contact's middle name
   5750              * <P>Type: TEXT</P>
   5751              */
   5752             public static final String MIDDLE_NAME = DATA5;
   5753 
   5754             /**
   5755              * The contact's honorific suffix, e.g. "Jr"
   5756              */
   5757             public static final String SUFFIX = DATA6;
   5758 
   5759             /**
   5760              * The phonetic version of the given name for the contact.
   5761              * <P>Type: TEXT</P>
   5762              */
   5763             public static final String PHONETIC_GIVEN_NAME = DATA7;
   5764 
   5765             /**
   5766              * The phonetic version of the additional name for the contact.
   5767              * <P>Type: TEXT</P>
   5768              */
   5769             public static final String PHONETIC_MIDDLE_NAME = DATA8;
   5770 
   5771             /**
   5772              * The phonetic version of the family name for the contact.
   5773              * <P>Type: TEXT</P>
   5774              */
   5775             public static final String PHONETIC_FAMILY_NAME = DATA9;
   5776 
   5777             /**
   5778              * The style used for combining given/middle/family name into a full name.
   5779              * See {@link ContactsContract.FullNameStyle}.
   5780              */
   5781             public static final String FULL_NAME_STYLE = DATA10;
   5782 
   5783             /**
   5784              * The alphabet used for capturing the phonetic name.
   5785              * See ContactsContract.PhoneticNameStyle.
   5786              */
   5787             public static final String PHONETIC_NAME_STYLE = DATA11;
   5788         }
   5789 
   5790         /**
   5791          * <p>A data kind representing the contact's nickname. For example, for
   5792          * Bob Parr ("Mr. Incredible"):
   5793          * <pre>
   5794          * ArrayList&lt;ContentProviderOperation&gt; ops =
   5795          *          new ArrayList&lt;ContentProviderOperation&gt;();
   5796          *
   5797          * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   5798          *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
   5799          *          .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
   5800          *          .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
   5801          *          .build());
   5802          *
   5803          * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
   5804          *          .withValue(Data.RAW_CONTACT_ID, rawContactId)
   5805          *          .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
   5806          *          .withValue(Nickname.NAME, "Mr. Incredible")
   5807          *          .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
   5808          *          .withValue(Nickname.LABEL, "Superhero")
   5809          *          .build());
   5810          *
   5811          * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
   5812          * </pre>
   5813          * </p>
   5814          * <p>
   5815          * You can use all columns defined for {@link ContactsContract.Data} as well as the
   5816          * following aliases.
   5817          * </p>
   5818          *
   5819          * <h2>Column aliases</h2>
   5820          * <table class="jd-sumtable">
   5821          * <tr>
   5822          * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
   5823          * </tr>
   5824          * <tr>
   5825          * <td>String</td>
   5826          * <td>{@link #NAME}</td>
   5827          * <td>{@link #DATA1}</td>
   5828          * <td></td>
   5829          * </tr>
   5830          * <tr>
   5831          * <td>int</td>
   5832          * <td>{@link #TYPE}</td>
   5833          * <td>{@link #DATA2}</td>
   5834          * <td>
   5835          * Allowed values are:
   5836          * <p>
   5837          * <ul>
   5838          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   5839          * <li>{@link #TYPE_DEFAULT}</li>
   5840          * <li>{@link #TYPE_OTHER_NAME}</li>
   5841          * <li>{@link #TYPE_MAIDEN_NAME}</li>
   5842          * <li>{@link #TYPE_SHORT_NAME}</li>
   5843          * <li>{@link #TYPE_INITIALS}</li>
   5844          * </ul>
   5845          * </p>
   5846          * </td>
   5847          * </tr>
   5848          * <tr>
   5849          * <td>String</td>
   5850          * <td>{@link #LABEL}</td>
   5851          * <td>{@link #DATA3}</td>
   5852          * <td></td>
   5853          * </tr>
   5854          * </table>
   5855          */
   5856         public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
   5857                 ContactCounts{
   5858             /**
   5859              * This utility class cannot be instantiated
   5860              */
   5861             private Nickname() {}
   5862 
   5863             /** MIME type used when storing this in data table. */
   5864             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
   5865 
   5866             public static final int TYPE_DEFAULT = 1;
   5867             public static final int TYPE_OTHER_NAME = 2;
   5868             public static final int TYPE_MAIDEN_NAME = 3;
   5869             /** @deprecated Use TYPE_MAIDEN_NAME instead. */
   5870             @Deprecated
   5871             public static final int TYPE_MAINDEN_NAME = 3;
   5872             public static final int TYPE_SHORT_NAME = 4;
   5873             public static final int TYPE_INITIALS = 5;
   5874 
   5875             /**
   5876              * The name itself
   5877              */
   5878             public static final String NAME = DATA;
   5879         }
   5880 
   5881         /**
   5882          * <p>
   5883          * A data kind representing a telephone number.
   5884          * </p>
   5885          * <p>
   5886          * You can use all columns defined for {@link ContactsContract.Data} as
   5887          * well as the following aliases.
   5888          * </p>
   5889          * <h2>Column aliases</h2>
   5890          * <table class="jd-sumtable">
   5891          * <tr>
   5892          * <th>Type</th>
   5893          * <th>Alias</th><th colspan='2'>Data column</th>
   5894          * </tr>
   5895          * <tr>
   5896          * <td>String</td>
   5897          * <td>{@link #NUMBER}</td>
   5898          * <td>{@link #DATA1}</td>
   5899          * <td></td>
   5900          * </tr>
   5901          * <tr>
   5902          * <td>int</td>
   5903          * <td>{@link #TYPE}</td>
   5904          * <td>{@link #DATA2}</td>
   5905          * <td>Allowed values are:
   5906          * <p>
   5907          * <ul>
   5908          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   5909          * <li>{@link #TYPE_HOME}</li>
   5910          * <li>{@link #TYPE_MOBILE}</li>
   5911          * <li>{@link #TYPE_WORK}</li>
   5912          * <li>{@link #TYPE_FAX_WORK}</li>
   5913          * <li>{@link #TYPE_FAX_HOME}</li>
   5914          * <li>{@link #TYPE_PAGER}</li>
   5915          * <li>{@link #TYPE_OTHER}</li>
   5916          * <li>{@link #TYPE_CALLBACK}</li>
   5917          * <li>{@link #TYPE_CAR}</li>
   5918          * <li>{@link #TYPE_COMPANY_MAIN}</li>
   5919          * <li>{@link #TYPE_ISDN}</li>
   5920          * <li>{@link #TYPE_MAIN}</li>
   5921          * <li>{@link #TYPE_OTHER_FAX}</li>
   5922          * <li>{@link #TYPE_RADIO}</li>
   5923          * <li>{@link #TYPE_TELEX}</li>
   5924          * <li>{@link #TYPE_TTY_TDD}</li>
   5925          * <li>{@link #TYPE_WORK_MOBILE}</li>
   5926          * <li>{@link #TYPE_WORK_PAGER}</li>
   5927          * <li>{@link #TYPE_ASSISTANT}</li>
   5928          * <li>{@link #TYPE_MMS}</li>
   5929          * </ul>
   5930          * </p>
   5931          * </td>
   5932          * </tr>
   5933          * <tr>
   5934          * <td>String</td>
   5935          * <td>{@link #LABEL}</td>
   5936          * <td>{@link #DATA3}</td>
   5937          * <td></td>
   5938          * </tr>
   5939          * </table>
   5940          */
   5941         public static final class Phone implements DataColumnsWithJoins, CommonColumns,
   5942                 ContactCounts {
   5943             /**
   5944              * This utility class cannot be instantiated
   5945              */
   5946             private Phone() {}
   5947 
   5948             /** MIME type used when storing this in data table. */
   5949             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
   5950 
   5951             /**
   5952              * The MIME type of {@link #CONTENT_URI} providing a directory of
   5953              * phones.
   5954              */
   5955             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
   5956 
   5957             /**
   5958              * The content:// style URI for all data records of the
   5959              * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
   5960              * associated raw contact and aggregate contact data.
   5961              */
   5962             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   5963                     "phones");
   5964 
   5965             /**
   5966             * URI used for getting all contacts from primary and managed profile.
   5967             *
   5968             * It supports the same semantics as {@link #CONTENT_URI} and returns the same
   5969             * columns.  If the device has no corp profile that is linked to the current profile, it
   5970             * behaves in the exact same way as {@link #CONTENT_URI}.  If there is a corp profile
   5971             * linked to the current profile, it will merge corp profile and current profile's
   5972             * results and return
   5973             *
   5974             * @hide
   5975             */
   5976             public static final Uri ENTERPRISE_CONTENT_URI =
   5977                     Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones");
   5978 
   5979             /**
   5980              * The content:// style URL for phone lookup using a filter. The filter returns
   5981              * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
   5982              * to display names as well as phone numbers. The filter argument should be passed
   5983              * as an additional path segment after this URI.
   5984              */
   5985             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
   5986                     "filter");
   5987 
   5988             /**
   5989              * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
   5990              * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
   5991              * parameters, otherwise it will throw IllegalArgumentException.
   5992              */
   5993             public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
   5994                     CONTENT_URI, "filter_enterprise");
   5995 
   5996             /**
   5997              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
   5998              * If "1" or "true", display names are searched.  If "0" or "false", display names
   5999              * are not searched.  Default is "1".
   6000              */
   6001             public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
   6002 
   6003             /**
   6004              * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
   6005              * If "1" or "true", phone numbers are searched.  If "0" or "false", phone numbers
   6006              * are not searched.  Default is "1".
   6007              */
   6008             public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
   6009 
   6010             public static final int TYPE_HOME = 1;
   6011             public static final int TYPE_MOBILE = 2;
   6012             public static final int TYPE_WORK = 3;
   6013             public static final int TYPE_FAX_WORK = 4;
   6014             public static final int TYPE_FAX_HOME = 5;
   6015             public static final int TYPE_PAGER = 6;
   6016             public static final int TYPE_OTHER = 7;
   6017             public static final int TYPE_CALLBACK = 8;
   6018             public static final int TYPE_CAR = 9;
   6019             public static final int TYPE_COMPANY_MAIN = 10;
   6020             public static final int TYPE_ISDN = 11;
   6021             public static final int TYPE_MAIN = 12;
   6022             public static final int TYPE_OTHER_FAX = 13;
   6023             public static final int TYPE_RADIO = 14;
   6024             public static final int TYPE_TELEX = 15;
   6025             public static final int TYPE_TTY_TDD = 16;
   6026             public static final int TYPE_WORK_MOBILE = 17;
   6027             public static final int TYPE_WORK_PAGER = 18;
   6028             public static final int TYPE_ASSISTANT = 19;
   6029             public static final int TYPE_MMS = 20;
   6030 
   6031             /**
   6032              * The phone number as the user entered it.
   6033              * <P>Type: TEXT</P>
   6034              */
   6035             public static final String NUMBER = DATA;
   6036 
   6037             /**
   6038              * The phone number's E164 representation. This value can be omitted in which
   6039              * case the provider will try to automatically infer it.  (It'll be left null if the
   6040              * provider fails to infer.)
   6041              * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
   6042              * <P>Type: TEXT</P>
   6043              */
   6044             public static final String NORMALIZED_NUMBER = DATA4;
   6045 
   6046             /**
   6047              * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
   6048              * @hide
   6049              */
   6050             @Deprecated
   6051             public static final CharSequence getDisplayLabel(Context context, int type,
   6052                     CharSequence label, CharSequence[] labelArray) {
   6053                 return getTypeLabel(context.getResources(), type, label);
   6054             }
   6055 
   6056             /**
   6057              * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
   6058              * @hide
   6059              */
   6060             @Deprecated
   6061             public static final CharSequence getDisplayLabel(Context context, int type,
   6062                     CharSequence label) {
   6063                 return getTypeLabel(context.getResources(), type, label);
   6064             }
   6065 
   6066             /**
   6067              * Return the string resource that best describes the given
   6068              * {@link #TYPE}. Will always return a valid resource.
   6069              */
   6070             public static final int getTypeLabelResource(int type) {
   6071                 switch (type) {
   6072                     case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
   6073                     case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
   6074                     case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
   6075                     case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
   6076                     case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
   6077                     case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
   6078                     case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
   6079                     case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
   6080                     case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
   6081                     case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
   6082                     case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
   6083                     case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
   6084                     case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
   6085                     case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
   6086                     case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
   6087                     case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
   6088                     case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
   6089                     case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
   6090                     case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
   6091                     case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
   6092                     default: return com.android.internal.R.string.phoneTypeCustom;
   6093                 }
   6094             }
   6095 
   6096             /**
   6097              * Return a {@link CharSequence} that best describes the given type,
   6098              * possibly substituting the given {@link #LABEL} value
   6099              * for {@link #TYPE_CUSTOM}.
   6100              */
   6101             public static final CharSequence getTypeLabel(Resources res, int type,
   6102                     CharSequence label) {
   6103                 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
   6104                     return label;
   6105                 } else {
   6106                     final int labelRes = getTypeLabelResource(type);
   6107                     return res.getText(labelRes);
   6108                 }
   6109             }
   6110         }
   6111 
   6112         /**
   6113          * <p>
   6114          * A data kind representing an email address.
   6115          * </p>
   6116          * <p>
   6117          * You can use all columns defined for {@link ContactsContract.Data} as
   6118          * well as the following aliases.
   6119          * </p>
   6120          * <h2>Column aliases</h2>
   6121          * <table class="jd-sumtable">
   6122          * <tr>
   6123          * <th>Type</th>
   6124          * <th>Alias</th><th colspan='2'>Data column</th>
   6125          * </tr>
   6126          * <tr>
   6127          * <td>String</td>
   6128          * <td>{@link #ADDRESS}</td>
   6129          * <td>{@link #DATA1}</td>
   6130          * <td>Email address itself.</td>
   6131          * </tr>
   6132          * <tr>
   6133          * <td>int</td>
   6134          * <td>{@link #TYPE}</td>
   6135          * <td>{@link #DATA2}</td>
   6136          * <td>Allowed values are:
   6137          * <p>
   6138          * <ul>
   6139          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6140          * <li>{@link #TYPE_HOME}</li>
   6141          * <li>{@link #TYPE_WORK}</li>
   6142          * <li>{@link #TYPE_OTHER}</li>
   6143          * <li>{@link #TYPE_MOBILE}</li>
   6144          * </ul>
   6145          * </p>
   6146          * </td>
   6147          * </tr>
   6148          * <tr>
   6149          * <td>String</td>
   6150          * <td>{@link #LABEL}</td>
   6151          * <td>{@link #DATA3}</td>
   6152          * <td></td>
   6153          * </tr>
   6154          * </table>
   6155          */
   6156         public static final class Email implements DataColumnsWithJoins, CommonColumns,
   6157                 ContactCounts {
   6158             /**
   6159              * This utility class cannot be instantiated
   6160              */
   6161             private Email() {}
   6162 
   6163             /** MIME type used when storing this in data table. */
   6164             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
   6165 
   6166             /**
   6167              * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
   6168              */
   6169             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
   6170 
   6171             /**
   6172              * The content:// style URI for all data records of the
   6173              * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
   6174              * associated raw contact and aggregate contact data.
   6175              */
   6176             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   6177                     "emails");
   6178 
   6179             /**
   6180              * <p>
   6181              * The content:// style URL for looking up data rows by email address. The
   6182              * lookup argument, an email address, should be passed as an additional path segment
   6183              * after this URI.
   6184              * </p>
   6185              * <p>Example:
   6186              * <pre>
   6187              * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
   6188              * Cursor c = getContentResolver().query(uri,
   6189              *          new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
   6190              *          null, null, null);
   6191              * </pre>
   6192              * </p>
   6193              */
   6194             public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
   6195                     "lookup");
   6196 
   6197             /**
   6198             * <p>URI used for enterprise email lookup.</p>
   6199             *
   6200             * <p>
   6201             * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same
   6202             * columns.  If the device has no corp profile that is linked to the current profile, it
   6203             * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}.  If there is a
   6204             * corp profile linked to the current profile, it first queries against the personal contact database,
   6205             * and if no matching contacts are found there, then queries against the
   6206             * corp contacts database.
   6207             * </p>
   6208             * <p>
   6209             * If a result is from the corp profile, it makes the following changes to the data:
   6210             * <ul>
   6211             *     <li>
   6212             *     {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
   6213             *     URIs.  Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
   6214             *     load pictures from them.
   6215             *     {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null.  Do not
   6216             *     use them.
   6217             *     </li>
   6218             *     <li>
   6219             *     Corp contacts will get artificial {@link #CONTACT_ID}s.  In order to tell whether
   6220             *     a contact
   6221             *     is from the corp profile, use
   6222             *     {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
   6223              *     </li>
   6224              *     <li>
   6225              *     Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
   6226              *     </li>
   6227              *     <li>
   6228              *     Returned work contact IDs and lookup keys are not accepted in places that not
   6229              *     explicitly say to accept them.
   6230              *     </li>
   6231              * </ul>
   6232              * <p>
   6233              * A contact lookup URL built by
   6234              * {@link ContactsContract.Contacts#getLookupUri(long, String)}
   6235              * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
   6236              * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
   6237              * corp profile.
   6238              * </p>
   6239             *
   6240             * <pre>
   6241             * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI,
   6242             *         Uri.encode(email));
   6243             * </pre>
   6244             */
   6245             public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI =
   6246                     Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise");
   6247 
   6248             /**
   6249              * <p>
   6250              * The content:// style URL for email lookup using a filter. The filter returns
   6251              * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
   6252              * to display names as well as email addresses. The filter argument should be passed
   6253              * as an additional path segment after this URI.
   6254              * </p>
   6255              * <p>The query in the following example will return "Robert Parr (bob (at) incredibles.com)"
   6256              * as well as "Bob Parr (incredible (at) android.com)".
   6257              * <pre>
   6258              * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
   6259              * Cursor c = getContentResolver().query(uri,
   6260              *          new String[]{Email.DISPLAY_NAME, Email.DATA},
   6261              *          null, null, null);
   6262              * </pre>
   6263              * </p>
   6264              */
   6265             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
   6266                     "filter");
   6267 
   6268             /**
   6269              * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
   6270              * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
   6271              * parameters, otherwise it will throw IllegalArgumentException.
   6272              */
   6273             public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
   6274                     CONTENT_URI, "filter_enterprise");
   6275 
   6276             /**
   6277              * The email address.
   6278              * <P>Type: TEXT</P>
   6279              */
   6280             public static final String ADDRESS = DATA1;
   6281 
   6282             public static final int TYPE_HOME = 1;
   6283             public static final int TYPE_WORK = 2;
   6284             public static final int TYPE_OTHER = 3;
   6285             public static final int TYPE_MOBILE = 4;
   6286 
   6287             /**
   6288              * The display name for the email address
   6289              * <P>Type: TEXT</P>
   6290              */
   6291             public static final String DISPLAY_NAME = DATA4;
   6292 
   6293             /**
   6294              * Return the string resource that best describes the given
   6295              * {@link #TYPE}. Will always return a valid resource.
   6296              */
   6297             public static final int getTypeLabelResource(int type) {
   6298                 switch (type) {
   6299                     case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
   6300                     case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
   6301                     case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
   6302                     case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
   6303                     default: return com.android.internal.R.string.emailTypeCustom;
   6304                 }
   6305             }
   6306 
   6307             /**
   6308              * Return a {@link CharSequence} that best describes the given type,
   6309              * possibly substituting the given {@link #LABEL} value
   6310              * for {@link #TYPE_CUSTOM}.
   6311              */
   6312             public static final CharSequence getTypeLabel(Resources res, int type,
   6313                     CharSequence label) {
   6314                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6315                     return label;
   6316                 } else {
   6317                     final int labelRes = getTypeLabelResource(type);
   6318                     return res.getText(labelRes);
   6319                 }
   6320             }
   6321         }
   6322 
   6323         /**
   6324          * <p>
   6325          * A data kind representing a postal addresses.
   6326          * </p>
   6327          * <p>
   6328          * You can use all columns defined for {@link ContactsContract.Data} as
   6329          * well as the following aliases.
   6330          * </p>
   6331          * <h2>Column aliases</h2>
   6332          * <table class="jd-sumtable">
   6333          * <tr>
   6334          * <th>Type</th>
   6335          * <th>Alias</th><th colspan='2'>Data column</th>
   6336          * </tr>
   6337          * <tr>
   6338          * <td>String</td>
   6339          * <td>{@link #FORMATTED_ADDRESS}</td>
   6340          * <td>{@link #DATA1}</td>
   6341          * <td></td>
   6342          * </tr>
   6343          * <tr>
   6344          * <td>int</td>
   6345          * <td>{@link #TYPE}</td>
   6346          * <td>{@link #DATA2}</td>
   6347          * <td>Allowed values are:
   6348          * <p>
   6349          * <ul>
   6350          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6351          * <li>{@link #TYPE_HOME}</li>
   6352          * <li>{@link #TYPE_WORK}</li>
   6353          * <li>{@link #TYPE_OTHER}</li>
   6354          * </ul>
   6355          * </p>
   6356          * </td>
   6357          * </tr>
   6358          * <tr>
   6359          * <td>String</td>
   6360          * <td>{@link #LABEL}</td>
   6361          * <td>{@link #DATA3}</td>
   6362          * <td></td>
   6363          * </tr>
   6364          * <tr>
   6365          * <td>String</td>
   6366          * <td>{@link #STREET}</td>
   6367          * <td>{@link #DATA4}</td>
   6368          * <td></td>
   6369          * </tr>
   6370          * <tr>
   6371          * <td>String</td>
   6372          * <td>{@link #POBOX}</td>
   6373          * <td>{@link #DATA5}</td>
   6374          * <td>Post Office Box number</td>
   6375          * </tr>
   6376          * <tr>
   6377          * <td>String</td>
   6378          * <td>{@link #NEIGHBORHOOD}</td>
   6379          * <td>{@link #DATA6}</td>
   6380          * <td></td>
   6381          * </tr>
   6382          * <tr>
   6383          * <td>String</td>
   6384          * <td>{@link #CITY}</td>
   6385          * <td>{@link #DATA7}</td>
   6386          * <td></td>
   6387          * </tr>
   6388          * <tr>
   6389          * <td>String</td>
   6390          * <td>{@link #REGION}</td>
   6391          * <td>{@link #DATA8}</td>
   6392          * <td></td>
   6393          * </tr>
   6394          * <tr>
   6395          * <td>String</td>
   6396          * <td>{@link #POSTCODE}</td>
   6397          * <td>{@link #DATA9}</td>
   6398          * <td></td>
   6399          * </tr>
   6400          * <tr>
   6401          * <td>String</td>
   6402          * <td>{@link #COUNTRY}</td>
   6403          * <td>{@link #DATA10}</td>
   6404          * <td></td>
   6405          * </tr>
   6406          * </table>
   6407          */
   6408         public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
   6409                 ContactCounts {
   6410             /**
   6411              * This utility class cannot be instantiated
   6412              */
   6413             private StructuredPostal() {
   6414             }
   6415 
   6416             /** MIME type used when storing this in data table. */
   6417             public static final String CONTENT_ITEM_TYPE =
   6418                     "vnd.android.cursor.item/postal-address_v2";
   6419 
   6420             /**
   6421              * The MIME type of {@link #CONTENT_URI} providing a directory of
   6422              * postal addresses.
   6423              */
   6424             public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
   6425 
   6426             /**
   6427              * The content:// style URI for all data records of the
   6428              * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
   6429              */
   6430             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   6431                     "postals");
   6432 
   6433             public static final int TYPE_HOME = 1;
   6434             public static final int TYPE_WORK = 2;
   6435             public static final int TYPE_OTHER = 3;
   6436 
   6437             /**
   6438              * The full, unstructured postal address. <i>This field must be
   6439              * consistent with any structured data.</i>
   6440              * <p>
   6441              * Type: TEXT
   6442              */
   6443             public static final String FORMATTED_ADDRESS = DATA;
   6444 
   6445             /**
   6446              * Can be street, avenue, road, etc. This element also includes the
   6447              * house number and room/apartment/flat/floor number.
   6448              * <p>
   6449              * Type: TEXT
   6450              */
   6451             public static final String STREET = DATA4;
   6452 
   6453             /**
   6454              * Covers actual P.O. boxes, drawers, locked bags, etc. This is
   6455              * usually but not always mutually exclusive with street.
   6456              * <p>
   6457              * Type: TEXT
   6458              */
   6459             public static final String POBOX = DATA5;
   6460 
   6461             /**
   6462              * This is used to disambiguate a street address when a city
   6463              * contains more than one street with the same name, or to specify a
   6464              * small place whose mail is routed through a larger postal town. In
   6465              * China it could be a county or a minor city.
   6466              * <p>
   6467              * Type: TEXT
   6468              */
   6469             public static final String NEIGHBORHOOD = DATA6;
   6470 
   6471             /**
   6472              * Can be city, village, town, borough, etc. This is the postal town
   6473              * and not necessarily the place of residence or place of business.
   6474              * <p>
   6475              * Type: TEXT
   6476              */
   6477             public static final String CITY = DATA7;
   6478 
   6479             /**
   6480              * A state, province, county (in Ireland), Land (in Germany),
   6481              * departement (in France), etc.
   6482              * <p>
   6483              * Type: TEXT
   6484              */
   6485             public static final String REGION = DATA8;
   6486 
   6487             /**
   6488              * Postal code. Usually country-wide, but sometimes specific to the
   6489              * city (e.g. "2" in "Dublin 2, Ireland" addresses).
   6490              * <p>
   6491              * Type: TEXT
   6492              */
   6493             public static final String POSTCODE = DATA9;
   6494 
   6495             /**
   6496              * The name or code of the country.
   6497              * <p>
   6498              * Type: TEXT
   6499              */
   6500             public static final String COUNTRY = DATA10;
   6501 
   6502             /**
   6503              * Return the string resource that best describes the given
   6504              * {@link #TYPE}. Will always return a valid resource.
   6505              */
   6506             public static final int getTypeLabelResource(int type) {
   6507                 switch (type) {
   6508                     case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
   6509                     case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
   6510                     case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
   6511                     default: return com.android.internal.R.string.postalTypeCustom;
   6512                 }
   6513             }
   6514 
   6515             /**
   6516              * Return a {@link CharSequence} that best describes the given type,
   6517              * possibly substituting the given {@link #LABEL} value
   6518              * for {@link #TYPE_CUSTOM}.
   6519              */
   6520             public static final CharSequence getTypeLabel(Resources res, int type,
   6521                     CharSequence label) {
   6522                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6523                     return label;
   6524                 } else {
   6525                     final int labelRes = getTypeLabelResource(type);
   6526                     return res.getText(labelRes);
   6527                 }
   6528             }
   6529         }
   6530 
   6531         /**
   6532          * <p>
   6533          * A data kind representing an IM address
   6534          * </p>
   6535          * <p>
   6536          * You can use all columns defined for {@link ContactsContract.Data} as
   6537          * well as the following aliases.
   6538          * </p>
   6539          * <h2>Column aliases</h2>
   6540          * <table class="jd-sumtable">
   6541          * <tr>
   6542          * <th>Type</th>
   6543          * <th>Alias</th><th colspan='2'>Data column</th>
   6544          * </tr>
   6545          * <tr>
   6546          * <td>String</td>
   6547          * <td>{@link #DATA}</td>
   6548          * <td>{@link #DATA1}</td>
   6549          * <td></td>
   6550          * </tr>
   6551          * <tr>
   6552          * <td>int</td>
   6553          * <td>{@link #TYPE}</td>
   6554          * <td>{@link #DATA2}</td>
   6555          * <td>Allowed values are:
   6556          * <p>
   6557          * <ul>
   6558          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6559          * <li>{@link #TYPE_HOME}</li>
   6560          * <li>{@link #TYPE_WORK}</li>
   6561          * <li>{@link #TYPE_OTHER}</li>
   6562          * </ul>
   6563          * </p>
   6564          * </td>
   6565          * </tr>
   6566          * <tr>
   6567          * <td>String</td>
   6568          * <td>{@link #LABEL}</td>
   6569          * <td>{@link #DATA3}</td>
   6570          * <td></td>
   6571          * </tr>
   6572          * <tr>
   6573          * <td>String</td>
   6574          * <td>{@link #PROTOCOL}</td>
   6575          * <td>{@link #DATA5}</td>
   6576          * <td>
   6577          * <p>
   6578          * Allowed values:
   6579          * <ul>
   6580          * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
   6581          * as {@link #CUSTOM_PROTOCOL}.</li>
   6582          * <li>{@link #PROTOCOL_AIM}</li>
   6583          * <li>{@link #PROTOCOL_MSN}</li>
   6584          * <li>{@link #PROTOCOL_YAHOO}</li>
   6585          * <li>{@link #PROTOCOL_SKYPE}</li>
   6586          * <li>{@link #PROTOCOL_QQ}</li>
   6587          * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
   6588          * <li>{@link #PROTOCOL_ICQ}</li>
   6589          * <li>{@link #PROTOCOL_JABBER}</li>
   6590          * <li>{@link #PROTOCOL_NETMEETING}</li>
   6591          * </ul>
   6592          * </p>
   6593          * </td>
   6594          * </tr>
   6595          * <tr>
   6596          * <td>String</td>
   6597          * <td>{@link #CUSTOM_PROTOCOL}</td>
   6598          * <td>{@link #DATA6}</td>
   6599          * <td></td>
   6600          * </tr>
   6601          * </table>
   6602          */
   6603         public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
   6604             /**
   6605              * This utility class cannot be instantiated
   6606              */
   6607             private Im() {}
   6608 
   6609             /** MIME type used when storing this in data table. */
   6610             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
   6611 
   6612             public static final int TYPE_HOME = 1;
   6613             public static final int TYPE_WORK = 2;
   6614             public static final int TYPE_OTHER = 3;
   6615 
   6616             /**
   6617              * This column should be populated with one of the defined
   6618              * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
   6619              * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
   6620              * should contain the name of the custom protocol.
   6621              */
   6622             public static final String PROTOCOL = DATA5;
   6623 
   6624             public static final String CUSTOM_PROTOCOL = DATA6;
   6625 
   6626             /*
   6627              * The predefined IM protocol types.
   6628              */
   6629             public static final int PROTOCOL_CUSTOM = -1;
   6630             public static final int PROTOCOL_AIM = 0;
   6631             public static final int PROTOCOL_MSN = 1;
   6632             public static final int PROTOCOL_YAHOO = 2;
   6633             public static final int PROTOCOL_SKYPE = 3;
   6634             public static final int PROTOCOL_QQ = 4;
   6635             public static final int PROTOCOL_GOOGLE_TALK = 5;
   6636             public static final int PROTOCOL_ICQ = 6;
   6637             public static final int PROTOCOL_JABBER = 7;
   6638             public static final int PROTOCOL_NETMEETING = 8;
   6639 
   6640             /**
   6641              * Return the string resource that best describes the given
   6642              * {@link #TYPE}. Will always return a valid resource.
   6643              */
   6644             public static final int getTypeLabelResource(int type) {
   6645                 switch (type) {
   6646                     case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
   6647                     case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
   6648                     case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
   6649                     default: return com.android.internal.R.string.imTypeCustom;
   6650                 }
   6651             }
   6652 
   6653             /**
   6654              * Return a {@link CharSequence} that best describes the given type,
   6655              * possibly substituting the given {@link #LABEL} value
   6656              * for {@link #TYPE_CUSTOM}.
   6657              */
   6658             public static final CharSequence getTypeLabel(Resources res, int type,
   6659                     CharSequence label) {
   6660                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6661                     return label;
   6662                 } else {
   6663                     final int labelRes = getTypeLabelResource(type);
   6664                     return res.getText(labelRes);
   6665                 }
   6666             }
   6667 
   6668             /**
   6669              * Return the string resource that best describes the given
   6670              * {@link #PROTOCOL}. Will always return a valid resource.
   6671              */
   6672             public static final int getProtocolLabelResource(int type) {
   6673                 switch (type) {
   6674                     case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
   6675                     case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
   6676                     case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
   6677                     case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
   6678                     case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
   6679                     case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
   6680                     case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
   6681                     case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
   6682                     case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
   6683                     default: return com.android.internal.R.string.imProtocolCustom;
   6684                 }
   6685             }
   6686 
   6687             /**
   6688              * Return a {@link CharSequence} that best describes the given
   6689              * protocol, possibly substituting the given
   6690              * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
   6691              */
   6692             public static final CharSequence getProtocolLabel(Resources res, int type,
   6693                     CharSequence label) {
   6694                 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
   6695                     return label;
   6696                 } else {
   6697                     final int labelRes = getProtocolLabelResource(type);
   6698                     return res.getText(labelRes);
   6699                 }
   6700             }
   6701         }
   6702 
   6703         /**
   6704          * <p>
   6705          * A data kind representing an organization.
   6706          * </p>
   6707          * <p>
   6708          * You can use all columns defined for {@link ContactsContract.Data} as
   6709          * well as the following aliases.
   6710          * </p>
   6711          * <h2>Column aliases</h2>
   6712          * <table class="jd-sumtable">
   6713          * <tr>
   6714          * <th>Type</th>
   6715          * <th>Alias</th><th colspan='2'>Data column</th>
   6716          * </tr>
   6717          * <tr>
   6718          * <td>String</td>
   6719          * <td>{@link #COMPANY}</td>
   6720          * <td>{@link #DATA1}</td>
   6721          * <td></td>
   6722          * </tr>
   6723          * <tr>
   6724          * <td>int</td>
   6725          * <td>{@link #TYPE}</td>
   6726          * <td>{@link #DATA2}</td>
   6727          * <td>Allowed values are:
   6728          * <p>
   6729          * <ul>
   6730          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6731          * <li>{@link #TYPE_WORK}</li>
   6732          * <li>{@link #TYPE_OTHER}</li>
   6733          * </ul>
   6734          * </p>
   6735          * </td>
   6736          * </tr>
   6737          * <tr>
   6738          * <td>String</td>
   6739          * <td>{@link #LABEL}</td>
   6740          * <td>{@link #DATA3}</td>
   6741          * <td></td>
   6742          * </tr>
   6743          * <tr>
   6744          * <td>String</td>
   6745          * <td>{@link #TITLE}</td>
   6746          * <td>{@link #DATA4}</td>
   6747          * <td></td>
   6748          * </tr>
   6749          * <tr>
   6750          * <td>String</td>
   6751          * <td>{@link #DEPARTMENT}</td>
   6752          * <td>{@link #DATA5}</td>
   6753          * <td></td>
   6754          * </tr>
   6755          * <tr>
   6756          * <td>String</td>
   6757          * <td>{@link #JOB_DESCRIPTION}</td>
   6758          * <td>{@link #DATA6}</td>
   6759          * <td></td>
   6760          * </tr>
   6761          * <tr>
   6762          * <td>String</td>
   6763          * <td>{@link #SYMBOL}</td>
   6764          * <td>{@link #DATA7}</td>
   6765          * <td></td>
   6766          * </tr>
   6767          * <tr>
   6768          * <td>String</td>
   6769          * <td>{@link #PHONETIC_NAME}</td>
   6770          * <td>{@link #DATA8}</td>
   6771          * <td></td>
   6772          * </tr>
   6773          * <tr>
   6774          * <td>String</td>
   6775          * <td>{@link #OFFICE_LOCATION}</td>
   6776          * <td>{@link #DATA9}</td>
   6777          * <td></td>
   6778          * </tr>
   6779          * <tr>
   6780          * <td>String</td>
   6781          * <td>PHONETIC_NAME_STYLE</td>
   6782          * <td>{@link #DATA10}</td>
   6783          * <td></td>
   6784          * </tr>
   6785          * </table>
   6786          */
   6787         public static final class Organization implements DataColumnsWithJoins, CommonColumns,
   6788                 ContactCounts {
   6789             /**
   6790              * This utility class cannot be instantiated
   6791              */
   6792             private Organization() {}
   6793 
   6794             /** MIME type used when storing this in data table. */
   6795             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
   6796 
   6797             public static final int TYPE_WORK = 1;
   6798             public static final int TYPE_OTHER = 2;
   6799 
   6800             /**
   6801              * The company as the user entered it.
   6802              * <P>Type: TEXT</P>
   6803              */
   6804             public static final String COMPANY = DATA;
   6805 
   6806             /**
   6807              * The position title at this company as the user entered it.
   6808              * <P>Type: TEXT</P>
   6809              */
   6810             public static final String TITLE = DATA4;
   6811 
   6812             /**
   6813              * The department at this company as the user entered it.
   6814              * <P>Type: TEXT</P>
   6815              */
   6816             public static final String DEPARTMENT = DATA5;
   6817 
   6818             /**
   6819              * The job description at this company as the user entered it.
   6820              * <P>Type: TEXT</P>
   6821              */
   6822             public static final String JOB_DESCRIPTION = DATA6;
   6823 
   6824             /**
   6825              * The symbol of this company as the user entered it.
   6826              * <P>Type: TEXT</P>
   6827              */
   6828             public static final String SYMBOL = DATA7;
   6829 
   6830             /**
   6831              * The phonetic name of this company as the user entered it.
   6832              * <P>Type: TEXT</P>
   6833              */
   6834             public static final String PHONETIC_NAME = DATA8;
   6835 
   6836             /**
   6837              * The office location of this organization.
   6838              * <P>Type: TEXT</P>
   6839              */
   6840             public static final String OFFICE_LOCATION = DATA9;
   6841 
   6842             /**
   6843              * The alphabet used for capturing the phonetic name.
   6844              * See {@link ContactsContract.PhoneticNameStyle}.
   6845              */
   6846             public static final String PHONETIC_NAME_STYLE = DATA10;
   6847 
   6848             /**
   6849              * Return the string resource that best describes the given
   6850              * {@link #TYPE}. Will always return a valid resource.
   6851              */
   6852             public static final int getTypeLabelResource(int type) {
   6853                 switch (type) {
   6854                     case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
   6855                     case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
   6856                     default: return com.android.internal.R.string.orgTypeCustom;
   6857                 }
   6858             }
   6859 
   6860             /**
   6861              * Return a {@link CharSequence} that best describes the given type,
   6862              * possibly substituting the given {@link #LABEL} value
   6863              * for {@link #TYPE_CUSTOM}.
   6864              */
   6865             public static final CharSequence getTypeLabel(Resources res, int type,
   6866                     CharSequence label) {
   6867                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6868                     return label;
   6869                 } else {
   6870                     final int labelRes = getTypeLabelResource(type);
   6871                     return res.getText(labelRes);
   6872                 }
   6873             }
   6874         }
   6875 
   6876         /**
   6877          * <p>
   6878          * A data kind representing a relation.
   6879          * </p>
   6880          * <p>
   6881          * You can use all columns defined for {@link ContactsContract.Data} as
   6882          * well as the following aliases.
   6883          * </p>
   6884          * <h2>Column aliases</h2>
   6885          * <table class="jd-sumtable">
   6886          * <tr>
   6887          * <th>Type</th>
   6888          * <th>Alias</th><th colspan='2'>Data column</th>
   6889          * </tr>
   6890          * <tr>
   6891          * <td>String</td>
   6892          * <td>{@link #NAME}</td>
   6893          * <td>{@link #DATA1}</td>
   6894          * <td></td>
   6895          * </tr>
   6896          * <tr>
   6897          * <td>int</td>
   6898          * <td>{@link #TYPE}</td>
   6899          * <td>{@link #DATA2}</td>
   6900          * <td>Allowed values are:
   6901          * <p>
   6902          * <ul>
   6903          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   6904          * <li>{@link #TYPE_ASSISTANT}</li>
   6905          * <li>{@link #TYPE_BROTHER}</li>
   6906          * <li>{@link #TYPE_CHILD}</li>
   6907          * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
   6908          * <li>{@link #TYPE_FATHER}</li>
   6909          * <li>{@link #TYPE_FRIEND}</li>
   6910          * <li>{@link #TYPE_MANAGER}</li>
   6911          * <li>{@link #TYPE_MOTHER}</li>
   6912          * <li>{@link #TYPE_PARENT}</li>
   6913          * <li>{@link #TYPE_PARTNER}</li>
   6914          * <li>{@link #TYPE_REFERRED_BY}</li>
   6915          * <li>{@link #TYPE_RELATIVE}</li>
   6916          * <li>{@link #TYPE_SISTER}</li>
   6917          * <li>{@link #TYPE_SPOUSE}</li>
   6918          * </ul>
   6919          * </p>
   6920          * </td>
   6921          * </tr>
   6922          * <tr>
   6923          * <td>String</td>
   6924          * <td>{@link #LABEL}</td>
   6925          * <td>{@link #DATA3}</td>
   6926          * <td></td>
   6927          * </tr>
   6928          * </table>
   6929          */
   6930         public static final class Relation implements DataColumnsWithJoins, CommonColumns,
   6931                 ContactCounts {
   6932             /**
   6933              * This utility class cannot be instantiated
   6934              */
   6935             private Relation() {}
   6936 
   6937             /** MIME type used when storing this in data table. */
   6938             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
   6939 
   6940             public static final int TYPE_ASSISTANT = 1;
   6941             public static final int TYPE_BROTHER = 2;
   6942             public static final int TYPE_CHILD = 3;
   6943             public static final int TYPE_DOMESTIC_PARTNER = 4;
   6944             public static final int TYPE_FATHER = 5;
   6945             public static final int TYPE_FRIEND = 6;
   6946             public static final int TYPE_MANAGER = 7;
   6947             public static final int TYPE_MOTHER = 8;
   6948             public static final int TYPE_PARENT = 9;
   6949             public static final int TYPE_PARTNER = 10;
   6950             public static final int TYPE_REFERRED_BY = 11;
   6951             public static final int TYPE_RELATIVE = 12;
   6952             public static final int TYPE_SISTER = 13;
   6953             public static final int TYPE_SPOUSE = 14;
   6954 
   6955             /**
   6956              * The name of the relative as the user entered it.
   6957              * <P>Type: TEXT</P>
   6958              */
   6959             public static final String NAME = DATA;
   6960 
   6961             /**
   6962              * Return the string resource that best describes the given
   6963              * {@link #TYPE}. Will always return a valid resource.
   6964              */
   6965             public static final int getTypeLabelResource(int type) {
   6966                 switch (type) {
   6967                     case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
   6968                     case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
   6969                     case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
   6970                     case TYPE_DOMESTIC_PARTNER:
   6971                             return com.android.internal.R.string.relationTypeDomesticPartner;
   6972                     case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
   6973                     case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
   6974                     case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
   6975                     case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
   6976                     case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
   6977                     case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
   6978                     case TYPE_REFERRED_BY:
   6979                             return com.android.internal.R.string.relationTypeReferredBy;
   6980                     case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
   6981                     case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
   6982                     case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
   6983                     default: return com.android.internal.R.string.orgTypeCustom;
   6984                 }
   6985             }
   6986 
   6987             /**
   6988              * Return a {@link CharSequence} that best describes the given type,
   6989              * possibly substituting the given {@link #LABEL} value
   6990              * for {@link #TYPE_CUSTOM}.
   6991              */
   6992             public static final CharSequence getTypeLabel(Resources res, int type,
   6993                     CharSequence label) {
   6994                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   6995                     return label;
   6996                 } else {
   6997                     final int labelRes = getTypeLabelResource(type);
   6998                     return res.getText(labelRes);
   6999                 }
   7000             }
   7001         }
   7002 
   7003         /**
   7004          * <p>
   7005          * A data kind representing an event.
   7006          * </p>
   7007          * <p>
   7008          * You can use all columns defined for {@link ContactsContract.Data} as
   7009          * well as the following aliases.
   7010          * </p>
   7011          * <h2>Column aliases</h2>
   7012          * <table class="jd-sumtable">
   7013          * <tr>
   7014          * <th>Type</th>
   7015          * <th>Alias</th><th colspan='2'>Data column</th>
   7016          * </tr>
   7017          * <tr>
   7018          * <td>String</td>
   7019          * <td>{@link #START_DATE}</td>
   7020          * <td>{@link #DATA1}</td>
   7021          * <td></td>
   7022          * </tr>
   7023          * <tr>
   7024          * <td>int</td>
   7025          * <td>{@link #TYPE}</td>
   7026          * <td>{@link #DATA2}</td>
   7027          * <td>Allowed values are:
   7028          * <p>
   7029          * <ul>
   7030          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   7031          * <li>{@link #TYPE_ANNIVERSARY}</li>
   7032          * <li>{@link #TYPE_OTHER}</li>
   7033          * <li>{@link #TYPE_BIRTHDAY}</li>
   7034          * </ul>
   7035          * </p>
   7036          * </td>
   7037          * </tr>
   7038          * <tr>
   7039          * <td>String</td>
   7040          * <td>{@link #LABEL}</td>
   7041          * <td>{@link #DATA3}</td>
   7042          * <td></td>
   7043          * </tr>
   7044          * </table>
   7045          */
   7046         public static final class Event implements DataColumnsWithJoins, CommonColumns,
   7047                 ContactCounts {
   7048             /**
   7049              * This utility class cannot be instantiated
   7050              */
   7051             private Event() {}
   7052 
   7053             /** MIME type used when storing this in data table. */
   7054             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
   7055 
   7056             public static final int TYPE_ANNIVERSARY = 1;
   7057             public static final int TYPE_OTHER = 2;
   7058             public static final int TYPE_BIRTHDAY = 3;
   7059 
   7060             /**
   7061              * The event start date as the user entered it.
   7062              * <P>Type: TEXT</P>
   7063              */
   7064             public static final String START_DATE = DATA;
   7065 
   7066             /**
   7067              * Return the string resource that best describes the given
   7068              * {@link #TYPE}. Will always return a valid resource.
   7069              */
   7070             public static int getTypeResource(Integer type) {
   7071                 if (type == null) {
   7072                     return com.android.internal.R.string.eventTypeOther;
   7073                 }
   7074                 switch (type) {
   7075                     case TYPE_ANNIVERSARY:
   7076                         return com.android.internal.R.string.eventTypeAnniversary;
   7077                     case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
   7078                     case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
   7079                     default: return com.android.internal.R.string.eventTypeCustom;
   7080                 }
   7081             }
   7082 
   7083             /**
   7084              * Return a {@link CharSequence} that best describes the given type,
   7085              * possibly substituting the given {@link #LABEL} value
   7086              * for {@link #TYPE_CUSTOM}.
   7087              */
   7088             public static final CharSequence getTypeLabel(Resources res, int type,
   7089                     CharSequence label) {
   7090                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   7091                     return label;
   7092                 } else {
   7093                     final int labelRes = getTypeResource(type);
   7094                     return res.getText(labelRes);
   7095                 }
   7096             }
   7097         }
   7098 
   7099         /**
   7100          * <p>
   7101          * A data kind representing a photo for the contact.
   7102          * </p>
   7103          * <p>
   7104          * Some sync adapters will choose to download photos in a separate
   7105          * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
   7106          * through {@link ContactsContract.Data#SYNC4} to store temporary
   7107          * data, e.g. the image URL or ID, state of download, server-side version
   7108          * of the image.  It is allowed for the {@link #PHOTO} to be null.
   7109          * </p>
   7110          * <p>
   7111          * You can use all columns defined for {@link ContactsContract.Data} as
   7112          * well as the following aliases.
   7113          * </p>
   7114          * <h2>Column aliases</h2>
   7115          * <table class="jd-sumtable">
   7116          * <tr>
   7117          * <th>Type</th>
   7118          * <th>Alias</th><th colspan='2'>Data column</th>
   7119          * </tr>
   7120          * <tr>
   7121          * <td>NUMBER</td>
   7122          * <td>{@link #PHOTO_FILE_ID}</td>
   7123          * <td>{@link #DATA14}</td>
   7124          * <td>ID of the hi-res photo file.</td>
   7125          * </tr>
   7126          * <tr>
   7127          * <td>BLOB</td>
   7128          * <td>{@link #PHOTO}</td>
   7129          * <td>{@link #DATA15}</td>
   7130          * <td>By convention, binary data is stored in DATA15.  The thumbnail of the
   7131          * photo is stored in this column.</td>
   7132          * </tr>
   7133          * </table>
   7134          */
   7135         public static final class Photo implements DataColumnsWithJoins, ContactCounts {
   7136             /**
   7137              * This utility class cannot be instantiated
   7138              */
   7139             private Photo() {}
   7140 
   7141             /** MIME type used when storing this in data table. */
   7142             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
   7143 
   7144             /**
   7145              * Photo file ID for the display photo of the raw contact.
   7146              * See {@link ContactsContract.DisplayPhoto}.
   7147              * <p>
   7148              * Type: NUMBER
   7149              */
   7150             public static final String PHOTO_FILE_ID = DATA14;
   7151 
   7152             /**
   7153              * Thumbnail photo of the raw contact. This is the raw bytes of an image
   7154              * that could be inflated using {@link android.graphics.BitmapFactory}.
   7155              * <p>
   7156              * Type: BLOB
   7157              */
   7158             public static final String PHOTO = DATA15;
   7159         }
   7160 
   7161         /**
   7162          * <p>
   7163          * Notes about the contact.
   7164          * </p>
   7165          * <p>
   7166          * You can use all columns defined for {@link ContactsContract.Data} as
   7167          * well as the following aliases.
   7168          * </p>
   7169          * <h2>Column aliases</h2>
   7170          * <table class="jd-sumtable">
   7171          * <tr>
   7172          * <th>Type</th>
   7173          * <th>Alias</th><th colspan='2'>Data column</th>
   7174          * </tr>
   7175          * <tr>
   7176          * <td>String</td>
   7177          * <td>{@link #NOTE}</td>
   7178          * <td>{@link #DATA1}</td>
   7179          * <td></td>
   7180          * </tr>
   7181          * </table>
   7182          */
   7183         public static final class Note implements DataColumnsWithJoins, ContactCounts {
   7184             /**
   7185              * This utility class cannot be instantiated
   7186              */
   7187             private Note() {}
   7188 
   7189             /** MIME type used when storing this in data table. */
   7190             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
   7191 
   7192             /**
   7193              * The note text.
   7194              * <P>Type: TEXT</P>
   7195              */
   7196             public static final String NOTE = DATA1;
   7197         }
   7198 
   7199         /**
   7200          * <p>
   7201          * Group Membership.
   7202          * </p>
   7203          * <p>
   7204          * You can use all columns defined for {@link ContactsContract.Data} as
   7205          * well as the following aliases.
   7206          * </p>
   7207          * <h2>Column aliases</h2>
   7208          * <table class="jd-sumtable">
   7209          * <tr>
   7210          * <th>Type</th>
   7211          * <th>Alias</th><th colspan='2'>Data column</th>
   7212          * </tr>
   7213          * <tr>
   7214          * <td>long</td>
   7215          * <td>{@link #GROUP_ROW_ID}</td>
   7216          * <td>{@link #DATA1}</td>
   7217          * <td></td>
   7218          * </tr>
   7219          * <tr>
   7220          * <td>String</td>
   7221          * <td>{@link #GROUP_SOURCE_ID}</td>
   7222          * <td>none</td>
   7223          * <td>
   7224          * <p>
   7225          * The sourceid of the group that this group membership refers to.
   7226          * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
   7227          * inserting a row.
   7228          * </p>
   7229          * <p>
   7230          * If this field is specified, the provider will first try to
   7231          * look up a group with this {@link Groups Groups.SOURCE_ID}.  If such a group
   7232          * is found, it will use the corresponding row id.  If the group is not
   7233          * found, it will create one.
   7234          * </td>
   7235          * </tr>
   7236          * </table>
   7237          */
   7238         public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
   7239             /**
   7240              * This utility class cannot be instantiated
   7241              */
   7242             private GroupMembership() {}
   7243 
   7244             /** MIME type used when storing this in data table. */
   7245             public static final String CONTENT_ITEM_TYPE =
   7246                     "vnd.android.cursor.item/group_membership";
   7247 
   7248             /**
   7249              * The row id of the group that this group membership refers to. Exactly one of
   7250              * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
   7251              * <P>Type: INTEGER</P>
   7252              */
   7253             public static final String GROUP_ROW_ID = DATA1;
   7254 
   7255             /**
   7256              * The sourceid of the group that this group membership refers to.  Exactly one of
   7257              * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
   7258              * <P>Type: TEXT</P>
   7259              */
   7260             public static final String GROUP_SOURCE_ID = "group_sourceid";
   7261         }
   7262 
   7263         /**
   7264          * <p>
   7265          * A data kind representing a website related to the contact.
   7266          * </p>
   7267          * <p>
   7268          * You can use all columns defined for {@link ContactsContract.Data} as
   7269          * well as the following aliases.
   7270          * </p>
   7271          * <h2>Column aliases</h2>
   7272          * <table class="jd-sumtable">
   7273          * <tr>
   7274          * <th>Type</th>
   7275          * <th>Alias</th><th colspan='2'>Data column</th>
   7276          * </tr>
   7277          * <tr>
   7278          * <td>String</td>
   7279          * <td>{@link #URL}</td>
   7280          * <td>{@link #DATA1}</td>
   7281          * <td></td>
   7282          * </tr>
   7283          * <tr>
   7284          * <td>int</td>
   7285          * <td>{@link #TYPE}</td>
   7286          * <td>{@link #DATA2}</td>
   7287          * <td>Allowed values are:
   7288          * <p>
   7289          * <ul>
   7290          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   7291          * <li>{@link #TYPE_HOMEPAGE}</li>
   7292          * <li>{@link #TYPE_BLOG}</li>
   7293          * <li>{@link #TYPE_PROFILE}</li>
   7294          * <li>{@link #TYPE_HOME}</li>
   7295          * <li>{@link #TYPE_WORK}</li>
   7296          * <li>{@link #TYPE_FTP}</li>
   7297          * <li>{@link #TYPE_OTHER}</li>
   7298          * </ul>
   7299          * </p>
   7300          * </td>
   7301          * </tr>
   7302          * <tr>
   7303          * <td>String</td>
   7304          * <td>{@link #LABEL}</td>
   7305          * <td>{@link #DATA3}</td>
   7306          * <td></td>
   7307          * </tr>
   7308          * </table>
   7309          */
   7310         public static final class Website implements DataColumnsWithJoins, CommonColumns,
   7311                 ContactCounts {
   7312             /**
   7313              * This utility class cannot be instantiated
   7314              */
   7315             private Website() {}
   7316 
   7317             /** MIME type used when storing this in data table. */
   7318             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
   7319 
   7320             public static final int TYPE_HOMEPAGE = 1;
   7321             public static final int TYPE_BLOG = 2;
   7322             public static final int TYPE_PROFILE = 3;
   7323             public static final int TYPE_HOME = 4;
   7324             public static final int TYPE_WORK = 5;
   7325             public static final int TYPE_FTP = 6;
   7326             public static final int TYPE_OTHER = 7;
   7327 
   7328             /**
   7329              * The website URL string.
   7330              * <P>Type: TEXT</P>
   7331              */
   7332             public static final String URL = DATA;
   7333         }
   7334 
   7335         /**
   7336          * <p>
   7337          * A data kind representing a SIP address for the contact.
   7338          * </p>
   7339          * <p>
   7340          * You can use all columns defined for {@link ContactsContract.Data} as
   7341          * well as the following aliases.
   7342          * </p>
   7343          * <h2>Column aliases</h2>
   7344          * <table class="jd-sumtable">
   7345          * <tr>
   7346          * <th>Type</th>
   7347          * <th>Alias</th><th colspan='2'>Data column</th>
   7348          * </tr>
   7349          * <tr>
   7350          * <td>String</td>
   7351          * <td>{@link #SIP_ADDRESS}</td>
   7352          * <td>{@link #DATA1}</td>
   7353          * <td></td>
   7354          * </tr>
   7355          * <tr>
   7356          * <td>int</td>
   7357          * <td>{@link #TYPE}</td>
   7358          * <td>{@link #DATA2}</td>
   7359          * <td>Allowed values are:
   7360          * <p>
   7361          * <ul>
   7362          * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
   7363          * <li>{@link #TYPE_HOME}</li>
   7364          * <li>{@link #TYPE_WORK}</li>
   7365          * <li>{@link #TYPE_OTHER}</li>
   7366          * </ul>
   7367          * </p>
   7368          * </td>
   7369          * </tr>
   7370          * <tr>
   7371          * <td>String</td>
   7372          * <td>{@link #LABEL}</td>
   7373          * <td>{@link #DATA3}</td>
   7374          * <td></td>
   7375          * </tr>
   7376          * </table>
   7377          */
   7378         public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
   7379                 ContactCounts {
   7380             /**
   7381              * This utility class cannot be instantiated
   7382              */
   7383             private SipAddress() {}
   7384 
   7385             /** MIME type used when storing this in data table. */
   7386             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
   7387 
   7388             public static final int TYPE_HOME = 1;
   7389             public static final int TYPE_WORK = 2;
   7390             public static final int TYPE_OTHER = 3;
   7391 
   7392             /**
   7393              * The SIP address.
   7394              * <P>Type: TEXT</P>
   7395              */
   7396             public static final String SIP_ADDRESS = DATA1;
   7397             // ...and TYPE and LABEL come from the CommonColumns interface.
   7398 
   7399             /**
   7400              * Return the string resource that best describes the given
   7401              * {@link #TYPE}. Will always return a valid resource.
   7402              */
   7403             public static final int getTypeLabelResource(int type) {
   7404                 switch (type) {
   7405                     case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
   7406                     case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
   7407                     case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
   7408                     default: return com.android.internal.R.string.sipAddressTypeCustom;
   7409                 }
   7410             }
   7411 
   7412             /**
   7413              * Return a {@link CharSequence} that best describes the given type,
   7414              * possibly substituting the given {@link #LABEL} value
   7415              * for {@link #TYPE_CUSTOM}.
   7416              */
   7417             public static final CharSequence getTypeLabel(Resources res, int type,
   7418                     CharSequence label) {
   7419                 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
   7420                     return label;
   7421                 } else {
   7422                     final int labelRes = getTypeLabelResource(type);
   7423                     return res.getText(labelRes);
   7424                 }
   7425             }
   7426         }
   7427 
   7428         /**
   7429          * A data kind representing an Identity related to the contact.
   7430          * <p>
   7431          * This can be used as a signal by the aggregator to combine raw contacts into
   7432          * contacts, e.g. if two contacts have Identity rows with
   7433          * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
   7434          * to the same person.
   7435          * </p>
   7436          */
   7437         public static final class Identity implements DataColumnsWithJoins, ContactCounts {
   7438             /**
   7439              * This utility class cannot be instantiated
   7440              */
   7441             private Identity() {}
   7442 
   7443             /** MIME type used when storing this in data table. */
   7444             public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
   7445 
   7446             /**
   7447              * The identity string.
   7448              * <P>Type: TEXT</P>
   7449              */
   7450             public static final String IDENTITY = DataColumns.DATA1;
   7451 
   7452             /**
   7453              * The namespace of the identity string, e.g. "com.google"
   7454              * <P>Type: TEXT</P>
   7455              */
   7456             public static final String NAMESPACE = DataColumns.DATA2;
   7457         }
   7458 
   7459         /**
   7460          * <p>
   7461          * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
   7462          * kind.
   7463          * </p>
   7464          * <p>
   7465          * This URI allows the ContactsProvider to return a unified result for "callable" data
   7466          * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
   7467          * current examples for "callable", but may be expanded to the other types.
   7468          * </p>
   7469          * <p>
   7470          * Each returned row may have a different MIMETYPE and thus different interpretation for
   7471          * each column. For example the meaning for {@link Phone}'s type is different than
   7472          * {@link SipAddress}'s.
   7473          * </p>
   7474          */
   7475         public static final class Callable implements DataColumnsWithJoins, CommonColumns,
   7476                 ContactCounts {
   7477             /**
   7478              * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
   7479              * phone numbers.
   7480              */
   7481             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   7482                     "callables");
   7483             /**
   7484              * Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
   7485              * data.
   7486              */
   7487             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
   7488                     "filter");
   7489 
   7490             /**
   7491              * Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter
   7492              * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
   7493              * parameters, otherwise it will throw IllegalArgumentException.
   7494              */
   7495             public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
   7496                     CONTENT_URI, "filter_enterprise");
   7497         }
   7498 
   7499         /**
   7500          * A special class of data items, used to refer to types of data that can be used to attempt
   7501          * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
   7502          * is NOT a separate data kind.
   7503          *
   7504          * This URI allows the ContactsProvider to return a unified result for data items that users
   7505          * can use to initiate communications with another contact. {@link Phone} and {@link Email}
   7506          * are the current data types in this category.
   7507          */
   7508         public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
   7509                 ContactCounts {
   7510             /**
   7511              * The content:// style URI for these data items, which requests a directory of data
   7512              * rows matching the selection criteria.
   7513              */
   7514             public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
   7515                     "contactables");
   7516 
   7517             /**
   7518              * The content:// style URI for these data items, which allows for a query parameter to
   7519              * be appended onto the end to filter for data items matching the query.
   7520              */
   7521             public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
   7522                     Contactables.CONTENT_URI, "filter");
   7523 
   7524             /**
   7525              * A boolean parameter for {@link Data#CONTENT_URI}.
   7526              * This specifies whether or not the returned data items should be filtered to show
   7527              * data items belonging to visible contacts only.
   7528              */
   7529             public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
   7530         }
   7531     }
   7532 
   7533     /**
   7534      * @see Groups
   7535      */
   7536     protected interface GroupsColumns {
   7537         /**
   7538          * The data set within the account that this group belongs to.  This allows
   7539          * multiple sync adapters for the same account type to distinguish between
   7540          * each others' group data.
   7541          *
   7542          * This is empty by default, and is completely optional.  It only needs to
   7543          * be populated if multiple sync adapters are entering distinct group data
   7544          * for the same account type and account name.
   7545          * <P>Type: TEXT</P>
   7546          */
   7547         public static final String DATA_SET = "data_set";
   7548 
   7549         /**
   7550          * A concatenation of the account type and data set (delimited by a forward
   7551          * slash) - if the data set is empty, this will be the same as the account
   7552          * type.  For applications that need to be aware of the data set, this can
   7553          * be used instead of account type to distinguish sets of data.  This is
   7554          * never intended to be used for specifying accounts.
   7555          * @hide
   7556          */
   7557         public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
   7558 
   7559         /**
   7560          * The display title of this group.
   7561          * <p>
   7562          * Type: TEXT
   7563          */
   7564         public static final String TITLE = "title";
   7565 
   7566         /**
   7567          * The package name to use when creating {@link Resources} objects for
   7568          * this group. This value is only designed for use when building user
   7569          * interfaces, and should not be used to infer the owner.
   7570          */
   7571         public static final String RES_PACKAGE = "res_package";
   7572 
   7573         /**
   7574          * The display title of this group to load as a resource from
   7575          * {@link #RES_PACKAGE}, which may be localized.
   7576          * <P>Type: TEXT</P>
   7577          */
   7578         public static final String TITLE_RES = "title_res";
   7579 
   7580         /**
   7581          * Notes about the group.
   7582          * <p>
   7583          * Type: TEXT
   7584          */
   7585         public static final String NOTES = "notes";
   7586 
   7587         /**
   7588          * The ID of this group if it is a System Group, i.e. a group that has a special meaning
   7589          * to the sync adapter, null otherwise.
   7590          * <P>Type: TEXT</P>
   7591          */
   7592         public static final String SYSTEM_ID = "system_id";
   7593 
   7594         /**
   7595          * The total number of {@link Contacts} that have
   7596          * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
   7597          * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
   7598          * <p>
   7599          * Type: INTEGER
   7600          */
   7601         public static final String SUMMARY_COUNT = "summ_count";
   7602 
   7603         /**
   7604          * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
   7605          * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
   7606          *
   7607          * @hide
   7608          */
   7609         public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
   7610                 "return_group_count_per_account";
   7611 
   7612         /**
   7613          * The total number of groups of the account that a group belongs to.
   7614          * This column is available only when the parameter
   7615          * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
   7616          * {@link Groups#CONTENT_SUMMARY_URI}.
   7617          *
   7618          * For example, when the account "A" has two groups "group1" and "group2", and the account
   7619          * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
   7620          * "group3" returns "1" for this column.
   7621          *
   7622          * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
   7623          *
   7624          * Type: INTEGER
   7625          * @hide
   7626          */
   7627         public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
   7628 
   7629         /**
   7630          * The total number of {@link Contacts} that have both
   7631          * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
   7632          * Read-only value that is only present when querying
   7633          * {@link Groups#CONTENT_SUMMARY_URI}.
   7634          * <p>
   7635          * Type: INTEGER
   7636          */
   7637         public static final String SUMMARY_WITH_PHONES = "summ_phones";
   7638 
   7639         /**
   7640          * Flag indicating if the contacts belonging to this group should be
   7641          * visible in any user interface.
   7642          * <p>
   7643          * Type: INTEGER (boolean)
   7644          */
   7645         public static final String GROUP_VISIBLE = "group_visible";
   7646 
   7647         /**
   7648          * The "deleted" flag: "0" by default, "1" if the row has been marked
   7649          * for deletion. When {@link android.content.ContentResolver#delete} is
   7650          * called on a group, it is marked for deletion. The sync adaptor
   7651          * deletes the group on the server and then calls ContactResolver.delete
   7652          * once more, this time setting the the
   7653          * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
   7654          * finalize the data removal.
   7655          * <P>Type: INTEGER</P>
   7656          */
   7657         public static final String DELETED = "deleted";
   7658 
   7659         /**
   7660          * Whether this group should be synced if the SYNC_EVERYTHING settings
   7661          * is false for this group's account.
   7662          * <p>
   7663          * Type: INTEGER (boolean)
   7664          */
   7665         public static final String SHOULD_SYNC = "should_sync";
   7666 
   7667         /**
   7668          * Any newly created contacts will automatically be added to groups that have this
   7669          * flag set to true.
   7670          * <p>
   7671          * Type: INTEGER (boolean)
   7672          */
   7673         public static final String AUTO_ADD = "auto_add";
   7674 
   7675         /**
   7676          * When a contacts is marked as a favorites it will be automatically added
   7677          * to the groups that have this flag set, and when it is removed from favorites
   7678          * it will be removed from these groups.
   7679          * <p>
   7680          * Type: INTEGER (boolean)
   7681          */
   7682         public static final String FAVORITES = "favorites";
   7683 
   7684         /**
   7685          * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
   7686          * deleted except by a sync adapter.  See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
   7687          * <P>Type: INTEGER</P>
   7688          */
   7689         public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
   7690     }
   7691 
   7692     /**
   7693      * Constants for the groups table. Only per-account groups are supported.
   7694      * <h2>Columns</h2>
   7695      * <table class="jd-sumtable">
   7696      * <tr>
   7697      * <th colspan='4'>Groups</th>
   7698      * </tr>
   7699      * <tr>
   7700      * <td>long</td>
   7701      * <td>{@link #_ID}</td>
   7702      * <td>read-only</td>
   7703      * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
   7704      * In other words, it would be a really bad idea to delete and reinsert a
   7705      * group. A sync adapter should always do an update instead.</td>
   7706      * </tr>
   7707      # <tr>
   7708      * <td>String</td>
   7709      * <td>{@link #DATA_SET}</td>
   7710      * <td>read/write-once</td>
   7711      * <td>
   7712      * <p>
   7713      * The data set within the account that this group belongs to.  This allows
   7714      * multiple sync adapters for the same account type to distinguish between
   7715      * each others' group data.  The combination of {@link #ACCOUNT_TYPE},
   7716      * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
   7717      * that is associated with a single sync adapter.
   7718      * </p>
   7719      * <p>
   7720      * This is empty by default, and is completely optional.  It only needs to
   7721      * be populated if multiple sync adapters are entering distinct data for
   7722      * the same account type and account name.
   7723      * </p>
   7724      * <p>
   7725      * It should be set at the time the group is inserted and never changed
   7726      * afterwards.
   7727      * </p>
   7728      * </td>
   7729      * </tr>
   7730      * <tr>
   7731      * <td>String</td>
   7732      * <td>{@link #TITLE}</td>
   7733      * <td>read/write</td>
   7734      * <td>The display title of this group.</td>
   7735      * </tr>
   7736      * <tr>
   7737      * <td>String</td>
   7738      * <td>{@link #NOTES}</td>
   7739      * <td>read/write</td>
   7740      * <td>Notes about the group.</td>
   7741      * </tr>
   7742      * <tr>
   7743      * <td>String</td>
   7744      * <td>{@link #SYSTEM_ID}</td>
   7745      * <td>read/write</td>
   7746      * <td>The ID of this group if it is a System Group, i.e. a group that has a
   7747      * special meaning to the sync adapter, null otherwise.</td>
   7748      * </tr>
   7749      * <tr>
   7750      * <td>int</td>
   7751      * <td>{@link #SUMMARY_COUNT}</td>
   7752      * <td>read-only</td>
   7753      * <td>The total number of {@link Contacts} that have
   7754      * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
   7755      * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
   7756      * </tr>
   7757      * <tr>
   7758      * <td>int</td>
   7759      * <td>{@link #SUMMARY_WITH_PHONES}</td>
   7760      * <td>read-only</td>
   7761      * <td>The total number of {@link Contacts} that have both
   7762      * {@link CommonDataKinds.GroupMembership} in this group, and also have
   7763      * phone numbers. Read-only value that is only present when querying
   7764      * {@link Groups#CONTENT_SUMMARY_URI}.</td>
   7765      * </tr>
   7766      * <tr>
   7767      * <td>int</td>
   7768      * <td>{@link #GROUP_VISIBLE}</td>
   7769      * <td>read-only</td>
   7770      * <td>Flag indicating if the contacts belonging to this group should be
   7771      * visible in any user interface. Allowed values: 0 and 1.</td>
   7772      * </tr>
   7773      * <tr>
   7774      * <td>int</td>
   7775      * <td>{@link #DELETED}</td>
   7776      * <td>read/write</td>
   7777      * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
   7778      * for deletion. When {@link android.content.ContentResolver#delete} is
   7779      * called on a group, it is marked for deletion. The sync adaptor deletes
   7780      * the group on the server and then calls ContactResolver.delete once more,
   7781      * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
   7782      * query parameter to finalize the data removal.</td>
   7783      * </tr>
   7784      * <tr>
   7785      * <td>int</td>
   7786      * <td>{@link #SHOULD_SYNC}</td>
   7787      * <td>read/write</td>
   7788      * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
   7789      * is false for this group's account.</td>
   7790      * </tr>
   7791      * </table>
   7792      */
   7793     public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
   7794         /**
   7795          * This utility class cannot be instantiated
   7796          */
   7797         private Groups() {
   7798         }
   7799 
   7800         /**
   7801          * The content:// style URI for this table
   7802          */
   7803         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
   7804 
   7805         /**
   7806          * The content:// style URI for this table joined with details data from
   7807          * {@link ContactsContract.Data}.
   7808          */
   7809         public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
   7810                 "groups_summary");
   7811 
   7812         /**
   7813          * The MIME type of a directory of groups.
   7814          */
   7815         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
   7816 
   7817         /**
   7818          * The MIME type of a single group.
   7819          */
   7820         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
   7821 
   7822         public static EntityIterator newEntityIterator(Cursor cursor) {
   7823             return new EntityIteratorImpl(cursor);
   7824         }
   7825 
   7826         private static class EntityIteratorImpl extends CursorEntityIterator {
   7827             public EntityIteratorImpl(Cursor cursor) {
   7828                 super(cursor);
   7829             }
   7830 
   7831             @Override
   7832             public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
   7833                 // we expect the cursor is already at the row we need to read from
   7834                 final ContentValues values = new ContentValues();
   7835                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
   7836                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
   7837                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
   7838                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
   7839                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
   7840                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
   7841                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
   7842                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
   7843                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
   7844                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
   7845                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
   7846                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
   7847                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
   7848                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
   7849                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
   7850                 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
   7851                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
   7852                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
   7853                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
   7854                 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
   7855                 cursor.moveToNext();
   7856                 return new Entity(values);
   7857             }
   7858         }
   7859     }
   7860 
   7861     /**
   7862      * <p>
   7863      * Constants for the contact aggregation exceptions table, which contains
   7864      * aggregation rules overriding those used by automatic aggregation. This
   7865      * type only supports query and update. Neither insert nor delete are
   7866      * supported.
   7867      * </p>
   7868      * <h2>Columns</h2>
   7869      * <table class="jd-sumtable">
   7870      * <tr>
   7871      * <th colspan='4'>AggregationExceptions</th>
   7872      * </tr>
   7873      * <tr>
   7874      * <td>int</td>
   7875      * <td>{@link #TYPE}</td>
   7876      * <td>read/write</td>
   7877      * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
   7878      * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
   7879      * </tr>
   7880      * <tr>
   7881      * <td>long</td>
   7882      * <td>{@link #RAW_CONTACT_ID1}</td>
   7883      * <td>read/write</td>
   7884      * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
   7885      * the rule applies to.</td>
   7886      * </tr>
   7887      * <tr>
   7888      * <td>long</td>
   7889      * <td>{@link #RAW_CONTACT_ID2}</td>
   7890      * <td>read/write</td>
   7891      * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
   7892      * that the rule applies to.</td>
   7893      * </tr>
   7894      * </table>
   7895      */
   7896     public static final class AggregationExceptions implements BaseColumns {
   7897         /**
   7898          * This utility class cannot be instantiated
   7899          */
   7900         private AggregationExceptions() {}
   7901 
   7902         /**
   7903          * The content:// style URI for this table
   7904          */
   7905         public static final Uri CONTENT_URI =
   7906                 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
   7907 
   7908         /**
   7909          * The MIME type of {@link #CONTENT_URI} providing a directory of data.
   7910          */
   7911         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
   7912 
   7913         /**
   7914          * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
   7915          */
   7916         public static final String CONTENT_ITEM_TYPE =
   7917                 "vnd.android.cursor.item/aggregation_exception";
   7918 
   7919         /**
   7920          * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
   7921          * {@link #TYPE_AUTOMATIC}.
   7922          *
   7923          * <P>Type: INTEGER</P>
   7924          */
   7925         public static final String TYPE = "type";
   7926 
   7927         /**
   7928          * Allows the provider to automatically decide whether the specified raw contacts should
   7929          * be included in the same aggregate contact or not.
   7930          */
   7931         public static final int TYPE_AUTOMATIC = 0;
   7932 
   7933         /**
   7934          * Makes sure that the specified raw contacts are included in the same
   7935          * aggregate contact.
   7936          */
   7937         public static final int TYPE_KEEP_TOGETHER = 1;
   7938 
   7939         /**
   7940          * Makes sure that the specified raw contacts are NOT included in the same
   7941          * aggregate contact.
   7942          */
   7943         public static final int TYPE_KEEP_SEPARATE = 2;
   7944 
   7945         /**
   7946          * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
   7947          */
   7948         public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
   7949 
   7950         /**
   7951          * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
   7952          * applies to.
   7953          */
   7954         public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
   7955     }
   7956 
   7957     /**
   7958      * @see Settings
   7959      */
   7960     protected interface SettingsColumns {
   7961         /**
   7962          * The name of the account instance to which this row belongs.
   7963          * <P>Type: TEXT</P>
   7964          */
   7965         public static final String ACCOUNT_NAME = "account_name";
   7966 
   7967         /**
   7968          * The type of account to which this row belongs, which when paired with
   7969          * {@link #ACCOUNT_NAME} identifies a specific account.
   7970          * <P>Type: TEXT</P>
   7971          */
   7972         public static final String ACCOUNT_TYPE = "account_type";
   7973 
   7974         /**
   7975          * The data set within the account that this row belongs to.  This allows
   7976          * multiple sync adapters for the same account type to distinguish between
   7977          * each others' data.
   7978          *
   7979          * This is empty by default, and is completely optional.  It only needs to
   7980          * be populated if multiple sync adapters are entering distinct data for
   7981          * the same account type and account name.
   7982          * <P>Type: TEXT</P>
   7983          */
   7984         public static final String DATA_SET = "data_set";
   7985 
   7986         /**
   7987          * Depending on the mode defined by the sync-adapter, this flag controls
   7988          * the top-level sync behavior for this data source.
   7989          * <p>
   7990          * Type: INTEGER (boolean)
   7991          */
   7992         public static final String SHOULD_SYNC = "should_sync";
   7993 
   7994         /**
   7995          * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
   7996          * entries should be visible in any user interface.
   7997          * <p>
   7998          * Type: INTEGER (boolean)
   7999          */
   8000         public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
   8001 
   8002         /**
   8003          * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
   8004          * {@link Groups#SHOULD_SYNC} under this account have been marked as
   8005          * unsynced.
   8006          */
   8007         public static final String ANY_UNSYNCED = "any_unsynced";
   8008 
   8009         /**
   8010          * Read-only count of {@link Contacts} from a specific source that have
   8011          * no {@link CommonDataKinds.GroupMembership} entries.
   8012          * <p>
   8013          * Type: INTEGER
   8014          */
   8015         public static final String UNGROUPED_COUNT = "summ_count";
   8016 
   8017         /**
   8018          * Read-only count of {@link Contacts} from a specific source that have
   8019          * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
   8020          * <p>
   8021          * Type: INTEGER
   8022          */
   8023         public static final String UNGROUPED_WITH_PHONES = "summ_phones";
   8024     }
   8025 
   8026     /**
   8027      * <p>
   8028      * Contacts-specific settings for various {@link Account}'s.
   8029      * </p>
   8030      * <h2>Columns</h2>
   8031      * <table class="jd-sumtable">
   8032      * <tr>
   8033      * <th colspan='4'>Settings</th>
   8034      * </tr>
   8035      * <tr>
   8036      * <td>String</td>
   8037      * <td>{@link #ACCOUNT_NAME}</td>
   8038      * <td>read/write-once</td>
   8039      * <td>The name of the account instance to which this row belongs.</td>
   8040      * </tr>
   8041      * <tr>
   8042      * <td>String</td>
   8043      * <td>{@link #ACCOUNT_TYPE}</td>
   8044      * <td>read/write-once</td>
   8045      * <td>The type of account to which this row belongs, which when paired with
   8046      * {@link #ACCOUNT_NAME} identifies a specific account.</td>
   8047      * </tr>
   8048      * <tr>
   8049      * <td>int</td>
   8050      * <td>{@link #SHOULD_SYNC}</td>
   8051      * <td>read/write</td>
   8052      * <td>Depending on the mode defined by the sync-adapter, this flag controls
   8053      * the top-level sync behavior for this data source.</td>
   8054      * </tr>
   8055      * <tr>
   8056      * <td>int</td>
   8057      * <td>{@link #UNGROUPED_VISIBLE}</td>
   8058      * <td>read/write</td>
   8059      * <td>Flag indicating if contacts without any
   8060      * {@link CommonDataKinds.GroupMembership} entries should be visible in any
   8061      * user interface.</td>
   8062      * </tr>
   8063      * <tr>
   8064      * <td>int</td>
   8065      * <td>{@link #ANY_UNSYNCED}</td>
   8066      * <td>read-only</td>
   8067      * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
   8068      * {@link Groups#SHOULD_SYNC} under this account have been marked as
   8069      * unsynced.</td>
   8070      * </tr>
   8071      * <tr>
   8072      * <td>int</td>
   8073      * <td>{@link #UNGROUPED_COUNT}</td>
   8074      * <td>read-only</td>
   8075      * <td>Read-only count of {@link Contacts} from a specific source that have
   8076      * no {@link CommonDataKinds.GroupMembership} entries.</td>
   8077      * </tr>
   8078      * <tr>
   8079      * <td>int</td>
   8080      * <td>{@link #UNGROUPED_WITH_PHONES}</td>
   8081      * <td>read-only</td>
   8082      * <td>Read-only count of {@link Contacts} from a specific source that have
   8083      * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
   8084      * numbers.</td>
   8085      * </tr>
   8086      * </table>
   8087      */
   8088     public static final class Settings implements SettingsColumns {
   8089         /**
   8090          * This utility class cannot be instantiated
   8091          */
   8092         private Settings() {
   8093         }
   8094 
   8095         /**
   8096          * The content:// style URI for this table
   8097          */
   8098         public static final Uri CONTENT_URI =
   8099                 Uri.withAppendedPath(AUTHORITY_URI, "settings");
   8100 
   8101         /**
   8102          * The MIME-type of {@link #CONTENT_URI} providing a directory of
   8103          * settings.
   8104          */
   8105         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
   8106 
   8107         /**
   8108          * The MIME-type of {@link #CONTENT_URI} providing a single setting.
   8109          */
   8110         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
   8111     }
   8112 
   8113     /**
   8114      * API for inquiring about the general status of the provider.
   8115      */
   8116     public static final class ProviderStatus {
   8117 
   8118         /**
   8119          * Not instantiable.
   8120          */
   8121         private ProviderStatus() {
   8122         }
   8123 
   8124         /**
   8125          * The content:// style URI for this table.  Requests to this URI can be
   8126          * performed on the UI thread because they are always unblocking.
   8127          */
   8128         public static final Uri CONTENT_URI =
   8129                 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
   8130 
   8131         /**
   8132          * The MIME-type of {@link #CONTENT_URI} providing a directory of
   8133          * settings.
   8134          */
   8135         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
   8136 
   8137         /**
   8138          * An integer representing the current status of the provider.
   8139          */
   8140         public static final String STATUS = "status";
   8141 
   8142         /**
   8143          * Default status of the provider.
   8144          */
   8145         public static final int STATUS_NORMAL = 0;
   8146 
   8147         /**
   8148          * The provider won't respond to queries. It is in the middle of a long running task, such
   8149          * as a database upgrade or locale change.
   8150          */
   8151         public static final int STATUS_BUSY = 1;
   8152 
   8153         /**
   8154          * The status that indicates that there are no accounts and no contacts
   8155          * on the device.
   8156          */
   8157         public static final int STATUS_EMPTY = 2;
   8158     }
   8159 
   8160     /**
   8161      * <p>
   8162      * API allowing applications to send usage information for each {@link Data} row to the
   8163      * Contacts Provider.  Applications can also clear all usage information.
   8164      * </p>
   8165      * <p>
   8166      * With the feedback, Contacts Provider may return more contextually appropriate results for
   8167      * Data listing, typically supplied with
   8168      * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
   8169      * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
   8170      * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
   8171      * from better ranked (sorted) lists in applications that show auto-complete list.
   8172      * </p>
   8173      * <p>
   8174      * There is no guarantee for how this feedback is used, or even whether it is used at all.
   8175      * The ranking algorithm will make best efforts to use the feedback data, but the exact
   8176      * implementation, the storage data structures as well as the resulting sort order is device
   8177      * and version specific and can change over time.
   8178      * </p>
   8179      * <p>
   8180      * When updating usage information, users of this API need to use
   8181      * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
   8182      * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
   8183      * its last path. They also need to append a query parameter to the Uri, to specify the type of
   8184      * the communication, which enables the Contacts Provider to differentiate between kinds of
   8185      * interactions using the same contact data field (for example a phone number can be used to
   8186      * make phone calls or send SMS).
   8187      * </p>
   8188      * <p>
   8189      * Selection and selectionArgs are ignored and must be set to null. To get data ids,
   8190      * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
   8191      * toward {@link Data#CONTENT_URI}.
   8192      * </p>
   8193      * <p>
   8194      * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
   8195      * integer when successful, and returns 0 if no contact with that id was found.
   8196      * </p>
   8197      * <p>
   8198      * Example:
   8199      * <pre>
   8200      * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
   8201      *         .appendPath(TextUtils.join(",", dataIds))
   8202      *         .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
   8203      *                 DataUsageFeedback.USAGE_TYPE_CALL)
   8204      *         .build();
   8205      * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
   8206      * </pre>
   8207      * </p>
   8208      * <p>
   8209      * Applications can also clear all usage information with:
   8210      * <pre>
   8211      * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
   8212      * </pre>
   8213      * </p>
   8214      */
   8215     public static final class DataUsageFeedback {
   8216 
   8217         /**
   8218          * The content:// style URI for sending usage feedback.
   8219          * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
   8220          */
   8221         public static final Uri FEEDBACK_URI =
   8222                 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
   8223 
   8224         /**
   8225          * The content:// style URI for deleting all usage information.
   8226          * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
   8227          * The {@code where} and {@code selectionArgs} parameters are ignored.
   8228          */
   8229         public static final Uri DELETE_USAGE_URI =
   8230                 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
   8231 
   8232         /**
   8233          * <p>
   8234          * Name for query parameter specifying the type of data usage.
   8235          * </p>
   8236          */
   8237         public static final String USAGE_TYPE = "type";
   8238 
   8239         /**
   8240          * <p>
   8241          * Type of usage for voice interaction, which includes phone call, voice chat, and
   8242          * video chat.
   8243          * </p>
   8244          */
   8245         public static final String USAGE_TYPE_CALL = "call";
   8246 
   8247         /**
   8248          * <p>
   8249          * Type of usage for text interaction involving longer messages, which includes email.
   8250          * </p>
   8251          */
   8252         public static final String USAGE_TYPE_LONG_TEXT = "long_text";
   8253 
   8254         /**
   8255          * <p>
   8256          * Type of usage for text interaction involving shorter messages, which includes SMS,
   8257          * text chat with email addresses.
   8258          * </p>
   8259          */
   8260         public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
   8261     }
   8262 
   8263     /**
   8264      * <p>
   8265      * Contact-specific information about whether or not a contact has been pinned by the user
   8266      * at a particular position within the system contact application's user interface.
   8267      * </p>
   8268      *
   8269      * <p>
   8270      * This pinning information can be used by individual applications to customize how
   8271      * they order particular pinned contacts. For example, a Dialer application could
   8272      * use pinned information to order user-pinned contacts in a top row of favorites.
   8273      * </p>
   8274      *
   8275      * <p>
   8276      * It is possible for two or more contacts to occupy the same pinned position (due
   8277      * to aggregation and sync), so this pinning information should be used on a best-effort
   8278      * basis to order contacts in-application rather than an absolute guide on where a contact
   8279      * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
   8280      * on this information, so it is up to the client application to reorder these contacts within
   8281      * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
   8282      * column.
   8283      * </p>
   8284      *
   8285      * <p>
   8286      * By default, unpinned contacts will have a pinned position of
   8287      * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
   8288      * integers that are greater than 1.
   8289      * </p>
   8290      */
   8291     public static final class PinnedPositions {
   8292         /**
   8293          * The method to invoke in order to undemote a formerly demoted contact. The contact id of
   8294          * the contact must be provided as an argument. If the contact was not previously demoted,
   8295          * nothing will be done.
   8296          * @hide
   8297          */
   8298         public static final String UNDEMOTE_METHOD = "undemote";
   8299 
   8300         /**
   8301          * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
   8302          * will be done.
   8303          *
   8304          * @param contentResolver to perform the undemote operation on.
   8305          * @param contactId the id of the contact to undemote.
   8306          */
   8307         public static void undemote(ContentResolver contentResolver, long contactId) {
   8308             contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
   8309                     String.valueOf(contactId), null);
   8310         }
   8311 
   8312         /**
   8313          * Pins a contact at a provided position, or unpins a contact.
   8314          *
   8315          * @param contentResolver to perform the pinning operation on.
   8316          * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
   8317          *         {@link PinnedPositions#UNPINNED}.
   8318          */
   8319         public static void pin(
   8320                 ContentResolver contentResolver, long contactId, int pinnedPosition) {
   8321             final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
   8322             final ContentValues values = new ContentValues();
   8323             values.put(Contacts.PINNED, pinnedPosition);
   8324             contentResolver.update(uri, values, null, null);
   8325         }
   8326 
   8327         /**
   8328          * Default value for the pinned position of an unpinned contact.
   8329          */
   8330         public static final int UNPINNED = 0;
   8331 
   8332         /**
   8333          * Value of pinned position for a contact that a user has indicated should be considered
   8334          * of the lowest priority. It is up to the client application to determine how to present
   8335          * such a contact - for example all the way at the bottom of a contact list, or simply
   8336          * just hidden from view.
   8337          */
   8338         public static final int DEMOTED = -1;
   8339     }
   8340 
   8341     /**
   8342      * Helper methods to display QuickContact dialogs that display all the information belonging to
   8343      * a specific {@link Contacts} entry.
   8344      */
   8345     public static final class QuickContact {
   8346         /**
   8347          * Action used to launch the system contacts application and bring up a QuickContact dialog
   8348          * for the provided {@link Contacts} entry.
   8349          */
   8350         public static final String ACTION_QUICK_CONTACT =
   8351                 "android.provider.action.QUICK_CONTACT";
   8352 
   8353         /**
   8354          * Extra used to specify pivot dialog location in screen coordinates.
   8355          * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
   8356          * @hide
   8357          */
   8358         @Deprecated
   8359         public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
   8360 
   8361         /**
   8362          * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts
   8363          * will respect this extra's value.
   8364          *
   8365          * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
   8366          */
   8367         public static final String EXTRA_MODE = "android.provider.extra.MODE";
   8368 
   8369         /**
   8370          * Extra used to specify which mimetype should be prioritized in the QuickContacts UI.
   8371          * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can
   8372          * cause phone numbers to be displayed more prominently in QuickContacts.
   8373          */
   8374         public static final String EXTRA_PRIORITIZED_MIMETYPE
   8375                 = "android.provider.extra.PRIORITIZED_MIMETYPE";
   8376 
   8377         /**
   8378          * Extra used to indicate a list of specific MIME-types to exclude and not display in the
   8379          * QuickContacts dialog. Stored as a {@link String} array.
   8380          */
   8381         public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
   8382 
   8383         /**
   8384          * Small QuickContact mode, usually presented with minimal actions.
   8385          */
   8386         public static final int MODE_SMALL = 1;
   8387 
   8388         /**
   8389          * Medium QuickContact mode, includes actions and light summary describing
   8390          * the {@link Contacts} entry being shown. This may include social
   8391          * status and presence details.
   8392          */
   8393         public static final int MODE_MEDIUM = 2;
   8394 
   8395         /**
   8396          * Large QuickContact mode, includes actions and larger, card-like summary
   8397          * of the {@link Contacts} entry being shown. This may include detailed
   8398          * information, such as a photo.
   8399          */
   8400         public static final int MODE_LARGE = 3;
   8401 
   8402         /** @hide */
   8403         public static final int MODE_DEFAULT = MODE_LARGE;
   8404 
   8405         /**
   8406          * Constructs the QuickContacts intent with a view's rect.
   8407          * @hide
   8408          */
   8409         public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
   8410                 int mode, String[] excludeMimes) {
   8411             // Find location and bounds of target view, adjusting based on the
   8412             // assumed local density.
   8413             final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
   8414             final int[] pos = new int[2];
   8415             target.getLocationOnScreen(pos);
   8416 
   8417             final Rect rect = new Rect();
   8418             rect.left = (int) (pos[0] * appScale + 0.5f);
   8419             rect.top = (int) (pos[1] * appScale + 0.5f);
   8420             rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
   8421             rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
   8422 
   8423             return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
   8424         }
   8425 
   8426         /**
   8427          * Constructs the QuickContacts intent.
   8428          * @hide
   8429          */
   8430         public static Intent composeQuickContactsIntent(Context context, Rect target,
   8431                 Uri lookupUri, int mode, String[] excludeMimes) {
   8432             // When launching from an Activiy, we don't want to start a new task, but otherwise
   8433             // we *must* start a new task.  (Otherwise startActivity() would crash.)
   8434             Context actualContext = context;
   8435             while ((actualContext instanceof ContextWrapper)
   8436                     && !(actualContext instanceof Activity)) {
   8437                 actualContext = ((ContextWrapper) actualContext).getBaseContext();
   8438             }
   8439             final int intentFlags = ((actualContext instanceof Activity)
   8440                     ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
   8441                     // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
   8442                     | Intent.FLAG_ACTIVITY_SINGLE_TOP;
   8443 
   8444             // Launch pivot dialog through intent for now
   8445             final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
   8446 
   8447             // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync.
   8448             intent.setData(lookupUri);
   8449             intent.setSourceBounds(target);
   8450             intent.putExtra(EXTRA_MODE, mode);
   8451             intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
   8452             return intent;
   8453         }
   8454 
   8455         /**
   8456          * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager
   8457          * to strip off anything not necessary.
   8458          *
   8459          * @hide
   8460          */
   8461         public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
   8462                 boolean isContactIdIgnored, long directoryId, Intent originalIntent) {
   8463             final Intent intent = new Intent(ACTION_QUICK_CONTACT);
   8464             // Rebuild the URI from a lookup key and a contact ID.
   8465             Uri uri = null;
   8466             if (!TextUtils.isEmpty(lookupKey)) {
   8467                 uri = isContactIdIgnored
   8468                         ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey)
   8469                         : Contacts.getLookupUri(contactId, lookupKey);
   8470             }
   8471             if (uri != null && directoryId != Directory.DEFAULT) {
   8472                 uri = uri.buildUpon().appendQueryParameter(
   8473                         ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build();
   8474             }
   8475             intent.setData(uri);
   8476 
   8477             // Copy flags and always set NEW_TASK because it won't have a parent activity.
   8478             intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
   8479 
   8480             // Copy extras.
   8481             intent.setSourceBounds(originalIntent.getSourceBounds());
   8482             intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT));
   8483             intent.putExtra(EXTRA_EXCLUDE_MIMES,
   8484                     originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES));
   8485             return intent;
   8486         }
   8487 
   8488 
   8489         /**
   8490          * Trigger a dialog that lists the various methods of interacting with
   8491          * the requested {@link Contacts} entry. This may be based on available
   8492          * {@link ContactsContract.Data} rows under that contact, and may also
   8493          * include social status and presence details.
   8494          *
   8495          * @param context The parent {@link Context} that may be used as the
   8496          *            parent for this dialog.
   8497          * @param target Specific {@link View} from your layout that this dialog
   8498          *            should be centered around. In particular, if the dialog
   8499          *            has a "callout" arrow, it will be pointed and centered
   8500          *            around this {@link View}.
   8501          * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8502          *            {@link Uri} that describes a specific contact to feature
   8503          *            in this dialog. A work lookup uri is supported here,
   8504          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
   8505          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   8506          * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
   8507          *            {@link #MODE_LARGE}, indicating the desired dialog size,
   8508          *            when supported.
   8509          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8510          *            to exclude when showing this dialog. For example, when
   8511          *            already viewing the contact details card, this can be used
   8512          *            to omit the details entry from the dialog.
   8513          */
   8514         public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
   8515                 String[] excludeMimes) {
   8516             // Trigger with obtained rectangle
   8517             Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
   8518                     excludeMimes);
   8519             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8520         }
   8521 
   8522         /**
   8523          * Trigger a dialog that lists the various methods of interacting with
   8524          * the requested {@link Contacts} entry. This may be based on available
   8525          * {@link ContactsContract.Data} rows under that contact, and may also
   8526          * include social status and presence details.
   8527          *
   8528          * @param context The parent {@link Context} that may be used as the
   8529          *            parent for this dialog.
   8530          * @param target Specific {@link Rect} that this dialog should be
   8531          *            centered around, in screen coordinates. In particular, if
   8532          *            the dialog has a "callout" arrow, it will be pointed and
   8533          *            centered around this {@link Rect}. If you are running at a
   8534          *            non-native density, you need to manually adjust using
   8535          *            {@link DisplayMetrics#density} before calling.
   8536          * @param lookupUri A
   8537          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8538          *            {@link Uri} that describes a specific contact to feature
   8539          *            in this dialog. A work lookup uri is supported here,
   8540          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
   8541          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   8542          * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
   8543          *            {@link #MODE_LARGE}, indicating the desired dialog size,
   8544          *            when supported.
   8545          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8546          *            to exclude when showing this dialog. For example, when
   8547          *            already viewing the contact details card, this can be used
   8548          *            to omit the details entry from the dialog.
   8549          */
   8550         public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
   8551                 String[] excludeMimes) {
   8552             Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
   8553                     excludeMimes);
   8554             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8555         }
   8556 
   8557         /**
   8558          * Trigger a dialog that lists the various methods of interacting with
   8559          * the requested {@link Contacts} entry. This may be based on available
   8560          * {@link ContactsContract.Data} rows under that contact, and may also
   8561          * include social status and presence details.
   8562          *
   8563          * @param context The parent {@link Context} that may be used as the
   8564          *            parent for this dialog.
   8565          * @param target Specific {@link View} from your layout that this dialog
   8566          *            should be centered around. In particular, if the dialog
   8567          *            has a "callout" arrow, it will be pointed and centered
   8568          *            around this {@link View}.
   8569          * @param lookupUri A
   8570          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8571          *            {@link Uri} that describes a specific contact to feature
   8572          *            in this dialog. A work lookup uri is supported here,
   8573          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
   8574          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   8575          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8576          *            to exclude when showing this dialog. For example, when
   8577          *            already viewing the contact details card, this can be used
   8578          *            to omit the details entry from the dialog.
   8579          * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
   8580          *             For example, passing the value
   8581          *             {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
   8582          *             displayed more prominently in QuickContacts.
   8583          */
   8584         public static void showQuickContact(Context context, View target, Uri lookupUri,
   8585                 String[] excludeMimes, String prioritizedMimeType) {
   8586             // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
   8587             // values defined in ContactsContract only affect very old implementations
   8588             // of QuickContacts.
   8589             Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
   8590                     excludeMimes);
   8591             intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
   8592             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8593         }
   8594 
   8595         /**
   8596          * Trigger a dialog that lists the various methods of interacting with
   8597          * the requested {@link Contacts} entry. This may be based on available
   8598          * {@link ContactsContract.Data} rows under that contact, and may also
   8599          * include social status and presence details.
   8600          *
   8601          * @param context The parent {@link Context} that may be used as the
   8602          *            parent for this dialog.
   8603          * @param target Specific {@link Rect} that this dialog should be
   8604          *            centered around, in screen coordinates. In particular, if
   8605          *            the dialog has a "callout" arrow, it will be pointed and
   8606          *            centered around this {@link Rect}. If you are running at a
   8607          *            non-native density, you need to manually adjust using
   8608          *            {@link DisplayMetrics#density} before calling.
   8609          * @param lookupUri A
   8610          *            {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
   8611          *            {@link Uri} that describes a specific contact to feature
   8612          *            in this dialog. A work lookup uri is supported here,
   8613          *            see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
   8614          *            {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
   8615          * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
   8616          *            to exclude when showing this dialog. For example, when
   8617          *            already viewing the contact details card, this can be used
   8618          *            to omit the details entry from the dialog.
   8619          * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
   8620          *             For example, passing the value
   8621          *             {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
   8622          *             displayed more prominently in QuickContacts.
   8623          */
   8624         public static void showQuickContact(Context context, Rect target, Uri lookupUri,
   8625                 String[] excludeMimes, String prioritizedMimeType) {
   8626             // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
   8627             // values defined in ContactsContract only affect very old implementations
   8628             // of QuickContacts.
   8629             Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
   8630                     excludeMimes);
   8631             intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
   8632             ContactsInternal.startQuickContactWithErrorToast(context, intent);
   8633         }
   8634     }
   8635 
   8636     /**
   8637      * Helper class for accessing full-size photos by photo file ID.
   8638      * <p>
   8639      * Usage example:
   8640      * <dl>
   8641      * <dt>Retrieving a full-size photo by photo file ID (see
   8642      * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
   8643      * </dt>
   8644      * <dd>
   8645      * <pre>
   8646      * public InputStream openDisplayPhoto(long photoFileId) {
   8647      *     Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
   8648      *     try {
   8649      *         AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
   8650      *             displayPhotoUri, "r");
   8651      *         return fd.createInputStream();
   8652      *     } catch (IOException e) {
   8653      *         return null;
   8654      *     }
   8655      * }
   8656      * </pre>
   8657      * </dd>
   8658      * </dl>
   8659      * </p>
   8660      */
   8661     public static final class DisplayPhoto {
   8662         /**
   8663          * no public constructor since this is a utility class
   8664          */
   8665         private DisplayPhoto() {}
   8666 
   8667         /**
   8668          * The content:// style URI for this class, which allows access to full-size photos,
   8669          * given a key.
   8670          */
   8671         public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
   8672 
   8673         /**
   8674          * This URI allows the caller to query for the maximum dimensions of a display photo
   8675          * or thumbnail.  Requests to this URI can be performed on the UI thread because
   8676          * they are always unblocking.
   8677          */
   8678         public static final Uri CONTENT_MAX_DIMENSIONS_URI =
   8679                 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
   8680 
   8681         /**
   8682          * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
   8683          * contain this column, populated with the maximum height and width (in pixels)
   8684          * that will be stored for a display photo.  Larger photos will be down-sized to
   8685          * fit within a square of this many pixels.
   8686          */
   8687         public static final String DISPLAY_MAX_DIM = "display_max_dim";
   8688 
   8689         /**
   8690          * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
   8691          * contain this column, populated with the height and width (in pixels) for photo
   8692          * thumbnails.
   8693          */
   8694         public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
   8695     }
   8696 
   8697     /**
   8698      * Contains helper classes used to create or manage {@link android.content.Intent Intents}
   8699      * that involve contacts.
   8700      */
   8701     public static final class Intents {
   8702         /**
   8703          * This is the intent that is fired when a search suggestion is clicked on.
   8704          */
   8705         public static final String SEARCH_SUGGESTION_CLICKED =
   8706                 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
   8707 
   8708         /**
   8709          * This is the intent that is fired when a search suggestion for dialing a number
   8710          * is clicked on.
   8711          */
   8712         public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
   8713                 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
   8714 
   8715         /**
   8716          * This is the intent that is fired when a search suggestion for creating a contact
   8717          * is clicked on.
   8718          */
   8719         public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
   8720                 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
   8721 
   8722         /**
   8723          * This is the intent that is fired when the contacts database is created. <p> The
   8724          * READ_CONTACT permission is required to receive these broadcasts.
   8725          */
   8726         public static final String CONTACTS_DATABASE_CREATED =
   8727                 "android.provider.Contacts.DATABASE_CREATED";
   8728 
   8729         /**
   8730          * Starts an Activity that lets the user pick a contact to attach an image to.
   8731          * After picking the contact it launches the image cropper in face detection mode.
   8732          */
   8733         public static final String ATTACH_IMAGE =
   8734                 "com.android.contacts.action.ATTACH_IMAGE";
   8735 
   8736         /**
   8737          * This is the intent that is fired when the user clicks the "invite to the network" button
   8738          * on a contact.  Only sent to an activity which is explicitly registered by a contact
   8739          * provider which supports the "invite to the network" feature.
   8740          * <p>
   8741          * {@link Intent#getData()} contains the lookup URI for the contact.
   8742          */
   8743         public static final String INVITE_CONTACT =
   8744                 "com.android.contacts.action.INVITE_CONTACT";
   8745 
   8746         /**
   8747          * Takes as input a data URI with a mailto: or tel: scheme. If a single
   8748          * contact exists with the given data it will be shown. If no contact
   8749          * exists, a dialog will ask the user if they want to create a new
   8750          * contact with the provided details filled in. If multiple contacts
   8751          * share the data the user will be prompted to pick which contact they
   8752          * want to view.
   8753          * <p>
   8754          * For <code>mailto:</code> URIs, the scheme specific portion must be a
   8755          * raw email address, such as one built using
   8756          * {@link Uri#fromParts(String, String, String)}.
   8757          * <p>
   8758          * For <code>tel:</code> URIs, the scheme specific portion is compared
   8759          * to existing numbers using the standard caller ID lookup algorithm.
   8760          * The number must be properly encoded, for example using
   8761          * {@link Uri#fromParts(String, String, String)}.
   8762          * <p>
   8763          * Any extras from the {@link Insert} class will be passed along to the
   8764          * create activity if there are no contacts to show.
   8765          * <p>
   8766          * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
   8767          * prompting the user when the contact doesn't exist.
   8768          */
   8769         public static final String SHOW_OR_CREATE_CONTACT =
   8770                 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
   8771 
   8772         /**
   8773          * Activity Action: Initiate a message to someone by voice. The message could be text,
   8774          * audio, video or image(photo). This action supports messaging with a specific contact
   8775          * regardless of the underlying messaging protocol used.
   8776          * <p>
   8777          * The action could be originated from the Voice Assistant as a voice interaction. In such
   8778          * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE}
   8779          * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before
   8780          * proceeding. By doing this check the activity verifies that the action indeed was
   8781          * initiated by Voice Assistant and could send a message right away, without any further
   8782          * input from the user. This allows for a smooth user experience when sending a message by
   8783          * voice. Note: this activity must also support the {@link
   8784          * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link
   8785          * android.service.voice.VoiceInteractionSession#startVoiceActivity}.
   8786          * <p>
   8787          * When the action was not initiated by Voice Assistant or when the receiving activity does
   8788          * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm
   8789          * with the user before sending the message (because in this case it is unknown which app
   8790          * sent the intent, it could be malicious).
   8791          * <p>
   8792          * To allow the Voice Assistant to help users with contacts disambiguation, the messaging
   8793          * app may choose to integrate with the Contacts Provider. You will need to specify a new
   8794          * MIME type in order to store your apps unique contact IDs and optional human readable
   8795          * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link
   8796          * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact
   8797          * disambiguation user experience. The following convention should be met when performing
   8798          * such integration:
   8799          * <ul>
   8800          * <li>This activity should have a string meta-data field associated with it, {@link
   8801          * #METADATA_ACCOUNT_TYPE}, which defines {@link RawContacts#ACCOUNT_TYPE} for your Contacts
   8802          * Provider implementation. The account type should be globally unique, for example you can
   8803          * use your app package name as the account type.</li>
   8804          * <li>This activity should have a string meta-data field associated with it, {@link
   8805          * #METADATA_MIMETYPE}, which defines {@link DataColumns#MIMETYPE} for your Contacts
   8806          * Provider implementation. For example, you can use
   8807          * "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li>
   8808          * <li>When filling Data table row for METADATA_MIMETYPE, column {@link DataColumns#DATA1}
   8809          * should store the unique contact ID as understood by the app. This value will be used in
   8810          * the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li>
   8811          * <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column {@link
   8812          * DataColumns#DATA3} could store a human readable label for the ID. For example it could be
   8813          * phone number or human readable username/user_id like "a_super_cool_user_name". This label
   8814          * may be shown below the Contact Name by the Voice Assistant as the user completes the
   8815          * voice action. If DATA3 is empty, the ID in DATA1 may be shown instead.</li>
   8816          * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will
   8817          * already get the Contact Name from the RawContacts display_name.</em></li>
   8818          * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1.
   8819          * If this applies to you and youd like phone number to be shown below the Contact Name by
   8820          * the Voice Assistant, then you may choose to leave DATA3 empty.</em></li>
   8821          * <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App,
   8822          * make sure it does not include prefix text such as "Message +<phone>" or "Free Message
   8823          * +<phone>", etc. If you must show the prefix text in the Contacts App, please use a
   8824          * different DATA# column, and update your contacts.xml to point to this new column. </em>
   8825          * </li>
   8826          * <li>Everytime the user sends a message to a contact, your app may choose to update the
   8827          * {@link ContactOptionsColumns#TIMES_CONTACTED} entry through DataUsageFeedback class.
   8828          * Doing this will allow Voice Assistant to bias speech recognition to contacts frequently
   8829          * contacted, this is particularly useful for contact names that are hard to pronounce.</li>
   8830          * </ul>
   8831          * If the app chooses not to integrate with the Contacts Provider (in particular, when
   8832          * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant
   8833          * will use existing phone number entries as contact ID's for such app.
   8834          * <p>
   8835          * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent.
   8836          * The intent sender will always put the concrete mime type in the intent type, like
   8837          * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to
   8838          * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled
   8839          * CharSequence. Otherwise, the message content will be supplied through {@link
   8840          * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter
   8841          * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages
   8842          * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text
   8843          * transcription of this recording.
   8844          * <p>
   8845          * The message can have n recipients. The n-th recipient of the message will be provided as
   8846          * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link
   8847          * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a
   8848          * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and
   8849          * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements
   8850          * is provided (e.g. all 3 are null) for the recipient or if the information provided is
   8851          * ambiguous then the activity should prompt the user for the recipient to send the message
   8852          * to.
   8853          * <p>
   8854          * Output: nothing
   8855          *
   8856          * @see #EXTRA_RECIPIENT_CONTACT_URI
   8857          * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID
   8858          * @see #EXTRA_RECIPIENT_CONTACT_NAME
   8859          * @see #METADATA_ACCOUNT_TYPE
   8860          * @see #METADATA_MIMETYPE
   8861          */
   8862         public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS =
   8863                 "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS";
   8864 
   8865         /**
   8866          * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were
   8867          * located in the Contacts Provider), used with {@link
   8868          * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this
   8869          * extra is a {@code String[]}. The number of elements in the array should be equal to
   8870          * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and
   8871          * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular
   8872          * recipient is absent, it will be set to null.
   8873          * <p>
   8874          * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging
   8875          * platform, so this may be ambiguous. E.g., one contact John Smith could have two
   8876          * accounts on the same messaging app.</em>
   8877          * <p>
   8878          * <em>Example value: {"content://com.android.contacts/contacts/16"}</em>
   8879          */
   8880         public static final String EXTRA_RECIPIENT_CONTACT_URI =
   8881                 "android.provider.extra.RECIPIENT_CONTACT_URI";
   8882 
   8883         /**
   8884          * This extra specifies a messaging apps unique ID(s) for the contact(s), used with {@link
   8885          * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this
   8886          * extra is a {@code String[]}. The number of elements in the array should be equal to
   8887          * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link
   8888          * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular
   8889          * recipient is absent, it will be set to null.
   8890          * <p>
   8891          * The value of the elements comes from the {@link DataColumns#DATA1} column in Contacts
   8892          * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both
   8893          * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app;
   8894          * otherwise, the value will be a phone number), and should be the unambiguous contact
   8895          * endpoint. This value is app-specific, it could be some proprietary ID or a phone number.
   8896          */
   8897         public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID =
   8898                 "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID";
   8899 
   8900         /**
   8901          * This extra specifies the contact name (full name from the Contacts Provider), used with
   8902          * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this
   8903          * extra is a {@code String[]}. The number of elements in the array should be equal to
   8904          * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link
   8905          * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular
   8906          * recipient is absent, it will be set to null.
   8907          * <p>
   8908          * The value of the elements comes from RawContact's display_name column.
   8909          * <p>
   8910          * <em>Example value: {"Jane Doe"}</em>
   8911          */
   8912         public static final String EXTRA_RECIPIENT_CONTACT_NAME =
   8913                 "android.provider.extra.RECIPIENT_CONTACT_NAME";
   8914 
   8915         /**
   8916          * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity
   8917          * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider
   8918          * implementation.
   8919          */
   8920         public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type";
   8921 
   8922         /**
   8923          * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity
   8924          * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider
   8925          * implementation.
   8926          */
   8927         public static final String METADATA_MIMETYPE = "android.provider.mimetype";
   8928 
   8929         /**
   8930          * Starts an Activity that lets the user select the multiple phones from a
   8931          * list of phone numbers which come from the contacts or
   8932          * {@link #EXTRA_PHONE_URIS}.
   8933          * <p>
   8934          * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
   8935          * could belong to the contacts or not, and will be selected by default.
   8936          * <p>
   8937          * The user's selection will be returned from
   8938          * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
   8939          * if the resultCode is
   8940          * {@link android.app.Activity#RESULT_OK}, the array of picked phone
   8941          * numbers are in the Intent's
   8942          * {@link #EXTRA_PHONE_URIS}; otherwise, the
   8943          * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
   8944          * left the Activity without changing the selection.
   8945          *
   8946          * @hide
   8947          */
   8948         public static final String ACTION_GET_MULTIPLE_PHONES =
   8949                 "com.android.contacts.action.GET_MULTIPLE_PHONES";
   8950 
   8951         /**
   8952          * A broadcast action which is sent when any change has been made to the profile, such
   8953          * as the profile name or the picture.  A receiver must have
   8954          * the android.permission.READ_PROFILE permission.
   8955          *
   8956          * @hide
   8957          */
   8958         public static final String ACTION_PROFILE_CHANGED =
   8959                 "android.provider.Contacts.PROFILE_CHANGED";
   8960 
   8961         /**
   8962          * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
   8963          * contact if no matching contact found. Otherwise, default behavior is
   8964          * to prompt user with dialog before creating.
   8965          * <p>
   8966          * Type: BOOLEAN
   8967          */
   8968         public static final String EXTRA_FORCE_CREATE =
   8969                 "com.android.contacts.action.FORCE_CREATE";
   8970 
   8971         /**
   8972          * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
   8973          * description to be shown when prompting user about creating a new
   8974          * contact.
   8975          * <p>
   8976          * Type: STRING
   8977          */
   8978         public static final String EXTRA_CREATE_DESCRIPTION =
   8979             "com.android.contacts.action.CREATE_DESCRIPTION";
   8980 
   8981         /**
   8982          * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
   8983          * <p>
   8984          * The phone numbers want to be picked by default should be passed in as
   8985          * input value. These phone numbers could belong to the contacts or not.
   8986          * <p>
   8987          * The phone numbers which were picked by the user are returned as output
   8988          * value.
   8989          * <p>
   8990          * Type: array of URIs, the tel URI is used for the phone numbers which don't
   8991          * belong to any contact, the content URI is used for phone id in contacts.
   8992          *
   8993          * @hide
   8994          */
   8995         public static final String EXTRA_PHONE_URIS =
   8996             "com.android.contacts.extra.PHONE_URIS";
   8997 
   8998         /**
   8999          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
   9000          * dialog location using screen coordinates. When not specified, the
   9001          * dialog will be centered.
   9002          *
   9003          * @hide
   9004          */
   9005         @Deprecated
   9006         public static final String EXTRA_TARGET_RECT = "target_rect";
   9007 
   9008         /**
   9009          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
   9010          * desired dialog style, usually a variation on size. One of
   9011          * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
   9012          *
   9013          * @hide
   9014          */
   9015         @Deprecated
   9016         public static final String EXTRA_MODE = "mode";
   9017 
   9018         /**
   9019          * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
   9020          *
   9021          * @hide
   9022          */
   9023         @Deprecated
   9024         public static final int MODE_SMALL = 1;
   9025 
   9026         /**
   9027          * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
   9028          *
   9029          * @hide
   9030          */
   9031         @Deprecated
   9032         public static final int MODE_MEDIUM = 2;
   9033 
   9034         /**
   9035          * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
   9036          *
   9037          * @hide
   9038          */
   9039         @Deprecated
   9040         public static final int MODE_LARGE = 3;
   9041 
   9042         /**
   9043          * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
   9044          * a list of specific MIME-types to exclude and not display. Stored as a
   9045          * {@link String} array.
   9046          *
   9047          * @hide
   9048          */
   9049         @Deprecated
   9050         public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
   9051 
   9052         /**
   9053          * Convenience class that contains string constants used
   9054          * to create contact {@link android.content.Intent Intents}.
   9055          */
   9056         public static final class Insert {
   9057             /** The action code to use when adding a contact */
   9058             public static final String ACTION = Intent.ACTION_INSERT;
   9059 
   9060             /**
   9061              * If present, forces a bypass of quick insert mode.
   9062              */
   9063             public static final String FULL_MODE = "full_mode";
   9064 
   9065             /**
   9066              * The extra field for the contact name.
   9067              * <P>Type: String</P>
   9068              */
   9069             public static final String NAME = "name";
   9070 
   9071             // TODO add structured name values here.
   9072 
   9073             /**
   9074              * The extra field for the contact phonetic name.
   9075              * <P>Type: String</P>
   9076              */
   9077             public static final String PHONETIC_NAME = "phonetic_name";
   9078 
   9079             /**
   9080              * The extra field for the contact company.
   9081              * <P>Type: String</P>
   9082              */
   9083             public static final String COMPANY = "company";
   9084 
   9085             /**
   9086              * The extra field for the contact job title.
   9087              * <P>Type: String</P>
   9088              */
   9089             public static final String JOB_TITLE = "job_title";
   9090 
   9091             /**
   9092              * The extra field for the contact notes.
   9093              * <P>Type: String</P>
   9094              */
   9095             public static final String NOTES = "notes";
   9096 
   9097             /**
   9098              * The extra field for the contact phone number.
   9099              * <P>Type: String</P>
   9100              */
   9101             public static final String PHONE = "phone";
   9102 
   9103             /**
   9104              * The extra field for the contact phone number type.
   9105              * <P>Type: Either an integer value from
   9106              * {@link CommonDataKinds.Phone},
   9107              *  or a string specifying a custom label.</P>
   9108              */
   9109             public static final String PHONE_TYPE = "phone_type";
   9110 
   9111             /**
   9112              * The extra field for the phone isprimary flag.
   9113              * <P>Type: boolean</P>
   9114              */
   9115             public static final String PHONE_ISPRIMARY = "phone_isprimary";
   9116 
   9117             /**
   9118              * The extra field for an optional second contact phone number.
   9119              * <P>Type: String</P>
   9120              */
   9121             public static final String SECONDARY_PHONE = "secondary_phone";
   9122 
   9123             /**
   9124              * The extra field for an optional second contact phone number type.
   9125              * <P>Type: Either an integer value from
   9126              * {@link CommonDataKinds.Phone},
   9127              *  or a string specifying a custom label.</P>
   9128              */
   9129             public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
   9130 
   9131             /**
   9132              * The extra field for an optional third contact phone number.
   9133              * <P>Type: String</P>
   9134              */
   9135             public static final String TERTIARY_PHONE = "tertiary_phone";
   9136 
   9137             /**
   9138              * The extra field for an optional third contact phone number type.
   9139              * <P>Type: Either an integer value from
   9140              * {@link CommonDataKinds.Phone},
   9141              *  or a string specifying a custom label.</P>
   9142              */
   9143             public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
   9144 
   9145             /**
   9146              * The extra field for the contact email address.
   9147              * <P>Type: String</P>
   9148              */
   9149             public static final String EMAIL = "email";
   9150 
   9151             /**
   9152              * The extra field for the contact email type.
   9153              * <P>Type: Either an integer value from
   9154              * {@link CommonDataKinds.Email}
   9155              *  or a string specifying a custom label.</P>
   9156              */
   9157             public static final String EMAIL_TYPE = "email_type";
   9158 
   9159             /**
   9160              * The extra field for the email isprimary flag.
   9161              * <P>Type: boolean</P>
   9162              */
   9163             public static final String EMAIL_ISPRIMARY = "email_isprimary";
   9164 
   9165             /**
   9166              * The extra field for an optional second contact email address.
   9167              * <P>Type: String</P>
   9168              */
   9169             public static final String SECONDARY_EMAIL = "secondary_email";
   9170 
   9171             /**
   9172              * The extra field for an optional second contact email type.
   9173              * <P>Type: Either an integer value from
   9174              * {@link CommonDataKinds.Email}
   9175              *  or a string specifying a custom label.</P>
   9176              */
   9177             public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
   9178 
   9179             /**
   9180              * The extra field for an optional third contact email address.
   9181              * <P>Type: String</P>
   9182              */
   9183             public static final String TERTIARY_EMAIL = "tertiary_email";
   9184 
   9185             /**
   9186              * The extra field for an optional third contact email type.
   9187              * <P>Type: Either an integer value from
   9188              * {@link CommonDataKinds.Email}
   9189              *  or a string specifying a custom label.</P>
   9190              */
   9191             public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
   9192 
   9193             /**
   9194              * The extra field for the contact postal address.
   9195              * <P>Type: String</P>
   9196              */
   9197             public static final String POSTAL = "postal";
   9198 
   9199             /**
   9200              * The extra field for the contact postal address type.
   9201              * <P>Type: Either an integer value from
   9202              * {@link CommonDataKinds.StructuredPostal}
   9203              *  or a string specifying a custom label.</P>
   9204              */
   9205             public static final String POSTAL_TYPE = "postal_type";
   9206 
   9207             /**
   9208              * The extra field for the postal isprimary flag.
   9209              * <P>Type: boolean</P>
   9210              */
   9211             public static final String POSTAL_ISPRIMARY = "postal_isprimary";
   9212 
   9213             /**
   9214              * The extra field for an IM handle.
   9215              * <P>Type: String</P>
   9216              */
   9217             public static final String IM_HANDLE = "im_handle";
   9218 
   9219             /**
   9220              * The extra field for the IM protocol
   9221              */
   9222             public static final String IM_PROTOCOL = "im_protocol";
   9223 
   9224             /**
   9225              * The extra field for the IM isprimary flag.
   9226              * <P>Type: boolean</P>
   9227              */
   9228             public static final String IM_ISPRIMARY = "im_isprimary";
   9229 
   9230             /**
   9231              * The extra field that allows the client to supply multiple rows of
   9232              * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
   9233              * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
   9234              * {@link ContentValues}, one per data row. Supplying this extra is
   9235              * similar to inserting multiple rows into the {@link Data} table,
   9236              * except the user gets a chance to see and edit them before saving.
   9237              * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
   9238              * If supplied values are not visible in the editor UI, they will be
   9239              * dropped.  Duplicate data will dropped.  Some fields
   9240              * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
   9241              * adjusted to comply with the constraints of the specific account type.
   9242              * For example, an Exchange contact can only have one phone numbers of type Home,
   9243              * so the contact editor may choose a different type for this phone number to
   9244              * avoid dropping the valueable part of the row, which is the phone number.
   9245              * <p>
   9246              * Example:
   9247              * <pre>
   9248              *  ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
   9249              *
   9250              *  ContentValues row1 = new ContentValues();
   9251              *  row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
   9252              *  row1.put(Organization.COMPANY, "Android");
   9253              *  data.add(row1);
   9254              *
   9255              *  ContentValues row2 = new ContentValues();
   9256              *  row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
   9257              *  row2.put(Email.TYPE, Email.TYPE_CUSTOM);
   9258              *  row2.put(Email.LABEL, "Green Bot");
   9259              *  row2.put(Email.ADDRESS, "android (at) android.com");
   9260              *  data.add(row2);
   9261              *
   9262              *  Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
   9263              *  intent.putParcelableArrayListExtra(Insert.DATA, data);
   9264              *
   9265              *  startActivity(intent);
   9266              * </pre>
   9267              */
   9268             public static final String DATA = "data";
   9269 
   9270             /**
   9271              * Used to specify the account in which to create the new contact.
   9272              * <p>
   9273              * If this value is not provided, the user is presented with a disambiguation
   9274              * dialog to chose an account
   9275              * <p>
   9276              * Type: {@link Account}
   9277              */
   9278             public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT";
   9279 
   9280             /**
   9281              * Used to specify the data set within the account in which to create the
   9282              * new contact.
   9283              * <p>
   9284              * This value is optional - if it is not specified, the contact will be
   9285              * created in the base account, with no data set.
   9286              * <p>
   9287              * Type: String
   9288              */
   9289             public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET";
   9290         }
   9291     }
   9292 
   9293     /**
   9294      * @hide
   9295      */
   9296     @SystemApi
   9297     protected interface MetadataSyncColumns {
   9298 
   9299         /**
   9300          * The raw contact backup id.
   9301          * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the
   9302          * persistent unique id for each raw contact within its source system.
   9303          */
   9304         public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";
   9305 
   9306         /**
   9307          * The account type to which the raw_contact of this item is associated. See
   9308          * {@link RawContacts#ACCOUNT_TYPE}
   9309          */
   9310         public static final String ACCOUNT_TYPE = "account_type";
   9311 
   9312         /**
   9313          * The account name to which the raw_contact of this item is associated. See
   9314          * {@link RawContacts#ACCOUNT_NAME}
   9315          */
   9316         public static final String ACCOUNT_NAME = "account_name";
   9317 
   9318         /**
   9319          * The data set within the account that the raw_contact of this row belongs to. This allows
   9320          * multiple sync adapters for the same account type to distinguish between
   9321          * each others' data.
   9322          * {@link RawContacts#DATA_SET}
   9323          */
   9324         public static final String DATA_SET = "data_set";
   9325 
   9326         /**
   9327          * A text column contains the Json string got from People API. The Json string contains
   9328          * all the metadata related to the raw contact, i.e., all the data fields and
   9329          * aggregation exceptions.
   9330          *
   9331          * Here is an example of the Json string got from the actual schema.
   9332          * <pre>
   9333          *     {
   9334          *       "unique_contact_id": {
   9335          *         "account_type": "CUSTOM_ACCOUNT",
   9336          *         "custom_account_type": "facebook",
   9337          *         "account_name": "android-test",
   9338          *         "contact_id": "1111111",
   9339          *         "data_set": "FOCUS"
   9340          *       },
   9341          *       "contact_prefs": {
   9342          *         "send_to_voicemail": true,
   9343          *         "starred": false,
   9344          *         "pinned": 2
   9345          *       },
   9346          *       "aggregation_data": [
   9347          *         {
   9348          *           "type": "TOGETHER",
   9349          *           "contact_ids": [
   9350          *             {
   9351          *               "account_type": "GOOGLE_ACCOUNT",
   9352          *               "account_name": "android-test2",
   9353          *               "contact_id": "2222222",
   9354          *               "data_set": "GOOGLE_PLUS"
   9355          *             },
   9356          *             {
   9357          *               "account_type": "GOOGLE_ACCOUNT",
   9358          *               "account_name": "android-test3",
   9359          *               "contact_id": "3333333",
   9360          *               "data_set": "CUSTOM",
   9361          *               "custom_data_set": "custom type"
   9362          *             }
   9363          *           ]
   9364          *         }
   9365          *       ],
   9366          *       "field_data": [
   9367          *         {
   9368          *           "field_data_id": "1001",
   9369          *           "field_data_prefs": {
   9370          *             "is_primary": true,
   9371          *             "is_super_primary": true
   9372          *           },
   9373          *           "usage_stats": [
   9374          *             {
   9375          *               "usage_type": "CALL",
   9376          *               "last_time_used": 10000001,
   9377          *               "usage_count": 10
   9378          *             }
   9379          *           ]
   9380          *         }
   9381          *       ]
   9382          *     }
   9383          * </pre>
   9384          */
   9385         public static final String DATA = "data";
   9386 
   9387         /**
   9388          * The "deleted" flag: "0" by default, "1" if the row has been marked
   9389          * for deletion. When {@link android.content.ContentResolver#delete} is
   9390          * called on a raw contact, updating MetadataSync table to set the flag of the raw contact
   9391          * as "1", then metadata sync adapter deletes the raw contact metadata on the server.
   9392          * <P>Type: INTEGER</P>
   9393          */
   9394         public static final String DELETED = "deleted";
   9395     }
   9396 
   9397     /**
   9398      * Constants for the metadata sync table. This table is used to cache the metadata_sync data
   9399      * from server before it is merged into other CP2 tables.
   9400      *
   9401      * @hide
   9402      */
   9403     @SystemApi
   9404     public static final class MetadataSync implements BaseColumns, MetadataSyncColumns {
   9405 
   9406         /** The authority for the contacts metadata */
   9407         public static final String METADATA_AUTHORITY = "com.android.contacts.metadata";
   9408 
   9409         /** A content:// style uri to the authority for the contacts metadata */
   9410         public static final Uri METADATA_AUTHORITY_URI = Uri.parse(
   9411                 "content://" + METADATA_AUTHORITY);
   9412 
   9413         /**
   9414          * This utility class cannot be instantiated
   9415          */
   9416         private MetadataSync() {
   9417         }
   9418 
   9419         /**
   9420          * The content:// style URI for this table.
   9421          */
   9422         public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI,
   9423                 "metadata_sync");
   9424 
   9425         /**
   9426          * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata
   9427          */
   9428         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata";
   9429 
   9430         /**
   9431          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata.
   9432          */
   9433         public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
   9434     }
   9435 
   9436     /**
   9437      * @hide
   9438      */
   9439     @SystemApi
   9440     protected interface MetadataSyncStateColumns {
   9441 
   9442         /**
   9443          * A reference to the name of the account to which this state belongs
   9444          * <P>Type: STRING</P>
   9445          */
   9446         public static final String ACCOUNT_TYPE = "account_type";
   9447 
   9448         /**
   9449          * A reference to the type of the account to which this state belongs
   9450          * <P>Type: STRING</P>
   9451          */
   9452         public static final String ACCOUNT_NAME = "account_name";
   9453 
   9454         /**
   9455          * A reference to the data set within the account to which this state belongs
   9456          * <P>Type: STRING</P>
   9457          */
   9458         public static final String DATA_SET = "data_set";
   9459 
   9460         /**
   9461          * The sync state associated with this account.
   9462          * <P>Type: Blob</P>
   9463          */
   9464         public static final String STATE = "state";
   9465     }
   9466 
   9467     /**
   9468      * Constants for the metadata_sync_state table. This table is used to store the metadata
   9469      * sync state for a set of accounts.
   9470      *
   9471      * @hide
   9472      */
   9473     @SystemApi
   9474     public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns {
   9475 
   9476         /**
   9477          * This utility class cannot be instantiated
   9478          */
   9479         private MetadataSyncState() {
   9480         }
   9481 
   9482         /**
   9483          * The content:// style URI for this table.
   9484          */
   9485         public static final Uri CONTENT_URI =
   9486                 Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state");
   9487 
   9488         /**
   9489          * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync
   9490          * states.
   9491          */
   9492         public static final String CONTENT_TYPE =
   9493                 "vnd.android.cursor.dir/contact_metadata_sync_state";
   9494 
   9495         /**
   9496          * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync
   9497          * state.
   9498          */
   9499         public static final String CONTENT_ITEM_TYPE =
   9500                 "vnd.android.cursor.item/contact_metadata_sync_state";
   9501     }
   9502 }
   9503