blob: 81e1eb99336b1a8b5b74a5b4807deeb8b9953b7b [file] [log] [blame]
Evan Millar088b2912009-05-28 15:24:37 -07001/*
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
17package android.provider;
18
Jeff Sharkey7b6771a2009-08-17 01:59:54 -070019import android.accounts.Account;
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -060020import android.annotation.SdkConstant;
21import android.annotation.SdkConstant.SdkConstantType;
Zheng Fu7997bee2015-06-09 16:50:02 -070022import android.annotation.SystemApi;
Philip P. Moltmann33115152018-04-11 13:39:36 -070023import android.annotation.TestApi;
Mathew Inwood6750f2e2018-08-10 09:29:25 +010024import android.annotation.UnsupportedAppUsage;
Daniel Lehmanne6d3d282011-07-13 15:35:05 -070025import android.app.Activity;
Makoto Onuki2a615372017-01-30 11:59:46 -080026import android.content.BroadcastReceiver;
Ta-wei Yendc9daaa2017-11-28 17:10:48 -080027import android.content.ComponentName;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070028import android.content.ContentProviderClient;
29import android.content.ContentProviderOperation;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070030import android.content.ContentResolver;
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -070031import android.content.ContentUris;
Jeff Hamilton85abdc52009-09-22 12:41:45 -050032import android.content.ContentValues;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070033import android.content.Context;
Makoto Onukibba33cd2012-05-25 17:09:05 -070034import android.content.ContextWrapper;
Fred Quintana328c0e72009-12-07 14:52:28 -080035import android.content.CursorEntityIterator;
Fred Quintana328c0e72009-12-07 14:52:28 -080036import android.content.Entity;
Tom O'Neill244327e22010-01-08 11:11:15 -080037import android.content.EntityIterator;
38import android.content.Intent;
Makoto Onuki2a615372017-01-30 11:59:46 -080039import android.content.IntentFilter;
Daniel Lehmannf5d46522011-07-14 22:16:21 -070040import android.content.res.AssetFileDescriptor;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -070041import android.content.res.Resources;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070042import android.database.Cursor;
Makoto Onuki93d94eb2016-08-25 14:24:03 -070043import android.database.CursorWrapper;
Fred Quintana328c0e72009-12-07 14:52:28 -080044import android.database.DatabaseUtils;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070045import android.graphics.Rect;
Evan Millar088b2912009-05-28 15:24:37 -070046import android.net.Uri;
Fred Quintana0f4e1ab2009-07-09 17:20:59 -070047import android.os.RemoteException;
Ta-wei Yendc9daaa2017-11-28 17:10:48 -080048import android.telecom.PhoneAccountHandle;
Dmitri Plotnikov93032952009-08-19 11:26:57 -070049import android.text.TextUtils;
Jeff Sharkeya503f6f2009-12-08 21:50:14 -080050import android.util.DisplayMetrics;
Fred Quintanac4516a72009-09-03 12:14:06 -070051import android.util.Pair;
Jeff Sharkey6449eb02009-09-16 21:41:51 -070052import android.view.View;
Ta-wei Yendc9daaa2017-11-28 17:10:48 -080053
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070054import java.io.ByteArrayInputStream;
Daniel Lehmannf5d46522011-07-14 22:16:21 -070055import java.io.IOException;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070056import java.io.InputStream;
Dmitri Plotnikov44730c22010-08-12 10:09:58 -070057import java.util.ArrayList;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -070058
Evan Millar088b2912009-05-28 15:24:37 -070059/**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080060 * <p>
61 * The contract between the contacts provider and applications. Contains
62 * definitions for the supported URIs and columns. These APIs supersede
63 * {@link Contacts}.
64 * </p>
65 * <h3>Overview</h3>
66 * <p>
67 * ContactsContract defines an extensible database of contact-related
68 * information. Contact information is stored in a three-tier data model:
69 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080070 * <ul>
71 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080072 * A row in the {@link Data} table can store any kind of personal data, such
73 * as a phone number or email addresses. The set of data kinds that can be
74 * stored in this table is open-ended. There is a predefined set of common
75 * kinds, but any application can add its own data kinds.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080076 * </li>
77 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080078 * A row in the {@link RawContacts} table represents a set of data describing a
79 * person and associated with a single account (for example, one of the user's
80 * Gmail accounts).
Dirk Dougherty4e7db252010-01-05 17:03:39 -080081 * </li>
82 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080083 * A row in the {@link Contacts} table represents an aggregate of one or more
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080084 * RawContacts presumably describing the same person. When data in or associated with
85 * the RawContacts table is changed, the affected aggregate contacts are updated as
86 * necessary.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080087 * </li>
88 * </ul>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080089 * <p>
90 * Other tables include:
91 * </p>
Dirk Dougherty4e7db252010-01-05 17:03:39 -080092 * <ul>
93 * <li>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -080094 * {@link Groups}, which contains information about raw contact groups
95 * such as Gmail contact groups. The
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080096 * current API does not support the notion of groups spanning multiple accounts.
Dirk Dougherty4e7db252010-01-05 17:03:39 -080097 * </li>
98 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -080099 * {@link StatusUpdates}, which contains social status updates including IM
100 * availability.
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800101 * </li>
102 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800103 * {@link AggregationExceptions}, which is used for manual aggregation and
104 * disaggregation of raw contacts
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800105 * </li>
106 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800107 * {@link Settings}, which contains visibility and sync settings for accounts
108 * and groups.
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800109 * </li>
110 * <li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800111 * {@link SyncState}, which contains free-form data maintained on behalf of sync
112 * adapters
Dirk Dougherty4e7db252010-01-05 17:03:39 -0800113 * </li>
114 * <li>
115 * {@link PhoneLookup}, which is used for quick caller-ID lookup</li>
116 * </ul>
Evan Millar088b2912009-05-28 15:24:37 -0700117 */
Jeff Hamilton0c232122009-09-24 00:26:50 -0500118@SuppressWarnings("unused")
Evan Millar088b2912009-05-28 15:24:37 -0700119public final class ContactsContract {
120 /** The authority for the contacts provider */
121 public static final String AUTHORITY = "com.android.contacts";
122 /** A content:// style uri to the authority for the contacts provider */
123 public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
124
Fred Quintana33f889a2009-09-14 17:31:26 -0700125 /**
Makoto Onuki203145e2016-09-28 15:41:29 -0700126 * Prefix for column names that are not visible to client apps.
127 * @hide
128 */
Jeff Sharkeycb269aac2019-01-25 11:15:38 -0700129 @TestApi
Makoto Onuki203145e2016-09-28 15:41:29 -0700130 public static final String HIDDEN_COLUMN_PREFIX = "x_";
131
132 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800133 * An optional URI parameter for insert, update, or delete queries
134 * that allows the caller
Fred Quintana33f889a2009-09-14 17:31:26 -0700135 * to specify that it is a sync adapter. The default value is false. If true
Tom O'Neilld6f9cd22010-01-14 18:17:01 -0800136 * {@link RawContacts#DIRTY} is not automatically set and the
137 * "syncToNetwork" parameter is set to false when calling
138 * {@link
139 * ContentResolver#notifyChange(android.net.Uri, android.database.ContentObserver, boolean)}.
140 * This prevents an unnecessary extra synchronization, see the discussion of
141 * the delete operation in {@link RawContacts}.
Fred Quintana33f889a2009-09-14 17:31:26 -0700142 */
143 public static final String CALLER_IS_SYNCADAPTER = "caller_is_syncadapter";
144
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500145 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700146 * Query parameter that should be used by the client to access a specific
147 * {@link Directory}. The parameter value should be the _ID of the corresponding
148 * directory, e.g.
149 * {@code content://com.android.contacts/data/emails/filter/acme?directory=3}
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700150 */
151 public static final String DIRECTORY_PARAM_KEY = "directory";
152
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700153 /**
Makoto Onuki93d94eb2016-08-25 14:24:03 -0700154 * A query parameter that limits the number of results returned for supported URIs. The
Dmitri Plotnikov5a998dd2010-08-31 17:32:16 -0700155 * parameter value should be an integer.
Makoto Onuki93d94eb2016-08-25 14:24:03 -0700156 *
157 * <p>This parameter is not supported by all URIs. Supported URIs include, but not limited to,
158 * {@link Contacts#CONTENT_URI},
159 * {@link RawContacts#CONTENT_URI},
160 * {@link Data#CONTENT_URI},
161 * {@link CommonDataKinds.Phone#CONTENT_URI},
162 * {@link CommonDataKinds.Callable#CONTENT_URI},
163 * {@link CommonDataKinds.Email#CONTENT_URI},
164 * {@link CommonDataKinds.Contactables#CONTENT_URI},
165 *
166 * <p>In order to limit the number of rows returned by a non-supported URI, you can implement a
167 * {@link CursorWrapper} and override the {@link CursorWrapper#getCount()} methods.
Dmitri Plotnikov5a998dd2010-08-31 17:32:16 -0700168 */
169 public static final String LIMIT_PARAM_KEY = "limit";
170
171 /**
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700172 * A query parameter specifing a primary account. This parameter should be used with
173 * {@link #PRIMARY_ACCOUNT_TYPE}. The contacts provider handling a query may rely on
174 * this information to optimize its query results.
175 *
176 * For example, in an email composition screen, its implementation can specify an account when
177 * obtaining possible recipients, letting the provider know which account is selected during
178 * the composition. The provider may use the "primary account" information to optimize
179 * the search result.
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700180 */
181 public static final String PRIMARY_ACCOUNT_NAME = "name_for_primary_account";
182
183 /**
184 * A query parameter specifing a primary account. This parameter should be used with
185 * {@link #PRIMARY_ACCOUNT_NAME}. See the doc in {@link #PRIMARY_ACCOUNT_NAME}.
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700186 */
187 public static final String PRIMARY_ACCOUNT_TYPE = "type_for_primary_account";
188
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700189 /**
190 * A boolean parameter for {@link Contacts#CONTENT_STREQUENT_URI} and
191 * {@link Contacts#CONTENT_STREQUENT_FILTER_URI}, which requires the ContactsProvider to
Makoto Onukiaa2dd622018-07-30 11:14:12 -0700192 * return only phone-related results.
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700193 */
194 public static final String STREQUENT_PHONE_ONLY = "strequent_phone_only";
Daisuke Miyakawa54fcd4c2011-04-06 17:35:38 -0700195
196 /**
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700197 * A key to a boolean in the "extras" bundle of the cursor.
198 * The boolean indicates that the provider did not create a snippet and that the client asking
199 * for the snippet should do it (true means the snippeting was deferred to the client).
Yorke Leeeaf094932014-07-01 10:28:56 -0700200 *
201 * @see SearchSnippets
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700202 */
203 public static final String DEFERRED_SNIPPETING = "deferred_snippeting";
204
205 /**
Yorke Leeeaf094932014-07-01 10:28:56 -0700206 * Key to retrieve the original deferred snippeting from the cursor on the client side.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700207 *
Yorke Leeeaf094932014-07-01 10:28:56 -0700208 * @see SearchSnippets
209 * @see #DEFERRED_SNIPPETING
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -0700210 */
211 public static final String DEFERRED_SNIPPETING_QUERY = "deferred_snippeting_query";
212
213 /**
Yorke Lee1ca440b2014-06-04 18:01:46 -0700214 * A boolean parameter for {@link CommonDataKinds.Phone#CONTENT_URI Phone.CONTENT_URI},
215 * {@link CommonDataKinds.Email#CONTENT_URI Email.CONTENT_URI}, and
216 * {@link CommonDataKinds.StructuredPostal#CONTENT_URI StructuredPostal.CONTENT_URI}.
Daisuke Miyakawa19352e02011-11-14 13:16:07 -0800217 * This enables a content provider to remove duplicate entries in results.
Daisuke Miyakawa19352e02011-11-14 13:16:07 -0800218 */
219 public static final String REMOVE_DUPLICATE_ENTRIES = "remove_duplicate_entries";
220
221 /**
Dave Santoroe43185e2011-10-10 18:11:00 -0700222 * <p>
223 * API for obtaining a pre-authorized version of a URI that normally requires special
224 * permission (beyond READ_CONTACTS) to read. The caller obtaining the pre-authorized URI
225 * must already have the necessary permissions to access the URI; otherwise a
Brian Attwellcc4b2f72015-01-08 14:58:15 -0800226 * {@link SecurityException} will be thrown. Unlike {@link Context#grantUriPermission},
227 * this can be used to grant permissions that aren't explicitly required for the URI inside
228 * AndroidManifest.xml. For example, permissions that are only required when reading URIs
229 * that refer to the user's profile.
Dave Santoroe43185e2011-10-10 18:11:00 -0700230 * </p>
231 * <p>
232 * The authorized URI returned in the bundle contains an expiring token that allows the
233 * caller to execute the query without having the special permissions that would normally
Brian Attwellcc4b2f72015-01-08 14:58:15 -0800234 * be required. The token expires in five minutes.
Dave Santoroe43185e2011-10-10 18:11:00 -0700235 * </p>
236 * <p>
237 * This API does not access disk, and should be safe to invoke from the UI thread.
238 * </p>
239 * <p>
240 * Example usage:
241 * <pre>
242 * Uri profileUri = ContactsContract.Profile.CONTENT_VCARD_URI;
243 * Bundle uriBundle = new Bundle();
244 * uriBundle.putParcelable(ContactsContract.Authorization.KEY_URI_TO_AUTHORIZE, uri);
245 * Bundle authResponse = getContext().getContentResolver().call(
246 * ContactsContract.AUTHORITY_URI,
247 * ContactsContract.Authorization.AUTHORIZATION_METHOD,
248 * null, // String arg, not used.
249 * uriBundle);
250 * if (authResponse != null) {
251 * Uri preauthorizedProfileUri = (Uri) authResponse.getParcelable(
252 * ContactsContract.Authorization.KEY_AUTHORIZED_URI);
253 * // This pre-authorized URI can be queried by a caller without READ_PROFILE
254 * // permission.
255 * }
256 * </pre>
257 * </p>
Brian Attwell7d383b92015-05-14 15:25:01 -0700258 *
259 * @hide
Dave Santoroe43185e2011-10-10 18:11:00 -0700260 */
261 public static final class Authorization {
262 /**
263 * The method to invoke to create a pre-authorized URI out of the input argument.
264 */
265 public static final String AUTHORIZATION_METHOD = "authorize";
266
267 /**
268 * The key to set in the outbound Bundle with the URI that should be authorized.
269 */
270 public static final String KEY_URI_TO_AUTHORIZE = "uri_to_authorize";
271
272 /**
273 * The key to retrieve from the returned Bundle to obtain the pre-authorized URI.
274 */
275 public static final String KEY_AUTHORIZED_URI = "authorized_uri";
276 }
277
Yorke Lee6355c8f2014-07-08 11:48:42 -0700278 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700279 * A Directory represents a contacts corpus, e.g. Local contacts,
280 * Google Apps Global Address List or Corporate Global Address List.
281 * <p>
282 * A Directory is implemented as a content provider with its unique authority and
283 * the same API as the main Contacts Provider. However, there is no expectation that
284 * every directory provider will implement this Contract in its entirety. If a
285 * directory provider does not have an implementation for a specific request, it
286 * should throw an UnsupportedOperationException.
287 * </p>
288 * <p>
289 * The most important use case for Directories is search. A Directory provider is
Dmitri Plotnikov13e03572010-08-19 16:31:29 -0700290 * expected to support at least {@link ContactsContract.Contacts#CONTENT_FILTER_URI
291 * Contacts.CONTENT_FILTER_URI}. If a Directory provider wants to participate
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700292 * in email and phone lookup functionalities, it should also implement
293 * {@link CommonDataKinds.Email#CONTENT_FILTER_URI CommonDataKinds.Email.CONTENT_FILTER_URI}
294 * and
295 * {@link CommonDataKinds.Phone#CONTENT_FILTER_URI CommonDataKinds.Phone.CONTENT_FILTER_URI}.
296 * </p>
297 * <p>
298 * A directory provider should return NULL for every projection field it does not
299 * recognize, rather than throwing an exception. This way it will not be broken
300 * if ContactsContract is extended with new fields in the future.
301 * </p>
302 * <p>
303 * The client interacts with a directory via Contacts Provider by supplying an
304 * optional {@code directory=} query parameter.
305 * <p>
306 * <p>
307 * When the Contacts Provider receives the request, it transforms the URI and forwards
308 * the request to the corresponding directory content provider.
309 * The URI is transformed in the following fashion:
310 * <ul>
311 * <li>The URI authority is replaced with the corresponding {@link #DIRECTORY_AUTHORITY}.</li>
312 * <li>The {@code accountName=} and {@code accountType=} parameters are added or
313 * replaced using the corresponding {@link #ACCOUNT_TYPE} and {@link #ACCOUNT_NAME} values.</li>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700314 * </ul>
315 * </p>
316 * <p>
317 * Clients should send directory requests to Contacts Provider and let it
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700318 * forward them to the respective providers rather than constructing
319 * directory provider URIs by themselves. This level of indirection allows
320 * Contacts Provider to implement additional system-level features and
321 * optimizations. Access to Contacts Provider is protected by the
Subir Jhanb603af612012-08-06 17:19:22 -0700322 * READ_CONTACTS permission, but access to the directory provider is protected by
323 * BIND_DIRECTORY_SEARCH. This permission was introduced at the API level 17, for previous
324 * platform versions the provider should perform the following check to make sure the call
325 * is coming from the ContactsProvider:
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700326 * <pre>
327 * private boolean isCallerAllowed() {
328 * PackageManager pm = getContext().getPackageManager();
329 * for (String packageName: pm.getPackagesForUid(Binder.getCallingUid())) {
330 * if (packageName.equals("com.android.providers.contacts")) {
331 * return true;
332 * }
333 * }
334 * return false;
335 * }
336 * </pre>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700337 * </p>
338 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700339 * The Directory table is read-only and is maintained by the Contacts Provider
340 * automatically.
341 * </p>
342 * <p>It always has at least these two rows:
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700343 * <ul>
344 * <li>
345 * The local directory. It has {@link Directory#_ID Directory._ID} =
346 * {@link Directory#DEFAULT Directory.DEFAULT}. This directory can be used to access locally
347 * stored contacts. The same can be achieved by omitting the {@code directory=}
348 * parameter altogether.
349 * </li>
350 * <li>
351 * The local invisible contacts. The corresponding directory ID is
352 * {@link Directory#LOCAL_INVISIBLE Directory.LOCAL_INVISIBLE}.
353 * </li>
354 * </ul>
355 * </p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700356 * <p>Custom Directories are discovered by the Contacts Provider following this procedure:
357 * <ul>
358 * <li>It finds all installed content providers with meta data identifying them
359 * as directory providers in AndroidManifest.xml:
360 * <code>
361 * &lt;meta-data android:name="android.content.ContactDirectory"
362 * android:value="true" /&gt;
363 * </code>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700364 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700365 * This tag should be placed inside the corresponding content provider declaration.
366 * </p>
367 * </li>
368 * <li>
369 * Then Contacts Provider sends a {@link Directory#CONTENT_URI Directory.CONTENT_URI}
370 * query to each of the directory authorities. A directory provider must implement
371 * this query and return a list of directories. Each directory returned by
372 * the provider must have a unique combination for the {@link #ACCOUNT_NAME} and
373 * {@link #ACCOUNT_TYPE} columns (nulls are allowed). Since directory IDs are assigned
374 * automatically, the _ID field will not be part of the query projection.
375 * </li>
376 * <li>Contacts Provider compiles directory lists received from all directory
377 * providers into one, assigns each individual directory a globally unique ID and
378 * stores all directory records in the Directory table.
379 * </li>
380 * </ul>
381 * </p>
382 * <p>Contacts Provider automatically interrogates newly installed or replaced packages.
383 * Thus simply installing a package containing a directory provider is sufficient
384 * to have that provider registered. A package supplying a directory provider does
385 * not have to contain launchable activities.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700386 * </p>
387 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700388 * Every row in the Directory table is automatically associated with the corresponding package
389 * (apk). If the package is later uninstalled, all corresponding directory rows
390 * are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700391 * </p>
392 * <p>
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700393 * When the list of directories handled by a directory provider changes
394 * (for instance when the user adds a new Directory account), the directory provider
395 * should call {@link #notifyDirectoryChange} to notify the Contacts Provider of the change.
396 * In response, the Contacts Provider will requery the directory provider to obtain the
397 * new list of directories.
398 * </p>
399 * <p>
400 * A directory row can be optionally associated with an existing account
401 * (see {@link android.accounts.AccountManager}). If the account is later removed,
Dmitri Plotnikove50ed082010-08-18 10:56:09 -0700402 * the corresponding directory rows are automatically removed from the Contacts Provider.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700403 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700404 */
405 public static final class Directory implements BaseColumns {
406
407 /**
408 * Not instantiable.
409 */
410 private Directory() {
411 }
412
413 /**
414 * The content:// style URI for this table. Requests to this URI can be
415 * performed on the UI thread because they are always unblocking.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700416 */
417 public static final Uri CONTENT_URI =
418 Uri.withAppendedPath(AUTHORITY_URI, "directories");
419
420 /**
Ricky Wai28ef5c52015-11-23 11:05:50 +0000421 * URI used for getting all directories from primary and managed profile.
422 * It supports the same semantics as {@link #CONTENT_URI} and returns the same columns.
423 * If the device has no managed profile that is linked to the current profile, it behaves
424 * in the exact same way as {@link #CONTENT_URI}.
425 * If there is a managed profile linked to the current profile, it will merge
426 * managed profile and current profile's results and return.
427 *
428 * Note: this query returns primary profile results before managed profile results,
429 * and this order is not affected by sorting parameter.
Ricky Waie3631212015-11-09 18:20:57 +0000430 *
431 */
Ricky Wai28ef5c52015-11-23 11:05:50 +0000432 public static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
433 "directories_enterprise");
Ricky Waie3631212015-11-09 18:20:57 +0000434
435 /**
Victor Changdc0406d2016-01-14 21:02:06 +0000436 * Access file provided by remote directory. It allows both personal and work remote
437 * directory, but not local and invisible diretory.
438 *
439 * It's supported only by a few specific places for referring to contact pictures in the
440 * remote directory. Contact picture URIs, e.g.
441 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}, may contain this kind of URI.
442 *
443 * @hide
444 */
445 public static final Uri ENTERPRISE_FILE_URI = Uri.withAppendedPath(AUTHORITY_URI,
446 "directory_file_enterprise");
447
448
449 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700450 * The MIME-type of {@link #CONTENT_URI} providing a directory of
451 * contact directories.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700452 */
453 public static final String CONTENT_TYPE =
454 "vnd.android.cursor.dir/contact_directories";
455
456 /**
457 * The MIME type of a {@link #CONTENT_URI} item.
458 */
459 public static final String CONTENT_ITEM_TYPE =
460 "vnd.android.cursor.item/contact_directory";
461
462 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700463 * _ID of the default directory, which represents locally stored contacts.
Makoto Onuki93d94eb2016-08-25 14:24:03 -0700464 * <b>This is only supported by {@link ContactsContract.Contacts#CONTENT_URI} and
465 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI}.
466 * Other URLs do not support the concept of "visible" or "invisible" contacts.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700467 */
468 public static final long DEFAULT = 0;
469
470 /**
471 * _ID of the directory that represents locally stored invisible contacts.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700472 */
473 public static final long LOCAL_INVISIBLE = 1;
474
475 /**
Ricky Waie3631212015-11-09 18:20:57 +0000476 * _ID of the work profile default directory, which represents locally stored contacts.
Ricky Waie3631212015-11-09 18:20:57 +0000477 */
478 public static final long ENTERPRISE_DEFAULT = Directory.ENTERPRISE_DIRECTORY_ID_BASE
479 + DEFAULT;
480
481 /**
482 * _ID of the work profile directory that represents locally stored invisible contacts.
Ricky Waie3631212015-11-09 18:20:57 +0000483 */
484 public static final long ENTERPRISE_LOCAL_INVISIBLE = Directory.ENTERPRISE_DIRECTORY_ID_BASE
485 + LOCAL_INVISIBLE;
486
487 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700488 * The name of the package that owns this directory. Contacts Provider
489 * fill it in with the name of the package containing the directory provider.
490 * If the package is later uninstalled, the directories it owns are
491 * automatically removed from this table.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700492 *
493 * <p>TYPE: TEXT</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700494 */
495 public static final String PACKAGE_NAME = "packageName";
496
497 /**
498 * The type of directory captured as a resource ID in the context of the
499 * package {@link #PACKAGE_NAME}, e.g. "Corporate Directory"
500 *
501 * <p>TYPE: INTEGER</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700502 */
503 public static final String TYPE_RESOURCE_ID = "typeResourceId";
504
505 /**
506 * An optional name that can be used in the UI to represent this directory,
507 * e.g. "Acme Corp"
508 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700509 */
510 public static final String DISPLAY_NAME = "displayName";
511
512 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700513 * <p>
514 * The authority of the Directory Provider. Contacts Provider will
515 * use this authority to forward requests to the directory provider.
516 * A directory provider can leave this column empty - Contacts Provider will fill it in.
517 * </p>
518 * <p>
519 * Clients of this API should not send requests directly to this authority.
520 * All directory requests must be routed through Contacts Provider.
521 * </p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700522 *
523 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700524 */
525 public static final String DIRECTORY_AUTHORITY = "authority";
526
527 /**
528 * The account type which this directory is associated.
529 *
530 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700531 */
532 public static final String ACCOUNT_TYPE = "accountType";
533
534 /**
535 * The account with which this directory is associated. If the account is later
536 * removed, the directories it owns are automatically removed from this table.
537 *
538 * <p>TYPE: text</p>
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700539 */
540 public static final String ACCOUNT_NAME = "accountName";
541
542 /**
Ricky Waie3631212015-11-09 18:20:57 +0000543 * Mimimal ID for corp directory returned from
544 * {@link Directory#CORP_CONTENT_URI}.
545 *
546 * @hide
547 */
548 // slightly smaller than 2 ** 30
549 public static final long ENTERPRISE_DIRECTORY_ID_BASE = 1000000000;
550
551 /**
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700552 * One of {@link #EXPORT_SUPPORT_NONE}, {@link #EXPORT_SUPPORT_ANY_ACCOUNT},
553 * {@link #EXPORT_SUPPORT_SAME_ACCOUNT_ONLY}. This is the expectation the
554 * directory has for data exported from it. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700555 */
556 public static final String EXPORT_SUPPORT = "exportSupport";
557
558 /**
559 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
560 * does not allow any data to be copied out of it.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700561 */
562 public static final int EXPORT_SUPPORT_NONE = 0;
563
564 /**
565 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
566 * allow its data copied only to the account specified by
567 * {@link #ACCOUNT_TYPE}/{@link #ACCOUNT_NAME}.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700568 */
569 public static final int EXPORT_SUPPORT_SAME_ACCOUNT_ONLY = 1;
570
571 /**
572 * An {@link #EXPORT_SUPPORT} setting that indicates that the directory
573 * allow its data copied to any contacts account.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700574 */
575 public static final int EXPORT_SUPPORT_ANY_ACCOUNT = 2;
576
577 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700578 * One of {@link #SHORTCUT_SUPPORT_NONE}, {@link #SHORTCUT_SUPPORT_DATA_ITEMS_ONLY},
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700579 * {@link #SHORTCUT_SUPPORT_FULL}. This is the expectation the directory
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700580 * has for shortcuts created for its elements. Clients must obey this setting.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700581 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700582 public static final String SHORTCUT_SUPPORT = "shortcutSupport";
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700583
584 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700585 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
586 * does not allow any shortcuts created for its contacts.
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700587 */
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700588 public static final int SHORTCUT_SUPPORT_NONE = 0;
589
590 /**
591 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
592 * allow creation of shortcuts for data items like email, phone or postal address,
593 * but not the entire contact.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700594 */
595 public static final int SHORTCUT_SUPPORT_DATA_ITEMS_ONLY = 1;
596
597 /**
598 * An {@link #SHORTCUT_SUPPORT} setting that indicates that the directory
599 * allow creation of shortcuts for contact as well as their constituent elements.
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -0700600 */
601 public static final int SHORTCUT_SUPPORT_FULL = 2;
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700602
603 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700604 * One of {@link #PHOTO_SUPPORT_NONE}, {@link #PHOTO_SUPPORT_THUMBNAIL_ONLY},
605 * {@link #PHOTO_SUPPORT_FULL}. This is a feature flag indicating the extent
606 * to which the directory supports contact photos.
607 */
608 public static final String PHOTO_SUPPORT = "photoSupport";
609
610 /**
611 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
612 * does not provide any photos.
613 */
614 public static final int PHOTO_SUPPORT_NONE = 0;
615
616 /**
617 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
618 * can only produce small size thumbnails of contact photos.
619 */
620 public static final int PHOTO_SUPPORT_THUMBNAIL_ONLY = 1;
621
622 /**
623 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
624 * has full-size contact photos, but cannot provide scaled thumbnails.
625 */
626 public static final int PHOTO_SUPPORT_FULL_SIZE_ONLY = 2;
627
628 /**
629 * An {@link #PHOTO_SUPPORT} setting that indicates that the directory
630 * can produce thumbnails as well as full-size contact photos.
631 */
632 public static final int PHOTO_SUPPORT_FULL = 3;
633
634 /**
Ricky Waie3631212015-11-09 18:20:57 +0000635 * Return TRUE if it is a remote stored directory.
636 */
Ricky Wai149a6c92016-04-25 12:14:53 +0100637 public static boolean isRemoteDirectoryId(long directoryId) {
Ricky Waie3631212015-11-09 18:20:57 +0000638 return directoryId != Directory.DEFAULT
639 && directoryId != Directory.LOCAL_INVISIBLE
640 && directoryId != Directory.ENTERPRISE_DEFAULT
641 && directoryId != Directory.ENTERPRISE_LOCAL_INVISIBLE;
642 }
643
644 /**
Ricky Wai149a6c92016-04-25 12:14:53 +0100645 * Return TRUE if it is a remote stored directory. TODO: Remove this method once all
646 * internal apps are not using this API.
647 *
648 * @hide
649 */
650 public static boolean isRemoteDirectory(long directoryId) {
651 return isRemoteDirectoryId(directoryId);
652 }
653
654 /**
Ricky Waie3631212015-11-09 18:20:57 +0000655 * Return TRUE if a directory ID is from the contacts provider on the enterprise profile.
656 *
657 */
658 public static boolean isEnterpriseDirectoryId(long directoryId) {
659 return directoryId >= ENTERPRISE_DIRECTORY_ID_BASE;
660 }
661
662 /**
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700663 * Notifies the system of a change in the list of directories handled by
664 * a particular directory provider. The Contacts provider will turn around
665 * and send a query to the directory provider for the full list of directories,
666 * which will replace the previous list.
Dmitri Plotnikov2ef9d252010-08-05 08:28:11 -0700667 */
668 public static void notifyDirectoryChange(ContentResolver resolver) {
669 // This is done to trigger a query by Contacts Provider back to the directory provider.
670 // No data needs to be sent back, because the provider can infer the calling
671 // package from binder.
672 ContentValues contentValues = new ContentValues();
673 resolver.update(Directory.CONTENT_URI, contentValues, null, null);
674 }
Makoto Onuki296a5fd2016-10-12 13:18:08 -0700675
676 /**
677 * A query parameter that's passed to directory providers which indicates the client
678 * package name that has made the query requests.
679 */
680 public static final String CALLER_PACKAGE_PARAM_KEY = "callerPackage";
Dmitri Plotnikova7f2f362010-05-20 20:48:50 -0700681 }
682
683 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500684 * @hide should be removed when users are updated to refer to SyncState
685 * @deprecated use SyncState instead
686 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -0700687 @Deprecated
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700688 public interface SyncStateColumns extends SyncStateContract.Columns {
689 }
690
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500691 /**
Dave Santoro063084e2011-08-23 15:42:49 -0700692 * A table provided for sync adapters to use for storing private sync state data for contacts.
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500693 *
694 * @see SyncStateContract
695 */
696 public static final class SyncState implements SyncStateContract.Columns {
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700697 /**
698 * This utility class cannot be instantiated
699 */
700 private SyncState() {}
701
702 public static final String CONTENT_DIRECTORY =
703 SyncStateContract.Constants.CONTENT_DIRECTORY;
704
705 /**
706 * The content:// style URI for this table
707 */
708 public static final Uri CONTENT_URI =
709 Uri.withAppendedPath(AUTHORITY_URI, CONTENT_DIRECTORY);
710
711 /**
712 * @see android.provider.SyncStateContract.Helpers#get
713 */
714 public static byte[] get(ContentProviderClient provider, Account account)
715 throws RemoteException {
716 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
717 }
718
719 /**
Fred Quintanac4516a72009-09-03 12:14:06 -0700720 * @see android.provider.SyncStateContract.Helpers#get
721 */
722 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
723 throws RemoteException {
724 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
725 }
726
727 /**
Fred Quintana0f4e1ab2009-07-09 17:20:59 -0700728 * @see android.provider.SyncStateContract.Helpers#set
729 */
730 public static void set(ContentProviderClient provider, Account account, byte[] data)
731 throws RemoteException {
732 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
733 }
734
735 /**
736 * @see android.provider.SyncStateContract.Helpers#newSetOperation
737 */
738 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
739 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
740 }
741 }
742
Dave Santoro063084e2011-08-23 15:42:49 -0700743
744 /**
745 * A table provided for sync adapters to use for storing private sync state data for the
746 * user's personal profile.
747 *
748 * @see SyncStateContract
749 */
750 public static final class ProfileSyncState implements SyncStateContract.Columns {
751 /**
752 * This utility class cannot be instantiated
753 */
754 private ProfileSyncState() {}
755
756 public static final String CONTENT_DIRECTORY =
757 SyncStateContract.Constants.CONTENT_DIRECTORY;
758
759 /**
760 * The content:// style URI for this table
761 */
762 public static final Uri CONTENT_URI =
763 Uri.withAppendedPath(Profile.CONTENT_URI, CONTENT_DIRECTORY);
764
765 /**
766 * @see android.provider.SyncStateContract.Helpers#get
767 */
768 public static byte[] get(ContentProviderClient provider, Account account)
769 throws RemoteException {
770 return SyncStateContract.Helpers.get(provider, CONTENT_URI, account);
771 }
772
773 /**
774 * @see android.provider.SyncStateContract.Helpers#get
775 */
776 public static Pair<Uri, byte[]> getWithUri(ContentProviderClient provider, Account account)
777 throws RemoteException {
778 return SyncStateContract.Helpers.getWithUri(provider, CONTENT_URI, account);
779 }
780
781 /**
782 * @see android.provider.SyncStateContract.Helpers#set
783 */
784 public static void set(ContentProviderClient provider, Account account, byte[] data)
785 throws RemoteException {
786 SyncStateContract.Helpers.set(provider, CONTENT_URI, account, data);
787 }
788
789 /**
790 * @see android.provider.SyncStateContract.Helpers#newSetOperation
791 */
792 public static ContentProviderOperation newSetOperation(Account account, byte[] data) {
793 return SyncStateContract.Helpers.newSetOperation(CONTENT_URI, account, data);
794 }
795 }
796
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700797 /**
798 * Generic columns for use by sync adapters. The specific functions of
799 * these columns are private to the sync adapter. Other clients of the API
800 * should not attempt to either read or write this column.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800801 *
802 * @see RawContacts
803 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700804 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700805 protected interface BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700806
807 /** Generic column for use by sync adapters. */
808 public static final String SYNC1 = "sync1";
809 /** Generic column for use by sync adapters. */
810 public static final String SYNC2 = "sync2";
811 /** Generic column for use by sync adapters. */
812 public static final String SYNC3 = "sync3";
813 /** Generic column for use by sync adapters. */
814 public static final String SYNC4 = "sync4";
815 }
816
817 /**
818 * Columns that appear when each row of a table belongs to a specific
819 * account, including sync information that an account may need.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800820 *
821 * @see RawContacts
822 * @see Groups
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700823 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700824 protected interface SyncColumns extends BaseSyncColumns {
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700825 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500826 * The name of the account instance to which this row belongs, which when paired with
827 * {@link #ACCOUNT_TYPE} identifies a specific account.
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -0700828 * <P>Type: TEXT</P>
829 */
830 public static final String ACCOUNT_NAME = "account_name";
831
832 /**
833 * The type of account to which this row belongs, which when paired with
834 * {@link #ACCOUNT_NAME} identifies a specific account.
835 * <P>Type: TEXT</P>
836 */
837 public static final String ACCOUNT_TYPE = "account_type";
838
839 /**
840 * String that uniquely identifies this row to its source account.
841 * <P>Type: TEXT</P>
842 */
843 public static final String SOURCE_ID = "sourceid";
844
845 /**
846 * Version number that is updated whenever this row or its related data
847 * changes.
848 * <P>Type: INTEGER</P>
849 */
850 public static final String VERSION = "version";
851
852 /**
853 * Flag indicating that {@link #VERSION} has changed, and this row needs
854 * to be synchronized by its owning account.
855 * <P>Type: INTEGER (boolean)</P>
856 */
857 public static final String DIRTY = "dirty";
858 }
859
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800860 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800861 * Columns of {@link ContactsContract.Contacts} that track the user's
862 * preferences for, or interactions with, the contact.
863 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800864 * @see Contacts
865 * @see RawContacts
866 * @see ContactsContract.Data
867 * @see PhoneLookup
868 * @see ContactsContract.Contacts.AggregationSuggestions
869 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700870 protected interface ContactOptionsColumns {
Evan Millar088b2912009-05-28 15:24:37 -0700871 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -0700872 * The number of times a contact has been contacted.
873 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For
874 * more information, see the
875 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
876 * page.</p>
Evan Millar088b2912009-05-28 15:24:37 -0700877 * <P>Type: INTEGER</P>
Makoto Onukiaa2dd622018-07-30 11:14:12 -0700878 *
879 * @deprecated Contacts affinity information is no longer supported as of
880 * Android version {@link android.os.Build.VERSION_CODES#Q}. This column
881 * always contains 0.
Evan Millar088b2912009-05-28 15:24:37 -0700882 */
Makoto Onukiaa2dd622018-07-30 11:14:12 -0700883 @Deprecated
Evan Millar088b2912009-05-28 15:24:37 -0700884 public static final String TIMES_CONTACTED = "times_contacted";
885
886 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -0500887 * The last time a contact was contacted.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -0700888 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete. For
889 * more information, see the
890 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
891 * page.</p>
Evan Millar088b2912009-05-28 15:24:37 -0700892 * <P>Type: INTEGER</P>
Makoto Onukiaa2dd622018-07-30 11:14:12 -0700893 *
894 * @deprecated Contacts affinity information is no longer supported as of
895 * Android version {@link android.os.Build.VERSION_CODES#Q}. This column
896 * always contains 0.
Evan Millar088b2912009-05-28 15:24:37 -0700897 */
Makoto Onukiaa2dd622018-07-30 11:14:12 -0700898 @Deprecated
Evan Millar088b2912009-05-28 15:24:37 -0700899 public static final String LAST_TIME_CONTACTED = "last_time_contacted";
900
Makoto Onuki203145e2016-09-28 15:41:29 -0700901 /** @hide Raw value. */
902 public static final String RAW_TIMES_CONTACTED = HIDDEN_COLUMN_PREFIX + TIMES_CONTACTED;
903
904 /** @hide Raw value. */
905 public static final String RAW_LAST_TIME_CONTACTED =
906 HIDDEN_COLUMN_PREFIX + LAST_TIME_CONTACTED;
907
908 /**
909 * @hide
910 * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification.
911 */
912 public static final String LR_TIMES_CONTACTED = TIMES_CONTACTED;
913
914 /**
915 * @hide
916 * Low res version. Same as {@link #TIMES_CONTACTED} but use it in CP2 for clarification.
917 */
918 public static final String LR_LAST_TIME_CONTACTED = LAST_TIME_CONTACTED;
919
Evan Millar088b2912009-05-28 15:24:37 -0700920 /**
921 * Is the contact starred?
922 * <P>Type: INTEGER (boolean)</P>
923 */
924 public static final String STARRED = "starred";
925
926 /**
Yorke Lee217d8a72013-11-27 10:14:04 -0800927 * The position at which the contact is pinned. If {@link PinnedPositions#UNPINNED},
Yorke Lee6acfa5d2013-07-17 09:55:26 -0700928 * the contact is not pinned. Also see {@link PinnedPositions}.
929 * <P>Type: INTEGER </P>
Yorke Lee6acfa5d2013-07-17 09:55:26 -0700930 */
931 public static final String PINNED = "pinned";
932
933 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800934 * URI for a custom ringtone associated with the contact. If null or missing,
935 * the default ringtone is used.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700936 * <P>Type: TEXT (URI to the ringtone)</P>
937 */
938 public static final String CUSTOM_RINGTONE = "custom_ringtone";
939
940 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800941 * Whether the contact should always be sent to voicemail. If missing,
942 * defaults to false.
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700943 * <P>Type: INTEGER (0 for false, 1 for true)</P>
944 */
945 public static final String SEND_TO_VOICEMAIL = "send_to_voicemail";
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700946 }
947
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800948 /**
Tom O'Neill244327e22010-01-08 11:11:15 -0800949 * Columns of {@link ContactsContract.Contacts} that refer to intrinsic
950 * properties of the contact, as opposed to the user-specified options
951 * found in {@link ContactOptionsColumns}.
952 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -0800953 * @see Contacts
954 * @see ContactsContract.Data
955 * @see PhoneLookup
956 * @see ContactsContract.Contacts.AggregationSuggestions
957 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -0700958 protected interface ContactsColumns {
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -0700959 /**
960 * The display name for the contact.
961 * <P>Type: TEXT</P>
962 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -0800963 public static final String DISPLAY_NAME = ContactNameColumns.DISPLAY_NAME_PRIMARY;
Dmitri Plotnikov693d50e2009-06-22 14:57:31 -0700964
965 /**
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800966 * Reference to the row in the RawContacts table holding the contact name.
967 * <P>Type: INTEGER REFERENCES raw_contacts(_id)</P>
Dmitri Plotnikov96186082009-12-01 14:35:04 -0800968 */
969 public static final String NAME_RAW_CONTACT_ID = "name_raw_contact_id";
970
971 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700972 * Reference to the row in the data table holding the photo. A photo can
973 * be referred to either by ID (this field) or by URI (see {@link #PHOTO_THUMBNAIL_URI}
974 * and {@link #PHOTO_URI}).
975 * If PHOTO_ID is null, consult {@link #PHOTO_URI} or {@link #PHOTO_THUMBNAIL_URI},
976 * which is a more generic mechanism for referencing the contact photo, especially for
977 * contacts returned by non-local directories (see {@link Directory}).
978 *
Evan Millar088b2912009-05-28 15:24:37 -0700979 * <P>Type: INTEGER REFERENCES data(_id)</P>
980 */
981 public static final String PHOTO_ID = "photo_id";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -0700982
983 /**
Dave Santoroa5282372011-06-29 00:25:16 -0700984 * Photo file ID of the full-size photo. If present, this will be used to populate
985 * {@link #PHOTO_URI}. The ID can also be used with
986 * {@link ContactsContract.DisplayPhoto#CONTENT_URI} to create a URI to the photo.
987 * If this is present, {@link #PHOTO_ID} is also guaranteed to be populated.
988 *
989 * <P>Type: INTEGER</P>
990 */
991 public static final String PHOTO_FILE_ID = "photo_file_id";
992
993 /**
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700994 * A URI that can be used to retrieve the contact's full-size photo.
Dave Santoroa5282372011-06-29 00:25:16 -0700995 * If PHOTO_FILE_ID is not null, this will be populated with a URI based off
996 * {@link ContactsContract.DisplayPhoto#CONTENT_URI}. Otherwise, this will
997 * be populated with the same value as {@link #PHOTO_THUMBNAIL_URI}.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -0700998 * A photo can be referred to either by a URI (this field) or by ID
Dave Santoroa5282372011-06-29 00:25:16 -0700999 * (see {@link #PHOTO_ID}). If either PHOTO_FILE_ID or PHOTO_ID is not null,
1000 * PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily
1001 * vice versa). Thus using PHOTO_URI is a more robust method of retrieving
1002 * contact photos.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -07001003 *
1004 * <P>Type: TEXT</P>
1005 */
1006 public static final String PHOTO_URI = "photo_uri";
1007
1008 /**
1009 * A URI that can be used to retrieve a thumbnail of the contact's photo.
1010 * A photo can be referred to either by a URI (this field or {@link #PHOTO_URI})
1011 * or by ID (see {@link #PHOTO_ID}). If PHOTO_ID is not null, PHOTO_URI and
1012 * PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa).
1013 * If the content provider does not differentiate between full-size photos
1014 * and thumbnail photos, PHOTO_THUMBNAIL_URI and {@link #PHOTO_URI} can contain
Dave Santoroa5282372011-06-29 00:25:16 -07001015 * the same value, but either both shall be null or both not null.
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -07001016 *
1017 * <P>Type: TEXT</P>
1018 */
1019 public static final String PHOTO_THUMBNAIL_URI = "photo_thumb_uri";
1020
1021 /**
Brian Attwell2fa85d32014-03-04 17:41:13 -08001022 * Flag that reflects whether the contact exists inside the default directory.
1023 * Ie, whether the contact is designed to only be visible outside search.
Brian Attwell2fa85d32014-03-04 17:41:13 -08001024 */
1025 public static final String IN_DEFAULT_DIRECTORY = "in_default_directory";
1026
1027 /**
Dave Santoro43251332011-05-11 11:39:54 -07001028 * Flag that reflects the {@link Groups#GROUP_VISIBLE} state of any
1029 * {@link CommonDataKinds.GroupMembership} for this contact.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07001030 */
1031 public static final String IN_VISIBLE_GROUP = "in_visible_group";
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07001032
1033 /**
Dave Santoro43251332011-05-11 11:39:54 -07001034 * Flag that reflects whether this contact represents the user's
1035 * personal profile entry.
1036 */
1037 public static final String IS_USER_PROFILE = "is_user_profile";
1038
1039 /**
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -07001040 * An indicator of whether this contact has at least one phone number. "1" if there is
1041 * at least one phone number, "0" otherwise.
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07001042 * <P>Type: INTEGER</P>
1043 */
Dmitri Plotnikov074fbfe2009-08-11 13:50:21 -07001044 public static final String HAS_PHONE_NUMBER = "has_phone_number";
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001045
1046 /**
1047 * An opaque value that contains hints on how to find the contact if
1048 * its row id changed as a result of a sync or aggregation.
1049 */
1050 public static final String LOOKUP_KEY = "lookup";
Chiao Cheng2355d132013-03-20 16:54:06 -07001051
1052 /**
1053 * Timestamp (milliseconds since epoch) of when this contact was last updated. This
1054 * includes updates to all data associated with this contact including raw contacts. Any
1055 * modification (including deletes and inserts) of underlying contact data are also
1056 * reflected in this timestamp.
1057 */
1058 public static final String CONTACT_LAST_UPDATED_TIMESTAMP =
1059 "contact_last_updated_timestamp";
Evan Millar088b2912009-05-28 15:24:37 -07001060 }
1061
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001062 /**
1063 * @see Contacts
1064 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07001065 protected interface ContactStatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001066 /**
1067 * Contact presence status. See {@link StatusUpdates} for individual status
1068 * definitions.
1069 * <p>Type: NUMBER</p>
1070 */
1071 public static final String CONTACT_PRESENCE = "contact_presence";
1072
1073 /**
Vasu Norifb5bccf2010-07-19 14:11:54 -07001074 * Contact Chat Capabilities. See {@link StatusUpdates} for individual
Vasu Nori5b31498ba12010-07-12 15:13:37 -07001075 * definitions.
1076 * <p>Type: NUMBER</p>
1077 */
1078 public static final String CONTACT_CHAT_CAPABILITY = "contact_chat_capability";
1079
1080 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001081 * Contact's latest status update.
1082 * <p>Type: TEXT</p>
1083 */
1084 public static final String CONTACT_STATUS = "contact_status";
1085
1086 /**
1087 * The absolute time in milliseconds when the latest status was
1088 * inserted/updated.
1089 * <p>Type: NUMBER</p>
1090 */
1091 public static final String CONTACT_STATUS_TIMESTAMP = "contact_status_ts";
1092
1093 /**
1094 * The package containing resources for this status: label and icon.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001095 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07001096 */
1097 public static final String CONTACT_STATUS_RES_PACKAGE = "contact_status_res_package";
1098
1099 /**
1100 * The resource ID of the label describing the source of contact
1101 * status, e.g. "Google Talk". This resource is scoped by the
1102 * {@link #CONTACT_STATUS_RES_PACKAGE}.
1103 * <p>Type: NUMBER</p>
1104 */
1105 public static final String CONTACT_STATUS_LABEL = "contact_status_label";
1106
1107 /**
1108 * The resource ID of the icon for the source of contact status. This
1109 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.
1110 * <p>Type: NUMBER</p>
1111 */
1112 public static final String CONTACT_STATUS_ICON = "contact_status_icon";
1113 }
1114
Evan Millar088b2912009-05-28 15:24:37 -07001115 /**
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001116 * Constants for various styles of combining given name, family name etc into
1117 * a full name. For example, the western tradition follows the pattern
1118 * 'given name' 'middle name' 'family name' with the alternative pattern being
1119 * 'family name', 'given name' 'middle name'. The CJK tradition is
1120 * 'family name' 'middle name' 'given name', with Japanese favoring a space between
1121 * the names and Chinese omitting the space.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001122 */
1123 public interface FullNameStyle {
1124 public static final int UNDEFINED = 0;
1125 public static final int WESTERN = 1;
1126
1127 /**
1128 * Used if the name is written in Hanzi/Kanji/Hanja and we could not determine
1129 * which specific language it belongs to: Chinese, Japanese or Korean.
1130 */
1131 public static final int CJK = 2;
1132
1133 public static final int CHINESE = 3;
1134 public static final int JAPANESE = 4;
1135 public static final int KOREAN = 5;
1136 }
1137
1138 /**
1139 * Constants for various styles of capturing the pronunciation of a person's name.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001140 */
1141 public interface PhoneticNameStyle {
1142 public static final int UNDEFINED = 0;
1143
1144 /**
1145 * Pinyin is a phonetic method of entering Chinese characters. Typically not explicitly
1146 * shown in UIs, but used for searches and sorting.
1147 */
1148 public static final int PINYIN = 3;
1149
1150 /**
1151 * Hiragana and Katakana are two common styles of writing out the pronunciation
1152 * of a Japanese names.
1153 */
1154 public static final int JAPANESE = 4;
1155
1156 /**
1157 * Hangul is the Korean phonetic alphabet.
1158 */
1159 public static final int KOREAN = 5;
1160 }
1161
1162 /**
Dmitri Plotnikovdbcdbf22011-02-23 15:49:58 -08001163 * Types of data used to produce the display name for a contact. In the order
1164 * of increasing priority: {@link #EMAIL}, {@link #PHONE},
Brian Attwell643db512015-03-04 21:05:27 -08001165 * {@link #ORGANIZATION}, {@link #NICKNAME}, {@link #STRUCTURED_PHONETIC_NAME},
1166 * {@link #STRUCTURED_NAME}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001167 */
1168 public interface DisplayNameSources {
1169 public static final int UNDEFINED = 0;
1170 public static final int EMAIL = 10;
1171 public static final int PHONE = 20;
1172 public static final int ORGANIZATION = 30;
1173 public static final int NICKNAME = 35;
Brian Attwell643db512015-03-04 21:05:27 -08001174 /** Display name comes from a structured name that only has phonetic components. */
1175 public static final int STRUCTURED_PHONETIC_NAME = 37;
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001176 public static final int STRUCTURED_NAME = 40;
1177 }
1178
1179 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08001180 * Contact name and contact name metadata columns in the RawContacts table.
1181 *
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001182 * @see Contacts
1183 * @see RawContacts
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001184 */
1185 protected interface ContactNameColumns {
1186
1187 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001188 * The kind of data that is used as the display name for the contact, such as
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001189 * structured name or email address. See {@link DisplayNameSources}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001190 */
1191 public static final String DISPLAY_NAME_SOURCE = "display_name_source";
1192
1193 /**
Tom O'Neill093a8702010-01-15 16:20:34 -08001194 * <p>
1195 * The standard text shown as the contact's display name, based on the best
1196 * available information for the contact (for example, it might be the email address
1197 * if the name is not available).
1198 * The information actually used to compute the name is stored in
1199 * {@link #DISPLAY_NAME_SOURCE}.
1200 * </p>
1201 * <p>
1202 * A contacts provider is free to choose whatever representation makes most
1203 * sense for its target market.
1204 * For example in the default Android Open Source Project implementation,
1205 * if the display name is
1206 * based on the structured name and the structured name follows
1207 * the Western full-name style, then this field contains the "given name first"
1208 * version of the full name.
1209 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001210 *
1211 * @see ContactsContract.ContactNameColumns#DISPLAY_NAME_ALTERNATIVE
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001212 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001213 public static final String DISPLAY_NAME_PRIMARY = "display_name";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001214
1215 /**
Tom O'Neill093a8702010-01-15 16:20:34 -08001216 * <p>
1217 * An alternative representation of the display name, such as "family name first"
1218 * instead of "given name first" for Western names. If an alternative is not
1219 * available, the values should be the same as {@link #DISPLAY_NAME_PRIMARY}.
1220 * </p>
1221 * <p>
1222 * A contacts provider is free to provide alternatives as necessary for
1223 * its target market.
1224 * For example the default Android Open Source Project contacts provider
1225 * currently provides an
1226 * alternative in a single case: if the display name is
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001227 * based on the structured name and the structured name follows
Tom O'Neill093a8702010-01-15 16:20:34 -08001228 * the Western full name style, then the field contains the "family name first"
1229 * version of the full name.
1230 * Other cases may be added later.
1231 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001232 */
1233 public static final String DISPLAY_NAME_ALTERNATIVE = "display_name_alt";
1234
1235 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001236 * The phonetic alphabet used to represent the {@link #PHONETIC_NAME}. See
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001237 * {@link PhoneticNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001238 */
1239 public static final String PHONETIC_NAME_STYLE = "phonetic_name_style";
1240
1241 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001242 * <p>
1243 * Pronunciation of the full name in the phonetic alphabet specified by
1244 * {@link #PHONETIC_NAME_STYLE}.
1245 * </p>
1246 * <p>
Dmitri Plotnikov59024f12010-08-27 10:59:22 -07001247 * The value may be set manually by the user. This capability is of
1248 * interest only in countries with commonly used phonetic alphabets,
1249 * such as Japan and Korea. See {@link PhoneticNameStyle}.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001250 * </p>
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001251 */
1252 public static final String PHONETIC_NAME = "phonetic_name";
1253
1254 /**
1255 * Sort key that takes into account locale-based traditions for sorting
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001256 * names in address books. The default
1257 * sort key is {@link #DISPLAY_NAME_PRIMARY}. For Chinese names
1258 * the sort key is the name's Pinyin spelling, and for Japanese names
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001259 * it is the Hiragana version of the phonetic name.
1260 */
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001261 public static final String SORT_KEY_PRIMARY = "sort_key";
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001262
1263 /**
1264 * Sort key based on the alternative representation of the full name,
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08001265 * {@link #DISPLAY_NAME_ALTERNATIVE}. Thus for Western names,
Dmitri Plotnikov2a650dd2010-01-26 17:28:52 -08001266 * it is the one using the "family name first" format.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08001267 */
1268 public static final String SORT_KEY_ALTERNATIVE = "sort_key_alt";
1269 }
1270
Yorke Lee94c87612014-07-18 18:57:17 -07001271 interface ContactCounts {
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001272
1273 /**
Yorke Lee94c87612014-07-18 18:57:17 -07001274 * Add this query parameter to a URI to get back row counts grouped by the address book
1275 * index as cursor extras. For most languages it is the first letter of the sort key. This
1276 * parameter does not affect the main content of the cursor.
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001277 *
Yorke Leef4b28452014-05-27 19:41:35 -07001278 * <p>
1279 * <pre>
1280 * Example:
Yorke Lee94c87612014-07-18 18:57:17 -07001281 *
1282 * import android.provider.ContactsContract.Contacts;
1283 *
Yorke Leef4b28452014-05-27 19:41:35 -07001284 * Uri uri = Contacts.CONTENT_URI.buildUpon()
Yorke Lee78814622014-09-04 16:07:50 -07001285 * .appendQueryParameter(Contacts.EXTRA_ADDRESS_BOOK_INDEX, "true")
Yorke Leef4b28452014-05-27 19:41:35 -07001286 * .build();
1287 * Cursor cursor = getContentResolver().query(uri,
1288 * new String[] {Contacts.DISPLAY_NAME},
1289 * null, null, null);
1290 * Bundle bundle = cursor.getExtras();
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001291 * if (bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES) &&
1292 * bundle.containsKey(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS)) {
Yorke Leef4b28452014-05-27 19:41:35 -07001293 * String sections[] =
Yorke Leea4aa9dc2014-08-04 13:47:50 -07001294 * bundle.getStringArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_TITLES);
1295 * int counts[] = bundle.getIntArray(Contacts.EXTRA_ADDRESS_BOOK_INDEX_COUNTS);
Yorke Leef4b28452014-05-27 19:41:35 -07001296 * }
1297 * </pre>
1298 * </p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001299 */
Yorke Lee78814622014-09-04 16:07:50 -07001300 public static final String EXTRA_ADDRESS_BOOK_INDEX =
1301 "android.provider.extra.ADDRESS_BOOK_INDEX";
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001302
1303 /**
1304 * The array of address book index titles, which are returned in the
1305 * same order as the data in the cursor.
1306 * <p>TYPE: String[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001307 */
Yorke Lee78814622014-09-04 16:07:50 -07001308 public static final String EXTRA_ADDRESS_BOOK_INDEX_TITLES =
1309 "android.provider.extra.ADDRESS_BOOK_INDEX_TITLES";
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001310
1311 /**
1312 * The array of group counts for the corresponding group. Contains the same number
1313 * of elements as the EXTRA_ADDRESS_BOOK_INDEX_TITLES array.
1314 * <p>TYPE: int[]</p>
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001315 */
Yorke Lee78814622014-09-04 16:07:50 -07001316 public static final String EXTRA_ADDRESS_BOOK_INDEX_COUNTS =
1317 "android.provider.extra.ADDRESS_BOOK_INDEX_COUNTS";
Dmitri Plotnikov53de9042010-02-17 10:57:19 -08001318 }
1319
1320 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001321 * Constants for the contacts table, which contains a record per aggregate
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001322 * of raw contacts representing the same person.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001323 * <h3>Operations</h3>
1324 * <dl>
1325 * <dt><b>Insert</b></dt>
1326 * <dd>A Contact cannot be created explicitly. When a raw contact is
1327 * inserted, the provider will first try to find a Contact representing the
1328 * same person. If one is found, the raw contact's
1329 * {@link RawContacts#CONTACT_ID} column gets the _ID of the aggregate
1330 * Contact. If no match is found, the provider automatically inserts a new
1331 * Contact and puts its _ID into the {@link RawContacts#CONTACT_ID} column
1332 * of the newly inserted raw contact.</dd>
1333 * <dt><b>Update</b></dt>
1334 * <dd>Only certain columns of Contact are modifiable:
Makoto Onukiaa2dd622018-07-30 11:14:12 -07001335 * {@link #STARRED}, {@link #CUSTOM_RINGTONE}, {@link #SEND_TO_VOICEMAIL}. Changing any of
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001336 * these columns on the Contact also changes them on all constituent raw
1337 * contacts.</dd>
1338 * <dt><b>Delete</b></dt>
1339 * <dd>Be careful with deleting Contacts! Deleting an aggregate contact
1340 * deletes all constituent raw contacts. The corresponding sync adapters
1341 * will notice the deletions of their respective raw contacts and remove
1342 * them from their back end storage.</dd>
1343 * <dt><b>Query</b></dt>
1344 * <dd>
1345 * <ul>
1346 * <li>If you need to read an individual contact, consider using
1347 * {@link #CONTENT_LOOKUP_URI} instead of {@link #CONTENT_URI}.</li>
1348 * <li>If you need to look up a contact by the phone number, use
1349 * {@link PhoneLookup#CONTENT_FILTER_URI PhoneLookup.CONTENT_FILTER_URI},
1350 * which is optimized for this purpose.</li>
1351 * <li>If you need to look up a contact by partial name, e.g. to produce
1352 * filter-as-you-type suggestions, use the {@link #CONTENT_FILTER_URI} URI.
1353 * <li>If you need to look up a contact by some data element like email
1354 * address, nickname, etc, use a query against the {@link ContactsContract.Data} table.
1355 * The result will contain contact ID, name etc.
1356 * </ul>
1357 * </dd>
1358 * </dl>
1359 * <h2>Columns</h2>
1360 * <table class="jd-sumtable">
1361 * <tr>
1362 * <th colspan='4'>Contacts</th>
1363 * </tr>
1364 * <tr>
1365 * <td>long</td>
1366 * <td>{@link #_ID}</td>
1367 * <td>read-only</td>
1368 * <td>Row ID. Consider using {@link #LOOKUP_KEY} instead.</td>
1369 * </tr>
1370 * <tr>
1371 * <td>String</td>
1372 * <td>{@link #LOOKUP_KEY}</td>
1373 * <td>read-only</td>
1374 * <td>An opaque value that contains hints on how to find the contact if its
1375 * row id changed as a result of a sync or aggregation.</td>
1376 * </tr>
1377 * <tr>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001378 * <td>long</td>
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001379 * <td>NAME_RAW_CONTACT_ID</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001380 * <td>read-only</td>
1381 * <td>The ID of the raw contact that contributes the display name
1382 * to the aggregate contact. During aggregation one of the constituent
1383 * raw contacts is chosen using a heuristic: a longer name or a name
1384 * with more diacritic marks or more upper case characters is chosen.</td>
1385 * </tr>
1386 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001387 * <td>String</td>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08001388 * <td>DISPLAY_NAME_PRIMARY</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001389 * <td>read-only</td>
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001390 * <td>The display name for the contact. It is the display name
Dmitri Plotnikov780211a2009-12-02 22:00:32 -08001391 * contributed by the raw contact referred to by the NAME_RAW_CONTACT_ID
Dmitri Plotnikov96186082009-12-01 14:35:04 -08001392 * column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001393 * </tr>
1394 * <tr>
1395 * <td>long</td>
1396 * <td>{@link #PHOTO_ID}</td>
1397 * <td>read-only</td>
1398 * <td>Reference to the row in the {@link ContactsContract.Data} table holding the photo.
1399 * That row has the mime type
1400 * {@link CommonDataKinds.Photo#CONTENT_ITEM_TYPE}. The value of this field
1401 * is computed automatically based on the
1402 * {@link CommonDataKinds.Photo#IS_SUPER_PRIMARY} field of the data rows of
1403 * that mime type.</td>
1404 * </tr>
1405 * <tr>
Dmitri Plotnikov3a668fe2010-09-22 14:24:15 -07001406 * <td>long</td>
1407 * <td>{@link #PHOTO_URI}</td>
1408 * <td>read-only</td>
1409 * <td>A URI that can be used to retrieve the contact's full-size photo. This
1410 * column is the preferred method of retrieving the contact photo.</td>
1411 * </tr>
1412 * <tr>
1413 * <td>long</td>
1414 * <td>{@link #PHOTO_THUMBNAIL_URI}</td>
1415 * <td>read-only</td>
1416 * <td>A URI that can be used to retrieve the thumbnail of contact's photo. This
1417 * column is the preferred method of retrieving the contact photo.</td>
1418 * </tr>
1419 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001420 * <td>int</td>
1421 * <td>{@link #IN_VISIBLE_GROUP}</td>
1422 * <td>read-only</td>
1423 * <td>An indicator of whether this contact is supposed to be visible in the
1424 * UI. "1" if the contact has at least one raw contact that belongs to a
1425 * visible group; "0" otherwise.</td>
1426 * </tr>
1427 * <tr>
1428 * <td>int</td>
1429 * <td>{@link #HAS_PHONE_NUMBER}</td>
1430 * <td>read-only</td>
1431 * <td>An indicator of whether this contact has at least one phone number.
1432 * "1" if there is at least one phone number, "0" otherwise.</td>
1433 * </tr>
1434 * <tr>
1435 * <td>int</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001436 * <td>{@link #STARRED}</td>
1437 * <td>read/write</td>
1438 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
1439 * When raw contacts are aggregated, this field is automatically computed:
1440 * if any constituent raw contacts are starred, then this field is set to
1441 * '1'. Setting this field automatically changes the corresponding field on
1442 * all constituent raw contacts.</td>
1443 * </tr>
1444 * <tr>
1445 * <td>String</td>
1446 * <td>{@link #CUSTOM_RINGTONE}</td>
1447 * <td>read/write</td>
1448 * <td>A custom ringtone associated with a contact. Typically this is the
1449 * URI returned by an activity launched with the
1450 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.</td>
1451 * </tr>
1452 * <tr>
1453 * <td>int</td>
1454 * <td>{@link #SEND_TO_VOICEMAIL}</td>
1455 * <td>read/write</td>
1456 * <td>An indicator of whether calls from this contact should be forwarded
1457 * directly to voice mail ('1') or not ('0'). When raw contacts are
1458 * aggregated, this field is automatically computed: if <i>all</i>
1459 * constituent raw contacts have SEND_TO_VOICEMAIL=1, then this field is set
1460 * to '1'. Setting this field automatically changes the corresponding field
1461 * on all constituent raw contacts.</td>
1462 * </tr>
1463 * <tr>
1464 * <td>int</td>
1465 * <td>{@link #CONTACT_PRESENCE}</td>
1466 * <td>read-only</td>
1467 * <td>Contact IM presence status. See {@link StatusUpdates} for individual
1468 * status definitions. Automatically computed as the highest presence of all
1469 * constituent raw contacts. The provider may choose not to store this value
1470 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07001471 * updated on a regular basis.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001472 * </tr>
1473 * <tr>
1474 * <td>String</td>
1475 * <td>{@link #CONTACT_STATUS}</td>
1476 * <td>read-only</td>
1477 * <td>Contact's latest status update. Automatically computed as the latest
1478 * of all constituent raw contacts' status updates.</td>
1479 * </tr>
1480 * <tr>
1481 * <td>long</td>
1482 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
1483 * <td>read-only</td>
1484 * <td>The absolute time in milliseconds when the latest status was
1485 * inserted/updated.</td>
1486 * </tr>
1487 * <tr>
1488 * <td>String</td>
1489 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
1490 * <td>read-only</td>
1491 * <td> The package containing resources for this status: label and icon.</td>
1492 * </tr>
1493 * <tr>
1494 * <td>long</td>
1495 * <td>{@link #CONTACT_STATUS_LABEL}</td>
1496 * <td>read-only</td>
1497 * <td>The resource ID of the label describing the source of contact status,
1498 * e.g. "Google Talk". This resource is scoped by the
1499 * {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1500 * </tr>
1501 * <tr>
1502 * <td>long</td>
1503 * <td>{@link #CONTACT_STATUS_ICON}</td>
1504 * <td>read-only</td>
1505 * <td>The resource ID of the icon for the source of contact status. This
1506 * resource is scoped by the {@link #CONTACT_STATUS_RES_PACKAGE}.</td>
1507 * </tr>
1508 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07001509 */
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07001510 public static class Contacts implements BaseColumns, ContactsColumns,
Yorke Lee94c87612014-07-18 18:57:17 -07001511 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07001512 /**
1513 * This utility class cannot be instantiated
1514 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001515 private Contacts() {}
Evan Millar088b2912009-05-28 15:24:37 -07001516
1517 /**
1518 * The content:// style URI for this table
1519 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001520 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
Evan Millar088b2912009-05-28 15:24:37 -07001521
1522 /**
Makoto Onuki31cd6f72014-07-08 15:20:39 -07001523 * Special contacts URI to refer to contacts on the corp profile from the personal
1524 * profile.
1525 *
1526 * It's supported only by a few specific places for referring to contact pictures that
1527 * are in the corp provider for enterprise caller-ID. Contact picture URIs returned from
1528 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may contain this kind of URI.
1529 *
1530 * @hide
1531 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01001532 @UnsupportedAppUsage
Makoto Onuki31cd6f72014-07-08 15:20:39 -07001533 public static final Uri CORP_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
1534 "contacts_corp");
1535
1536 /**
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001537 * A content:// style URI for this table that should be used to create
1538 * shortcuts or otherwise create long-term links to contacts. This URI
1539 * should always be followed by a "/" and the contact's {@link #LOOKUP_KEY}.
1540 * It can optionally also have a "/" and last known contact ID appended after
1541 * that. This "complete" format is an important optimization and is highly recommended.
1542 * <p>
1543 * As long as the contact's row ID remains the same, this URI is
1544 * equivalent to {@link #CONTENT_URI}. If the contact's row ID changes
1545 * as a result of a sync or aggregation, this URI will look up the
1546 * contact using indirect information (sync IDs or constituent raw
1547 * contacts).
1548 * <p>
1549 * Lookup key should be appended unencoded - it is stored in the encoded
1550 * form, ready for use in a URI.
1551 */
1552 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
1553 "lookup");
1554
1555 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001556 * Base {@link Uri} for referencing a single {@link Contacts} entry,
Jeff Sharkey8f767342009-09-28 18:22:46 -07001557 * created by appending {@link #LOOKUP_KEY} using
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001558 * {@link Uri#withAppendedPath(Uri, String)}. Provides
1559 * {@link OpenableColumns} columns when queried, or returns the
1560 * referenced contact formatted as a vCard when opened through
1561 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1562 */
1563 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1564 "as_vcard");
1565
Martijn Coenen037d3ff2011-06-15 16:01:45 +02001566 /**
1567 * Boolean parameter that may be used with {@link #CONTENT_VCARD_URI}
1568 * and {@link #CONTENT_MULTI_VCARD_URI} to indicate that the returned
1569 * vcard should not contain a photo.
1570 *
Brian Attwellf9fb60a2015-02-02 12:16:13 -08001571 * This is useful for obtaining a space efficient vcard.
Martijn Coenen037d3ff2011-06-15 16:01:45 +02001572 */
Brian Attwellf9fb60a2015-02-02 12:16:13 -08001573 public static final String QUERY_PARAMETER_VCARD_NO_PHOTO = "no_photo";
Martijn Coenen037d3ff2011-06-15 16:01:45 +02001574
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001575 /**
Daniel Lehmann63e91402010-03-12 13:44:31 -08001576 * Base {@link Uri} for referencing multiple {@link Contacts} entry,
1577 * created by appending {@link #LOOKUP_KEY} using
1578 * {@link Uri#withAppendedPath(Uri, String)}. The lookup keys have to be
Yorke Lee217d8a72013-11-27 10:14:04 -08001579 * joined with the colon (":") separator, and the resulting string encoded.
1580 *
1581 * Provides {@link OpenableColumns} columns when queried, or returns the
Daniel Lehmann63e91402010-03-12 13:44:31 -08001582 * referenced contact formatted as a vCard when opened through
1583 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
1584 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001585 * <p>
1586 * Usage example:
1587 * <dl>
1588 * <dt>The following code snippet creates a multi-vcard URI that references all the
1589 * contacts in a user's database.</dt>
1590 * <dd>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001591 *
Yorke Lee217d8a72013-11-27 10:14:04 -08001592 * <pre>
1593 * public Uri getAllContactsVcardUri() {
1594 * Cursor cursor = getActivity().getContentResolver().query(Contacts.CONTENT_URI,
1595 * new String[] {Contacts.LOOKUP_KEY}, null, null, null);
1596 * if (cursor == null) {
1597 * return null;
1598 * }
1599 * try {
1600 * StringBuilder uriListBuilder = new StringBuilder();
1601 * int index = 0;
1602 * while (cursor.moveToNext()) {
1603 * if (index != 0) uriListBuilder.append(':');
1604 * uriListBuilder.append(cursor.getString(0));
1605 * index++;
1606 * }
1607 * return Uri.withAppendedPath(Contacts.CONTENT_MULTI_VCARD_URI,
1608 * Uri.encode(uriListBuilder.toString()));
1609 * } finally {
1610 * cursor.close();
1611 * }
1612 * }
1613 * </pre>
1614 *
1615 * </p>
Daniel Lehmann63e91402010-03-12 13:44:31 -08001616 */
1617 public static final Uri CONTENT_MULTI_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
1618 "as_multi_vcard");
1619
1620 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001621 * Builds a {@link #CONTENT_LOOKUP_URI} style {@link Uri} describing the
1622 * requested {@link Contacts} entry.
1623 *
1624 * @param contactUri A {@link #CONTENT_URI} row, or an existing
1625 * {@link #CONTENT_LOOKUP_URI} to attempt refreshing.
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001626 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001627 public static Uri getLookupUri(ContentResolver resolver, Uri contactUri) {
1628 final Cursor c = resolver.query(contactUri, new String[] {
1629 Contacts.LOOKUP_KEY, Contacts._ID
1630 }, null, null, null);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001631 if (c == null) {
1632 return null;
1633 }
1634
1635 try {
1636 if (c.moveToFirst()) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07001637 final String lookupKey = c.getString(0);
1638 final long contactId = c.getLong(1);
1639 return getLookupUri(contactId, lookupKey);
Dmitri Plotnikovf35bce42009-08-28 19:52:50 -07001640 }
1641 } finally {
1642 c.close();
1643 }
1644 return null;
1645 }
1646
1647 /**
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001648 * Build a {@link #CONTENT_LOOKUP_URI} lookup {@link Uri} using the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001649 * given {@link ContactsContract.Contacts#_ID} and {@link #LOOKUP_KEY}.
Jay Shrauner1ebaff22015-03-12 15:24:16 -07001650 * <p>
1651 * Returns null if unable to construct a valid lookup URI from the
1652 * provided parameters.
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001653 */
1654 public static Uri getLookupUri(long contactId, String lookupKey) {
Jay Shrauner1ebaff22015-03-12 15:24:16 -07001655 if (TextUtils.isEmpty(lookupKey)) {
1656 return null;
1657 }
Jeff Sharkeyf46a9cf2009-09-09 13:17:44 -07001658 return ContentUris.withAppendedId(Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI,
1659 lookupKey), contactId);
1660 }
1661
1662 /**
Dmitri Plotnikovb5759b52009-09-01 15:58:40 -07001663 * Computes a content URI (see {@link #CONTENT_URI}) given a lookup URI.
1664 * <p>
1665 * Returns null if the contact cannot be found.
1666 */
1667 public static Uri lookupContact(ContentResolver resolver, Uri lookupUri) {
1668 if (lookupUri == null) {
1669 return null;
1670 }
1671
1672 Cursor c = resolver.query(lookupUri, new String[]{Contacts._ID}, null, null, null);
1673 if (c == null) {
1674 return null;
1675 }
1676
1677 try {
1678 if (c.moveToFirst()) {
1679 long contactId = c.getLong(0);
1680 return ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
1681 }
1682 } finally {
1683 c.close();
1684 }
1685 return null;
1686 }
1687
1688 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001689 * Mark a contact as having been contacted. Updates two fields:
1690 * {@link #TIMES_CONTACTED} and {@link #LAST_TIME_CONTACTED}. The
1691 * TIMES_CONTACTED field is incremented by 1 and the LAST_TIME_CONTACTED
1692 * field is populated with the current system time.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001693 *
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07001694 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this method is obsolete. For
1695 * more information, see the
1696 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
1697 * page.
1698 *
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001699 * @param resolver the ContentResolver to use
1700 * @param contactId the person who was contacted
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001701 *
Makoto Onukiaa2dd622018-07-30 11:14:12 -07001702 * @deprecated Contacts affinity information is no longer supported as of
1703 * Android version {@link android.os.Build.VERSION_CODES#Q}. This method
1704 * is no-op.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001705 */
Daniel Lehmanna1620dc2012-04-13 13:29:49 -07001706 @Deprecated
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001707 public static void markAsContacted(ContentResolver resolver, long contactId) {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05001708 }
1709
1710 /**
Evan Millar161dd862009-06-12 16:02:43 -07001711 * The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001712 * {@link #CONTENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001713 * various parts of the contact name. The filter argument should be passed
Evan Millar161dd862009-06-12 16:02:43 -07001714 * as an additional path segment after this URI.
1715 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001716 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
1717 CONTENT_URI, "filter");
1718
Evan Millardc2da5f2009-06-18 16:07:13 -07001719 /**
Ricky Wai6b38e062015-11-26 23:21:39 +00001720 * It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the same
1721 * columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in parameters,
Ricky Wai149a6c92016-04-25 12:14:53 +01001722 * otherwise it will throw IllegalArgumentException.
Ricky Waia5efc472015-11-16 12:25:45 +00001723 */
Ricky Wai6b38e062015-11-26 23:21:39 +00001724 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
1725 CONTENT_URI, "filter_enterprise");
Ricky Waia5efc472015-11-16 12:25:45 +00001726
1727 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07001728 * The content:// style URI for this table joined with useful data from
Makoto Onukiaa2dd622018-07-30 11:14:12 -07001729 * {@link ContactsContract.Data}, filtered to include only starred contacts.
1730 * Frequent contacts are no longer included in the result as of
1731 * Android version {@link android.os.Build.VERSION_CODES#Q}.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07001732 *
1733 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts
1734 * results based on contacts frequency. For more information, see the
1735 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
1736 * page.
Evan Millardc2da5f2009-06-18 16:07:13 -07001737 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001738 public static final Uri CONTENT_STREQUENT_URI = Uri.withAppendedPath(
1739 CONTENT_URI, "strequent");
1740
Evan Millardc2da5f2009-06-18 16:07:13 -07001741 /**
Yorke Lee8d370092014-06-26 10:32:17 -07001742 * The content:// style URI for showing a list of frequently contacted people.
Makoto Onukiaa2dd622018-07-30 11:14:12 -07001743 *
1744 * @deprecated Frequent contacts are no longer supported as of
1745 * Android version {@link android.os.Build.VERSION_CODES#Q}.
1746 * This URI always returns an empty cursor.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07001747 *
1748 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts
1749 * results based on contacts frequency. For more information, see the
1750 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
1751 * page.
Daisuke Miyakawa3604bc52011-07-21 10:14:32 -07001752 */
Makoto Onukiaa2dd622018-07-30 11:14:12 -07001753 @Deprecated
Daisuke Miyakawa3604bc52011-07-21 10:14:32 -07001754 public static final Uri CONTENT_FREQUENT_URI = Uri.withAppendedPath(
1755 CONTENT_URI, "frequent");
1756
1757 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07001758 * <p>The content:// style URI used for "type-to-filter" functionality on the
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001759 * {@link #CONTENT_STREQUENT_URI} URI. The filter string will be used to match
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001760 * various parts of the contact name. The filter argument should be passed
Evan Millardc2da5f2009-06-18 16:07:13 -07001761 * as an additional path segment after this URI.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07001762 *
1763 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts
1764 * results based on contacts frequency. For more information, see the
1765 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
1766 * page.
Evan Millardc2da5f2009-06-18 16:07:13 -07001767 */
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001768 public static final Uri CONTENT_STREQUENT_FILTER_URI = Uri.withAppendedPath(
1769 CONTENT_STREQUENT_URI, "filter");
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001770
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07001771 public static final Uri CONTENT_GROUP_URI = Uri.withAppendedPath(
1772 CONTENT_URI, "group");
1773
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07001774 /**
Evan Millar088b2912009-05-28 15:24:37 -07001775 * The MIME type of {@link #CONTENT_URI} providing a directory of
1776 * people.
1777 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001778 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001779
1780 /**
1781 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1782 * person.
1783 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001784 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
Evan Millar088b2912009-05-28 15:24:37 -07001785
1786 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001787 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
1788 * person.
1789 */
1790 public static final String CONTENT_VCARD_TYPE = "text/x-vcard";
1791
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001792 /**
1793 * Mimimal ID for corp contacts returned from
1794 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1795 *
1796 * @hide
1797 */
Makoto Onuki0e917332014-08-26 14:06:30 -07001798 public static long ENTERPRISE_CONTACT_ID_BASE = 1000000000; // slightly smaller than 2 ** 30
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001799
1800 /**
Makoto Onuki1040da12015-03-19 11:24:00 -07001801 * Prefix for corp contacts returned from
1802 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
1803 *
1804 * @hide
1805 */
1806 public static String ENTERPRISE_CONTACT_LOOKUP_PREFIX = "c-";
1807
1808 /**
Makoto Onuki0e917332014-08-26 14:06:30 -07001809 * Return TRUE if a contact ID is from the contacts provider on the enterprise profile.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001810 *
1811 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI} may return such a contact.
1812 */
Makoto Onuki0e917332014-08-26 14:06:30 -07001813 public static boolean isEnterpriseContactId(long contactId) {
1814 return (contactId >= ENTERPRISE_CONTACT_ID_BASE) && (contactId < Profile.MIN_ID);
Makoto Onuki80b3ab62014-07-10 11:24:21 -07001815 }
1816
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07001817 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07001818 * A sub-directory of a single contact that contains all of the constituent raw contact
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001819 * {@link ContactsContract.Data} rows. This directory can be used either
1820 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07001821 */
Fred Quintana8851e162009-08-05 21:06:45 -07001822 public static final class Data implements BaseColumns, DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07001823 /**
1824 * no public constructor since this is a utility class
1825 */
1826 private Data() {}
1827
1828 /**
1829 * The directory twig for this sub-table
1830 */
1831 public static final String CONTENT_DIRECTORY = "data";
1832 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001833
1834 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001835 * <p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001836 * A sub-directory of a contact that contains all of its
1837 * {@link ContactsContract.RawContacts} as well as
1838 * {@link ContactsContract.Data} rows. To access this directory append
1839 * {@link #CONTENT_DIRECTORY} to the contact URI.
1840 * </p>
1841 * <p>
1842 * Entity has three ID fields: {@link #CONTACT_ID} for the contact,
1843 * {@link #RAW_CONTACT_ID} for the raw contact and {@link #DATA_ID} for
1844 * the data rows. Entity always contains at least one row per
1845 * constituent raw contact, even if there are no actual data rows. In
1846 * this case the {@link #DATA_ID} field will be null.
1847 * </p>
1848 * <p>
1849 * Entity reads all data for the entire contact in one transaction, to
1850 * guarantee consistency. There is significant data duplication
1851 * in the Entity (each row repeats all Contact columns and all RawContact
1852 * columns), so the benefits of transactional consistency should be weighed
1853 * against the cost of transferring large amounts of denormalized data
1854 * from the Provider.
1855 * </p>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07001856 * <p>
1857 * To reduce the amount of data duplication the contacts provider and directory
1858 * providers implementing this protocol are allowed to provide common Contacts
1859 * and RawContacts fields in the first row returned for each raw contact only and
1860 * leave them as null in subsequent rows.
1861 * </p>
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001862 */
1863 public static final class Entity implements BaseColumns, ContactsColumns,
1864 ContactNameColumns, RawContactsColumns, BaseSyncColumns, SyncColumns, DataColumns,
Paul Soulos42cdda82014-06-19 16:13:38 -07001865 StatusColumns, ContactOptionsColumns, ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001866 /**
1867 * no public constructor since this is a utility class
1868 */
1869 private Entity() {
1870 }
1871
1872 /**
1873 * The directory twig for this sub-table
1874 */
1875 public static final String CONTENT_DIRECTORY = "entities";
1876
1877 /**
1878 * The ID of the raw contact row.
1879 * <P>Type: INTEGER</P>
1880 */
1881 public static final String RAW_CONTACT_ID = "raw_contact_id";
1882
1883 /**
1884 * The ID of the data row. The value will be null if this raw contact has no
1885 * data rows.
1886 * <P>Type: INTEGER</P>
1887 */
1888 public static final String DATA_ID = "data_id";
1889 }
1890
1891 /**
Dave Santoro0b61f592011-10-03 18:25:26 -07001892 * <p>
Dave Santorod414f102011-06-20 14:35:06 -07001893 * A sub-directory of a single contact that contains all of the constituent raw contact
1894 * {@link ContactsContract.StreamItems} rows. This directory can be used either
1895 * with a {@link #CONTENT_URI} or {@link #CONTENT_LOOKUP_URI}.
Dave Santoro0b61f592011-10-03 18:25:26 -07001896 * </p>
1897 * <p>
1898 * Querying for social stream data requires android.permission.READ_SOCIAL_STREAM
1899 * permission.
1900 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07001901 *
1902 * @deprecated - Do not use. This will not be supported in the future. In the future,
1903 * cursors returned from related queries will be empty.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00001904 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00001905 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07001906 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001907 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001908 public static final class StreamItems implements StreamItemsColumns {
1909 /**
1910 * no public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07001911 *
1912 * @deprecated - Do not use. This will not be supported in the future. In the future,
1913 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001914 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001915 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001916 private StreamItems() {}
1917
1918 /**
1919 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07001920 *
1921 * @deprecated - Do not use. This will not be supported in the future. In the future,
1922 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07001923 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07001924 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07001925 public static final String CONTENT_DIRECTORY = "stream_items";
1926 }
1927
1928 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07001929 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08001930 * A <i>read-only</i> sub-directory of a single contact aggregate that
1931 * contains all aggregation suggestions (other contacts). The
1932 * aggregation suggestions are computed based on approximate data
1933 * matches with this contact.
1934 * </p>
1935 * <p>
1936 * <i>Note: this query may be expensive! If you need to use it in bulk,
1937 * make sure the user experience is acceptable when the query runs for a
1938 * long time.</i>
1939 * <p>
1940 * Usage example:
1941 *
1942 * <pre>
1943 * Uri uri = Contacts.CONTENT_URI.buildUpon()
1944 * .appendEncodedPath(String.valueOf(contactId))
1945 * .appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY)
1946 * .appendQueryParameter(&quot;limit&quot;, &quot;3&quot;)
1947 * .build()
1948 * Cursor cursor = getContentResolver().query(suggestionsUri,
1949 * new String[] {Contacts.DISPLAY_NAME, Contacts._ID, Contacts.LOOKUP_KEY},
1950 * null, null, null);
1951 * </pre>
1952 *
1953 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001954 * <p>
1955 * This directory can be used either with a {@link #CONTENT_URI} or
1956 * {@link #CONTENT_LOOKUP_URI}.
1957 * </p>
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001958 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07001959 public static final class AggregationSuggestions implements BaseColumns, ContactsColumns,
1960 ContactOptionsColumns, ContactStatusColumns {
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001961 /**
1962 * No public constructor since this is a utility class
1963 */
1964 private AggregationSuggestions() {}
1965
1966 /**
Dmitri Plotnikov0fc02442009-09-21 13:26:28 -07001967 * The directory twig for this sub-table. The URI can be followed by an optional
Jeff Hamiltonf8526982009-09-24 11:34:58 -05001968 * type-to-filter, similar to
1969 * {@link android.provider.ContactsContract.Contacts#CONTENT_FILTER_URI}.
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07001970 */
1971 public static final String CONTENT_DIRECTORY = "suggestions";
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001972
1973 /**
Brian Attwell9ffad072015-01-21 16:28:59 -08001974 * Used to specify what kind of data is supplied for the suggestion query.
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001975 *
1976 * @hide
1977 */
1978 public static final String PARAMETER_MATCH_NAME = "name";
1979
1980 /**
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001981 * A convenience builder for aggregation suggestion content URIs.
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001982 */
1983 public static final class Builder {
1984 private long mContactId;
Brian Attwell9ffad072015-01-21 16:28:59 -08001985 private final ArrayList<String> mValues = new ArrayList<String>();
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001986 private int mLimit;
1987
1988 /**
1989 * Optional existing contact ID. If it is not provided, the search
Brian Attwell9ffad072015-01-21 16:28:59 -08001990 * will be based exclusively on the values supplied with {@link #addNameParameter}.
1991 *
1992 * @param contactId contact to find aggregation suggestions for
1993 * @return This Builder object to allow for chaining of calls to builder methods
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07001994 */
1995 public Builder setContactId(long contactId) {
1996 this.mContactId = contactId;
1997 return this;
1998 }
1999
2000 /**
Brian Attwell9ffad072015-01-21 16:28:59 -08002001 * Add a name to be used when searching for aggregation suggestions.
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002002 *
Brian Attwell9ffad072015-01-21 16:28:59 -08002003 * @param name name to find aggregation suggestions for
2004 * @return This Builder object to allow for chaining of calls to builder methods
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002005 */
Brian Attwell9ffad072015-01-21 16:28:59 -08002006 public Builder addNameParameter(String name) {
2007 mValues.add(name);
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002008 return this;
2009 }
2010
Brian Attwell9ffad072015-01-21 16:28:59 -08002011 /**
2012 * Sets the Maximum number of suggested aggregations that should be returned.
2013 * @param limit The maximum number of suggested aggregations
2014 *
2015 * @return This Builder object to allow for chaining of calls to builder methods
2016 */
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002017 public Builder setLimit(int limit) {
2018 mLimit = limit;
2019 return this;
2020 }
2021
Brian Attwell9ffad072015-01-21 16:28:59 -08002022 /**
2023 * Combine all of the options that have been set and return a new {@link Uri}
2024 * object for fetching aggregation suggestions.
2025 */
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002026 public Uri build() {
2027 android.net.Uri.Builder builder = Contacts.CONTENT_URI.buildUpon();
2028 builder.appendEncodedPath(String.valueOf(mContactId));
2029 builder.appendPath(Contacts.AggregationSuggestions.CONTENT_DIRECTORY);
2030 if (mLimit != 0) {
2031 builder.appendQueryParameter("limit", String.valueOf(mLimit));
2032 }
2033
Brian Attwell9ffad072015-01-21 16:28:59 -08002034 int count = mValues.size();
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002035 for (int i = 0; i < count; i++) {
Brian Attwell9ffad072015-01-21 16:28:59 -08002036 builder.appendQueryParameter("query", PARAMETER_MATCH_NAME
2037 + ":" + mValues.get(i));
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002038 }
2039
2040 return builder.build();
2041 }
2042 }
2043
2044 /**
2045 * @hide
2046 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01002047 @UnsupportedAppUsage
Dmitri Plotnikov44730c22010-08-12 10:09:58 -07002048 public static final Builder builder() {
2049 return new Builder();
2050 }
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07002051 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002052
2053 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002054 * A <i>read-only</i> sub-directory of a single contact that contains
Dave Santoroa5282372011-06-29 00:25:16 -07002055 * the contact's primary photo. The photo may be stored in up to two ways -
2056 * the default "photo" is a thumbnail-sized image stored directly in the data
2057 * row, while the "display photo", if present, is a larger version stored as
2058 * a file.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002059 * <p>
2060 * Usage example:
Dave Santoroa5282372011-06-29 00:25:16 -07002061 * <dl>
2062 * <dt>Retrieving the thumbnail-sized photo</dt>
2063 * <dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002064 * <pre>
2065 * public InputStream openPhoto(long contactId) {
2066 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
2067 * Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
2068 * Cursor cursor = getContentResolver().query(photoUri,
2069 * new String[] {Contacts.Photo.PHOTO}, null, null, null);
2070 * if (cursor == null) {
2071 * return null;
2072 * }
2073 * try {
2074 * if (cursor.moveToFirst()) {
2075 * byte[] data = cursor.getBlob(0);
2076 * if (data != null) {
2077 * return new ByteArrayInputStream(data);
2078 * }
2079 * }
2080 * } finally {
2081 * cursor.close();
2082 * }
2083 * return null;
2084 * }
2085 * </pre>
Dave Santoroa5282372011-06-29 00:25:16 -07002086 * </dd>
2087 * <dt>Retrieving the larger photo version</dt>
2088 * <dd>
2089 * <pre>
2090 * public InputStream openDisplayPhoto(long contactId) {
2091 * Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
2092 * Uri displayPhotoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.DISPLAY_PHOTO);
2093 * try {
2094 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07002095 * getContentResolver().openAssetFileDescriptor(displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07002096 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07002097 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07002098 * return null;
2099 * }
2100 * }
2101 * </pre>
2102 * </dd>
2103 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002104 *
2105 * </p>
Dave Santoroa5282372011-06-29 00:25:16 -07002106 * <p>You may also consider using the convenience method
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002107 * {@link ContactsContract.Contacts#openContactPhotoInputStream(ContentResolver, Uri, boolean)}
2108 * to retrieve the raw photo contents of either the thumbnail-sized or the full-sized photo.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002109 * </p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002110 * <p>
2111 * This directory can be used either with a {@link #CONTENT_URI} or
2112 * {@link #CONTENT_LOOKUP_URI}.
2113 * </p>
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002114 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002115 public static final class Photo implements BaseColumns, DataColumnsWithJoins {
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07002116 /**
2117 * no public constructor since this is a utility class
2118 */
2119 private Photo() {}
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07002120
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07002121 /**
2122 * The directory twig for this sub-table
2123 */
2124 public static final String CONTENT_DIRECTORY = "photo";
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002125
2126 /**
Dave Santoroa5282372011-06-29 00:25:16 -07002127 * The directory twig for retrieving the full-size display photo.
2128 */
2129 public static final String DISPLAY_PHOTO = "display_photo";
2130
2131 /**
2132 * Full-size photo file ID of the raw contact.
2133 * See {@link ContactsContract.DisplayPhoto}.
2134 * <p>
2135 * Type: NUMBER
2136 */
2137 public static final String PHOTO_FILE_ID = DATA14;
2138
2139 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002140 * Thumbnail photo of the raw contact. This is the raw bytes of an image
2141 * that could be inflated using {@link android.graphics.BitmapFactory}.
2142 * <p>
2143 * Type: BLOB
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002144 */
2145 public static final String PHOTO = DATA15;
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002146 }
2147
2148 /**
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002149 * Opens an InputStream for the contacts's photo and returns the
2150 * photo as a byte stream.
2151 * @param cr The content resolver to use for querying
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002152 * @param contactUri the contact whose photo should be used. This can be used with
2153 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002154 * @param preferHighres If this is true and the contact has a higher resolution photo
2155 * available, it is returned. If false, this function always tries to get the thumbnail
Jeff Hamilton85abdc52009-09-22 12:41:45 -05002156 * @return an InputStream of the photo, or null if no photo is present
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002157 */
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002158 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri,
2159 boolean preferHighres) {
2160 if (preferHighres) {
2161 final Uri displayPhotoUri = Uri.withAppendedPath(contactUri,
2162 Contacts.Photo.DISPLAY_PHOTO);
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002163 try {
2164 AssetFileDescriptor fd = cr.openAssetFileDescriptor(displayPhotoUri, "r");
Makoto Onukida072b32016-02-05 13:23:21 -08002165 if (fd != null) {
2166 return fd.createInputStream();
2167 }
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002168 } catch (IOException e) {
2169 // fallback to the thumbnail code
2170 }
2171 }
2172
Dmitri Plotnikoveb1a2ec2009-08-21 11:11:19 -07002173 Uri photoUri = Uri.withAppendedPath(contactUri, Photo.CONTENT_DIRECTORY);
Dmitri Plotnikov1c1629d2009-08-20 08:13:46 -07002174 if (photoUri == null) {
2175 return null;
2176 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002177 Cursor cursor = cr.query(photoUri,
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002178 new String[] {
2179 ContactsContract.CommonDataKinds.Photo.PHOTO
2180 }, null, null, null);
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002181 try {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002182 if (cursor == null || !cursor.moveToNext()) {
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002183 return null;
2184 }
2185 byte[] data = cursor.getBlob(0);
2186 if (data == null) {
2187 return null;
2188 }
2189 return new ByteArrayInputStream(data);
2190 } finally {
Mike Lockwood7d6eb9a2009-08-24 18:12:51 -07002191 if (cursor != null) {
2192 cursor.close();
2193 }
Dmitri Plotnikov3c513ed2009-08-19 15:56:30 -07002194 }
2195 }
Daniel Lehmannf5d46522011-07-14 22:16:21 -07002196
2197 /**
2198 * Opens an InputStream for the contacts's thumbnail photo and returns the
2199 * photo as a byte stream.
2200 * @param cr The content resolver to use for querying
2201 * @param contactUri the contact whose photo should be used. This can be used with
2202 * either a {@link #CONTENT_URI} or a {@link #CONTENT_LOOKUP_URI} URI.
2203 * @return an InputStream of the photo, or null if no photo is present
2204 * @see #openContactPhotoInputStream(ContentResolver, Uri, boolean), if instead
2205 * of the thumbnail the high-res picture is preferred
2206 */
2207 public static InputStream openContactPhotoInputStream(ContentResolver cr, Uri contactUri) {
2208 return openContactPhotoInputStream(cr, contactUri, false);
2209 }
Evan Millar088b2912009-05-28 15:24:37 -07002210 }
2211
Dave Santoro43251332011-05-11 11:39:54 -07002212 /**
2213 * <p>
2214 * Constants for the user's profile data, which is represented as a single contact on
2215 * the device that represents the user. The profile contact is not aggregated
2216 * together automatically in the same way that normal contacts are; instead, each
Dave Santoro063084e2011-08-23 15:42:49 -07002217 * account (including data set, if applicable) on the device may contribute a single
2218 * raw contact representing the user's personal profile data from that source.
Dave Santoro43251332011-05-11 11:39:54 -07002219 * </p>
2220 * <p>
2221 * Access to the profile entry through these URIs (or incidental access to parts of
2222 * the profile if retrieved directly via ID) requires additional permissions beyond
2223 * the read/write contact permissions required by the provider. Querying for profile
2224 * data requires android.permission.READ_PROFILE permission, and inserting or
2225 * updating profile data requires android.permission.WRITE_PROFILE permission.
2226 * </p>
2227 * <h3>Operations</h3>
2228 * <dl>
2229 * <dt><b>Insert</b></dt>
2230 * <dd>The user's profile entry cannot be created explicitly (attempting to do so
2231 * will throw an exception). When a raw contact is inserted into the profile, the
2232 * provider will check for the existence of a profile on the device. If one is
2233 * found, the raw contact's {@link RawContacts#CONTACT_ID} column gets the _ID of
2234 * the profile Contact. If no match is found, the profile Contact is created and
2235 * its _ID is put into the {@link RawContacts#CONTACT_ID} column of the newly
2236 * inserted raw contact.</dd>
2237 * <dt><b>Update</b></dt>
2238 * <dd>The profile Contact has the same update restrictions as Contacts in general,
2239 * but requires the android.permission.WRITE_PROFILE permission.</dd>
2240 * <dt><b>Delete</b></dt>
2241 * <dd>The profile Contact cannot be explicitly deleted. It will be removed
2242 * automatically if all of its constituent raw contact entries are deleted.</dd>
2243 * <dt><b>Query</b></dt>
2244 * <dd>
2245 * <ul>
2246 * <li>The {@link #CONTENT_URI} for profiles behaves in much the same way as
2247 * retrieving a contact by ID, except that it will only ever return the user's
2248 * profile contact.
2249 * </li>
2250 * <li>
2251 * The profile contact supports all of the same sub-paths as an individual contact
2252 * does - the content of the profile contact can be retrieved as entities or
2253 * data rows. Similarly, specific raw contact entries can be retrieved by appending
2254 * the desired raw contact ID within the profile.
2255 * </li>
2256 * </ul>
2257 * </dd>
2258 * </dl>
2259 */
2260 public static final class Profile implements BaseColumns, ContactsColumns,
2261 ContactOptionsColumns, ContactNameColumns, ContactStatusColumns {
2262 /**
2263 * This utility class cannot be instantiated
2264 */
2265 private Profile() {
2266 }
2267
2268 /**
2269 * The content:// style URI for this table, which requests the contact entry
2270 * representing the user's personal profile data.
2271 */
2272 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "profile");
2273
2274 /**
2275 * {@link Uri} for referencing the user's profile {@link Contacts} entry,
2276 * Provides {@link OpenableColumns} columns when queried, or returns the
2277 * user's profile contact formatted as a vCard when opened through
2278 * {@link ContentResolver#openAssetFileDescriptor(Uri, String)}.
2279 */
2280 public static final Uri CONTENT_VCARD_URI = Uri.withAppendedPath(CONTENT_URI,
2281 "as_vcard");
2282
2283 /**
2284 * {@link Uri} for referencing the raw contacts that make up the user's profile
2285 * {@link Contacts} entry. An individual raw contact entry within the profile
2286 * can be addressed by appending the raw contact ID. The entities or data within
2287 * that specific raw contact can be requested by appending the entity or data
2288 * path as well.
2289 */
2290 public static final Uri CONTENT_RAW_CONTACTS_URI = Uri.withAppendedPath(CONTENT_URI,
2291 "raw_contacts");
Dave Santoro063084e2011-08-23 15:42:49 -07002292
2293 /**
2294 * The minimum ID for any entity that belongs to the profile. This essentially
2295 * defines an ID-space in which profile data is stored, and is used by the provider
2296 * to determine whether a request via a non-profile-specific URI should be directed
2297 * to the profile data rather than general contacts data, along with all the special
2298 * permission checks that entails.
2299 *
2300 * Callers may use {@link #isProfileId} to check whether a specific ID falls into
2301 * the set of data intended for the profile.
2302 */
2303 public static final long MIN_ID = Long.MAX_VALUE - (long) Integer.MAX_VALUE;
2304 }
2305
2306 /**
2307 * This method can be used to identify whether the given ID is associated with profile
2308 * data. It does not necessarily indicate that the ID is tied to valid data, merely
2309 * that accessing data using this ID will result in profile access checks and will only
2310 * return data from the profile.
2311 *
2312 * @param id The ID to check.
2313 * @return Whether the ID is associated with profile data.
2314 */
2315 public static boolean isProfileId(long id) {
2316 return id >= Profile.MIN_ID;
Dave Santoro43251332011-05-11 11:39:54 -07002317 }
2318
Chiao Cheng2355d132013-03-20 16:54:06 -07002319 protected interface DeletedContactsColumns {
2320
2321 /**
2322 * A reference to the {@link ContactsContract.Contacts#_ID} that was deleted.
2323 * <P>Type: INTEGER</P>
2324 */
2325 public static final String CONTACT_ID = "contact_id";
2326
2327 /**
2328 * Time (milliseconds since epoch) that the contact was deleted.
2329 */
2330 public static final String CONTACT_DELETED_TIMESTAMP = "contact_deleted_timestamp";
2331 }
2332
2333 /**
2334 * Constants for the deleted contact table. This table holds a log of deleted contacts.
2335 * <p>
2336 * Log older than {@link #DAYS_KEPT_MILLISECONDS} may be deleted.
2337 */
2338 public static final class DeletedContacts implements DeletedContactsColumns {
2339
2340 /**
2341 * This utility class cannot be instantiated
2342 */
2343 private DeletedContacts() {
2344 }
2345
2346 /**
2347 * The content:// style URI for this table, which requests a directory of raw contact rows
2348 * matching the selection criteria.
2349 */
2350 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
2351 "deleted_contacts");
2352
2353 /**
2354 * Number of days that the delete log will be kept. After this time, delete records may be
2355 * deleted.
2356 *
2357 * @hide
2358 */
2359 private static final int DAYS_KEPT = 30;
2360
2361 /**
2362 * Milliseconds that the delete log will be kept. After this time, delete records may be
2363 * deleted.
2364 */
2365 public static final long DAYS_KEPT_MILLISECONDS = 1000L * 60L * 60L * 24L * (long)DAYS_KEPT;
2366 }
2367
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07002368 protected interface RawContactsColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002369 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002370 * A reference to the {@link ContactsContract.Contacts#_ID} that this
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002371 * data belongs to.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002372 * <P>Type: INTEGER</P>
Evan Millar088b2912009-05-28 15:24:37 -07002373 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002374 public static final String CONTACT_ID = "contact_id";
Evan Millar088b2912009-05-28 15:24:37 -07002375
2376 /**
Zheng Fu9ea9a132015-01-07 11:33:19 -08002377 * Persistent unique id for each raw_contact within its account.
2378 * This id is provided by its own data source, and can be used to backup metadata
2379 * to the server.
2380 * This should be unique within each set of account_name/account_type/data_set
Zheng Fu9ea9a132015-01-07 11:33:19 -08002381 */
2382 public static final String BACKUP_ID = "backup_id";
2383
2384 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07002385 * The data set within the account that this row belongs to. This allows
2386 * multiple sync adapters for the same account type to distinguish between
2387 * each others' data.
2388 *
2389 * This is empty by default, and is completely optional. It only needs to
2390 * be populated if multiple sync adapters are entering distinct data for
2391 * the same account type and account name.
2392 * <P>Type: TEXT</P>
2393 */
2394 public static final String DATA_SET = "data_set";
2395
2396 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07002397 * A concatenation of the account type and data set (delimited by a forward
2398 * slash) - if the data set is empty, this will be the same as the account
2399 * type. For applications that need to be aware of the data set, this can
2400 * be used instead of account type to distinguish sets of data. This is
2401 * never intended to be used for specifying accounts.
Makoto Onuki0e917332014-08-26 14:06:30 -07002402 * <p>
2403 * This column does *not* escape forward slashes in the account type or the data set.
2404 * If this is an issue, consider using
2405 * {@link ContactsContract.RawContacts#ACCOUNT_TYPE} and
2406 * {@link ContactsContract.RawContacts#DATA_SET} directly.
Dave Santoro1d55c332011-07-25 16:44:45 -07002407 */
2408 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
2409
2410 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002411 * The aggregation mode for this contact.
2412 * <P>Type: INTEGER</P>
2413 */
2414 public static final String AGGREGATION_MODE = "aggregation_mode";
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002415
2416 /**
2417 * The "deleted" flag: "0" by default, "1" if the row has been marked
2418 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07002419 * called on a raw contact, it is marked for deletion and removed from its
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002420 * aggregate contact. The sync adaptor deletes the raw contact on the server and
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002421 * then calls ContactResolver.delete once more, this time passing the
Fred Quintana33f889a2009-09-14 17:31:26 -07002422 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2423 * the data removal.
Dmitri Plotnikovd5f56d12009-07-27 09:26:05 -07002424 * <P>Type: INTEGER</P>
2425 */
2426 public static final String DELETED = "deleted";
Dmitri Plotnikov918007b2010-01-20 12:12:11 -08002427
2428 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07002429 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
2430 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
2431 * <P>Type: INTEGER</P>
2432 */
Dmitri Plotnikov86fe8392010-07-16 11:19:46 -07002433 public static final String RAW_CONTACT_IS_READ_ONLY = "raw_contact_is_read_only";
Dave Santoro43251332011-05-11 11:39:54 -07002434
2435 /**
2436 * Flag that reflects whether this raw contact belongs to the user's
2437 * personal profile entry.
2438 */
2439 public static final String RAW_CONTACT_IS_USER_PROFILE = "raw_contact_is_user_profile";
Tingting Wang03583a42015-05-04 13:48:23 -07002440
2441 /**
2442 * Flag indicating that a raw contact's metadata has changed, and its metadata
2443 * needs to be synchronized by the server.
2444 * <P>Type: INTEGER (boolean)</P>
2445 */
2446 public static final String METADATA_DIRTY = "metadata_dirty";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002447 }
2448
2449 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002450 * Constants for the raw contacts table, which contains one row of contact
2451 * information for each person in each synced account. Sync adapters and
2452 * contact management apps
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002453 * are the primary consumers of this API.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002454 *
2455 * <h3>Aggregation</h3>
2456 * <p>
2457 * As soon as a raw contact is inserted or whenever its constituent data
2458 * changes, the provider will check if the raw contact matches other
2459 * existing raw contacts and if so will aggregate it with those. The
2460 * aggregation is reflected in the {@link RawContacts} table by the change of the
2461 * {@link #CONTACT_ID} field, which is the reference to the aggregate contact.
2462 * </p>
2463 * <p>
2464 * Changes to the structured name, organization, phone number, email address,
2465 * or nickname trigger a re-aggregation.
2466 * </p>
2467 * <p>
2468 * See also {@link AggregationExceptions} for a mechanism to control
2469 * aggregation programmatically.
2470 * </p>
2471 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002472 * <h3>Operations</h3>
2473 * <dl>
2474 * <dt><b>Insert</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002475 * <dd>
2476 * <p>
2477 * Raw contacts can be inserted incrementally or in a batch.
2478 * The incremental method is more traditional but less efficient.
2479 * It should be used
2480 * only if no {@link Data} values are available at the time the raw contact is created:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002481 * <pre>
2482 * ContentValues values = new ContentValues();
2483 * values.put(RawContacts.ACCOUNT_TYPE, accountType);
2484 * values.put(RawContacts.ACCOUNT_NAME, accountName);
2485 * Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
2486 * long rawContactId = ContentUris.parseId(rawContactUri);
2487 * </pre>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002488 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002489 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002490 * Once {@link Data} values become available, insert those.
2491 * For example, here's how you would insert a name:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002492 *
2493 * <pre>
2494 * values.clear();
2495 * values.put(Data.RAW_CONTACT_ID, rawContactId);
2496 * values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
2497 * values.put(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;);
2498 * getContentResolver().insert(Data.CONTENT_URI, values);
2499 * </pre>
2500 * </p>
2501 * <p>
2502 * The batch method is by far preferred. It inserts the raw contact and its
2503 * constituent data rows in a single database transaction
2504 * and causes at most one aggregation pass.
2505 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07002506 * ArrayList&lt;ContentProviderOperation&gt; ops =
2507 * new ArrayList&lt;ContentProviderOperation&gt;();
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002508 * ...
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002509 * int rawContactInsertIndex = ops.size();
2510 * ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
2511 * .withValue(RawContacts.ACCOUNT_TYPE, accountType)
2512 * .withValue(RawContacts.ACCOUNT_NAME, accountName)
2513 * .build());
2514 *
2515 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
2516 * .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex)
2517 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
2518 * .withValue(StructuredName.DISPLAY_NAME, &quot;Mike Sullivan&quot;)
2519 * .build());
2520 *
2521 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
2522 * </pre>
2523 * </p>
2524 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002525 * Note the use of {@link ContentProviderOperation.Builder#withValueBackReference(String, int)}
2526 * to refer to the as-yet-unknown index value of the raw contact inserted in the
2527 * first operation.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002528 * </p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002529 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002530 * <dt><b>Update</b></dt>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002531 * <dd><p>
2532 * Raw contacts can be updated incrementally or in a batch.
2533 * Batch mode should be used whenever possible.
2534 * The procedures and considerations are analogous to those documented above for inserts.
2535 * </p></dd>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002536 * <dt><b>Delete</b></dt>
2537 * <dd><p>When a raw contact is deleted, all of its Data rows as well as StatusUpdates,
2538 * AggregationExceptions, PhoneLookup rows are deleted automatically. When all raw
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002539 * contacts associated with a {@link Contacts} row are deleted, the {@link Contacts} row
2540 * itself is also deleted automatically.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002541 * </p>
2542 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002543 * The invocation of {@code resolver.delete(...)}, does not immediately delete
2544 * a raw contacts row.
2545 * Instead, it sets the {@link #DELETED} flag on the raw contact and
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002546 * removes the raw contact from its aggregate contact.
2547 * The sync adapter then deletes the raw contact from the server and
2548 * finalizes phone-side deletion by calling {@code resolver.delete(...)}
Fred Quintana328c0e72009-12-07 14:52:28 -08002549 * again and passing the {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter.<p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002550 * <p>Some sync adapters are read-only, meaning that they only sync server-side
2551 * changes to the phone, but not the reverse. If one of those raw contacts
2552 * is marked for deletion, it will remain on the phone. However it will be
2553 * effectively invisible, because it will not be part of any aggregate contact.
2554 * </dd>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002555 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002556 * <dt><b>Query</b></dt>
2557 * <dd>
2558 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002559 * It is easy to find all raw contacts in a Contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002560 * <pre>
2561 * Cursor c = getContentResolver().query(RawContacts.CONTENT_URI,
2562 * new String[]{RawContacts._ID},
2563 * RawContacts.CONTACT_ID + "=?",
2564 * new String[]{String.valueOf(contactId)}, null);
2565 * </pre>
2566 * </p>
2567 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002568 * To find raw contacts within a specific account,
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002569 * you can either put the account name and type in the selection or pass them as query
2570 * parameters. The latter approach is preferable, especially when you can reuse the
2571 * URI:
2572 * <pre>
Adam Koch95e5a072013-05-21 09:47:55 -04002573 * Uri rawContactUri = RawContacts.CONTENT_URI.buildUpon()
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002574 * .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName)
2575 * .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType)
2576 * .build();
2577 * Cursor c1 = getContentResolver().query(rawContactUri,
2578 * RawContacts.STARRED + "&lt;&gt;0", null, null, null);
2579 * ...
2580 * Cursor c2 = getContentResolver().query(rawContactUri,
2581 * RawContacts.DELETED + "&lt;&gt;0", null, null, null);
2582 * </pre>
2583 * </p>
2584 * <p>The best way to read a raw contact along with all the data associated with it is
2585 * by using the {@link Entity} directory. If the raw contact has data rows,
2586 * the Entity cursor will contain a row for each data row. If the raw contact has no
2587 * data rows, the cursor will still contain one row with the raw contact-level information.
2588 * <pre>
2589 * Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId);
2590 * Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY);
2591 * Cursor c = getContentResolver().query(entityUri,
2592 * new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1},
2593 * null, null, null);
2594 * try {
2595 * while (c.moveToNext()) {
2596 * String sourceId = c.getString(0);
2597 * if (!c.isNull(1)) {
2598 * String mimeType = c.getString(2);
2599 * String data = c.getString(3);
2600 * ...
2601 * }
2602 * }
2603 * } finally {
2604 * c.close();
2605 * }
2606 * </pre>
2607 * </p>
2608 * </dd>
2609 * </dl>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002610 * <h2>Columns</h2>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002611 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002612 * <table class="jd-sumtable">
2613 * <tr>
2614 * <th colspan='4'>RawContacts</th>
2615 * </tr>
2616 * <tr>
2617 * <td>long</td>
2618 * <td>{@link #_ID}</td>
2619 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002620 * <td>Row ID. Sync adapters should try to preserve row IDs during updates. In other words,
2621 * it is much better for a sync adapter to update a raw contact rather than to delete and
2622 * re-insert it.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002623 * </tr>
2624 * <tr>
2625 * <td>long</td>
2626 * <td>{@link #CONTACT_ID}</td>
2627 * <td>read-only</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002628 * <td>The ID of the row in the {@link ContactsContract.Contacts} table
2629 * that this raw contact belongs
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002630 * to. Raw contacts are linked to contacts by the aggregation process, which can be controlled
2631 * by the {@link #AGGREGATION_MODE} field and {@link AggregationExceptions}.</td>
2632 * </tr>
2633 * <tr>
2634 * <td>int</td>
2635 * <td>{@link #AGGREGATION_MODE}</td>
2636 * <td>read/write</td>
2637 * <td>A mechanism that allows programmatic control of the aggregation process. The allowed
2638 * values are {@link #AGGREGATION_MODE_DEFAULT}, {@link #AGGREGATION_MODE_DISABLED}
2639 * and {@link #AGGREGATION_MODE_SUSPENDED}. See also {@link AggregationExceptions}.</td>
2640 * </tr>
2641 * <tr>
2642 * <td>int</td>
2643 * <td>{@link #DELETED}</td>
2644 * <td>read/write</td>
2645 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
2646 * for deletion. When {@link android.content.ContentResolver#delete} is
2647 * called on a raw contact, it is marked for deletion and removed from its
2648 * aggregate contact. The sync adaptor deletes the raw contact on the server and
2649 * then calls ContactResolver.delete once more, this time passing the
2650 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to finalize
2651 * the data removal.</td>
2652 * </tr>
2653 * <tr>
2654 * <td>int</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002655 * <td>{@link #STARRED}</td>
2656 * <td>read/write</td>
2657 * <td>An indicator for favorite contacts: '1' if favorite, '0' otherwise.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002658 * Changing this field immediately affects the corresponding aggregate contact:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002659 * if any raw contacts in that aggregate contact are starred, then the contact
2660 * itself is marked as starred.</td>
2661 * </tr>
2662 * <tr>
2663 * <td>String</td>
2664 * <td>{@link #CUSTOM_RINGTONE}</td>
2665 * <td>read/write</td>
2666 * <td>A custom ringtone associated with a raw contact. Typically this is the
2667 * URI returned by an activity launched with the
2668 * {@link android.media.RingtoneManager#ACTION_RINGTONE_PICKER} intent.
2669 * To have an effect on the corresponding value of the aggregate contact, this field
2670 * should be set at the time the raw contact is inserted. To set a custom
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002671 * ringtone on a contact, use the field {@link ContactsContract.Contacts#CUSTOM_RINGTONE
2672 * Contacts.CUSTOM_RINGTONE}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002673 * instead.</td>
2674 * </tr>
2675 * <tr>
2676 * <td>int</td>
2677 * <td>{@link #SEND_TO_VOICEMAIL}</td>
2678 * <td>read/write</td>
2679 * <td>An indicator of whether calls from this raw contact should be forwarded
2680 * directly to voice mail ('1') or not ('0'). To have an effect
2681 * on the corresponding value of the aggregate contact, this field
2682 * should be set at the time the raw contact is inserted.</td>
2683 * </tr>
2684 * <tr>
2685 * <td>String</td>
2686 * <td>{@link #ACCOUNT_NAME}</td>
2687 * <td>read/write-once</td>
2688 * <td>The name of the account instance to which this row belongs, which when paired with
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002689 * {@link #ACCOUNT_TYPE} identifies a specific account.
2690 * For example, this will be the Gmail address if it is a Google account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002691 * It should be set at the time the raw contact is inserted and never
2692 * changed afterwards.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002693 * </tr>
2694 * <tr>
2695 * <td>String</td>
2696 * <td>{@link #ACCOUNT_TYPE}</td>
2697 * <td>read/write-once</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002698 * <td>
2699 * <p>
2700 * The type of account to which this row belongs, which when paired with
2701 * {@link #ACCOUNT_NAME} identifies a specific account.
Dave Santorod7bdc182011-06-24 15:39:39 -07002702 * It should be set at the time the raw contact is inserted and never
2703 * changed afterwards.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002704 * </p>
2705 * <p>
2706 * To ensure uniqueness, new account types should be chosen according to the
2707 * Java package naming convention. Thus a Google account is of type "com.google".
2708 * </p>
2709 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002710 * </tr>
2711 * <tr>
2712 * <td>String</td>
Dave Santorod7bdc182011-06-24 15:39:39 -07002713 * <td>{@link #DATA_SET}</td>
2714 * <td>read/write-once</td>
2715 * <td>
2716 * <p>
2717 * The data set within the account that this row belongs to. This allows
2718 * multiple sync adapters for the same account type to distinguish between
2719 * each others' data. The combination of {@link #ACCOUNT_TYPE},
2720 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
2721 * that is associated with a single sync adapter.
2722 * </p>
2723 * <p>
2724 * This is empty by default, and is completely optional. It only needs to
2725 * be populated if multiple sync adapters are entering distinct data for
2726 * the same account type and account name.
2727 * </p>
2728 * <p>
2729 * It should be set at the time the raw contact is inserted and never
2730 * changed afterwards.
2731 * </p>
2732 * </td>
2733 * </tr>
2734 * <tr>
2735 * <td>String</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002736 * <td>{@link #SOURCE_ID}</td>
2737 * <td>read/write</td>
2738 * <td>String that uniquely identifies this row to its source account.
2739 * Typically it is set at the time the raw contact is inserted and never
2740 * changed afterwards. The one notable exception is a new raw contact: it
Dave Santorod7bdc182011-06-24 15:39:39 -07002741 * will have an account name and type (and possibly a data set), but no
2742 * source id. This indicates to the sync adapter that a new contact needs
2743 * to be created server-side and its ID stored in the corresponding
2744 * SOURCE_ID field on the phone.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002745 * </td>
2746 * </tr>
2747 * <tr>
2748 * <td>int</td>
2749 * <td>{@link #VERSION}</td>
2750 * <td>read-only</td>
2751 * <td>Version number that is updated whenever this row or its related data
2752 * changes. This field can be used for optimistic locking of a raw contact.
2753 * </td>
2754 * </tr>
2755 * <tr>
2756 * <td>int</td>
2757 * <td>{@link #DIRTY}</td>
2758 * <td>read/write</td>
2759 * <td>Flag indicating that {@link #VERSION} has changed, and this row needs
2760 * to be synchronized by its owning account. The value is set to "1" automatically
2761 * whenever the raw contact changes, unless the URI has the
2762 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter specified.
2763 * The sync adapter should always supply this query parameter to prevent
2764 * unnecessary synchronization: user changes some data on the server,
2765 * the sync adapter updates the contact on the phone (without the
2766 * CALLER_IS_SYNCADAPTER flag) flag, which sets the DIRTY flag,
2767 * which triggers a sync to bring the changes to the server.
2768 * </td>
2769 * </tr>
2770 * <tr>
2771 * <td>String</td>
2772 * <td>{@link #SYNC1}</td>
2773 * <td>read/write</td>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002774 * <td>Generic column provided for arbitrary use by sync adapters.
2775 * The content provider
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002776 * stores this information on behalf of the sync adapter but does not
2777 * interpret it in any way.
2778 * </td>
2779 * </tr>
2780 * <tr>
2781 * <td>String</td>
2782 * <td>{@link #SYNC2}</td>
2783 * <td>read/write</td>
2784 * <td>Generic column for use by sync adapters.
2785 * </td>
2786 * </tr>
2787 * <tr>
2788 * <td>String</td>
2789 * <td>{@link #SYNC3}</td>
2790 * <td>read/write</td>
2791 * <td>Generic column for use by sync adapters.
2792 * </td>
2793 * </tr>
2794 * <tr>
2795 * <td>String</td>
2796 * <td>{@link #SYNC4}</td>
2797 * <td>read/write</td>
2798 * <td>Generic column for use by sync adapters.
2799 * </td>
2800 * </tr>
2801 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002802 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002803 public static final class RawContacts implements BaseColumns, RawContactsColumns,
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08002804 ContactOptionsColumns, ContactNameColumns, SyncColumns {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002805 /**
2806 * This utility class cannot be instantiated
2807 */
Dmitri Plotnikov2365ded2009-07-27 09:36:09 -07002808 private RawContacts() {
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002809 }
2810
2811 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002812 * The content:// style URI for this table, which requests a directory of
2813 * raw contact rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07002814 */
Makoto Onuki0554b192018-10-01 18:50:08 +00002815 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "raw_contacts");
Evan Millar088b2912009-05-28 15:24:37 -07002816
2817 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002818 * The MIME type of the results from {@link #CONTENT_URI} when a specific
2819 * ID value is not provided, and multiple raw contacts may be returned.
Evan Millar088b2912009-05-28 15:24:37 -07002820 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002821 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002822
2823 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002824 * The MIME type of the results when a raw contact ID is appended to {@link #CONTENT_URI},
2825 * yielding a subdirectory of a single person.
Evan Millar088b2912009-05-28 15:24:37 -07002826 */
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07002827 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/raw_contact";
Evan Millar088b2912009-05-28 15:24:37 -07002828
2829 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002830 * Aggregation mode: aggregate immediately after insert or update operation(s) are complete.
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002831 */
2832 public static final int AGGREGATION_MODE_DEFAULT = 0;
2833
2834 /**
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002835 * Aggregation mode: aggregate at the time the raw contact is inserted/updated.
2836 * @deprecated Aggregation is synchronous, this historic value is a no-op
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002837 */
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002838 @Deprecated
Omari Stephensbc9aa772009-09-08 19:10:53 -07002839 public static final int AGGREGATION_MODE_IMMEDIATE = 1;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002840
2841 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002842 * <p>
2843 * Aggregation mode: aggregation suspended temporarily, and is likely to be resumed later.
2844 * Changes to the raw contact will update the associated aggregate contact but will not
2845 * result in any change in how the contact is aggregated. Similar to
2846 * {@link #AGGREGATION_MODE_DISABLED}, but maintains a link to the corresponding
2847 * {@link Contacts} aggregate.
2848 * </p>
2849 * <p>
2850 * This can be used to postpone aggregation until after a series of updates, for better
2851 * performance and/or user experience.
2852 * </p>
2853 * <p>
2854 * Note that changing
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002855 * {@link #AGGREGATION_MODE} from {@link #AGGREGATION_MODE_SUSPENDED} to
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002856 * {@link #AGGREGATION_MODE_DEFAULT} does not trigger an aggregation pass, but any
2857 * subsequent
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002858 * change to the raw contact's data will.
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002859 * </p>
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002860 */
2861 public static final int AGGREGATION_MODE_SUSPENDED = 2;
2862
2863 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002864 * <p>
2865 * Aggregation mode: never aggregate this raw contact. The raw contact will not
2866 * have a corresponding {@link Contacts} aggregate and therefore will not be included in
2867 * {@link Contacts} query results.
2868 * </p>
2869 * <p>
2870 * For example, this mode can be used for a raw contact that is marked for deletion while
2871 * waiting for the deletion to occur on the server side.
2872 * </p>
2873 *
2874 * @see #AGGREGATION_MODE_SUSPENDED
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002875 */
Dmitri Plotnikov5223b162009-08-25 15:15:06 -07002876 public static final int AGGREGATION_MODE_DISABLED = 3;
Dmitri Plotnikovc991bfc2009-07-14 17:27:31 -07002877
2878 /**
Jeff Hamiltonf8526982009-09-24 11:34:58 -05002879 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
2880 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
2881 * entry of the given {@link RawContacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07002882 */
2883 public static Uri getContactLookupUri(ContentResolver resolver, Uri rawContactUri) {
2884 // TODO: use a lighter query by joining rawcontacts with contacts in provider
2885 final Uri dataUri = Uri.withAppendedPath(rawContactUri, Data.CONTENT_DIRECTORY);
2886 final Cursor cursor = resolver.query(dataUri, new String[] {
2887 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
2888 }, null, null, null);
2889
2890 Uri lookupUri = null;
2891 try {
2892 if (cursor != null && cursor.moveToFirst()) {
2893 final long contactId = cursor.getLong(0);
2894 final String lookupKey = cursor.getString(1);
2895 return Contacts.getLookupUri(contactId, lookupKey);
2896 }
2897 } finally {
2898 if (cursor != null) cursor.close();
2899 }
2900 return lookupUri;
2901 }
2902
2903 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002904 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002905 * {@link ContactsContract.Data} rows. To access this directory
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002906 * append {@link Data#CONTENT_DIRECTORY} to the raw contact URI.
Evan Millar088b2912009-05-28 15:24:37 -07002907 */
2908 public static final class Data implements BaseColumns, DataColumns {
2909 /**
2910 * no public constructor since this is a utility class
2911 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07002912 private Data() {
2913 }
Evan Millar088b2912009-05-28 15:24:37 -07002914
2915 /**
2916 * The directory twig for this sub-table
2917 */
2918 public static final String CONTENT_DIRECTORY = "data";
2919 }
Fred Quintana5bba6322009-10-05 14:21:12 -07002920
2921 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002922 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002923 * A sub-directory of a single raw contact that contains all of its
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002924 * {@link ContactsContract.Data} rows. To access this directory append
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002925 * {@link RawContacts.Entity#CONTENT_DIRECTORY} to the raw contact URI. See
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002926 * {@link RawContactsEntity} for a stand-alone table containing the same
2927 * data.
2928 * </p>
2929 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002930 * Entity has two ID fields: {@link #_ID} for the raw contact
2931 * and {@link #DATA_ID} for the data rows.
2932 * Entity always contains at least one row, even if there are no
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08002933 * actual data rows. In this case the {@link #DATA_ID} field will be
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002934 * null.
2935 * </p>
2936 * <p>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07002937 * Using Entity should be preferred to using two separate queries:
2938 * RawContacts followed by Data. The reason is that Entity reads all
2939 * data for a raw contact in one transaction, so there is no possibility
2940 * of the data changing between the two queries.
Fred Quintana5bba6322009-10-05 14:21:12 -07002941 */
2942 public static final class Entity implements BaseColumns, DataColumns {
2943 /**
2944 * no public constructor since this is a utility class
2945 */
2946 private Entity() {
2947 }
2948
2949 /**
2950 * The directory twig for this sub-table
2951 */
2952 public static final String CONTENT_DIRECTORY = "entity";
2953
2954 /**
Dmitri Plotnikovb2ce4812010-07-29 18:28:50 -07002955 * The ID of the data row. The value will be null if this raw contact has no
Fred Quintana5bba6322009-10-05 14:21:12 -07002956 * data rows.
2957 * <P>Type: INTEGER</P>
2958 */
2959 public static final String DATA_ID = "data_id";
2960 }
Fred Quintana328c0e72009-12-07 14:52:28 -08002961
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08002962 /**
Dave Santorod414f102011-06-20 14:35:06 -07002963 * <p>
2964 * A sub-directory of a single raw contact that contains all of its
2965 * {@link ContactsContract.StreamItems} rows. To access this directory append
2966 * {@link RawContacts.StreamItems#CONTENT_DIRECTORY} to the raw contact URI. See
2967 * {@link ContactsContract.StreamItems} for a stand-alone table containing the
2968 * same data.
2969 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07002970 * <p>
2971 * Access to the social stream through this sub-directory requires additional permissions
2972 * beyond the read/write contact permissions required by the provider. Querying for
2973 * social stream data requires android.permission.READ_SOCIAL_STREAM permission, and
2974 * inserting or updating social stream items requires android.permission.WRITE_SOCIAL_STREAM
2975 * permission.
2976 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07002977 *
2978 * @deprecated - Do not use. This will not be supported in the future. In the future,
2979 * cursors returned from related queries will be empty.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00002980 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00002981 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07002982 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002983 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002984 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
2985 /**
2986 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07002987 *
2988 * @deprecated - Do not use. This will not be supported in the future. In the future,
2989 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07002990 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07002991 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07002992 private StreamItems() {
2993 }
2994
2995 /**
2996 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07002997 *
2998 * @deprecated - Do not use. This will not be supported in the future. In the future,
2999 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003000 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003001 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003002 public static final String CONTENT_DIRECTORY = "stream_items";
3003 }
3004
3005 /**
Dave Santoroa5282372011-06-29 00:25:16 -07003006 * <p>
3007 * A sub-directory of a single raw contact that represents its primary
3008 * display photo. To access this directory append
3009 * {@link RawContacts.DisplayPhoto#CONTENT_DIRECTORY} to the raw contact URI.
3010 * The resulting URI represents an image file, and should be interacted with
Dave Santoro040e6b32011-07-15 15:14:08 -07003011 * using ContentResolver.openAssetFileDescriptor.
Dave Santoroa5282372011-06-29 00:25:16 -07003012 * <p>
3013 * <p>
3014 * Note that this sub-directory also supports opening the photo as an asset file
3015 * in write mode. Callers can create or replace the primary photo associated
3016 * with this raw contact by opening the asset file and writing the full-size
3017 * photo contents into it. When the file is closed, the image will be parsed,
3018 * sized down if necessary for the full-size display photo and thumbnail
3019 * dimensions, and stored.
3020 * </p>
3021 * <p>
3022 * Usage example:
3023 * <pre>
3024 * public void writeDisplayPhoto(long rawContactId, byte[] photo) {
3025 * Uri rawContactPhotoUri = Uri.withAppendedPath(
3026 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3027 * RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
3028 * try {
3029 * AssetFileDescriptor fd =
Dave Santoro040e6b32011-07-15 15:14:08 -07003030 * getContentResolver().openAssetFileDescriptor(rawContactPhotoUri, "rw");
Dave Santoroa5282372011-06-29 00:25:16 -07003031 * OutputStream os = fd.createOutputStream();
3032 * os.write(photo);
3033 * os.close();
3034 * fd.close();
3035 * } catch (IOException e) {
3036 * // Handle error cases.
3037 * }
3038 * }
3039 * </pre>
3040 * </p>
3041 */
3042 public static final class DisplayPhoto {
3043 /**
3044 * No public constructor since this is a utility class
3045 */
3046 private DisplayPhoto() {
3047 }
3048
3049 /**
3050 * The directory twig for this sub-table
3051 */
3052 public static final String CONTENT_DIRECTORY = "display_photo";
3053 }
3054
3055 /**
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08003056 * TODO: javadoc
3057 * @param cursor
3058 * @return
3059 */
Fred Quintana328c0e72009-12-07 14:52:28 -08003060 public static EntityIterator newEntityIterator(Cursor cursor) {
3061 return new EntityIteratorImpl(cursor);
3062 }
3063
3064 private static class EntityIteratorImpl extends CursorEntityIterator {
3065 private static final String[] DATA_KEYS = new String[]{
3066 Data.DATA1,
3067 Data.DATA2,
3068 Data.DATA3,
3069 Data.DATA4,
3070 Data.DATA5,
3071 Data.DATA6,
3072 Data.DATA7,
3073 Data.DATA8,
3074 Data.DATA9,
3075 Data.DATA10,
3076 Data.DATA11,
3077 Data.DATA12,
3078 Data.DATA13,
3079 Data.DATA14,
3080 Data.DATA15,
3081 Data.SYNC1,
3082 Data.SYNC2,
3083 Data.SYNC3,
3084 Data.SYNC4};
3085
3086 public EntityIteratorImpl(Cursor cursor) {
3087 super(cursor);
3088 }
3089
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08003090 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08003091 public android.content.Entity getEntityAndIncrementCursor(Cursor cursor)
3092 throws RemoteException {
3093 final int columnRawContactId = cursor.getColumnIndexOrThrow(RawContacts._ID);
3094 final long rawContactId = cursor.getLong(columnRawContactId);
3095
3096 // we expect the cursor is already at the row we need to read from
3097 ContentValues cv = new ContentValues();
3098 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_NAME);
3099 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, ACCOUNT_TYPE);
Katherine Kuan1d837232011-08-24 16:06:06 -07003100 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, DATA_SET);
Fred Quintana328c0e72009-12-07 14:52:28 -08003101 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, _ID);
3102 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DIRTY);
3103 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, VERSION);
3104 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SOURCE_ID);
3105 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC1);
3106 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC2);
3107 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC3);
3108 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, SYNC4);
3109 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, DELETED);
3110 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, CONTACT_ID);
3111 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, STARRED);
Fred Quintana328c0e72009-12-07 14:52:28 -08003112 android.content.Entity contact = new android.content.Entity(cv);
3113
3114 // read data rows until the contact id changes
3115 do {
3116 if (rawContactId != cursor.getLong(columnRawContactId)) {
3117 break;
3118 }
3119 // add the data to to the contact
3120 cv = new ContentValues();
3121 cv.put(Data._ID, cursor.getLong(cursor.getColumnIndexOrThrow(Entity.DATA_ID)));
3122 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3123 Data.RES_PACKAGE);
3124 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv, Data.MIMETYPE);
3125 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.IS_PRIMARY);
3126 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv,
3127 Data.IS_SUPER_PRIMARY);
3128 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, cv, Data.DATA_VERSION);
3129 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3130 CommonDataKinds.GroupMembership.GROUP_SOURCE_ID);
3131 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, cv,
3132 Data.DATA_VERSION);
3133 for (String key : DATA_KEYS) {
3134 final int columnIndex = cursor.getColumnIndexOrThrow(key);
Daniel Lehmann156add92010-07-19 18:01:10 -07003135 switch (cursor.getType(columnIndex)) {
3136 case Cursor.FIELD_TYPE_NULL:
3137 // don't put anything
3138 break;
3139 case Cursor.FIELD_TYPE_INTEGER:
3140 case Cursor.FIELD_TYPE_FLOAT:
3141 case Cursor.FIELD_TYPE_STRING:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003142 cv.put(key, cursor.getString(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003143 break;
3144 case Cursor.FIELD_TYPE_BLOB:
Fred Quintana274dc9d2009-12-11 13:17:08 -08003145 cv.put(key, cursor.getBlob(columnIndex));
Daniel Lehmann156add92010-07-19 18:01:10 -07003146 break;
3147 default:
3148 throw new IllegalStateException("Invalid or unhandled data type");
Fred Quintana328c0e72009-12-07 14:52:28 -08003149 }
Fred Quintana328c0e72009-12-07 14:52:28 -08003150 }
3151 contact.addSubValue(ContactsContract.Data.CONTENT_URI, cv);
3152 } while (cursor.moveToNext());
3153
3154 return contact;
3155 }
3156
3157 }
Evan Millar088b2912009-05-28 15:24:37 -07003158 }
3159
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003160 /**
3161 * Social status update columns.
3162 *
3163 * @see StatusUpdates
3164 * @see ContactsContract.Data
3165 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003166 protected interface StatusColumns {
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003167 /**
Dmitri Plotnikova60479d2009-09-27 20:16:31 -07003168 * Contact's latest presence level.
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003169 * <P>Type: INTEGER (one of the values below)</P>
3170 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003171 public static final String PRESENCE = "mode";
3172
3173 /**
3174 * @deprecated use {@link #PRESENCE}
3175 */
3176 @Deprecated
3177 public static final String PRESENCE_STATUS = PRESENCE;
3178
Tom O'Neill244327e22010-01-08 11:11:15 -08003179 /**
3180 * An allowed value of {@link #PRESENCE}.
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003181 */
3182 int OFFLINE = 0;
Tom O'Neill244327e22010-01-08 11:11:15 -08003183
3184 /**
3185 * An allowed value of {@link #PRESENCE}.
3186 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003187 int INVISIBLE = 1;
Tom O'Neill244327e22010-01-08 11:11:15 -08003188
3189 /**
3190 * An allowed value of {@link #PRESENCE}.
3191 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003192 int AWAY = 2;
Tom O'Neill244327e22010-01-08 11:11:15 -08003193
3194 /**
3195 * An allowed value of {@link #PRESENCE}.
3196 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003197 int IDLE = 3;
Tom O'Neill244327e22010-01-08 11:11:15 -08003198
3199 /**
3200 * An allowed value of {@link #PRESENCE}.
3201 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003202 int DO_NOT_DISTURB = 4;
Tom O'Neill244327e22010-01-08 11:11:15 -08003203
3204 /**
3205 * An allowed value of {@link #PRESENCE}.
3206 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003207 int AVAILABLE = 5;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003208
3209 /**
3210 * Contact latest status update.
3211 * <p>Type: TEXT</p>
3212 */
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003213 public static final String STATUS = "status";
3214
3215 /**
3216 * @deprecated use {@link #STATUS}
3217 */
Tom O'Neill244327e22010-01-08 11:11:15 -08003218 @Deprecated
Jeff Hamiltonf3960b12009-11-20 20:04:03 -08003219 public static final String PRESENCE_CUSTOM_STATUS = STATUS;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003220
3221 /**
3222 * The absolute time in milliseconds when the latest status was inserted/updated.
3223 * <p>Type: NUMBER</p>
3224 */
3225 public static final String STATUS_TIMESTAMP = "status_ts";
3226
3227 /**
3228 * The package containing resources for this status: label and icon.
Dave Santoro040e6b32011-07-15 15:14:08 -07003229 * <p>Type: TEXT</p>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003230 */
3231 public static final String STATUS_RES_PACKAGE = "status_res_package";
3232
3233 /**
3234 * The resource ID of the label describing the source of the status update, e.g. "Google
3235 * Talk". This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3236 * <p>Type: NUMBER</p>
3237 */
3238 public static final String STATUS_LABEL = "status_label";
3239
3240 /**
3241 * The resource ID of the icon for the source of the status update.
3242 * This resource should be scoped by the {@link #STATUS_RES_PACKAGE}.
3243 * <p>Type: NUMBER</p>
3244 */
3245 public static final String STATUS_ICON = "status_icon";
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003246
3247 /**
3248 * Contact's audio/video chat capability level.
3249 * <P>Type: INTEGER (one of the values below)</P>
3250 */
3251 public static final String CHAT_CAPABILITY = "chat_capability";
3252
3253 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003254 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates audio-chat capability (microphone
3255 * and speaker)
3256 */
3257 public static final int CAPABILITY_HAS_VOICE = 1;
3258
3259 /**
3260 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device can
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003261 * display a video feed.
3262 */
Daniel Lehmannb3327472010-08-13 15:16:11 -07003263 public static final int CAPABILITY_HAS_VIDEO = 2;
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003264
3265 /**
Daniel Lehmannb3327472010-08-13 15:16:11 -07003266 * An allowed flag of {@link #CHAT_CAPABILITY}. Indicates that the contact's device has a
Vasu Nori5b31498ba12010-07-12 15:13:37 -07003267 * camera that can be used for video chat (e.g. a front-facing camera on a phone).
3268 */
3269 public static final int CAPABILITY_HAS_CAMERA = 4;
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07003270 }
3271
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08003272 /**
Dave Santorod414f102011-06-20 14:35:06 -07003273 * <p>
3274 * Constants for the stream_items table, which contains social stream updates from
3275 * the user's contact list.
3276 * </p>
3277 * <p>
3278 * Only a certain number of stream items will ever be stored under a given raw contact.
3279 * Users of this API can query {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} to
3280 * determine this limit, and should restrict the number of items inserted in any given
3281 * transaction correspondingly. Insertion of more items beyond the limit will
3282 * automatically lead to deletion of the oldest items, by {@link StreamItems#TIMESTAMP}.
3283 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003284 * <p>
3285 * Access to the social stream through these URIs requires additional permissions beyond the
3286 * read/write contact permissions required by the provider. Querying for social stream data
3287 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating social
3288 * stream items requires android.permission.WRITE_SOCIAL_STREAM permission.
3289 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003290 * <h3>Account check</h3>
3291 * <p>
3292 * The content URIs to the insert, update and delete operations are required to have the account
3293 * information matching that of the owning raw contact as query parameters, namely
3294 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3295 * {@link RawContacts#DATA_SET} isn't required.
3296 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003297 * <h3>Operations</h3>
3298 * <dl>
3299 * <dt><b>Insert</b></dt>
3300 * <dd>
3301 * <p>Social stream updates are always associated with a raw contact. There are a couple
3302 * of ways to insert these entries.
3303 * <dl>
3304 * <dt>Via the {@link RawContacts.StreamItems#CONTENT_DIRECTORY} sub-path of a raw contact:</dt>
3305 * <dd>
3306 * <pre>
3307 * ContentValues values = new ContentValues();
3308 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3309 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003310 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003311 * Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
3312 * ContentUris.appendId(builder, rawContactId);
3313 * builder.appendEncodedPath(RawContacts.StreamItems.CONTENT_DIRECTORY);
3314 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3315 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3316 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003317 * long streamItemId = ContentUris.parseId(streamItemUri);
3318 * </pre>
3319 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003320 * <dt>Via {@link StreamItems#CONTENT_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003321 * <dd>
Scott Main45107052011-09-26 21:52:05 -07003322 *<pre>
Dave Santorod414f102011-06-20 14:35:06 -07003323 * ContentValues values = new ContentValues();
3324 * values.put(StreamItems.RAW_CONTACT_ID, rawContactId);
3325 * values.put(StreamItems.TEXT, "Breakfasted at Tiffanys");
3326 * values.put(StreamItems.TIMESTAMP, timestamp);
Dave Santoro040e6b32011-07-15 15:14:08 -07003327 * values.put(StreamItems.COMMENTS, "3 people reshared this");
Makoto Onuki46891a82012-04-26 12:46:47 -07003328 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3329 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3330 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3331 * Uri streamItemUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003332 * long streamItemId = ContentUris.parseId(streamItemUri);
Scott Main45107052011-09-26 21:52:05 -07003333 *</pre>
Dave Santorod414f102011-06-20 14:35:06 -07003334 * </dd>
3335 * </dl>
3336 * </dd>
3337 * </p>
3338 * <p>
3339 * Once a {@link StreamItems} entry has been inserted, photos associated with that
3340 * social update can be inserted. For example, after one of the insertions above,
3341 * photos could be added to the stream item in one of the following ways:
3342 * <dl>
3343 * <dt>Via a URI including the stream item ID:</dt>
3344 * <dd>
3345 * <pre>
3346 * values.clear();
3347 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003348 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003349 * getContentResolver().insert(Uri.withAppendedPath(
3350 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId),
3351 * StreamItems.StreamItemPhotos.CONTENT_DIRECTORY), values);
3352 * </pre>
3353 * </dd>
Scott Main45107052011-09-26 21:52:05 -07003354 * <dt>Via {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI}:</dt>
Dave Santorod414f102011-06-20 14:35:06 -07003355 * <dd>
3356 * <pre>
3357 * values.clear();
3358 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3359 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003360 * values.put(StreamItemPhotos.PHOTO, photoData);
Dave Santorod414f102011-06-20 14:35:06 -07003361 * getContentResolver().insert(StreamItems.CONTENT_PHOTO_URI, values);
3362 * </pre>
Scott Main45107052011-09-26 21:52:05 -07003363 * <p>Note that this latter form allows the insertion of a stream item and its
Dave Santorod414f102011-06-20 14:35:06 -07003364 * photos in a single transaction, by using {@link ContentProviderOperation} with
3365 * back references to populate the stream item ID in the {@link ContentValues}.
3366 * </dd>
3367 * </dl>
3368 * </p>
3369 * </dd>
3370 * <dt><b>Update</b></dt>
3371 * <dd>Updates can be performed by appending the stream item ID to the
3372 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3373 * created by the calling package can be updated.</dd>
3374 * <dt><b>Delete</b></dt>
3375 * <dd>Deletes can be performed by appending the stream item ID to the
3376 * {@link StreamItems#CONTENT_URI} URI. Only social stream entries that were
3377 * created by the calling package can be deleted.</dd>
3378 * <dt><b>Query</b></dt>
3379 * <dl>
3380 * <dt>Finding all social stream updates for a given contact</dt>
3381 * <dd>By Contact ID:
3382 * <pre>
3383 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3384 * ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
3385 * Contacts.StreamItems.CONTENT_DIRECTORY),
3386 * null, null, null, null);
3387 * </pre>
3388 * </dd>
3389 * <dd>By lookup key:
3390 * <pre>
3391 * Cursor c = getContentResolver().query(Contacts.CONTENT_URI.buildUpon()
3392 * .appendPath(lookupKey)
3393 * .appendPath(Contacts.StreamItems.CONTENT_DIRECTORY).build(),
3394 * null, null, null, null);
3395 * </pre>
3396 * </dd>
3397 * <dt>Finding all social stream updates for a given raw contact</dt>
3398 * <dd>
3399 * <pre>
3400 * Cursor c = getContentResolver().query(Uri.withAppendedPath(
3401 * ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId),
3402 * RawContacts.StreamItems.CONTENT_DIRECTORY)),
3403 * null, null, null, null);
3404 * </pre>
3405 * </dd>
3406 * <dt>Querying for a specific stream item by ID</dt>
3407 * <dd>
3408 * <pre>
3409 * Cursor c = getContentResolver().query(ContentUris.withAppendedId(
3410 * StreamItems.CONTENT_URI, streamItemId),
3411 * null, null, null, null);
3412 * </pre>
3413 * </dd>
3414 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003415 *
3416 * @deprecated - Do not use. This will not be supported in the future. In the future,
3417 * cursors returned from related queries will be empty.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003418 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003419 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07003420 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003421 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003422 public static final class StreamItems implements BaseColumns, StreamItemsColumns {
3423 /**
3424 * This utility class cannot be instantiated
Brian Attwellbdb13c82014-07-16 21:43:54 -07003425 *
3426 * @deprecated - Do not use. This will not be supported in the future. In the future,
3427 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003428 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003429 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003430 private StreamItems() {
3431 }
3432
3433 /**
3434 * The content:// style URI for this table, which handles social network stream
3435 * updates for the user's contacts.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003436 *
3437 * @deprecated - Do not use. This will not be supported in the future. In the future,
3438 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003439 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003440 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003441 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "stream_items");
3442
3443 /**
3444 * <p>
3445 * A content:// style URI for the photos stored in a sub-table underneath
3446 * stream items. This is only used for inserts, and updates - queries and deletes
3447 * for photos should be performed by appending
3448 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} path to URIs for a
3449 * specific stream item.
3450 * </p>
3451 * <p>
3452 * When using this URI, the stream item ID for the photo(s) must be identified
3453 * in the {@link ContentValues} passed in.
3454 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003455 *
3456 * @deprecated - Do not use. This will not be supported in the future. In the future,
3457 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003458 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003459 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003460 public static final Uri CONTENT_PHOTO_URI = Uri.withAppendedPath(CONTENT_URI, "photo");
3461
3462 /**
3463 * This URI allows the caller to query for the maximum number of stream items
Dave Santoro040e6b32011-07-15 15:14:08 -07003464 * that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003465 *
3466 * @deprecated - Do not use. This will not be supported in the future. In the future,
3467 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003468 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003469 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003470 public static final Uri CONTENT_LIMIT_URI =
3471 Uri.withAppendedPath(AUTHORITY_URI, "stream_items_limit");
3472
3473 /**
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003474 * The MIME type of a directory of stream items.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003475 *
3476 * @deprecated - Do not use. This will not be supported in the future. In the future,
3477 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003478 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003479 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003480 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item";
3481
3482 /**
3483 * The MIME type of a single stream item.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003484 *
3485 * @deprecated - Do not use. This will not be supported in the future. In the future,
3486 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003487 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003488 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003489 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/stream_item";
3490
3491 /**
Dave Santorod414f102011-06-20 14:35:06 -07003492 * Queries to {@link ContactsContract.StreamItems#CONTENT_LIMIT_URI} will
3493 * contain this column, with the value indicating the maximum number of
3494 * stream items that will be stored under any single raw contact.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003495 *
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.
Dave Santorod414f102011-06-20 14:35:06 -07003498 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003499 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003500 public static final String MAX_ITEMS = "max_items";
3501
3502 /**
Dave Santorod414f102011-06-20 14:35:06 -07003503 * <p>
3504 * A sub-directory of a single stream item entry that contains all of its
3505 * photo rows. To access this
3506 * directory append {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} to
3507 * an individual stream item URI.
3508 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003509 * <p>
3510 * Access to social stream photos requires additional permissions beyond the read/write
3511 * contact permissions required by the provider. Querying for social stream photos
3512 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3513 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3514 * </p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003515 *
3516 * @deprecated - Do not use. This will not be supported in the future. In the future,
3517 * cursors returned from related queries will be empty.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003518 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003519 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07003520 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003521 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003522 public static final class StreamItemPhotos
3523 implements BaseColumns, StreamItemPhotosColumns {
3524 /**
3525 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003526 *
3527 * @deprecated - Do not use. This will not be supported in the future. In the future,
3528 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003529 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003530 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003531 private StreamItemPhotos() {
3532 }
3533
3534 /**
3535 * The directory twig for this sub-table
Brian Attwellbdb13c82014-07-16 21:43:54 -07003536 *
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.
Dave Santorod414f102011-06-20 14:35:06 -07003539 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003540 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003541 public static final String CONTENT_DIRECTORY = "photo";
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003542
3543 /**
3544 * The MIME type of a directory of stream item photos.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003545 *
3546 * @deprecated - Do not use. This will not be supported in the future. In the future,
3547 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003548 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003549 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003550 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/stream_item_photo";
3551
3552 /**
3553 * The MIME type of a single stream item photo.
Brian Attwellbdb13c82014-07-16 21:43:54 -07003554 *
3555 * @deprecated - Do not use. This will not be supported in the future. In the future,
3556 * cursors returned from related queries will be empty.
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003557 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003558 @Deprecated
Makoto Onukifc6d2fd2011-08-22 14:04:01 -07003559 public static final String CONTENT_ITEM_TYPE
3560 = "vnd.android.cursor.item/stream_item_photo";
Dave Santorod414f102011-06-20 14:35:06 -07003561 }
3562 }
3563
3564 /**
3565 * Columns in the StreamItems table.
3566 *
3567 * @see ContactsContract.StreamItems
Brian Attwellbdb13c82014-07-16 21:43:54 -07003568 * @deprecated - Do not use. This will not be supported in the future. In the future,
3569 * cursors returned from related queries will be empty.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003570 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003571 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07003572 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003573 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003574 protected interface StreamItemsColumns {
3575 /**
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003576 * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
3577 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003578 *
3579 * <p>Type: INTEGER</p>
3580 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003581 *
3582 * @deprecated - Do not use. This will not be supported in the future. In the future,
3583 * cursors returned from related queries will be empty.
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003584 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003585 @Deprecated
Daniel Lehmanne8aae092011-08-24 16:41:00 -07003586 public static final String CONTACT_ID = "contact_id";
3587
3588 /**
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003589 * A reference to the {@link android.provider.ContactsContract.Contacts#LOOKUP_KEY}
3590 * that this stream item belongs to.
3591 *
3592 * <p>Type: TEXT</p>
3593 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003594 *
3595 * @deprecated - Do not use. This will not be supported in the future. In the future,
3596 * cursors returned from related queries will be empty.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003597 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003598 @Deprecated
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003599 public static final String CONTACT_LOOKUP_KEY = "contact_lookup";
3600
3601 /**
Dave Santorod414f102011-06-20 14:35:06 -07003602 * A reference to the {@link RawContacts#_ID}
3603 * that this stream item belongs to.
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003604 * <p>Type: INTEGER</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003605 *
3606 * @deprecated - Do not use. This will not be supported in the future. In the future,
3607 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003608 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003609 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003610 public static final String RAW_CONTACT_ID = "raw_contact_id";
3611
3612 /**
3613 * The package name to use when creating {@link Resources} objects for
3614 * this stream item. This value is only designed for use when building
3615 * user interfaces, and should not be used to infer the owner.
Dave Santoro040e6b32011-07-15 15:14:08 -07003616 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003617 *
3618 * @deprecated - Do not use. This will not be supported in the future. In the future,
3619 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003620 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003621 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003622 public static final String RES_PACKAGE = "res_package";
3623
3624 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003625 * The account type to which the raw_contact of this item is associated. See
3626 * {@link RawContacts#ACCOUNT_TYPE}
3627 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003628 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003629 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003630 *
3631 * @deprecated - Do not use. This will not be supported in the future. In the future,
3632 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003633 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003634 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003635 public static final String ACCOUNT_TYPE = "account_type";
3636
3637 /**
3638 * The account name to which the raw_contact of this item is associated. See
3639 * {@link RawContacts#ACCOUNT_NAME}
3640 *
Daniel Lehmannceb476a2011-08-29 14:37:31 -07003641 * <p>Type: TEXT</p>
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003642 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003643 *
3644 * @deprecated - Do not use. This will not be supported in the future. In the future,
3645 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003646 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003647 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003648 public static final String ACCOUNT_NAME = "account_name";
3649
3650 /**
3651 * The data set within the account that the raw_contact of this row belongs to. This allows
3652 * multiple sync adapters for the same account type to distinguish between
3653 * each others' data.
3654 * {@link RawContacts#DATA_SET}
3655 *
3656 * <P>Type: TEXT</P>
3657 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003658 *
3659 * @deprecated - Do not use. This will not be supported in the future. In the future,
3660 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003661 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003662 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003663 public static final String DATA_SET = "data_set";
3664
3665 /**
3666 * The source_id of the raw_contact that this row belongs to.
3667 * {@link RawContacts#SOURCE_ID}
3668 *
3669 * <P>Type: TEXT</P>
3670 * <p>read-only</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003671 *
3672 * @deprecated - Do not use. This will not be supported in the future. In the future,
3673 * cursors returned from related queries will be empty.
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003674 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003675 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003676 public static final String RAW_CONTACT_SOURCE_ID = "raw_contact_source_id";
3677
3678 /**
3679 * The resource name of the icon for the source of the stream item.
3680 * This resource should be scoped by the {@link #RES_PACKAGE}. As this can only reference
3681 * drawables, the "@drawable/" prefix must be omitted.
3682 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003683 *
3684 * @deprecated - Do not use. This will not be supported in the future. In the future,
3685 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003686 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003687 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003688 public static final String RES_ICON = "icon";
3689
3690 /**
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003691 * The resource name of the label describing the source of the status update, e.g. "Google
3692 * Talk". This resource should be scoped by the {@link #RES_PACKAGE}. As this can only
3693 * reference strings, the "@string/" prefix must be omitted.
3694 * <p>Type: TEXT</p>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003695 *
3696 * @deprecated - Do not use. This will not be supported in the future. In the future,
3697 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003698 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003699 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003700 public static final String RES_LABEL = "label";
3701
3702 /**
3703 * <P>
3704 * The main textual contents of the item. Typically this is content
3705 * that was posted by the source of this stream item, but it can also
3706 * be a textual representation of an action (e.g. ”Checked in at Joe's”).
3707 * This text is displayed to the user and allows formatting and embedded
3708 * resource images via HTML (as parseable via
3709 * {@link android.text.Html#fromHtml}).
3710 * </P>
3711 * <P>
3712 * Long content may be truncated and/or ellipsized - the exact behavior
3713 * is unspecified, but it should not break tags.
3714 * </P>
3715 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003716 *
3717 * @deprecated - Do not use. This will not be supported in the future. In the future,
3718 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003719 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003720 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003721 public static final String TEXT = "text";
3722
3723 /**
3724 * The absolute time (milliseconds since epoch) when this stream item was
3725 * inserted/updated.
3726 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003727 *
3728 * @deprecated - Do not use. This will not be supported in the future. In the future,
3729 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003730 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003731 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003732 public static final String TIMESTAMP = "timestamp";
3733
3734 /**
3735 * <P>
3736 * Summary information about the stream item, for example to indicate how
3737 * many people have reshared it, how many have liked it, how many thumbs
3738 * up and/or thumbs down it has, what the original source was, etc.
3739 * </P>
3740 * <P>
3741 * This text is displayed to the user and allows simple formatting via
3742 * HTML, in the same manner as {@link #TEXT} allows.
3743 * </P>
3744 * <P>
3745 * Long content may be truncated and/or ellipsized - the exact behavior
3746 * is unspecified, but it should not break tags.
3747 * </P>
3748 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003749 *
3750 * @deprecated - Do not use. This will not be supported in the future. In the future,
3751 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003752 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003753 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003754 public static final String COMMENTS = "comments";
3755
Brian Attwellbdb13c82014-07-16 21:43:54 -07003756 /**
3757 * Generic column for use by sync adapters.
3758 *
3759 * @deprecated - Do not use. This will not be supported in the future. In the future,
3760 * cursors returned from related queries will be empty.
3761 */
3762 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003763 public static final String SYNC1 = "stream_item_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003764 /**
3765 * Generic column for use by sync adapters.
3766 *
3767 * @deprecated - Do not use. This will not be supported in the future. In the future,
3768 * cursors returned from related queries will be empty.
3769 */
3770 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003771 public static final String SYNC2 = "stream_item_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003772 /**
3773 * Generic column for use by sync adapters.
3774 *
3775 * @deprecated - Do not use. This will not be supported in the future. In the future,
3776 * cursors returned from related queries will be empty.
3777 */
3778 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003779 public static final String SYNC3 = "stream_item_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07003780 /**
3781 * Generic column for use by sync adapters.
3782 *
3783 * @deprecated - Do not use. This will not be supported in the future. In the future,
3784 * cursors returned from related queries will be empty.
3785 */
3786 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07003787 public static final String SYNC4 = "stream_item_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07003788 }
3789
3790 /**
3791 * <p>
3792 * Constants for the stream_item_photos table, which contains photos associated with
3793 * social stream updates.
3794 * </p>
Dave Santoro0b61f592011-10-03 18:25:26 -07003795 * <p>
3796 * Access to social stream photos requires additional permissions beyond the read/write
3797 * contact permissions required by the provider. Querying for social stream photos
3798 * requires android.permission.READ_SOCIAL_STREAM permission, and inserting or updating
3799 * social stream photos requires android.permission.WRITE_SOCIAL_STREAM permission.
3800 * </p>
Makoto Onuki46891a82012-04-26 12:46:47 -07003801 * <h3>Account check</h3>
3802 * <p>
3803 * The content URIs to the insert, update and delete operations are required to have the account
3804 * information matching that of the owning raw contact as query parameters, namely
3805 * {@link RawContacts#ACCOUNT_TYPE} and {@link RawContacts#ACCOUNT_NAME}.
3806 * {@link RawContacts#DATA_SET} isn't required.
3807 * </p>
Dave Santorod414f102011-06-20 14:35:06 -07003808 * <h3>Operations</h3>
3809 * <dl>
3810 * <dt><b>Insert</b></dt>
3811 * <dd>
3812 * <p>Social stream photo entries are associated with a social stream item. Photos
3813 * can be inserted into a social stream item in a couple of ways:
3814 * <dl>
3815 * <dt>
3816 * Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3817 * stream item:
3818 * </dt>
3819 * <dd>
3820 * <pre>
3821 * ContentValues values = new ContentValues();
3822 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003823 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003824 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3825 * ContentUris.appendId(builder, streamItemId);
3826 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3827 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3828 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3829 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003830 * long photoId = ContentUris.parseId(photoUri);
3831 * </pre>
3832 * </dd>
3833 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3834 * <dd>
3835 * <pre>
3836 * ContentValues values = new ContentValues();
3837 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
3838 * values.put(StreamItemPhotos.SORT_INDEX, 1);
Dave Santoro040e6b32011-07-15 15:14:08 -07003839 * values.put(StreamItemPhotos.PHOTO, photoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003840 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3841 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3842 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3843 * Uri photoUri = getContentResolver().insert(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003844 * long photoId = ContentUris.parseId(photoUri);
3845 * </pre>
3846 * </dd>
3847 * </dl>
3848 * </p>
3849 * </dd>
3850 * <dt><b>Update</b></dt>
3851 * <dd>
3852 * <p>Updates can only be made against a specific {@link StreamItemPhotos} entry,
3853 * identified by both the stream item ID it belongs to and the stream item photo ID.
3854 * This can be specified in two ways.
3855 * <dl>
3856 * <dt>Via the {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a
3857 * stream item:
3858 * </dt>
3859 * <dd>
3860 * <pre>
3861 * ContentValues values = new ContentValues();
Dave Santoro040e6b32011-07-15 15:14:08 -07003862 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003863 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3864 * ContentUris.appendId(builder, streamItemId);
3865 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3866 * ContentUris.appendId(builder, streamItemPhotoId);
3867 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3868 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3869 * getContentResolver().update(builder.build(), values, null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003870 * </pre>
3871 * </dd>
3872 * <dt>Via the {@link ContactsContract.StreamItems#CONTENT_PHOTO_URI} URI:</dt>
3873 * <dd>
3874 * <pre>
3875 * ContentValues values = new ContentValues();
3876 * values.put(StreamItemPhotos.STREAM_ITEM_ID, streamItemId);
Dave Santoro040e6b32011-07-15 15:14:08 -07003877 * values.put(StreamItemPhotos.PHOTO, newPhotoData);
Makoto Onuki46891a82012-04-26 12:46:47 -07003878 * Uri.Builder builder = StreamItems.CONTENT_PHOTO_URI.buildUpon();
3879 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3880 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3881 * getContentResolver().update(builder.build(), values);
Dave Santorod414f102011-06-20 14:35:06 -07003882 * </pre>
3883 * </dd>
3884 * </dl>
3885 * </p>
3886 * </dd>
3887 * <dt><b>Delete</b></dt>
3888 * <dd>Deletes can be made against either a specific photo item in a stream item, or
3889 * against all or a selected subset of photo items under a stream item.
3890 * For example:
3891 * <dl>
3892 * <dt>Deleting a single photo via the
3893 * {@link StreamItems.StreamItemPhotos#CONTENT_DIRECTORY} sub-path of a stream item:
3894 * </dt>
3895 * <dd>
3896 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003897 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3898 * ContentUris.appendId(builder, streamItemId);
3899 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3900 * ContentUris.appendId(builder, streamItemPhotoId);
3901 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3902 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3903 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003904 * </pre>
3905 * </dd>
3906 * <dt>Deleting all photos under a stream item</dt>
3907 * <dd>
3908 * <pre>
Makoto Onuki46891a82012-04-26 12:46:47 -07003909 * Uri.Builder builder = StreamItems.CONTENT_URI.buildUpon();
3910 * ContentUris.appendId(builder, streamItemId);
3911 * builder.appendEncodedPath(StreamItems.StreamItemPhotos.CONTENT_DIRECTORY);
3912 * builder.appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName);
3913 * builder.appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType);
3914 * getContentResolver().delete(builder.build(), null, null);
Dave Santorod414f102011-06-20 14:35:06 -07003915 * </pre>
3916 * </dd>
3917 * </dl>
3918 * </dd>
3919 * <dt><b>Query</b></dt>
3920 * <dl>
3921 * <dt>Querying for a specific photo in a stream item</dt>
3922 * <dd>
3923 * <pre>
3924 * Cursor c = getContentResolver().query(
3925 * ContentUris.withAppendedId(
3926 * Uri.withAppendedPath(
3927 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3928 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3929 * streamItemPhotoId), null, null, null, null);
3930 * </pre>
3931 * </dd>
3932 * <dt>Querying for all photos in a stream item</dt>
3933 * <dd>
3934 * <pre>
3935 * Cursor c = getContentResolver().query(
3936 * Uri.withAppendedPath(
3937 * ContentUris.withAppendedId(StreamItems.CONTENT_URI, streamItemId)
3938 * StreamItems.StreamItemPhotos#CONTENT_DIRECTORY),
3939 * null, null, null, StreamItemPhotos.SORT_INDEX);
3940 * </pre>
3941 * </dl>
Dave Santoro040e6b32011-07-15 15:14:08 -07003942 * The record will contain both a {@link StreamItemPhotos#PHOTO_FILE_ID} and a
3943 * {@link StreamItemPhotos#PHOTO_URI}. The {@link StreamItemPhotos#PHOTO_FILE_ID}
3944 * can be used in conjunction with the {@link ContactsContract.DisplayPhoto} API to
3945 * retrieve photo content, or you can open the {@link StreamItemPhotos#PHOTO_URI} as
3946 * an asset file, as follows:
3947 * <pre>
3948 * public InputStream openDisplayPhoto(String photoUri) {
3949 * try {
3950 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(photoUri, "r");
3951 * return fd.createInputStream();
3952 * } catch (IOException e) {
3953 * return null;
3954 * }
3955 * }
3956 * <pre>
Dave Santorod414f102011-06-20 14:35:06 -07003957 * </dd>
3958 * </dl>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003959 *
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.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003962 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00003963 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07003964 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003965 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003966 public static final class StreamItemPhotos implements BaseColumns, StreamItemPhotosColumns {
3967 /**
3968 * No public constructor since this is a utility class
Brian Attwellbdb13c82014-07-16 21:43:54 -07003969 *
3970 * @deprecated - Do not use. This will not be supported in the future. In the future,
3971 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07003972 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003973 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07003974 private StreamItemPhotos() {
3975 }
Dave Santoro040e6b32011-07-15 15:14:08 -07003976
3977 /**
3978 * <p>
3979 * The binary representation of the photo. Any size photo can be inserted;
3980 * the provider will resize it appropriately for storage and display.
3981 * </p>
3982 * <p>
3983 * This is only intended for use when inserting or updating a stream item photo.
3984 * To retrieve the photo that was stored, open {@link StreamItemPhotos#PHOTO_URI}
3985 * as an asset file.
3986 * </p>
3987 * <P>Type: BLOB</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07003988 *
3989 * @deprecated - Do not use. This will not be supported in the future. In the future,
3990 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07003991 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07003992 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07003993 public static final String PHOTO = "photo";
Dave Santorod414f102011-06-20 14:35:06 -07003994 }
3995
3996 /**
3997 * Columns in the StreamItemPhotos table.
3998 *
3999 * @see ContactsContract.StreamItemPhotos
Brian Attwellbdb13c82014-07-16 21:43:54 -07004000 * @deprecated - Do not use. This will not be supported in the future. In the future,
4001 * cursors returned from related queries will be empty.
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00004002 *
Svetoslav Ganov6d2c0e52015-06-23 16:33:36 +00004003 * @removed
Dave Santorod414f102011-06-20 14:35:06 -07004004 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07004005 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07004006 protected interface StreamItemPhotosColumns {
4007 /**
4008 * A reference to the {@link StreamItems#_ID} this photo is associated with.
4009 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07004010 *
4011 * @deprecated - Do not use. This will not be supported in the future. In the future,
4012 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07004013 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07004014 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07004015 public static final String STREAM_ITEM_ID = "stream_item_id";
4016
4017 /**
4018 * An integer to use for sort order for photos in the stream item. If not
4019 * specified, the {@link StreamItemPhotos#_ID} will be used for sorting.
4020 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07004021 *
4022 * @deprecated - Do not use. This will not be supported in the future. In the future,
4023 * cursors returned from related queries will be empty.
Dave Santorod414f102011-06-20 14:35:06 -07004024 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07004025 @Deprecated
Dave Santorod414f102011-06-20 14:35:06 -07004026 public static final String SORT_INDEX = "sort_index";
4027
4028 /**
Dave Santoro040e6b32011-07-15 15:14:08 -07004029 * Photo file ID for the photo.
4030 * See {@link ContactsContract.DisplayPhoto}.
4031 * <P>Type: NUMBER</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07004032 *
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.
Dave Santorod414f102011-06-20 14:35:06 -07004035 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07004036 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07004037 public static final String PHOTO_FILE_ID = "photo_file_id";
4038
4039 /**
4040 * URI for retrieving the photo content, automatically populated. Callers
4041 * may retrieve the photo content by opening this URI as an asset file.
4042 * <P>Type: TEXT</P>
Brian Attwellbdb13c82014-07-16 21:43:54 -07004043 *
4044 * @deprecated - Do not use. This will not be supported in the future. In the future,
4045 * cursors returned from related queries will be empty.
Dave Santoro040e6b32011-07-15 15:14:08 -07004046 */
Brian Attwellbdb13c82014-07-16 21:43:54 -07004047 @Deprecated
Dave Santoro040e6b32011-07-15 15:14:08 -07004048 public static final String PHOTO_URI = "photo_uri";
Dave Santorod414f102011-06-20 14:35:06 -07004049
Brian Attwellbdb13c82014-07-16 21:43:54 -07004050 /**
4051 * Generic column for use by sync adapters.
4052 *
4053 * @deprecated - Do not use. This will not be supported in the future. In the future,
4054 * cursors returned from related queries will be empty.
4055 */
4056 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07004057 public static final String SYNC1 = "stream_item_photo_sync1";
Brian Attwellbdb13c82014-07-16 21:43:54 -07004058 /**
4059 * Generic column for use by sync adapters.
4060 *
4061 * @deprecated - Do not use. This will not be supported in the future. In the future,
4062 * cursors returned from related queries will be empty.
4063 */
4064 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07004065 public static final String SYNC2 = "stream_item_photo_sync2";
Brian Attwellbdb13c82014-07-16 21:43:54 -07004066 /**
4067 * Generic column for use by sync adapters.
4068 *
4069 * @deprecated - Do not use. This will not be supported in the future. In the future,
4070 * cursors returned from related queries will be empty.
4071 */
4072 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07004073 public static final String SYNC3 = "stream_item_photo_sync3";
Brian Attwellbdb13c82014-07-16 21:43:54 -07004074 /**
4075 * Generic column for use by sync adapters.
4076 *
4077 * @deprecated - Do not use. This will not be supported in the future. In the future,
4078 * cursors returned from related queries will be empty.
4079 */
4080 @Deprecated
Daniel Lehmannf188dfd2011-08-14 15:39:22 -07004081 public static final String SYNC4 = "stream_item_photo_sync4";
Dave Santorod414f102011-06-20 14:35:06 -07004082 }
4083
4084 /**
Dave Santoroa5282372011-06-29 00:25:16 -07004085 * <p>
4086 * Constants for the photo files table, which tracks metadata for hi-res photos
4087 * stored in the file system.
4088 * </p>
4089 *
4090 * @hide
4091 */
4092 public static final class PhotoFiles implements BaseColumns, PhotoFilesColumns {
4093 /**
4094 * No public constructor since this is a utility class
4095 */
4096 private PhotoFiles() {
4097 }
4098 }
4099
4100 /**
4101 * Columns in the PhotoFiles table.
4102 *
4103 * @see ContactsContract.PhotoFiles
4104 *
4105 * @hide
4106 */
4107 protected interface PhotoFilesColumns {
4108
4109 /**
4110 * The height, in pixels, of the photo this entry is associated with.
4111 * <P>Type: NUMBER</P>
4112 */
4113 public static final String HEIGHT = "height";
4114
4115 /**
4116 * The width, in pixels, of the photo this entry is associated with.
4117 * <P>Type: NUMBER</P>
4118 */
4119 public static final String WIDTH = "width";
4120
4121 /**
4122 * The size, in bytes, of the photo stored on disk.
4123 * <P>Type: NUMBER</P>
4124 */
4125 public static final String FILESIZE = "filesize";
4126 }
4127
4128 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004129 * Columns in the Data table.
4130 *
4131 * @see ContactsContract.Data
4132 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004133 protected interface DataColumns {
Evan Millar088b2912009-05-28 15:24:37 -07004134 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004135 * The package name to use when creating {@link Resources} objects for
4136 * this data row. This value is only designed for use when building user
4137 * interfaces, and should not be used to infer the owner.
4138 */
4139 public static final String RES_PACKAGE = "res_package";
4140
4141 /**
4142 * The MIME type of the item represented by this row.
Evan Millar088b2912009-05-28 15:24:37 -07004143 */
4144 public static final String MIMETYPE = "mimetype";
4145
4146 /**
Zheng Fu9ea9a132015-01-07 11:33:19 -08004147 * Hash id on the data fields, used for backup and restore.
4148 *
4149 * @hide
4150 */
4151 public static final String HASH_ID = "hash_id";
4152
4153 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004154 * A reference to the {@link RawContacts#_ID}
Dmitri Plotnikov56927772009-05-28 17:23:39 -07004155 * that this data belongs to.
Evan Millar088b2912009-05-28 15:24:37 -07004156 */
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07004157 public static final String RAW_CONTACT_ID = "raw_contact_id";
4158
Evan Millarab5742d2009-06-02 16:21:45 -07004159 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004160 * Whether this is the primary entry of its kind for the raw contact it belongs to.
Evan Millarab5742d2009-06-02 16:21:45 -07004161 * <P>Type: INTEGER (if set, non-0 means true)</P>
4162 */
4163 public static final String IS_PRIMARY = "is_primary";
4164
4165 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07004166 * Whether this is the primary entry of its kind for the aggregate
4167 * contact it belongs to. Any data record that is "super primary" must
4168 * also be "primary".
Evan Millarab5742d2009-06-02 16:21:45 -07004169 * <P>Type: INTEGER (if set, non-0 means true)</P>
4170 */
4171 public static final String IS_SUPER_PRIMARY = "is_super_primary";
4172
Jeff Sharkey28b68e52009-06-10 15:26:58 -07004173 /**
Dmitri Plotnikov30b7be32010-07-16 10:43:40 -07004174 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
4175 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
4176 * <P>Type: INTEGER</P>
4177 */
4178 public static final String IS_READ_ONLY = "is_read_only";
4179
4180 /**
Fred Quintanac933fb62009-06-11 12:14:40 -07004181 * The version of this data record. This is a read-only value. The data column is
4182 * guaranteed to not change without the version going up. This value is monotonically
4183 * increasing.
4184 * <P>Type: INTEGER</P>
4185 */
4186 public static final String DATA_VERSION = "data_version";
4187
Evan Millar088b2912009-05-28 15:24:37 -07004188 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4189 public static final String DATA1 = "data1";
4190 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4191 public static final String DATA2 = "data2";
4192 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4193 public static final String DATA3 = "data3";
4194 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4195 public static final String DATA4 = "data4";
4196 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4197 public static final String DATA5 = "data5";
4198 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4199 public static final String DATA6 = "data6";
4200 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4201 public static final String DATA7 = "data7";
4202 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4203 public static final String DATA8 = "data8";
4204 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4205 public static final String DATA9 = "data9";
4206 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4207 public static final String DATA10 = "data10";
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004208 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4209 public static final String DATA11 = "data11";
4210 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4211 public static final String DATA12 = "data12";
4212 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4213 public static final String DATA13 = "data13";
4214 /** Generic data column, the meaning is {@link #MIMETYPE} specific */
4215 public static final String DATA14 = "data14";
Tom O'Neill244327e22010-01-08 11:11:15 -08004216 /**
4217 * Generic data column, the meaning is {@link #MIMETYPE} specific. By convention,
4218 * this field is used to store BLOBs (binary data).
4219 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07004220 public static final String DATA15 = "data15";
Dmitri Plotnikov91e4e852009-08-03 18:06:29 -07004221
Fred Quintana8851e162009-08-05 21:06:45 -07004222 /** Generic column for use by sync adapters. */
4223 public static final String SYNC1 = "data_sync1";
4224 /** Generic column for use by sync adapters. */
4225 public static final String SYNC2 = "data_sync2";
4226 /** Generic column for use by sync adapters. */
4227 public static final String SYNC3 = "data_sync3";
4228 /** Generic column for use by sync adapters. */
4229 public static final String SYNC4 = "data_sync4";
Etan Cohen534a65d2015-05-01 11:03:24 -07004230
4231 /**
4232 * Carrier presence information.
4233 * <P>
4234 * Type: INTEGER (A bitmask of CARRIER_PRESENCE_* fields)
4235 * </P>
4236 */
4237 public static final String CARRIER_PRESENCE = "carrier_presence";
4238
4239 /**
Etan Cohene4dc7e12015-06-08 13:02:44 -07004240 * Indicates that the entry is Video Telephony (VT) capable on the
4241 * current carrier. An allowed bitmask of {@link #CARRIER_PRESENCE}.
Etan Cohen534a65d2015-05-01 11:03:24 -07004242 */
4243 public static final int CARRIER_PRESENCE_VT_CAPABLE = 0x01;
Ta-wei Yendc9daaa2017-11-28 17:10:48 -08004244
4245 /**
4246 * The flattened {@link android.content.ComponentName} of a {@link
4247 * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to
Ta-wei Yen3ec3d5b2017-12-13 15:25:49 -08004248 * call the contact with.
Ta-wei Yendc9daaa2017-11-28 17:10:48 -08004249 *
Ta-wei Yen3ec3d5b2017-12-13 15:25:49 -08004250 * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row
4251 * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using
4252 * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking
4253 * every time.
4254 *
4255 * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)}
4256 * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
4257 * set to the {@link PhoneAccountHandle} using the {@link ComponentName} from this field.
4258 *
4259 * @see #PREFERRED_PHONE_ACCOUNT_ID
Ta-wei Yendc9daaa2017-11-28 17:10:48 -08004260 * @see PhoneAccountHandle#getComponentName()
4261 * @see ComponentName#flattenToString()
4262 */
4263 String PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME = "preferred_phone_account_component_name";
4264
4265 /**
Ta-wei Yen3ec3d5b2017-12-13 15:25:49 -08004266 * The ID of a {@link
Ta-wei Yendc9daaa2017-11-28 17:10:48 -08004267 * android.telecom.PhoneAccountHandle} that is the preferred {@code PhoneAccountHandle} to
4268 * call the contact with. Used by {@link CommonDataKinds.Phone}.
4269 *
Ta-wei Yen3ec3d5b2017-12-13 15:25:49 -08004270 * <p> On a multi-SIM device this field can be used in a {@link CommonDataKinds.Phone} row
4271 * to indicate the {@link PhoneAccountHandle} to call the number with, instead of using
4272 * {@link android.telecom.TelecomManager#getDefaultOutgoingPhoneAccount(String)} or asking
4273 * every time.
4274 *
4275 * <p>{@link android.telecom.TelecomManager#placeCall(Uri, android.os.Bundle)}
4276 * should be called with {@link android.telecom.TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
4277 * set to the {@link PhoneAccountHandle} using the id from this field.
4278 *
4279 * @see #PREFERRED_PHONE_ACCOUNT_COMPONENT_NAME
4280 * @see PhoneAccountHandle#getId()
Ta-wei Yendc9daaa2017-11-28 17:10:48 -08004281 */
4282 String PREFERRED_PHONE_ACCOUNT_ID = "preferred_phone_account_id";
Evan Millar088b2912009-05-28 15:24:37 -07004283 }
4284
4285 /**
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004286 * Columns in the Data_Usage_Stat table
4287 */
4288 protected interface DataUsageStatColumns {
Makoto Onukiaa2dd622018-07-30 11:14:12 -07004289 /**
4290 * The last time (in milliseconds) this {@link Data} was used.
4291 * @deprecated Contacts affinity information is no longer supported as of
4292 * Android version {@link android.os.Build.VERSION_CODES#Q}.
4293 * This column always contains 0.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07004294 *
4295 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete.
4296 * For more information, see the
4297 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
4298 * page.
Makoto Onukiaa2dd622018-07-30 11:14:12 -07004299 */
4300 @Deprecated
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004301 public static final String LAST_TIME_USED = "last_time_used";
4302
Makoto Onukiaa2dd622018-07-30 11:14:12 -07004303 /**
4304 * The number of times the referenced {@link Data} has been used.
4305 * @deprecated Contacts affinity information is no longer supported as of
4306 * Android version {@link android.os.Build.VERSION_CODES#Q}.
4307 * This column always contains 0.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07004308 *
4309 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field is obsolete.
4310 * For more information, see the
4311 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
4312 * page.
Makoto Onukiaa2dd622018-07-30 11:14:12 -07004313 */
4314 @Deprecated
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004315 public static final String TIMES_USED = "times_used";
Makoto Onuki203145e2016-09-28 15:41:29 -07004316
4317 /** @hide Raw value. */
4318 public static final String RAW_LAST_TIME_USED = HIDDEN_COLUMN_PREFIX + LAST_TIME_USED;
4319
4320 /** @hide Raw value. */
4321 public static final String RAW_TIMES_USED = HIDDEN_COLUMN_PREFIX + TIMES_USED;
4322
4323 /**
4324 * @hide
4325 * Low res version. Same as {@link #LAST_TIME_USED} but use it in CP2 for clarification.
4326 */
4327 public static final String LR_LAST_TIME_USED = LAST_TIME_USED;
4328
4329 /**
4330 * @hide
4331 * Low res version. Same as {@link #TIMES_USED} but use it in CP2 for clarification.
4332 */
4333 public static final String LR_TIMES_USED = TIMES_USED;
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004334 }
4335
4336 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004337 * Combines all columns returned by {@link ContactsContract.Data} table queries.
4338 *
4339 * @see ContactsContract.Data
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004340 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07004341 protected interface DataColumnsWithJoins extends BaseColumns, DataColumns, StatusColumns,
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08004342 RawContactsColumns, ContactsColumns, ContactNameColumns, ContactOptionsColumns,
Yorke Lee0dc523fa2013-03-12 12:48:06 -07004343 ContactStatusColumns, DataUsageStatColumns {
Dmitri Plotnikov0dc98412009-09-18 17:47:53 -07004344 }
4345
4346 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004347 * <p>
4348 * Constants for the data table, which contains data points tied to a raw
Tom O'Neill244327e22010-01-08 11:11:15 -08004349 * contact. Each row of the data table is typically used to store a single
4350 * piece of contact
4351 * information (such as a phone number) and its
4352 * associated metadata (such as whether it is a work or home number).
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004353 * </p>
4354 * <h3>Data kinds</h3>
4355 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004356 * Data is a generic table that can hold any kind of contact data.
4357 * The kind of data stored in a given row is specified by the row's
4358 * {@link #MIMETYPE} value, which determines the meaning of the
4359 * generic columns {@link #DATA1} through
4360 * {@link #DATA15}.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004361 * For example, if the data kind is
Tom O'Neill244327e22010-01-08 11:11:15 -08004362 * {@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}, then the column
4363 * {@link #DATA1} stores the
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004364 * phone number, but if the data kind is
Tom O'Neill244327e22010-01-08 11:11:15 -08004365 * {@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}, then {@link #DATA1}
4366 * stores the email address.
4367 * Sync adapters and applications can introduce their own data kinds.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004368 * </p>
4369 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004370 * ContactsContract defines a small number of pre-defined data kinds, e.g.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004371 * {@link CommonDataKinds.Phone}, {@link CommonDataKinds.Email} etc. As a
4372 * convenience, these classes define data kind specific aliases for DATA1 etc.
4373 * For example, {@link CommonDataKinds.Phone Phone.NUMBER} is the same as
4374 * {@link ContactsContract.Data Data.DATA1}.
4375 * </p>
4376 * <p>
4377 * {@link #DATA1} is an indexed column and should be used for the data element that is
4378 * expected to be most frequently used in query selections. For example, in the
4379 * case of a row representing email addresses {@link #DATA1} should probably
4380 * be used for the email address itself, while {@link #DATA2} etc can be
4381 * used for auxiliary information like type of email address.
4382 * <p>
4383 * <p>
4384 * By convention, {@link #DATA15} is used for storing BLOBs (binary data).
4385 * </p>
4386 * <p>
Tom O'Neilld6f9cd22010-01-14 18:17:01 -08004387 * The sync adapter for a given account type must correctly handle every data type
4388 * used in the corresponding raw contacts. Otherwise it could result in lost or
4389 * corrupted data.
4390 * </p>
4391 * <p>
4392 * Similarly, you should refrain from introducing new kinds of data for an other
Tom O'Neill244327e22010-01-08 11:11:15 -08004393 * party's account types. For example, if you add a data row for
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004394 * "favorite song" to a raw contact owned by a Google account, it will not
4395 * get synced to the server, because the Google sync adapter does not know
4396 * how to handle this data kind. Thus new data kinds are typically
4397 * introduced along with new account types, i.e. new sync adapters.
4398 * </p>
4399 * <h3>Batch operations</h3>
4400 * <p>
4401 * Data rows can be inserted/updated/deleted using the traditional
4402 * {@link ContentResolver#insert}, {@link ContentResolver#update} and
4403 * {@link ContentResolver#delete} methods, however the newer mechanism based
4404 * on a batch of {@link ContentProviderOperation} will prove to be a better
4405 * choice in almost all cases. All operations in a batch are executed in a
4406 * single transaction, which ensures that the phone-side and server-side
4407 * state of a raw contact are always consistent. Also, the batch-based
4408 * approach is far more efficient: not only are the database operations
4409 * faster when executed in a single transaction, but also sending a batch of
4410 * commands to the content provider saves a lot of time on context switching
4411 * between your process and the process in which the content provider runs.
4412 * </p>
4413 * <p>
4414 * The flip side of using batched operations is that a large batch may lock
4415 * up the database for a long time preventing other applications from
4416 * accessing data and potentially causing ANRs ("Application Not Responding"
4417 * dialogs.)
4418 * </p>
4419 * <p>
4420 * To avoid such lockups of the database, make sure to insert "yield points"
4421 * in the batch. A yield point indicates to the content provider that before
4422 * executing the next operation it can commit the changes that have already
4423 * been made, yield to other requests, open another transaction and continue
4424 * processing operations. A yield point will not automatically commit the
4425 * transaction, but only if there is another request waiting on the
4426 * database. Normally a sync adapter should insert a yield point at the
4427 * beginning of each raw contact operation sequence in the batch. See
4428 * {@link ContentProviderOperation.Builder#withYieldAllowed(boolean)}.
4429 * </p>
4430 * <h3>Operations</h3>
4431 * <dl>
4432 * <dt><b>Insert</b></dt>
4433 * <dd>
4434 * <p>
4435 * An individual data row can be inserted using the traditional
4436 * {@link ContentResolver#insert(Uri, ContentValues)} method. Multiple rows
4437 * should always be inserted as a batch.
4438 * </p>
4439 * <p>
4440 * An example of a traditional insert:
4441 * <pre>
4442 * ContentValues values = new ContentValues();
4443 * values.put(Data.RAW_CONTACT_ID, rawContactId);
4444 * values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
4445 * values.put(Phone.NUMBER, "1-800-GOOG-411");
4446 * values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
4447 * values.put(Phone.LABEL, "free directory assistance");
4448 * Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values);
4449 * </pre>
4450 * <p>
4451 * The same done using ContentProviderOperations:
4452 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004453 * ArrayList&lt;ContentProviderOperation&gt; ops =
4454 * new ArrayList&lt;ContentProviderOperation&gt;();
4455 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004456 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
4457 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
4458 * .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
4459 * .withValue(Phone.NUMBER, "1-800-GOOG-411")
4460 * .withValue(Phone.TYPE, Phone.TYPE_CUSTOM)
4461 * .withValue(Phone.LABEL, "free directory assistance")
4462 * .build());
4463 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4464 * </pre>
4465 * </p>
4466 * <dt><b>Update</b></dt>
4467 * <dd>
4468 * <p>
4469 * Just as with insert, update can be done incrementally or as a batch,
4470 * the batch mode being the preferred method:
4471 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004472 * ArrayList&lt;ContentProviderOperation&gt; ops =
4473 * new ArrayList&lt;ContentProviderOperation&gt;();
4474 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004475 * ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI)
4476 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4477 * .withValue(Email.DATA, "somebody@android.com")
4478 * .build());
4479 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4480 * </pre>
4481 * </p>
4482 * </dd>
4483 * <dt><b>Delete</b></dt>
4484 * <dd>
4485 * <p>
4486 * Just as with insert and update, deletion can be done either using the
4487 * {@link ContentResolver#delete} method or using a ContentProviderOperation:
4488 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07004489 * ArrayList&lt;ContentProviderOperation&gt; ops =
4490 * new ArrayList&lt;ContentProviderOperation&gt;();
4491 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004492 * ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI)
4493 * .withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)})
4494 * .build());
4495 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
4496 * </pre>
4497 * </p>
4498 * </dd>
4499 * <dt><b>Query</b></dt>
4500 * <dd>
4501 * <p>
4502 * <dl>
4503 * <dt>Finding all Data of a given type for a given contact</dt>
4504 * <dd>
4505 * <pre>
4506 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4507 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4508 * Data.CONTACT_ID + &quot;=?&quot; + " AND "
4509 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4510 * new String[] {String.valueOf(contactId)}, null);
4511 * </pre>
4512 * </p>
4513 * <p>
4514 * </dd>
4515 * <dt>Finding all Data of a given type for a given raw contact</dt>
4516 * <dd>
4517 * <pre>
4518 * Cursor c = getContentResolver().query(Data.CONTENT_URI,
4519 * new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},
4520 * Data.RAW_CONTACT_ID + &quot;=?&quot; + " AND "
4521 * + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'",
4522 * new String[] {String.valueOf(rawContactId)}, null);
4523 * </pre>
4524 * </dd>
4525 * <dt>Finding all Data for a given raw contact</dt>
4526 * <dd>
4527 * Most sync adapters will want to read all data rows for a raw contact
4528 * along with the raw contact itself. For that you should use the
4529 * {@link RawContactsEntity}. See also {@link RawContacts}.
4530 * </dd>
4531 * </dl>
4532 * </p>
4533 * </dd>
4534 * </dl>
4535 * <h2>Columns</h2>
Tom O'Neill244327e22010-01-08 11:11:15 -08004536 * <p>
4537 * Many columns are available via a {@link Data#CONTENT_URI} query. For best performance you
4538 * should explicitly specify a projection to only those columns that you need.
4539 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004540 * <table class="jd-sumtable">
4541 * <tr>
4542 * <th colspan='4'>Data</th>
4543 * </tr>
4544 * <tr>
4545 * <td style="width: 7em;">long</td>
4546 * <td style="width: 20em;">{@link #_ID}</td>
4547 * <td style="width: 5em;">read-only</td>
4548 * <td>Row ID. Sync adapter should try to preserve row IDs during updates. In other words,
Tom O'Neill244327e22010-01-08 11:11:15 -08004549 * it would be a bad idea to delete and reinsert a data row. A sync adapter should
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004550 * always do an update instead.</td>
4551 * </tr>
4552 * <tr>
4553 * <td>String</td>
4554 * <td>{@link #MIMETYPE}</td>
4555 * <td>read/write-once</td>
4556 * <td>
4557 * <p>The MIME type of the item represented by this row. Examples of common
4558 * MIME types are:
4559 * <ul>
4560 * <li>{@link CommonDataKinds.StructuredName StructuredName.CONTENT_ITEM_TYPE}</li>
4561 * <li>{@link CommonDataKinds.Phone Phone.CONTENT_ITEM_TYPE}</li>
4562 * <li>{@link CommonDataKinds.Email Email.CONTENT_ITEM_TYPE}</li>
4563 * <li>{@link CommonDataKinds.Photo Photo.CONTENT_ITEM_TYPE}</li>
4564 * <li>{@link CommonDataKinds.Organization Organization.CONTENT_ITEM_TYPE}</li>
4565 * <li>{@link CommonDataKinds.Im Im.CONTENT_ITEM_TYPE}</li>
4566 * <li>{@link CommonDataKinds.Nickname Nickname.CONTENT_ITEM_TYPE}</li>
4567 * <li>{@link CommonDataKinds.Note Note.CONTENT_ITEM_TYPE}</li>
4568 * <li>{@link CommonDataKinds.StructuredPostal StructuredPostal.CONTENT_ITEM_TYPE}</li>
4569 * <li>{@link CommonDataKinds.GroupMembership GroupMembership.CONTENT_ITEM_TYPE}</li>
4570 * <li>{@link CommonDataKinds.Website Website.CONTENT_ITEM_TYPE}</li>
4571 * <li>{@link CommonDataKinds.Event Event.CONTENT_ITEM_TYPE}</li>
4572 * <li>{@link CommonDataKinds.Relation Relation.CONTENT_ITEM_TYPE}</li>
David Brown846eb302010-08-23 17:40:51 -07004573 * <li>{@link CommonDataKinds.SipAddress SipAddress.CONTENT_ITEM_TYPE}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004574 * </ul>
4575 * </p>
4576 * </td>
4577 * </tr>
4578 * <tr>
4579 * <td>long</td>
4580 * <td>{@link #RAW_CONTACT_ID}</td>
4581 * <td>read/write-once</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08004582 * <td>The id of the row in the {@link RawContacts} table that this data belongs to.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004583 * </tr>
4584 * <tr>
4585 * <td>int</td>
4586 * <td>{@link #IS_PRIMARY}</td>
4587 * <td>read/write</td>
4588 * <td>Whether this is the primary entry of its kind for the raw contact it belongs to.
Tom O'Neill244327e22010-01-08 11:11:15 -08004589 * "1" if true, "0" if false.
4590 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004591 * </tr>
4592 * <tr>
4593 * <td>int</td>
4594 * <td>{@link #IS_SUPER_PRIMARY}</td>
4595 * <td>read/write</td>
4596 * <td>Whether this is the primary entry of its kind for the aggregate
4597 * contact it belongs to. Any data record that is "super primary" must
Tom O'Neill244327e22010-01-08 11:11:15 -08004598 * also be "primary". For example, the super-primary entry may be
4599 * interpreted as the default contact value of its kind (for example,
4600 * the default phone number to use for the contact).</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004601 * </tr>
4602 * <tr>
4603 * <td>int</td>
4604 * <td>{@link #DATA_VERSION}</td>
4605 * <td>read-only</td>
4606 * <td>The version of this data record. Whenever the data row changes
4607 * the version goes up. This value is monotonically increasing.</td>
4608 * </tr>
4609 * <tr>
4610 * <td>Any type</td>
4611 * <td>
4612 * {@link #DATA1}<br>
4613 * {@link #DATA2}<br>
4614 * {@link #DATA3}<br>
4615 * {@link #DATA4}<br>
4616 * {@link #DATA5}<br>
4617 * {@link #DATA6}<br>
4618 * {@link #DATA7}<br>
4619 * {@link #DATA8}<br>
4620 * {@link #DATA9}<br>
4621 * {@link #DATA10}<br>
4622 * {@link #DATA11}<br>
4623 * {@link #DATA12}<br>
4624 * {@link #DATA13}<br>
4625 * {@link #DATA14}<br>
4626 * {@link #DATA15}
4627 * </td>
4628 * <td>read/write</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08004629 * <td>
4630 * <p>
4631 * Generic data columns. The meaning of each column is determined by the
4632 * {@link #MIMETYPE}. By convention, {@link #DATA15} is used for storing
4633 * BLOBs (binary data).
4634 * </p>
4635 * <p>
4636 * Data columns whose meaning is not explicitly defined for a given MIMETYPE
4637 * should not be used. There is no guarantee that any sync adapter will
4638 * preserve them. Sync adapters themselves should not use such columns either,
4639 * but should instead use {@link #SYNC1}-{@link #SYNC4}.
4640 * </p>
4641 * </td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004642 * </tr>
4643 * <tr>
4644 * <td>Any type</td>
4645 * <td>
4646 * {@link #SYNC1}<br>
4647 * {@link #SYNC2}<br>
4648 * {@link #SYNC3}<br>
4649 * {@link #SYNC4}
4650 * </td>
4651 * <td>read/write</td>
4652 * <td>Generic columns for use by sync adapters. For example, a Photo row
4653 * may store the image URL in SYNC1, a status (not loaded, loading, loaded, error)
4654 * in SYNC2, server-side version number in SYNC3 and error code in SYNC4.</td>
4655 * </tr>
4656 * </table>
4657 *
Tom O'Neill244327e22010-01-08 11:11:15 -08004658 * <p>
4659 * Some columns from the most recent associated status update are also available
4660 * through an implicit join.
4661 * </p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004662 * <table class="jd-sumtable">
4663 * <tr>
4664 * <th colspan='4'>Join with {@link StatusUpdates}</th>
4665 * </tr>
4666 * <tr>
4667 * <td style="width: 7em;">int</td>
4668 * <td style="width: 20em;">{@link #PRESENCE}</td>
4669 * <td style="width: 5em;">read-only</td>
4670 * <td>IM presence status linked to this data row. Compare with
4671 * {@link #CONTACT_PRESENCE}, which contains the contact's presence across
4672 * all IM rows. See {@link StatusUpdates} for individual status definitions.
4673 * The provider may choose not to store this value
4674 * in persistent storage. The expectation is that presence status will be
kmccormick50e27c82013-03-28 16:33:11 -07004675 * updated on a regular basis.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004676 * </td>
4677 * </tr>
4678 * <tr>
4679 * <td>String</td>
4680 * <td>{@link #STATUS}</td>
4681 * <td>read-only</td>
4682 * <td>Latest status update linked with this data row.</td>
4683 * </tr>
4684 * <tr>
4685 * <td>long</td>
4686 * <td>{@link #STATUS_TIMESTAMP}</td>
4687 * <td>read-only</td>
4688 * <td>The absolute time in milliseconds when the latest status was
4689 * inserted/updated for this data row.</td>
4690 * </tr>
4691 * <tr>
4692 * <td>String</td>
4693 * <td>{@link #STATUS_RES_PACKAGE}</td>
4694 * <td>read-only</td>
4695 * <td>The package containing resources for this status: label and icon.</td>
4696 * </tr>
4697 * <tr>
4698 * <td>long</td>
4699 * <td>{@link #STATUS_LABEL}</td>
4700 * <td>read-only</td>
4701 * <td>The resource ID of the label describing the source of status update linked
4702 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4703 * </tr>
4704 * <tr>
4705 * <td>long</td>
4706 * <td>{@link #STATUS_ICON}</td>
4707 * <td>read-only</td>
4708 * <td>The resource ID of the icon for the source of the status update linked
4709 * to this data row. This resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
4710 * </tr>
4711 * </table>
4712 *
4713 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004714 * Some columns from the associated raw contact are also available through an
4715 * implicit join. The other columns are excluded as uninteresting in this
4716 * context.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004717 * </p>
4718 *
4719 * <table class="jd-sumtable">
4720 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08004721 * <th colspan='4'>Join with {@link ContactsContract.RawContacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004722 * </tr>
4723 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08004724 * <td style="width: 7em;">long</td>
4725 * <td style="width: 20em;">{@link #CONTACT_ID}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004726 * <td style="width: 5em;">read-only</td>
Tom O'Neill244327e22010-01-08 11:11:15 -08004727 * <td>The id of the row in the {@link Contacts} table that this data belongs
4728 * to.</td>
4729 * </tr>
4730 * <tr>
4731 * <td>int</td>
4732 * <td>{@link #AGGREGATION_MODE}</td>
4733 * <td>read-only</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004734 * <td>See {@link RawContacts}.</td>
4735 * </tr>
4736 * <tr>
4737 * <td>int</td>
4738 * <td>{@link #DELETED}</td>
4739 * <td>read-only</td>
4740 * <td>See {@link RawContacts}.</td>
4741 * </tr>
4742 * </table>
4743 *
4744 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004745 * The ID column for the associated aggregated contact table
4746 * {@link ContactsContract.Contacts} is available
4747 * via the implicit join to the {@link RawContacts} table, see above.
4748 * The remaining columns from this table are also
4749 * available, through an implicit join. This
4750 * facilitates lookup by
4751 * the value of a single data element, such as the email address.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004752 * </p>
4753 *
4754 * <table class="jd-sumtable">
4755 * <tr>
Tom O'Neill244327e22010-01-08 11:11:15 -08004756 * <th colspan='4'>Join with {@link ContactsContract.Contacts}</th>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004757 * </tr>
4758 * <tr>
4759 * <td style="width: 7em;">String</td>
4760 * <td style="width: 20em;">{@link #LOOKUP_KEY}</td>
4761 * <td style="width: 5em;">read-only</td>
4762 * <td>See {@link ContactsContract.Contacts}</td>
4763 * </tr>
4764 * <tr>
4765 * <td>String</td>
4766 * <td>{@link #DISPLAY_NAME}</td>
4767 * <td>read-only</td>
4768 * <td>See {@link ContactsContract.Contacts}</td>
4769 * </tr>
4770 * <tr>
4771 * <td>long</td>
4772 * <td>{@link #PHOTO_ID}</td>
4773 * <td>read-only</td>
4774 * <td>See {@link ContactsContract.Contacts}.</td>
4775 * </tr>
4776 * <tr>
4777 * <td>int</td>
4778 * <td>{@link #IN_VISIBLE_GROUP}</td>
4779 * <td>read-only</td>
4780 * <td>See {@link ContactsContract.Contacts}.</td>
4781 * </tr>
4782 * <tr>
4783 * <td>int</td>
4784 * <td>{@link #HAS_PHONE_NUMBER}</td>
4785 * <td>read-only</td>
4786 * <td>See {@link ContactsContract.Contacts}.</td>
4787 * </tr>
4788 * <tr>
4789 * <td>int</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004790 * <td>{@link #STARRED}</td>
4791 * <td>read-only</td>
4792 * <td>See {@link ContactsContract.Contacts}.</td>
4793 * </tr>
4794 * <tr>
4795 * <td>String</td>
4796 * <td>{@link #CUSTOM_RINGTONE}</td>
4797 * <td>read-only</td>
4798 * <td>See {@link ContactsContract.Contacts}.</td>
4799 * </tr>
4800 * <tr>
4801 * <td>int</td>
4802 * <td>{@link #SEND_TO_VOICEMAIL}</td>
4803 * <td>read-only</td>
4804 * <td>See {@link ContactsContract.Contacts}.</td>
4805 * </tr>
4806 * <tr>
4807 * <td>int</td>
4808 * <td>{@link #CONTACT_PRESENCE}</td>
4809 * <td>read-only</td>
4810 * <td>See {@link ContactsContract.Contacts}.</td>
4811 * </tr>
4812 * <tr>
4813 * <td>String</td>
4814 * <td>{@link #CONTACT_STATUS}</td>
4815 * <td>read-only</td>
4816 * <td>See {@link ContactsContract.Contacts}.</td>
4817 * </tr>
4818 * <tr>
4819 * <td>long</td>
4820 * <td>{@link #CONTACT_STATUS_TIMESTAMP}</td>
4821 * <td>read-only</td>
4822 * <td>See {@link ContactsContract.Contacts}.</td>
4823 * </tr>
4824 * <tr>
4825 * <td>String</td>
4826 * <td>{@link #CONTACT_STATUS_RES_PACKAGE}</td>
4827 * <td>read-only</td>
4828 * <td>See {@link ContactsContract.Contacts}.</td>
4829 * </tr>
4830 * <tr>
4831 * <td>long</td>
4832 * <td>{@link #CONTACT_STATUS_LABEL}</td>
4833 * <td>read-only</td>
4834 * <td>See {@link ContactsContract.Contacts}.</td>
4835 * </tr>
4836 * <tr>
4837 * <td>long</td>
4838 * <td>{@link #CONTACT_STATUS_ICON}</td>
4839 * <td>read-only</td>
4840 * <td>See {@link ContactsContract.Contacts}.</td>
4841 * </tr>
4842 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07004843 */
Yorke Lee94c87612014-07-18 18:57:17 -07004844 public final static class Data implements DataColumnsWithJoins, ContactCounts {
Evan Millar088b2912009-05-28 15:24:37 -07004845 /**
4846 * This utility class cannot be instantiated
4847 */
4848 private Data() {}
4849
4850 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004851 * The content:// style URI for this table, which requests a directory
4852 * of data rows matching the selection criteria.
Evan Millar088b2912009-05-28 15:24:37 -07004853 */
4854 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
4855
4856 /**
Ricky Waifa5bbaf2015-02-26 16:51:32 +00004857 * The content:// style URI for this table in managed profile, which requests a directory
4858 * of data rows matching the selection criteria.
4859 *
4860 * @hide
4861 */
4862 static final Uri ENTERPRISE_CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
4863 "data_enterprise");
4864
4865 /**
Yorke Lee4f401eb2013-03-06 17:17:17 -08004866 * A boolean parameter for {@link Data#CONTENT_URI}.
4867 * This specifies whether or not the returned data items should be filtered to show
4868 * data items belonging to visible contacts only.
4869 */
4870 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
4871
4872 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004873 * The MIME type of the results from {@link #CONTENT_URI}.
Evan Millar088b2912009-05-28 15:24:37 -07004874 */
4875 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004876
4877 /**
Tom O'Neill244327e22010-01-08 11:11:15 -08004878 * <p>
Jeff Hamiltonf8526982009-09-24 11:34:58 -05004879 * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
4880 * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004881 * entry of the given {@link ContactsContract.Data} entry.
Tom O'Neill244327e22010-01-08 11:11:15 -08004882 * </p>
4883 * <p>
4884 * Returns the Uri for the contact in the first entry returned by
4885 * {@link ContentResolver#query(Uri, String[], String, String[], String)}
4886 * for the provided {@code dataUri}. If the query returns null or empty
4887 * results, silently returns null.
4888 * </p>
Jeff Sharkey6449eb02009-09-16 21:41:51 -07004889 */
4890 public static Uri getContactLookupUri(ContentResolver resolver, Uri dataUri) {
4891 final Cursor cursor = resolver.query(dataUri, new String[] {
4892 RawContacts.CONTACT_ID, Contacts.LOOKUP_KEY
4893 }, null, null, null);
4894
4895 Uri lookupUri = null;
4896 try {
4897 if (cursor != null && cursor.moveToFirst()) {
4898 final long contactId = cursor.getLong(0);
4899 final String lookupKey = cursor.getString(1);
4900 return Contacts.getLookupUri(contactId, lookupKey);
4901 }
4902 } finally {
4903 if (cursor != null) cursor.close();
4904 }
4905 return lookupUri;
4906 }
Evan Millar088b2912009-05-28 15:24:37 -07004907 }
4908
Fred Quintana5bba6322009-10-05 14:21:12 -07004909 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004910 * <p>
Tom O'Neill244327e22010-01-08 11:11:15 -08004911 * Constants for the raw contacts entities table, which can be thought of as
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08004912 * an outer join of the raw_contacts table with the data table. It is a strictly
4913 * read-only table.
4914 * </p>
4915 * <p>
4916 * If a raw contact has data rows, the RawContactsEntity cursor will contain
4917 * a one row for each data row. If the raw contact has no data rows, the
4918 * cursor will still contain one row with the raw contact-level information
4919 * and nulls for data columns.
4920 *
4921 * <pre>
4922 * Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId);
4923 * Cursor c = getContentResolver().query(entityUri,
4924 * new String[]{
4925 * RawContactsEntity.SOURCE_ID,
4926 * RawContactsEntity.DATA_ID,
4927 * RawContactsEntity.MIMETYPE,
4928 * RawContactsEntity.DATA1
4929 * }, null, null, null);
4930 * try {
4931 * while (c.moveToNext()) {
4932 * String sourceId = c.getString(0);
4933 * if (!c.isNull(1)) {
4934 * String mimeType = c.getString(2);
4935 * String data = c.getString(3);
4936 * ...
4937 * }
4938 * }
4939 * } finally {
4940 * c.close();
4941 * }
4942 * </pre>
4943 *
4944 * <h3>Columns</h3>
4945 * RawContactsEntity has a combination of RawContact and Data columns.
4946 *
4947 * <table class="jd-sumtable">
4948 * <tr>
4949 * <th colspan='4'>RawContacts</th>
4950 * </tr>
4951 * <tr>
4952 * <td style="width: 7em;">long</td>
4953 * <td style="width: 20em;">{@link #_ID}</td>
4954 * <td style="width: 5em;">read-only</td>
4955 * <td>Raw contact row ID. See {@link RawContacts}.</td>
4956 * </tr>
4957 * <tr>
4958 * <td>long</td>
4959 * <td>{@link #CONTACT_ID}</td>
4960 * <td>read-only</td>
4961 * <td>See {@link RawContacts}.</td>
4962 * </tr>
4963 * <tr>
4964 * <td>int</td>
4965 * <td>{@link #AGGREGATION_MODE}</td>
4966 * <td>read-only</td>
4967 * <td>See {@link RawContacts}.</td>
4968 * </tr>
4969 * <tr>
4970 * <td>int</td>
4971 * <td>{@link #DELETED}</td>
4972 * <td>read-only</td>
4973 * <td>See {@link RawContacts}.</td>
4974 * </tr>
4975 * </table>
4976 *
4977 * <table class="jd-sumtable">
4978 * <tr>
4979 * <th colspan='4'>Data</th>
4980 * </tr>
4981 * <tr>
4982 * <td style="width: 7em;">long</td>
4983 * <td style="width: 20em;">{@link #DATA_ID}</td>
4984 * <td style="width: 5em;">read-only</td>
4985 * <td>Data row ID. It will be null if the raw contact has no data rows.</td>
4986 * </tr>
4987 * <tr>
4988 * <td>String</td>
4989 * <td>{@link #MIMETYPE}</td>
4990 * <td>read-only</td>
4991 * <td>See {@link ContactsContract.Data}.</td>
4992 * </tr>
4993 * <tr>
4994 * <td>int</td>
4995 * <td>{@link #IS_PRIMARY}</td>
4996 * <td>read-only</td>
4997 * <td>See {@link ContactsContract.Data}.</td>
4998 * </tr>
4999 * <tr>
5000 * <td>int</td>
5001 * <td>{@link #IS_SUPER_PRIMARY}</td>
5002 * <td>read-only</td>
5003 * <td>See {@link ContactsContract.Data}.</td>
5004 * </tr>
5005 * <tr>
5006 * <td>int</td>
5007 * <td>{@link #DATA_VERSION}</td>
5008 * <td>read-only</td>
5009 * <td>See {@link ContactsContract.Data}.</td>
5010 * </tr>
5011 * <tr>
5012 * <td>Any type</td>
5013 * <td>
5014 * {@link #DATA1}<br>
5015 * {@link #DATA2}<br>
5016 * {@link #DATA3}<br>
5017 * {@link #DATA4}<br>
5018 * {@link #DATA5}<br>
5019 * {@link #DATA6}<br>
5020 * {@link #DATA7}<br>
5021 * {@link #DATA8}<br>
5022 * {@link #DATA9}<br>
5023 * {@link #DATA10}<br>
5024 * {@link #DATA11}<br>
5025 * {@link #DATA12}<br>
5026 * {@link #DATA13}<br>
5027 * {@link #DATA14}<br>
5028 * {@link #DATA15}
5029 * </td>
5030 * <td>read-only</td>
5031 * <td>See {@link ContactsContract.Data}.</td>
5032 * </tr>
5033 * <tr>
5034 * <td>Any type</td>
5035 * <td>
5036 * {@link #SYNC1}<br>
5037 * {@link #SYNC2}<br>
5038 * {@link #SYNC3}<br>
5039 * {@link #SYNC4}
5040 * </td>
5041 * <td>read-only</td>
5042 * <td>See {@link ContactsContract.Data}.</td>
5043 * </tr>
5044 * </table>
Fred Quintana5bba6322009-10-05 14:21:12 -07005045 */
5046 public final static class RawContactsEntity
5047 implements BaseColumns, DataColumns, RawContactsColumns {
5048 /**
5049 * This utility class cannot be instantiated
5050 */
5051 private RawContactsEntity() {}
5052
5053 /**
5054 * The content:// style URI for this table
5055 */
5056 public static final Uri CONTENT_URI =
5057 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities");
5058
5059 /**
Ricky Wai9aaaa1e2015-03-08 00:53:20 +00005060 * The content:// style URI for this table in corp profile
5061 *
5062 * @hide
5063 */
Philip P. Moltmann33115152018-04-11 13:39:36 -07005064 @TestApi
Ricky Wai9aaaa1e2015-03-08 00:53:20 +00005065 public static final Uri CORP_CONTENT_URI =
5066 Uri.withAppendedPath(AUTHORITY_URI, "raw_contact_entities_corp");
5067
5068 /**
Dave Santoro2b4d0752011-09-07 17:37:33 -07005069 * The content:// style URI for this table, specific to the user's profile.
5070 */
5071 public static final Uri PROFILE_CONTENT_URI =
5072 Uri.withAppendedPath(Profile.CONTENT_URI, "raw_contact_entities");
5073
5074 /**
Fred Quintana5bba6322009-10-05 14:21:12 -07005075 * The MIME type of {@link #CONTENT_URI} providing a directory of raw contact entities.
5076 */
5077 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/raw_contact_entity";
5078
5079 /**
5080 * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
5081 * Data.CONTENT_URI contains only exportable data.
5082 *
5083 * This flag is useful (currently) only for vCard exporter in Contacts app, which
5084 * needs to exclude "un-exportable" data from available data to export, while
5085 * Contacts app itself has priviledge to access all data including "un-expotable"
5086 * ones and providers return all of them regardless of the callers' intention.
5087 * <P>Type: INTEGER</p>
5088 *
5089 * @hide Maybe available only in Eclair and not really ready for public use.
5090 * TODO: remove, or implement this feature completely. As of now (Eclair),
5091 * we only use this flag in queryEntities(), not query().
5092 */
5093 public static final String FOR_EXPORT_ONLY = "for_export_only";
5094
5095 /**
5096 * The ID of the data column. The value will be null if this raw contact has no data rows.
5097 * <P>Type: INTEGER</P>
5098 */
5099 public static final String DATA_ID = "data_id";
5100 }
5101
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005102 /**
5103 * @see PhoneLookup
5104 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005105 protected interface PhoneLookupColumns {
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005106 /**
Tony Makfd9ec5a2016-02-17 14:11:52 +00005107 * The ID of the data row.
5108 * <P>Type: INTEGER</P>
5109 */
5110 public static final String DATA_ID = "data_id";
5111 /**
5112 * A reference to the {@link ContactsContract.Contacts#_ID} that this
5113 * data belongs to.
5114 * <P>Type: INTEGER</P>
5115 */
5116 public static final String CONTACT_ID = "contact_id";
5117 /**
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005118 * The phone number as the user entered it.
5119 * <P>Type: TEXT</P>
5120 */
5121 public static final String NUMBER = "number";
5122
5123 /**
5124 * The type of phone number, for example Home or Work.
5125 * <P>Type: INTEGER</P>
5126 */
5127 public static final String TYPE = "type";
5128
5129 /**
5130 * The user defined label for the phone number.
5131 * <P>Type: TEXT</P>
5132 */
5133 public static final String LABEL = "label";
Bai Tao224744c2010-08-31 09:59:13 +08005134
5135 /**
5136 * The phone number's E164 representation.
5137 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08005138 */
5139 public static final String NORMALIZED_NUMBER = "normalized_number";
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005140 }
5141
Evan Millar088b2912009-05-28 15:24:37 -07005142 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005143 * A table that represents the result of looking up a phone number, for
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005144 * example for caller ID. To perform a lookup you must append the number you
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005145 * want to find to {@link #CONTENT_FILTER_URI}. This query is highly
5146 * optimized.
5147 * <pre>
5148 * Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
5149 * resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
5150 * </pre>
5151 *
5152 * <h3>Columns</h3>
5153 *
5154 * <table class="jd-sumtable">
5155 * <tr>
5156 * <th colspan='4'>PhoneLookup</th>
5157 * </tr>
5158 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005159 * <td>String</td>
5160 * <td>{@link #NUMBER}</td>
5161 * <td>read-only</td>
5162 * <td>Phone number.</td>
5163 * </tr>
5164 * <tr>
5165 * <td>String</td>
5166 * <td>{@link #TYPE}</td>
5167 * <td>read-only</td>
5168 * <td>Phone number type. See {@link CommonDataKinds.Phone}.</td>
5169 * </tr>
5170 * <tr>
5171 * <td>String</td>
5172 * <td>{@link #LABEL}</td>
5173 * <td>read-only</td>
5174 * <td>Custom label for the phone number. See {@link CommonDataKinds.Phone}.</td>
5175 * </tr>
5176 * </table>
5177 * <p>
5178 * Columns from the Contacts table are also available through a join.
5179 * </p>
5180 * <table class="jd-sumtable">
5181 * <tr>
5182 * <th colspan='4'>Join with {@link Contacts}</th>
5183 * </tr>
5184 * <tr>
Dmitri Plotnikov817b3f92011-01-09 17:07:13 -08005185 * <td>long</td>
5186 * <td>{@link #_ID}</td>
5187 * <td>read-only</td>
5188 * <td>Contact ID.</td>
5189 * </tr>
5190 * <tr>
Tony Makfd9ec5a2016-02-17 14:11:52 +00005191 * <td>long</td>
5192 * <td>{@link #CONTACT_ID}</td>
5193 * <td>read-only</td>
5194 * <td>Contact ID.</td>
5195 * </tr>
5196 * <tr>
5197 * <td>long</td>
5198 * <td>{@link #DATA_ID}</td>
5199 * <td>read-only</td>
5200 * <td>Data ID.</td>
5201 * </tr>
5202 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005203 * <td>String</td>
5204 * <td>{@link #LOOKUP_KEY}</td>
5205 * <td>read-only</td>
5206 * <td>See {@link ContactsContract.Contacts}</td>
5207 * </tr>
5208 * <tr>
5209 * <td>String</td>
5210 * <td>{@link #DISPLAY_NAME}</td>
5211 * <td>read-only</td>
5212 * <td>See {@link ContactsContract.Contacts}</td>
5213 * </tr>
5214 * <tr>
5215 * <td>long</td>
5216 * <td>{@link #PHOTO_ID}</td>
5217 * <td>read-only</td>
5218 * <td>See {@link ContactsContract.Contacts}.</td>
5219 * </tr>
5220 * <tr>
5221 * <td>int</td>
5222 * <td>{@link #IN_VISIBLE_GROUP}</td>
5223 * <td>read-only</td>
5224 * <td>See {@link ContactsContract.Contacts}.</td>
5225 * </tr>
5226 * <tr>
5227 * <td>int</td>
5228 * <td>{@link #HAS_PHONE_NUMBER}</td>
5229 * <td>read-only</td>
5230 * <td>See {@link ContactsContract.Contacts}.</td>
5231 * </tr>
5232 * <tr>
5233 * <td>int</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005234 * <td>{@link #STARRED}</td>
5235 * <td>read-only</td>
5236 * <td>See {@link ContactsContract.Contacts}.</td>
5237 * </tr>
5238 * <tr>
5239 * <td>String</td>
5240 * <td>{@link #CUSTOM_RINGTONE}</td>
5241 * <td>read-only</td>
5242 * <td>See {@link ContactsContract.Contacts}.</td>
5243 * </tr>
5244 * <tr>
5245 * <td>int</td>
5246 * <td>{@link #SEND_TO_VOICEMAIL}</td>
5247 * <td>read-only</td>
5248 * <td>See {@link ContactsContract.Contacts}.</td>
5249 * </tr>
5250 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005251 */
Dmitri Plotnikov93032952009-08-19 11:26:57 -07005252 public static final class PhoneLookup implements BaseColumns, PhoneLookupColumns,
Suprabh Shukla2c3fb3f2016-09-06 15:30:53 -07005253 ContactsColumns, ContactOptionsColumns, ContactNameColumns {
Evan Millar088b2912009-05-28 15:24:37 -07005254 /**
5255 * This utility class cannot be instantiated
5256 */
5257 private PhoneLookup() {}
5258
5259 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07005260 * The content:// style URI for this table.
5261 *
5262 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
5263 * sorts results based on contacts frequency. For more information, see the
5264 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
5265 * page.
5266 *
5267 * Append the phone number you want to lookup
Evan Millar088b2912009-05-28 15:24:37 -07005268 * to this URI and query it to perform a lookup. For example:
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005269 * <pre>
Scott Kennedy7ed189e2013-01-11 22:31:43 -08005270 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
5271 * Uri.encode(phoneNumber));
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005272 * </pre>
Evan Millar088b2912009-05-28 15:24:37 -07005273 */
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005274 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5275 "phone_lookup");
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005276
5277 /**
Ricky Wai323b30e2015-02-27 14:58:00 +00005278 * <p>URI used for the "enterprise caller-id".</p>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005279 *
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07005280 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
5281 * sorts results based on contacts frequency. For more information, see the
5282 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
5283 * page.
5284 *
Ricky Wai323b30e2015-02-27 14:58:00 +00005285 * <p>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005286 * It supports the same semantics as {@link #CONTENT_FILTER_URI} and returns the same
5287 * columns. If the device has no corp profile that is linked to the current profile, it
5288 * behaves in the exact same way as {@link #CONTENT_FILTER_URI}. If there is a corp profile
5289 * linked to the current profile, it first queries against the personal contact database,
5290 * and if no matching contacts are found there, then queries against the
5291 * corp contacts database.
Ricky Wai323b30e2015-02-27 14:58:00 +00005292 * </p>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005293 * <p>
5294 * If a result is from the corp profile, it makes the following changes to the data:
5295 * <ul>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005296 * <li>
5297 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
5298 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
5299 * load pictures from them.
Makoto Onuki80b3ab62014-07-10 11:24:21 -07005300 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not use them.
5301 * </li>
5302 * <li>
5303 * Corp contacts will get artificial {@link #_ID}s. In order to tell whether a contact
Makoto Onuki0e917332014-08-26 14:06:30 -07005304 * is from the corp profile, use
5305 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005306 * </li>
Makoto Onuki1040da12015-03-19 11:24:00 -07005307 * <li>
5308 * Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
5309 * </li>
Tony Mak935dafe2016-03-07 20:27:53 +00005310 * <li>
5311 * Returned work contact IDs and lookup keys are not accepted in places that not
5312 * explicitly say to accept them.
5313 * </li>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005314 * </ul>
Makoto Onuki95a9cfb2014-07-08 17:11:54 -07005315 * <p>
Makoto Onuki1040da12015-03-19 11:24:00 -07005316 * A contact lookup URL built by
5317 * {@link ContactsContract.Contacts#getLookupUri(long, String)}
5318 * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
5319 * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
5320 * corp profile.
5321 * </p>
Makoto Onuki31cd6f72014-07-08 15:20:39 -07005322 *
5323 * <pre>
5324 * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
5325 * Uri.encode(phoneNumber));
5326 * </pre>
5327 */
5328 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
5329 "phone_lookup_enterprise");
5330
5331 /**
Dmitri Plotnikov0b0b8a82010-03-04 18:20:08 -08005332 * The MIME type of {@link #CONTENT_FILTER_URI} providing a directory of phone lookup rows.
5333 *
5334 * @hide
5335 */
5336 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_lookup";
Flavio Lerda52c01c22011-11-02 22:16:23 +00005337
Yorke Lee217d8a72013-11-27 10:14:04 -08005338 /**
5339 * If this boolean parameter is set to true, then the appended query is treated as a
5340 * SIP address and the lookup will be performed against SIP addresses in the user's
5341 * contacts.
5342 */
Flavio Lerda52c01c22011-11-02 22:16:23 +00005343 public static final String QUERY_PARAMETER_SIP_ADDRESS = "sip";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005344 }
5345
5346 /**
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005347 * Additional data mixed in with {@link StatusColumns} to link
5348 * back to specific {@link ContactsContract.Data#_ID} entries.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005349 *
5350 * @see StatusUpdates
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005351 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005352 protected interface PresenceColumns {
Dmitri Plotnikov55048a92009-07-24 10:25:34 -07005353
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005354 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005355 * Reference to the {@link Data#_ID} entry that owns this presence.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005356 * <P>Type: INTEGER</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005357 */
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07005358 public static final String DATA_ID = "presence_data_id";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005359
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005360 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005361 * See {@link CommonDataKinds.Im} for a list of defined protocol constants.
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07005362 * <p>Type: NUMBER</p>
5363 */
5364 public static final String PROTOCOL = "protocol";
5365
5366 /**
5367 * Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5368 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5369 * omitted if {@link #PROTOCOL} value is not
5370 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.
5371 *
5372 * <p>Type: NUMBER</p>
5373 */
5374 public static final String CUSTOM_PROTOCOL = "custom_protocol";
5375
5376 /**
5377 * The IM handle the presence item is for. The handle is scoped to
5378 * {@link #PROTOCOL}.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005379 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005380 */
5381 public static final String IM_HANDLE = "im_handle";
5382
5383 /**
5384 * The IM account for the local user that the presence data came from.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005385 * <P>Type: TEXT</P>
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005386 */
5387 public static final String IM_ACCOUNT = "im_account";
5388 }
5389
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005390 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005391 * <p>
5392 * A status update is linked to a {@link ContactsContract.Data} row and captures
5393 * the user's latest status update via the corresponding source, e.g.
5394 * "Having lunch" via "Google Talk".
5395 * </p>
5396 * <p>
5397 * There are two ways a status update can be inserted: by explicitly linking
5398 * it to a Data row using {@link #DATA_ID} or indirectly linking it to a data row
5399 * using a combination of {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5400 * {@link #IM_HANDLE}. There is no difference between insert and update, you can use
5401 * either.
5402 * </p>
5403 * <p>
Dave Santoro063084e2011-08-23 15:42:49 -07005404 * Inserting or updating a status update for the user's profile requires either using
5405 * the {@link #DATA_ID} to identify the data row to attach the update to, or
5406 * {@link StatusUpdates#PROFILE_CONTENT_URI} to ensure that the change is scoped to the
5407 * profile.
5408 * </p>
5409 * <p>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005410 * You cannot use {@link ContentResolver#update} to change a status, but
5411 * {@link ContentResolver#insert} will replace the latests status if it already
5412 * exists.
5413 * </p>
5414 * <p>
5415 * Use {@link ContentResolver#bulkInsert(Uri, ContentValues[])} to insert/update statuses
5416 * for multiple contacts at once.
5417 * </p>
5418 *
5419 * <h3>Columns</h3>
5420 * <table class="jd-sumtable">
5421 * <tr>
5422 * <th colspan='4'>StatusUpdates</th>
5423 * </tr>
5424 * <tr>
5425 * <td>long</td>
5426 * <td>{@link #DATA_ID}</td>
5427 * <td>read/write</td>
5428 * <td>Reference to the {@link Data#_ID} entry that owns this presence. If this
5429 * field is <i>not</i> specified, the provider will attempt to find a data row
5430 * that matches the {@link #PROTOCOL} (or {@link #CUSTOM_PROTOCOL}) and
5431 * {@link #IM_HANDLE} columns.
5432 * </td>
5433 * </tr>
5434 * <tr>
5435 * <td>long</td>
5436 * <td>{@link #PROTOCOL}</td>
5437 * <td>read/write</td>
5438 * <td>See {@link CommonDataKinds.Im} for a list of defined protocol constants.</td>
5439 * </tr>
5440 * <tr>
5441 * <td>String</td>
5442 * <td>{@link #CUSTOM_PROTOCOL}</td>
5443 * <td>read/write</td>
5444 * <td>Name of the custom protocol. Should be supplied along with the {@link #PROTOCOL} value
5445 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}. Should be null or
5446 * omitted if {@link #PROTOCOL} value is not
5447 * {@link ContactsContract.CommonDataKinds.Im#PROTOCOL_CUSTOM}.</td>
5448 * </tr>
5449 * <tr>
5450 * <td>String</td>
5451 * <td>{@link #IM_HANDLE}</td>
5452 * <td>read/write</td>
5453 * <td> The IM handle the presence item is for. The handle is scoped to
5454 * {@link #PROTOCOL}.</td>
5455 * </tr>
5456 * <tr>
5457 * <td>String</td>
5458 * <td>{@link #IM_ACCOUNT}</td>
5459 * <td>read/write</td>
5460 * <td>The IM account for the local user that the presence data came from.</td>
5461 * </tr>
5462 * <tr>
5463 * <td>int</td>
5464 * <td>{@link #PRESENCE}</td>
5465 * <td>read/write</td>
5466 * <td>Contact IM presence status. The allowed values are:
5467 * <p>
5468 * <ul>
5469 * <li>{@link #OFFLINE}</li>
5470 * <li>{@link #INVISIBLE}</li>
5471 * <li>{@link #AWAY}</li>
5472 * <li>{@link #IDLE}</li>
5473 * <li>{@link #DO_NOT_DISTURB}</li>
5474 * <li>{@link #AVAILABLE}</li>
5475 * </ul>
5476 * </p>
5477 * <p>
5478 * Since presence status is inherently volatile, the content provider
5479 * may choose not to store this field in long-term storage.
5480 * </p>
5481 * </td>
5482 * </tr>
5483 * <tr>
Vasu Nori5b31498ba12010-07-12 15:13:37 -07005484 * <td>int</td>
5485 * <td>{@link #CHAT_CAPABILITY}</td>
5486 * <td>read/write</td>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005487 * <td>Contact IM chat compatibility value. The allowed values combinations of the following
5488 * flags. If None of these flags is set, the device can only do text messaging.
Vasu Nori5b31498ba12010-07-12 15:13:37 -07005489 * <p>
5490 * <ul>
Daniel Lehmannb3327472010-08-13 15:16:11 -07005491 * <li>{@link #CAPABILITY_HAS_VIDEO}</li>
Vasu Nori5b31498ba12010-07-12 15:13:37 -07005492 * <li>{@link #CAPABILITY_HAS_VOICE}</li>
5493 * <li>{@link #CAPABILITY_HAS_CAMERA}</li>
5494 * </ul>
5495 * </p>
5496 * <p>
5497 * Since chat compatibility is inherently volatile as the contact's availability moves from
5498 * one device to another, the content provider may choose not to store this field in long-term
5499 * storage.
5500 * </p>
5501 * </td>
5502 * </tr>
5503 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005504 * <td>String</td>
5505 * <td>{@link #STATUS}</td>
5506 * <td>read/write</td>
5507 * <td>Contact's latest status update, e.g. "having toast for breakfast"</td>
5508 * </tr>
5509 * <tr>
5510 * <td>long</td>
5511 * <td>{@link #STATUS_TIMESTAMP}</td>
5512 * <td>read/write</td>
5513 * <td>The absolute time in milliseconds when the status was
5514 * entered by the user. If this value is not provided, the provider will follow
5515 * this logic: if there was no prior status update, the value will be left as null.
5516 * If there was a prior status update, the provider will default this field
5517 * to the current time.</td>
5518 * </tr>
5519 * <tr>
5520 * <td>String</td>
5521 * <td>{@link #STATUS_RES_PACKAGE}</td>
5522 * <td>read/write</td>
5523 * <td> The package containing resources for this status: label and icon.</td>
5524 * </tr>
5525 * <tr>
5526 * <td>long</td>
5527 * <td>{@link #STATUS_LABEL}</td>
5528 * <td>read/write</td>
5529 * <td>The resource ID of the label describing the source of contact status,
5530 * e.g. "Google Talk". This resource is scoped by the
5531 * {@link #STATUS_RES_PACKAGE}.</td>
5532 * </tr>
5533 * <tr>
5534 * <td>long</td>
5535 * <td>{@link #STATUS_ICON}</td>
5536 * <td>read/write</td>
5537 * <td>The resource ID of the icon for the source of contact status. This
5538 * resource is scoped by the {@link #STATUS_RES_PACKAGE}.</td>
5539 * </tr>
5540 * </table>
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005541 */
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005542 public static class StatusUpdates implements StatusColumns, PresenceColumns {
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005543
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005544 /**
5545 * This utility class cannot be instantiated
5546 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005547 private StatusUpdates() {}
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005548
5549 /**
5550 * The content:// style URI for this table
5551 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005552 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "status_updates");
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005553
5554 /**
Dave Santoro063084e2011-08-23 15:42:49 -07005555 * The content:// style URI for this table, specific to the user's profile.
5556 */
5557 public static final Uri PROFILE_CONTENT_URI =
5558 Uri.withAppendedPath(Profile.CONTENT_URI, "status_updates");
5559
5560 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005561 * Gets the resource ID for the proper presence icon.
5562 *
5563 * @param status the status to get the icon for
5564 * @return the resource ID for the proper presence icon
5565 */
5566 public static final int getPresenceIconResourceId(int status) {
5567 switch (status) {
5568 case AVAILABLE:
5569 return android.R.drawable.presence_online;
5570 case IDLE:
5571 case AWAY:
5572 return android.R.drawable.presence_away;
5573 case DO_NOT_DISTURB:
5574 return android.R.drawable.presence_busy;
5575 case INVISIBLE:
5576 return android.R.drawable.presence_invisible;
5577 case OFFLINE:
5578 default:
5579 return android.R.drawable.presence_offline;
5580 }
5581 }
5582
5583 /**
Evan Millarc0437522009-06-23 17:31:05 -07005584 * Returns the precedence of the status code the higher number being the higher precedence.
5585 *
5586 * @param status The status code.
5587 * @return An integer representing the precedence, 0 being the lowest.
5588 */
5589 public static final int getPresencePrecedence(int status) {
5590 // Keep this function here incase we want to enforce a different precedence than the
5591 // natural order of the status constants.
5592 return status;
5593 }
5594
5595 /**
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005596 * The MIME type of {@link #CONTENT_URI} providing a directory of
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005597 * status update details.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005598 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005599 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/status-update";
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005600
5601 /**
5602 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005603 * status update detail.
Jeff Sharkeyd530b3c2009-06-01 20:23:57 -07005604 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005605 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/status-update";
5606 }
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07005607
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005608 /**
5609 * @deprecated This old name was never meant to be made public. Do not use.
5610 */
Dmitri Plotnikov879664e2009-09-27 08:52:56 -07005611 @Deprecated
5612 public static final class Presence extends StatusUpdates {
5613
Evan Millar088b2912009-05-28 15:24:37 -07005614 }
5615
5616 /**
Yorke Lee8d370092014-06-26 10:32:17 -07005617 * Additional column returned by
5618 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI Contacts.CONTENT_FILTER_URI} explaining
Yorke Leeeaf094932014-07-01 10:28:56 -07005619 * why the filter matched the contact. This column will contain extracts from the contact's
5620 * constituent {@link Data Data} items, formatted in a way that indicates the section of the
5621 * snippet that matched the filter.
5622 *
5623 * <p>
5624 * The following example searches for all contacts that match the query "presi" and requests
5625 * the snippet column as well.
5626 * <pre>
5627 * Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
5628 * builder.appendPath("presi");
5629 * // Defer snippeting to the client side if possible, for performance reasons.
5630 * builder.appendQueryParameter(SearchSnippets.DEFERRED_SNIPPETING_KEY,"1");
5631 *
5632 * Cursor cursor = getContentResolver().query(builder.build());
5633 *
5634 * Bundle extras = cursor.getExtras();
5635 * if (extras.getBoolean(ContactsContract.DEFERRED_SNIPPETING)) {
5636 * // Do our own snippet formatting.
5637 * // For a contact with the email address (president@organization.com), the snippet
5638 * // column will contain the string "president@organization.com".
5639 * } else {
5640 * // The snippet has already been pre-formatted, we can display it as is.
5641 * // For a contact with the email address (president@organization.com), the snippet
5642 * // column will contain the string "[presi]dent@organization.com".
5643 * }
5644 * </pre>
5645 * </p>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005646 */
Yorke Leeeaf094932014-07-01 10:28:56 -07005647 public static class SearchSnippets {
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005648
5649 /**
Yorke Leeeaf094932014-07-01 10:28:56 -07005650 * The search snippet constructed by SQLite snippeting functionality.
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005651 * <p>
Yorke Leeeaf094932014-07-01 10:28:56 -07005652 * The snippet may contain (parts of) several data elements belonging to the contact,
5653 * with the matching parts optionally surrounded by special characters that indicate the
5654 * start and end of matching text.
5655 *
5656 * For example, if a contact has an address "123 Main Street", using a filter "mai" would
5657 * return the formatted snippet "123 [Mai]n street".
5658 *
5659 * @see <a href="http://www.sqlite.org/fts3.html#snippet">
5660 * http://www.sqlite.org/fts3.html#snippet</a>
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005661 */
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005662 public static final String SNIPPET = "snippet";
5663
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005664 /**
5665 * Comma-separated parameters for the generation of the snippet:
5666 * <ul>
Yorke Leeeaf094932014-07-01 10:28:56 -07005667 * <li>The "start match" text. Default is '['</li>
5668 * <li>The "end match" text. Default is ']'</li>
5669 * <li>The "ellipsis" text. Default is "..."</li>
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005670 * <li>Maximum number of tokens to include in the snippet. Can be either
5671 * a positive or a negative number: A positive number indicates how many
5672 * tokens can be returned in total. A negative number indicates how many
5673 * tokens can be returned per occurrence of the search terms.</li>
5674 * </ul>
Yorke Leeeaf094932014-07-01 10:28:56 -07005675 *
5676 * @hide
Dmitri Plotnikov123653b2011-02-08 16:31:20 -08005677 */
5678 public static final String SNIPPET_ARGS_PARAM_KEY = "snippet_args";
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005679
5680 /**
Yorke Leeeaf094932014-07-01 10:28:56 -07005681 * The key to ask the provider to defer the formatting of the snippet to the client if
5682 * possible, for performance reasons.
5683 * A value of 1 indicates true, 0 indicates false. False is the default.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005684 * When a cursor is returned to the client, it should check for an extra with the name
5685 * {@link ContactsContract#DEFERRED_SNIPPETING} in the cursor. If it exists, the client
Yorke Leeeaf094932014-07-01 10:28:56 -07005686 * should do its own formatting of the snippet. If it doesn't exist, the snippet column
5687 * in the cursor should already contain a formatted snippet.
Isaac Katzenelson9fe83f02011-09-02 17:58:28 -07005688 */
5689 public static final String DEFERRED_SNIPPETING_KEY = "deferred_snippeting";
Dmitri Plotnikov3ba8a3b2010-02-24 18:23:43 -08005690 }
5691
5692 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005693 * Container for definitions of common data types stored in the {@link ContactsContract.Data}
5694 * table.
Evan Millar088b2912009-05-28 15:24:37 -07005695 */
5696 public static final class CommonDataKinds {
5697 /**
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005698 * This utility class cannot be instantiated
5699 */
5700 private CommonDataKinds() {}
5701
5702 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005703 * The {@link Data#RES_PACKAGE} value for common data that should be
5704 * shown using a default style.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005705 *
5706 * @hide RES_PACKAGE is hidden
Evan Millar088b2912009-05-28 15:24:37 -07005707 */
5708 public static final String PACKAGE_COMMON = "common";
5709
5710 /**
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005711 * The base types that all "Typed" data kinds support.
5712 */
5713 public interface BaseTypes {
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005714 /**
5715 * A custom type. The custom label should be supplied by user.
5716 */
5717 public static int TYPE_CUSTOM = 0;
5718 }
5719
5720 /**
Evan Millar088b2912009-05-28 15:24:37 -07005721 * Columns common across the specific types.
5722 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07005723 protected interface CommonColumns extends BaseTypes {
Evan Millar088b2912009-05-28 15:24:37 -07005724 /**
Evan Millar088b2912009-05-28 15:24:37 -07005725 * The data for the contact method.
5726 * <P>Type: TEXT</P>
5727 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005728 public static final String DATA = DataColumns.DATA1;
5729
5730 /**
5731 * The type of data, for example Home or Work.
5732 * <P>Type: INTEGER</P>
5733 */
5734 public static final String TYPE = DataColumns.DATA2;
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005735
5736 /**
5737 * The user defined label for the the contact method.
5738 * <P>Type: TEXT</P>
5739 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005740 public static final String LABEL = DataColumns.DATA3;
Evan Millar088b2912009-05-28 15:24:37 -07005741 }
5742
5743 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005744 * A data kind representing the contact's proper name. You can use all
5745 * columns defined for {@link ContactsContract.Data} as well as the following aliases.
5746 *
5747 * <h2>Column aliases</h2>
5748 * <table class="jd-sumtable">
5749 * <tr>
5750 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5751 * </tr>
5752 * <tr>
5753 * <td>String</td>
5754 * <td>{@link #DISPLAY_NAME}</td>
5755 * <td>{@link #DATA1}</td>
5756 * <td></td>
5757 * </tr>
5758 * <tr>
5759 * <td>String</td>
5760 * <td>{@link #GIVEN_NAME}</td>
5761 * <td>{@link #DATA2}</td>
5762 * <td></td>
5763 * </tr>
5764 * <tr>
5765 * <td>String</td>
5766 * <td>{@link #FAMILY_NAME}</td>
5767 * <td>{@link #DATA3}</td>
5768 * <td></td>
5769 * </tr>
5770 * <tr>
5771 * <td>String</td>
5772 * <td>{@link #PREFIX}</td>
5773 * <td>{@link #DATA4}</td>
5774 * <td>Common prefixes in English names are "Mr", "Ms", "Dr" etc.</td>
5775 * </tr>
5776 * <tr>
5777 * <td>String</td>
5778 * <td>{@link #MIDDLE_NAME}</td>
5779 * <td>{@link #DATA5}</td>
5780 * <td></td>
5781 * </tr>
5782 * <tr>
5783 * <td>String</td>
5784 * <td>{@link #SUFFIX}</td>
5785 * <td>{@link #DATA6}</td>
5786 * <td>Common suffixes in English names are "Sr", "Jr", "III" etc.</td>
5787 * </tr>
5788 * <tr>
5789 * <td>String</td>
5790 * <td>{@link #PHONETIC_GIVEN_NAME}</td>
5791 * <td>{@link #DATA7}</td>
5792 * <td>Used for phonetic spelling of the name, e.g. Pinyin, Katakana, Hiragana</td>
5793 * </tr>
5794 * <tr>
5795 * <td>String</td>
5796 * <td>{@link #PHONETIC_MIDDLE_NAME}</td>
5797 * <td>{@link #DATA8}</td>
5798 * <td></td>
5799 * </tr>
5800 * <tr>
5801 * <td>String</td>
5802 * <td>{@link #PHONETIC_FAMILY_NAME}</td>
5803 * <td>{@link #DATA9}</td>
5804 * <td></td>
5805 * </tr>
5806 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005807 */
Yorke Lee94c87612014-07-18 18:57:17 -07005808 public static final class StructuredName implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005809 /**
5810 * This utility class cannot be instantiated
5811 */
Evan Millar088b2912009-05-28 15:24:37 -07005812 private StructuredName() {}
5813
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005814 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005815 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
5816
5817 /**
Evan Millar088b2912009-05-28 15:24:37 -07005818 * The name that should be used to display the contact.
Jeff Sharkey62b83b72009-08-11 17:33:48 -07005819 * <i>Unstructured component of the name should be consistent with
5820 * its structured representation.</i>
5821 * <p>
5822 * Type: TEXT
Evan Millar088b2912009-05-28 15:24:37 -07005823 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07005824 public static final String DISPLAY_NAME = DATA1;
5825
5826 /**
5827 * The given name for the contact.
5828 * <P>Type: TEXT</P>
5829 */
5830 public static final String GIVEN_NAME = DATA2;
5831
5832 /**
5833 * The family name for the contact.
5834 * <P>Type: TEXT</P>
5835 */
5836 public static final String FAMILY_NAME = DATA3;
5837
5838 /**
5839 * The contact's honorific prefix, e.g. "Sir"
5840 * <P>Type: TEXT</P>
5841 */
5842 public static final String PREFIX = DATA4;
5843
5844 /**
5845 * The contact's middle name
5846 * <P>Type: TEXT</P>
5847 */
5848 public static final String MIDDLE_NAME = DATA5;
5849
5850 /**
5851 * The contact's honorific suffix, e.g. "Jr"
5852 */
5853 public static final String SUFFIX = DATA6;
5854
5855 /**
5856 * The phonetic version of the given name for the contact.
5857 * <P>Type: TEXT</P>
5858 */
5859 public static final String PHONETIC_GIVEN_NAME = DATA7;
5860
5861 /**
5862 * The phonetic version of the additional name for the contact.
5863 * <P>Type: TEXT</P>
5864 */
5865 public static final String PHONETIC_MIDDLE_NAME = DATA8;
5866
5867 /**
5868 * The phonetic version of the family name for the contact.
5869 * <P>Type: TEXT</P>
5870 */
5871 public static final String PHONETIC_FAMILY_NAME = DATA9;
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005872
5873 /**
5874 * The style used for combining given/middle/family name into a full name.
5875 * See {@link ContactsContract.FullNameStyle}.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005876 */
5877 public static final String FULL_NAME_STYLE = DATA10;
5878
5879 /**
5880 * The alphabet used for capturing the phonetic name.
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08005881 * See ContactsContract.PhoneticNameStyle.
Dmitri Plotnikov07ab85b2009-12-15 11:56:23 -08005882 */
5883 public static final String PHONETIC_NAME_STYLE = DATA11;
Evan Millar088b2912009-05-28 15:24:37 -07005884 }
5885
5886 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005887 * <p>A data kind representing the contact's nickname. For example, for
5888 * Bob Parr ("Mr. Incredible"):
5889 * <pre>
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07005890 * ArrayList&lt;ContentProviderOperation&gt; ops =
5891 * new ArrayList&lt;ContentProviderOperation&gt;();
5892 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005893 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5894 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5895 * .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
5896 * .withValue(StructuredName.DISPLAY_NAME, &quot;Bob Parr&quot;)
5897 * .build());
5898 *
5899 * ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
5900 * .withValue(Data.RAW_CONTACT_ID, rawContactId)
5901 * .withValue(Data.MIMETYPE, Nickname.CONTENT_ITEM_TYPE)
5902 * .withValue(Nickname.NAME, "Mr. Incredible")
5903 * .withValue(Nickname.TYPE, Nickname.TYPE_CUSTOM)
5904 * .withValue(Nickname.LABEL, "Superhero")
5905 * .build());
5906 *
5907 * getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
5908 * </pre>
5909 * </p>
5910 * <p>
5911 * You can use all columns defined for {@link ContactsContract.Data} as well as the
5912 * following aliases.
5913 * </p>
5914 *
5915 * <h2>Column aliases</h2>
5916 * <table class="jd-sumtable">
5917 * <tr>
5918 * <th>Type</th><th>Alias</th><th colspan='2'>Data column</th>
5919 * </tr>
5920 * <tr>
5921 * <td>String</td>
5922 * <td>{@link #NAME}</td>
5923 * <td>{@link #DATA1}</td>
5924 * <td></td>
5925 * </tr>
5926 * <tr>
5927 * <td>int</td>
5928 * <td>{@link #TYPE}</td>
5929 * <td>{@link #DATA2}</td>
5930 * <td>
5931 * Allowed values are:
5932 * <p>
5933 * <ul>
5934 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
5935 * <li>{@link #TYPE_DEFAULT}</li>
5936 * <li>{@link #TYPE_OTHER_NAME}</li>
David Brown747c6152010-09-15 13:34:13 -07005937 * <li>{@link #TYPE_MAIDEN_NAME}</li>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005938 * <li>{@link #TYPE_SHORT_NAME}</li>
5939 * <li>{@link #TYPE_INITIALS}</li>
5940 * </ul>
5941 * </p>
5942 * </td>
5943 * </tr>
5944 * <tr>
5945 * <td>String</td>
5946 * <td>{@link #LABEL}</td>
5947 * <td>{@link #DATA3}</td>
5948 * <td></td>
5949 * </tr>
5950 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07005951 */
Yorke Lee94c87612014-07-18 18:57:17 -07005952 public static final class Nickname implements DataColumnsWithJoins, CommonColumns,
5953 ContactCounts{
Jeff Hamilton85abdc52009-09-22 12:41:45 -05005954 /**
5955 * This utility class cannot be instantiated
5956 */
Evan Millar088b2912009-05-28 15:24:37 -07005957 private Nickname() {}
5958
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07005959 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07005960 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
5961
Evan Millar78e79ad2009-06-08 10:24:44 -07005962 public static final int TYPE_DEFAULT = 1;
5963 public static final int TYPE_OTHER_NAME = 2;
David Brown747c6152010-09-15 13:34:13 -07005964 public static final int TYPE_MAIDEN_NAME = 3;
5965 /** @deprecated Use TYPE_MAIDEN_NAME instead. */
5966 @Deprecated
Evan Millar78e79ad2009-06-08 10:24:44 -07005967 public static final int TYPE_MAINDEN_NAME = 3;
5968 public static final int TYPE_SHORT_NAME = 4;
5969 public static final int TYPE_INITIALS = 5;
Evan Millar088b2912009-05-28 15:24:37 -07005970
5971 /**
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07005972 * The name itself
5973 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07005974 public static final String NAME = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07005975 }
5976
5977 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08005978 * <p>
5979 * A data kind representing a telephone number.
5980 * </p>
5981 * <p>
5982 * You can use all columns defined for {@link ContactsContract.Data} as
5983 * well as the following aliases.
5984 * </p>
5985 * <h2>Column aliases</h2>
5986 * <table class="jd-sumtable">
5987 * <tr>
5988 * <th>Type</th>
5989 * <th>Alias</th><th colspan='2'>Data column</th>
5990 * </tr>
5991 * <tr>
5992 * <td>String</td>
5993 * <td>{@link #NUMBER}</td>
5994 * <td>{@link #DATA1}</td>
5995 * <td></td>
5996 * </tr>
5997 * <tr>
5998 * <td>int</td>
5999 * <td>{@link #TYPE}</td>
6000 * <td>{@link #DATA2}</td>
6001 * <td>Allowed values are:
6002 * <p>
6003 * <ul>
6004 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6005 * <li>{@link #TYPE_HOME}</li>
6006 * <li>{@link #TYPE_MOBILE}</li>
6007 * <li>{@link #TYPE_WORK}</li>
6008 * <li>{@link #TYPE_FAX_WORK}</li>
6009 * <li>{@link #TYPE_FAX_HOME}</li>
6010 * <li>{@link #TYPE_PAGER}</li>
6011 * <li>{@link #TYPE_OTHER}</li>
6012 * <li>{@link #TYPE_CALLBACK}</li>
6013 * <li>{@link #TYPE_CAR}</li>
6014 * <li>{@link #TYPE_COMPANY_MAIN}</li>
6015 * <li>{@link #TYPE_ISDN}</li>
6016 * <li>{@link #TYPE_MAIN}</li>
6017 * <li>{@link #TYPE_OTHER_FAX}</li>
6018 * <li>{@link #TYPE_RADIO}</li>
6019 * <li>{@link #TYPE_TELEX}</li>
6020 * <li>{@link #TYPE_TTY_TDD}</li>
6021 * <li>{@link #TYPE_WORK_MOBILE}</li>
6022 * <li>{@link #TYPE_WORK_PAGER}</li>
6023 * <li>{@link #TYPE_ASSISTANT}</li>
6024 * <li>{@link #TYPE_MMS}</li>
6025 * </ul>
6026 * </p>
6027 * </td>
6028 * </tr>
6029 * <tr>
6030 * <td>String</td>
6031 * <td>{@link #LABEL}</td>
6032 * <td>{@link #DATA3}</td>
6033 * <td></td>
6034 * </tr>
6035 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006036 */
Yorke Lee94c87612014-07-18 18:57:17 -07006037 public static final class Phone implements DataColumnsWithJoins, CommonColumns,
6038 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006039 /**
6040 * This utility class cannot be instantiated
6041 */
Evan Millar088b2912009-05-28 15:24:37 -07006042 private Phone() {}
6043
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006044 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07006045 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone_v2";
Evan Millar088b2912009-05-28 15:24:37 -07006046
Evan Millar161dd862009-06-12 16:02:43 -07006047 /**
6048 * The MIME type of {@link #CONTENT_URI} providing a directory of
6049 * phones.
6050 */
Evan Millarb3c49982009-09-01 11:38:04 -07006051 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone_v2";
Evan Millar161dd862009-06-12 16:02:43 -07006052
6053 /**
6054 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006055 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07006056 * associated raw contact and aggregate contact data.
Evan Millar161dd862009-06-12 16:02:43 -07006057 */
6058 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6059 "phones");
6060
6061 /**
Ricky Waifa5bbaf2015-02-26 16:51:32 +00006062 * URI used for getting all contacts from primary and managed profile.
6063 *
6064 * It supports the same semantics as {@link #CONTENT_URI} and returns the same
6065 * columns. If the device has no corp profile that is linked to the current profile, it
6066 * behaves in the exact same way as {@link #CONTENT_URI}. If there is a corp profile
6067 * linked to the current profile, it will merge corp profile and current profile's
6068 * results and return
6069 *
6070 * @hide
6071 */
Philip P. Moltmann33115152018-04-11 13:39:36 -07006072 @TestApi
Ricky Waifa5bbaf2015-02-26 16:51:32 +00006073 public static final Uri ENTERPRISE_CONTENT_URI =
6074 Uri.withAppendedPath(Data.ENTERPRISE_CONTENT_URI, "phones");
6075
6076 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006077 * <p>The content:// style URL for phone lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006078 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006079 * to display names as well as phone numbers. The filter argument should be passed
6080 * as an additional path segment after this URI.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006081 *
6082 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
6083 * sorts results based on contacts frequency. For more information, see the
6084 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
6085 * page.
Evan Millar161dd862009-06-12 16:02:43 -07006086 */
6087 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
6088 "filter");
6089
Daniel Lehmann1024de52012-06-15 20:32:33 -07006090 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006091 * <p>It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the
6092 * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
Ricky Wai149a6c92016-04-25 12:14:53 +01006093 * parameters, otherwise it will throw IllegalArgumentException.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006094 *
6095 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts
6096 * results based on contacts frequency. For more information, see the
6097 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
6098 * page.
Victor Chang3d47ceb2015-12-01 16:30:43 +00006099 */
6100 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
6101 CONTENT_URI, "filter_enterprise");
6102
6103 /**
Daniel Lehmann1024de52012-06-15 20:32:33 -07006104 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
6105 * If "1" or "true", display names are searched. If "0" or "false", display names
6106 * are not searched. Default is "1".
6107 */
6108 public static final String SEARCH_DISPLAY_NAME_KEY = "search_display_name";
6109
6110 /**
6111 * A boolean query parameter that can be used with {@link #CONTENT_FILTER_URI}.
6112 * If "1" or "true", phone numbers are searched. If "0" or "false", phone numbers
6113 * are not searched. Default is "1".
6114 */
6115 public static final String SEARCH_PHONE_NUMBER_KEY = "search_phone_number";
6116
Evan Millar088b2912009-05-28 15:24:37 -07006117 public static final int TYPE_HOME = 1;
6118 public static final int TYPE_MOBILE = 2;
6119 public static final int TYPE_WORK = 3;
6120 public static final int TYPE_FAX_WORK = 4;
6121 public static final int TYPE_FAX_HOME = 5;
6122 public static final int TYPE_PAGER = 6;
6123 public static final int TYPE_OTHER = 7;
Fred Quintana3f867152009-08-03 11:43:16 -07006124 public static final int TYPE_CALLBACK = 8;
6125 public static final int TYPE_CAR = 9;
6126 public static final int TYPE_COMPANY_MAIN = 10;
6127 public static final int TYPE_ISDN = 11;
6128 public static final int TYPE_MAIN = 12;
6129 public static final int TYPE_OTHER_FAX = 13;
6130 public static final int TYPE_RADIO = 14;
6131 public static final int TYPE_TELEX = 15;
6132 public static final int TYPE_TTY_TDD = 16;
6133 public static final int TYPE_WORK_MOBILE = 17;
6134 public static final int TYPE_WORK_PAGER = 18;
6135 public static final int TYPE_ASSISTANT = 19;
Jeff Sharkeyd5abd462009-09-16 19:54:29 -07006136 public static final int TYPE_MMS = 20;
Evan Millar088b2912009-05-28 15:24:37 -07006137
6138 /**
6139 * The phone number as the user entered it.
6140 * <P>Type: TEXT</P>
6141 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006142 public static final String NUMBER = DATA;
Dmitri Plotnikov93032952009-08-19 11:26:57 -07006143
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006144 /**
Daniel Lehmanndb919152012-03-09 14:30:50 -08006145 * The phone number's E164 representation. This value can be omitted in which
Makoto Onukie5420e92012-04-25 13:24:41 -07006146 * case the provider will try to automatically infer it. (It'll be left null if the
6147 * provider fails to infer.)
6148 * If present, {@link #NUMBER} has to be set as well (it will be ignored otherwise).
Bai Tao224744c2010-08-31 09:59:13 +08006149 * <P>Type: TEXT</P>
Bai Tao224744c2010-08-31 09:59:13 +08006150 */
6151 public static final String NORMALIZED_NUMBER = DATA4;
6152
6153 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006154 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006155 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006156 */
6157 @Deprecated
Dmitri Plotnikov93032952009-08-19 11:26:57 -07006158 public static final CharSequence getDisplayLabel(Context context, int type,
6159 CharSequence label, CharSequence[] labelArray) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006160 return getTypeLabel(context.getResources(), type, label);
Dmitri Plotnikov93032952009-08-19 11:26:57 -07006161 }
6162
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006163 /**
6164 * @deprecated use {@link #getTypeLabel(Resources, int, CharSequence)} instead.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006165 * @hide
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006166 */
6167 @Deprecated
Mathew Inwood6750f2e2018-08-10 09:29:25 +01006168 @UnsupportedAppUsage
Dmitri Plotnikov93032952009-08-19 11:26:57 -07006169 public static final CharSequence getDisplayLabel(Context context, int type,
6170 CharSequence label) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006171 return getTypeLabel(context.getResources(), type, label);
6172 }
6173
6174 /**
6175 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006176 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006177 */
6178 public static final int getTypeLabelResource(int type) {
6179 switch (type) {
6180 case TYPE_HOME: return com.android.internal.R.string.phoneTypeHome;
6181 case TYPE_MOBILE: return com.android.internal.R.string.phoneTypeMobile;
6182 case TYPE_WORK: return com.android.internal.R.string.phoneTypeWork;
6183 case TYPE_FAX_WORK: return com.android.internal.R.string.phoneTypeFaxWork;
6184 case TYPE_FAX_HOME: return com.android.internal.R.string.phoneTypeFaxHome;
6185 case TYPE_PAGER: return com.android.internal.R.string.phoneTypePager;
6186 case TYPE_OTHER: return com.android.internal.R.string.phoneTypeOther;
6187 case TYPE_CALLBACK: return com.android.internal.R.string.phoneTypeCallback;
6188 case TYPE_CAR: return com.android.internal.R.string.phoneTypeCar;
6189 case TYPE_COMPANY_MAIN: return com.android.internal.R.string.phoneTypeCompanyMain;
6190 case TYPE_ISDN: return com.android.internal.R.string.phoneTypeIsdn;
6191 case TYPE_MAIN: return com.android.internal.R.string.phoneTypeMain;
6192 case TYPE_OTHER_FAX: return com.android.internal.R.string.phoneTypeOtherFax;
6193 case TYPE_RADIO: return com.android.internal.R.string.phoneTypeRadio;
6194 case TYPE_TELEX: return com.android.internal.R.string.phoneTypeTelex;
6195 case TYPE_TTY_TDD: return com.android.internal.R.string.phoneTypeTtyTdd;
6196 case TYPE_WORK_MOBILE: return com.android.internal.R.string.phoneTypeWorkMobile;
6197 case TYPE_WORK_PAGER: return com.android.internal.R.string.phoneTypeWorkPager;
6198 case TYPE_ASSISTANT: return com.android.internal.R.string.phoneTypeAssistant;
6199 case TYPE_MMS: return com.android.internal.R.string.phoneTypeMms;
6200 default: return com.android.internal.R.string.phoneTypeCustom;
6201 }
6202 }
6203
6204 /**
6205 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006206 * possibly substituting the given {@link #LABEL} value
6207 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006208 */
6209 public static final CharSequence getTypeLabel(Resources res, int type,
6210 CharSequence label) {
Tingting Wang86ac2282015-07-16 21:19:28 +00006211 if ((type == TYPE_CUSTOM || type == TYPE_ASSISTANT) && !TextUtils.isEmpty(label)) {
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006212 return label;
6213 } else {
6214 final int labelRes = getTypeLabelResource(type);
6215 return res.getText(labelRes);
6216 }
Dmitri Plotnikov93032952009-08-19 11:26:57 -07006217 }
Evan Millar088b2912009-05-28 15:24:37 -07006218 }
6219
6220 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006221 * <p>
6222 * A data kind representing an email address.
6223 * </p>
6224 * <p>
6225 * You can use all columns defined for {@link ContactsContract.Data} as
6226 * well as the following aliases.
6227 * </p>
6228 * <h2>Column aliases</h2>
6229 * <table class="jd-sumtable">
6230 * <tr>
6231 * <th>Type</th>
6232 * <th>Alias</th><th colspan='2'>Data column</th>
6233 * </tr>
6234 * <tr>
6235 * <td>String</td>
Dmitri Plotnikov1ecf5512010-09-02 11:00:04 -07006236 * <td>{@link #ADDRESS}</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006237 * <td>{@link #DATA1}</td>
6238 * <td>Email address itself.</td>
6239 * </tr>
6240 * <tr>
6241 * <td>int</td>
6242 * <td>{@link #TYPE}</td>
6243 * <td>{@link #DATA2}</td>
6244 * <td>Allowed values are:
6245 * <p>
6246 * <ul>
6247 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6248 * <li>{@link #TYPE_HOME}</li>
6249 * <li>{@link #TYPE_WORK}</li>
6250 * <li>{@link #TYPE_OTHER}</li>
6251 * <li>{@link #TYPE_MOBILE}</li>
6252 * </ul>
6253 * </p>
6254 * </td>
6255 * </tr>
6256 * <tr>
6257 * <td>String</td>
6258 * <td>{@link #LABEL}</td>
6259 * <td>{@link #DATA3}</td>
6260 * <td></td>
6261 * </tr>
6262 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006263 */
Yorke Lee94c87612014-07-18 18:57:17 -07006264 public static final class Email implements DataColumnsWithJoins, CommonColumns,
6265 ContactCounts {
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006266 /*
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006267 * This utility class cannot be instantiated
6268 */
Evan Millar088b2912009-05-28 15:24:37 -07006269 private Email() {}
6270
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006271 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07006272 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email_v2";
Evan Millar088b2912009-05-28 15:24:37 -07006273
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006274 /**
Dmitri Plotnikovabf15c32009-09-18 20:29:11 -07006275 * The MIME type of {@link #CONTENT_URI} providing a directory of email addresses.
6276 */
6277 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/email_v2";
6278
6279 /**
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006280 * The content:// style URI for all data records of the
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006281 * {@link #CONTENT_ITEM_TYPE} MIME type, combined with the
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006282 * associated raw contact and aggregate contact data.
6283 */
6284 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6285 "emails");
6286
6287 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006288 * <p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006289 * The content:// style URL for looking up data rows by email address. The
6290 * lookup argument, an email address, should be passed as an additional path segment
6291 * after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006292 * </p>
6293 * <p>Example:
6294 * <pre>
6295 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode(email));
6296 * Cursor c = getContentResolver().query(uri,
6297 * new String[]{Email.CONTACT_ID, Email.DISPLAY_NAME, Email.DATA},
6298 * null, null, null);
6299 * </pre>
6300 * </p>
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006301 */
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006302 public static final Uri CONTENT_LOOKUP_URI = Uri.withAppendedPath(CONTENT_URI,
6303 "lookup");
6304
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006305 /**
Ricky Wai323b30e2015-02-27 14:58:00 +00006306 * <p>URI used for enterprise email lookup.</p>
6307 *
6308 * <p>
6309 * It supports the same semantics as {@link #CONTENT_LOOKUP_URI} and returns the same
6310 * columns. If the device has no corp profile that is linked to the current profile, it
6311 * behaves in the exact same way as {@link #CONTENT_LOOKUP_URI}. If there is a
6312 * corp profile linked to the current profile, it first queries against the personal contact database,
6313 * and if no matching contacts are found there, then queries against the
6314 * corp contacts database.
6315 * </p>
6316 * <p>
6317 * If a result is from the corp profile, it makes the following changes to the data:
6318 * <ul>
6319 * <li>
6320 * {@link #PHOTO_THUMBNAIL_URI} and {@link #PHOTO_URI} will be rewritten to special
6321 * URIs. Use {@link ContentResolver#openAssetFileDescriptor} or its siblings to
6322 * load pictures from them.
6323 * {@link #PHOTO_ID} and {@link #PHOTO_FILE_ID} will be set to null. Do not
6324 * use them.
6325 * </li>
6326 * <li>
6327 * Corp contacts will get artificial {@link #CONTACT_ID}s. In order to tell whether
6328 * a contact
6329 * is from the corp profile, use
6330 * {@link ContactsContract.Contacts#isEnterpriseContactId(long)}.
Makoto Onuki1040da12015-03-19 11:24:00 -07006331 * </li>
6332 * <li>
6333 * Corp contacts will get artificial {@link #LOOKUP_KEY}s too.
6334 * </li>
Tony Mak935dafe2016-03-07 20:27:53 +00006335 * <li>
6336 * Returned work contact IDs and lookup keys are not accepted in places that not
6337 * explicitly say to accept them.
6338 * </li>
Makoto Onuki1040da12015-03-19 11:24:00 -07006339 * </ul>
6340 * <p>
6341 * A contact lookup URL built by
6342 * {@link ContactsContract.Contacts#getLookupUri(long, String)}
6343 * with an {@link #_ID} and a {@link #LOOKUP_KEY} returned by this API can be passed to
6344 * {@link ContactsContract.QuickContact#showQuickContact} even if a contact is from the
6345 * corp profile.
6346 * </p>
Ricky Wai323b30e2015-02-27 14:58:00 +00006347 *
6348 * <pre>
6349 * Uri lookupUri = Uri.withAppendedPath(Email.ENTERPRISE_CONTENT_LOOKUP_URI,
6350 * Uri.encode(email));
6351 * </pre>
6352 */
6353 public static final Uri ENTERPRISE_CONTENT_LOOKUP_URI =
6354 Uri.withAppendedPath(CONTENT_URI, "lookup_enterprise");
6355
6356 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006357 * <p>The content:// style URL for email lookup using a filter. The filter returns
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006358 * records of MIME type {@link #CONTENT_ITEM_TYPE}. The filter is applied
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006359 * to display names as well as email addresses. The filter argument should be passed
6360 * as an additional path segment after this URI.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006361 * </p>
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006362 *
6363 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer sorts
6364 * results based on contacts frequency. For more information, see the
6365 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
6366 * page.</p>
6367 *
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006368 * <p>The query in the following example will return "Robert Parr (bob@incredibles.com)"
6369 * as well as "Bob Parr (incredible@android.com)".
6370 * <pre>
6371 * Uri uri = Uri.withAppendedPath(Email.CONTENT_LOOKUP_URI, Uri.encode("bob"));
6372 * Cursor c = getContentResolver().query(uri,
6373 * new String[]{Email.DISPLAY_NAME, Email.DATA},
6374 * null, null, null);
6375 * </pre>
6376 * </p>
Dmitri Plotnikov989f2632009-09-06 12:22:24 -07006377 */
6378 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07006379 "filter");
6380
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006381 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006382 * <p>It supports the similar semantics as {@link #CONTENT_FILTER_URI} and returns the
6383 * same columns. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
Ricky Wai149a6c92016-04-25 12:14:53 +01006384 * parameters, otherwise it will throw IllegalArgumentException.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07006385 *
6386 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
6387 * sorts results based on contacts frequency. For more information, see the
6388 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
6389 * page.
Tony Mak415369e2015-12-08 07:24:55 +00006390 */
6391 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
6392 CONTENT_URI, "filter_enterprise");
6393
6394 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006395 * The email address.
6396 * <P>Type: TEXT</P>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006397 */
6398 public static final String ADDRESS = DATA1;
6399
Evan Millar088b2912009-05-28 15:24:37 -07006400 public static final int TYPE_HOME = 1;
6401 public static final int TYPE_WORK = 2;
6402 public static final int TYPE_OTHER = 3;
Jeff Sharkey14fb1532009-08-29 15:54:26 -07006403 public static final int TYPE_MOBILE = 4;
Fred Quintana8851e162009-08-05 21:06:45 -07006404
6405 /**
6406 * The display name for the email address
6407 * <P>Type: TEXT</P>
6408 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006409 public static final String DISPLAY_NAME = DATA4;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006410
6411 /**
6412 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006413 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006414 */
6415 public static final int getTypeLabelResource(int type) {
6416 switch (type) {
6417 case TYPE_HOME: return com.android.internal.R.string.emailTypeHome;
6418 case TYPE_WORK: return com.android.internal.R.string.emailTypeWork;
6419 case TYPE_OTHER: return com.android.internal.R.string.emailTypeOther;
6420 case TYPE_MOBILE: return com.android.internal.R.string.emailTypeMobile;
6421 default: return com.android.internal.R.string.emailTypeCustom;
6422 }
6423 }
6424
6425 /**
6426 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006427 * possibly substituting the given {@link #LABEL} value
6428 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006429 */
6430 public static final CharSequence getTypeLabel(Resources res, int type,
6431 CharSequence label) {
6432 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6433 return label;
6434 } else {
6435 final int labelRes = getTypeLabelResource(type);
6436 return res.getText(labelRes);
6437 }
6438 }
Evan Millar088b2912009-05-28 15:24:37 -07006439 }
6440
6441 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006442 * <p>
6443 * A data kind representing a postal addresses.
6444 * </p>
6445 * <p>
6446 * You can use all columns defined for {@link ContactsContract.Data} as
6447 * well as the following aliases.
6448 * </p>
6449 * <h2>Column aliases</h2>
6450 * <table class="jd-sumtable">
6451 * <tr>
6452 * <th>Type</th>
6453 * <th>Alias</th><th colspan='2'>Data column</th>
6454 * </tr>
6455 * <tr>
6456 * <td>String</td>
6457 * <td>{@link #FORMATTED_ADDRESS}</td>
6458 * <td>{@link #DATA1}</td>
6459 * <td></td>
6460 * </tr>
6461 * <tr>
6462 * <td>int</td>
6463 * <td>{@link #TYPE}</td>
6464 * <td>{@link #DATA2}</td>
6465 * <td>Allowed values are:
6466 * <p>
6467 * <ul>
6468 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6469 * <li>{@link #TYPE_HOME}</li>
6470 * <li>{@link #TYPE_WORK}</li>
6471 * <li>{@link #TYPE_OTHER}</li>
6472 * </ul>
6473 * </p>
6474 * </td>
6475 * </tr>
6476 * <tr>
6477 * <td>String</td>
6478 * <td>{@link #LABEL}</td>
6479 * <td>{@link #DATA3}</td>
6480 * <td></td>
6481 * </tr>
6482 * <tr>
6483 * <td>String</td>
6484 * <td>{@link #STREET}</td>
6485 * <td>{@link #DATA4}</td>
6486 * <td></td>
6487 * </tr>
6488 * <tr>
6489 * <td>String</td>
6490 * <td>{@link #POBOX}</td>
6491 * <td>{@link #DATA5}</td>
6492 * <td>Post Office Box number</td>
6493 * </tr>
6494 * <tr>
6495 * <td>String</td>
6496 * <td>{@link #NEIGHBORHOOD}</td>
6497 * <td>{@link #DATA6}</td>
6498 * <td></td>
6499 * </tr>
6500 * <tr>
6501 * <td>String</td>
6502 * <td>{@link #CITY}</td>
6503 * <td>{@link #DATA7}</td>
6504 * <td></td>
6505 * </tr>
6506 * <tr>
6507 * <td>String</td>
6508 * <td>{@link #REGION}</td>
6509 * <td>{@link #DATA8}</td>
6510 * <td></td>
6511 * </tr>
6512 * <tr>
6513 * <td>String</td>
6514 * <td>{@link #POSTCODE}</td>
6515 * <td>{@link #DATA9}</td>
6516 * <td></td>
6517 * </tr>
6518 * <tr>
6519 * <td>String</td>
6520 * <td>{@link #COUNTRY}</td>
6521 * <td>{@link #DATA10}</td>
6522 * <td></td>
6523 * </tr>
6524 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006525 */
Yorke Lee94c87612014-07-18 18:57:17 -07006526 public static final class StructuredPostal implements DataColumnsWithJoins, CommonColumns,
6527 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006528 /**
6529 * This utility class cannot be instantiated
6530 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006531 private StructuredPostal() {
6532 }
Evan Millar088b2912009-05-28 15:24:37 -07006533
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006534 /** MIME type used when storing this in data table. */
Evan Millarb3c49982009-09-01 11:38:04 -07006535 public static final String CONTENT_ITEM_TYPE =
6536 "vnd.android.cursor.item/postal-address_v2";
Evan Millar088b2912009-05-28 15:24:37 -07006537
Evan Millar161dd862009-06-12 16:02:43 -07006538 /**
6539 * The MIME type of {@link #CONTENT_URI} providing a directory of
6540 * postal addresses.
6541 */
Evan Millarb3c49982009-09-01 11:38:04 -07006542 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address_v2";
Evan Millar161dd862009-06-12 16:02:43 -07006543
6544 /**
6545 * The content:// style URI for all data records of the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006546 * {@link StructuredPostal#CONTENT_ITEM_TYPE} MIME type.
Evan Millar161dd862009-06-12 16:02:43 -07006547 */
6548 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
6549 "postals");
6550
Evan Millar088b2912009-05-28 15:24:37 -07006551 public static final int TYPE_HOME = 1;
6552 public static final int TYPE_WORK = 2;
6553 public static final int TYPE_OTHER = 3;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006554
6555 /**
Jeff Sharkey62b83b72009-08-11 17:33:48 -07006556 * The full, unstructured postal address. <i>This field must be
6557 * consistent with any structured data.</i>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006558 * <p>
6559 * Type: TEXT
6560 */
6561 public static final String FORMATTED_ADDRESS = DATA;
6562
6563 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006564 * Can be street, avenue, road, etc. This element also includes the
6565 * house number and room/apartment/flat/floor number.
6566 * <p>
6567 * Type: TEXT
6568 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006569 public static final String STREET = DATA4;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006570
6571 /**
6572 * Covers actual P.O. boxes, drawers, locked bags, etc. This is
6573 * usually but not always mutually exclusive with street.
6574 * <p>
6575 * Type: TEXT
6576 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006577 public static final String POBOX = DATA5;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006578
6579 /**
6580 * This is used to disambiguate a street address when a city
6581 * contains more than one street with the same name, or to specify a
6582 * small place whose mail is routed through a larger postal town. In
6583 * China it could be a county or a minor city.
6584 * <p>
6585 * Type: TEXT
6586 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006587 public static final String NEIGHBORHOOD = DATA6;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006588
6589 /**
6590 * Can be city, village, town, borough, etc. This is the postal town
6591 * and not necessarily the place of residence or place of business.
6592 * <p>
6593 * Type: TEXT
6594 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006595 public static final String CITY = DATA7;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006596
6597 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006598 * A state, province, county (in Ireland), Land (in Germany),
6599 * departement (in France), etc.
6600 * <p>
6601 * Type: TEXT
6602 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006603 public static final String REGION = DATA8;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006604
6605 /**
Jeff Sharkeyef348c72009-07-26 14:14:34 -07006606 * Postal code. Usually country-wide, but sometimes specific to the
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006607 * city (e.g. "2" in "Dublin 2, Ireland" addresses).
6608 * <p>
6609 * Type: TEXT
6610 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006611 public static final String POSTCODE = DATA9;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006612
6613 /**
6614 * The name or code of the country.
6615 * <p>
6616 * Type: TEXT
6617 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006618 public static final String COUNTRY = DATA10;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006619
6620 /**
6621 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006622 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006623 */
6624 public static final int getTypeLabelResource(int type) {
6625 switch (type) {
6626 case TYPE_HOME: return com.android.internal.R.string.postalTypeHome;
6627 case TYPE_WORK: return com.android.internal.R.string.postalTypeWork;
6628 case TYPE_OTHER: return com.android.internal.R.string.postalTypeOther;
6629 default: return com.android.internal.R.string.postalTypeCustom;
6630 }
6631 }
6632
6633 /**
6634 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006635 * possibly substituting the given {@link #LABEL} value
6636 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006637 */
6638 public static final CharSequence getTypeLabel(Resources res, int type,
6639 CharSequence label) {
6640 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6641 return label;
6642 } else {
6643 final int labelRes = getTypeLabelResource(type);
6644 return res.getText(labelRes);
6645 }
6646 }
Evan Millar088b2912009-05-28 15:24:37 -07006647 }
6648
Fred Quintana8851e162009-08-05 21:06:45 -07006649 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006650 * <p>
6651 * A data kind representing an IM address
6652 * </p>
6653 * <p>
6654 * You can use all columns defined for {@link ContactsContract.Data} as
6655 * well as the following aliases.
6656 * </p>
6657 * <h2>Column aliases</h2>
6658 * <table class="jd-sumtable">
6659 * <tr>
6660 * <th>Type</th>
6661 * <th>Alias</th><th colspan='2'>Data column</th>
6662 * </tr>
6663 * <tr>
6664 * <td>String</td>
6665 * <td>{@link #DATA}</td>
6666 * <td>{@link #DATA1}</td>
6667 * <td></td>
6668 * </tr>
6669 * <tr>
6670 * <td>int</td>
6671 * <td>{@link #TYPE}</td>
6672 * <td>{@link #DATA2}</td>
6673 * <td>Allowed values are:
6674 * <p>
6675 * <ul>
6676 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6677 * <li>{@link #TYPE_HOME}</li>
6678 * <li>{@link #TYPE_WORK}</li>
6679 * <li>{@link #TYPE_OTHER}</li>
6680 * </ul>
6681 * </p>
6682 * </td>
6683 * </tr>
6684 * <tr>
6685 * <td>String</td>
6686 * <td>{@link #LABEL}</td>
6687 * <td>{@link #DATA3}</td>
6688 * <td></td>
6689 * </tr>
6690 * <tr>
6691 * <td>String</td>
6692 * <td>{@link #PROTOCOL}</td>
6693 * <td>{@link #DATA5}</td>
6694 * <td>
6695 * <p>
6696 * Allowed values:
6697 * <ul>
6698 * <li>{@link #PROTOCOL_CUSTOM}. Also provide the actual protocol name
6699 * as {@link #CUSTOM_PROTOCOL}.</li>
6700 * <li>{@link #PROTOCOL_AIM}</li>
6701 * <li>{@link #PROTOCOL_MSN}</li>
6702 * <li>{@link #PROTOCOL_YAHOO}</li>
6703 * <li>{@link #PROTOCOL_SKYPE}</li>
6704 * <li>{@link #PROTOCOL_QQ}</li>
6705 * <li>{@link #PROTOCOL_GOOGLE_TALK}</li>
6706 * <li>{@link #PROTOCOL_ICQ}</li>
6707 * <li>{@link #PROTOCOL_JABBER}</li>
6708 * <li>{@link #PROTOCOL_NETMEETING}</li>
6709 * </ul>
6710 * </p>
6711 * </td>
6712 * </tr>
6713 * <tr>
6714 * <td>String</td>
6715 * <td>{@link #CUSTOM_PROTOCOL}</td>
6716 * <td>{@link #DATA6}</td>
6717 * <td></td>
6718 * </tr>
6719 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07006720 */
Yorke Lee94c87612014-07-18 18:57:17 -07006721 public static final class Im implements DataColumnsWithJoins, CommonColumns, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006722 /**
6723 * This utility class cannot be instantiated
6724 */
Evan Millar088b2912009-05-28 15:24:37 -07006725 private Im() {}
6726
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006727 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006728 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
6729
Evan Millar088b2912009-05-28 15:24:37 -07006730 public static final int TYPE_HOME = 1;
6731 public static final int TYPE_WORK = 2;
6732 public static final int TYPE_OTHER = 3;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006733
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006734 /**
6735 * This column should be populated with one of the defined
6736 * constants, e.g. {@link #PROTOCOL_YAHOO}. If the value of this
6737 * column is {@link #PROTOCOL_CUSTOM}, the {@link #CUSTOM_PROTOCOL}
6738 * should contain the name of the custom protocol.
6739 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006740 public static final String PROTOCOL = DATA5;
Dmitri Plotnikov56927772009-05-28 17:23:39 -07006741
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006742 public static final String CUSTOM_PROTOCOL = DATA6;
Jeff Sharkey732da922009-07-30 09:59:31 -07006743
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07006744 /*
6745 * The predefined IM protocol types.
Evan Millar088b2912009-05-28 15:24:37 -07006746 */
Jeff Sharkey732da922009-07-30 09:59:31 -07006747 public static final int PROTOCOL_CUSTOM = -1;
Evan Millar088b2912009-05-28 15:24:37 -07006748 public static final int PROTOCOL_AIM = 0;
6749 public static final int PROTOCOL_MSN = 1;
6750 public static final int PROTOCOL_YAHOO = 2;
6751 public static final int PROTOCOL_SKYPE = 3;
6752 public static final int PROTOCOL_QQ = 4;
6753 public static final int PROTOCOL_GOOGLE_TALK = 5;
6754 public static final int PROTOCOL_ICQ = 6;
6755 public static final int PROTOCOL_JABBER = 7;
Fred Quintana8851e162009-08-05 21:06:45 -07006756 public static final int PROTOCOL_NETMEETING = 8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006757
6758 /**
6759 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006760 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006761 */
6762 public static final int getTypeLabelResource(int type) {
6763 switch (type) {
6764 case TYPE_HOME: return com.android.internal.R.string.imTypeHome;
6765 case TYPE_WORK: return com.android.internal.R.string.imTypeWork;
6766 case TYPE_OTHER: return com.android.internal.R.string.imTypeOther;
6767 default: return com.android.internal.R.string.imTypeCustom;
6768 }
6769 }
6770
6771 /**
6772 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006773 * possibly substituting the given {@link #LABEL} value
6774 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006775 */
6776 public static final CharSequence getTypeLabel(Resources res, int type,
6777 CharSequence label) {
6778 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6779 return label;
6780 } else {
6781 final int labelRes = getTypeLabelResource(type);
6782 return res.getText(labelRes);
6783 }
6784 }
6785
6786 /**
6787 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006788 * {@link #PROTOCOL}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006789 */
6790 public static final int getProtocolLabelResource(int type) {
6791 switch (type) {
6792 case PROTOCOL_AIM: return com.android.internal.R.string.imProtocolAim;
6793 case PROTOCOL_MSN: return com.android.internal.R.string.imProtocolMsn;
6794 case PROTOCOL_YAHOO: return com.android.internal.R.string.imProtocolYahoo;
6795 case PROTOCOL_SKYPE: return com.android.internal.R.string.imProtocolSkype;
6796 case PROTOCOL_QQ: return com.android.internal.R.string.imProtocolQq;
6797 case PROTOCOL_GOOGLE_TALK: return com.android.internal.R.string.imProtocolGoogleTalk;
6798 case PROTOCOL_ICQ: return com.android.internal.R.string.imProtocolIcq;
6799 case PROTOCOL_JABBER: return com.android.internal.R.string.imProtocolJabber;
6800 case PROTOCOL_NETMEETING: return com.android.internal.R.string.imProtocolNetMeeting;
6801 default: return com.android.internal.R.string.imProtocolCustom;
6802 }
6803 }
6804
6805 /**
6806 * Return a {@link CharSequence} that best describes the given
6807 * protocol, possibly substituting the given
6808 * {@link #CUSTOM_PROTOCOL} value for {@link #PROTOCOL_CUSTOM}.
6809 */
6810 public static final CharSequence getProtocolLabel(Resources res, int type,
6811 CharSequence label) {
6812 if (type == PROTOCOL_CUSTOM && !TextUtils.isEmpty(label)) {
6813 return label;
6814 } else {
6815 final int labelRes = getProtocolLabelResource(type);
6816 return res.getText(labelRes);
6817 }
6818 }
Evan Millar088b2912009-05-28 15:24:37 -07006819 }
6820
6821 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006822 * <p>
6823 * A data kind representing an organization.
6824 * </p>
6825 * <p>
6826 * You can use all columns defined for {@link ContactsContract.Data} as
6827 * well as the following aliases.
6828 * </p>
6829 * <h2>Column aliases</h2>
6830 * <table class="jd-sumtable">
6831 * <tr>
6832 * <th>Type</th>
6833 * <th>Alias</th><th colspan='2'>Data column</th>
6834 * </tr>
6835 * <tr>
6836 * <td>String</td>
6837 * <td>{@link #COMPANY}</td>
6838 * <td>{@link #DATA1}</td>
6839 * <td></td>
6840 * </tr>
6841 * <tr>
6842 * <td>int</td>
6843 * <td>{@link #TYPE}</td>
6844 * <td>{@link #DATA2}</td>
6845 * <td>Allowed values are:
6846 * <p>
6847 * <ul>
6848 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
6849 * <li>{@link #TYPE_WORK}</li>
6850 * <li>{@link #TYPE_OTHER}</li>
6851 * </ul>
6852 * </p>
6853 * </td>
6854 * </tr>
6855 * <tr>
6856 * <td>String</td>
6857 * <td>{@link #LABEL}</td>
6858 * <td>{@link #DATA3}</td>
6859 * <td></td>
6860 * </tr>
6861 * <tr>
6862 * <td>String</td>
6863 * <td>{@link #TITLE}</td>
6864 * <td>{@link #DATA4}</td>
6865 * <td></td>
6866 * </tr>
6867 * <tr>
6868 * <td>String</td>
6869 * <td>{@link #DEPARTMENT}</td>
6870 * <td>{@link #DATA5}</td>
6871 * <td></td>
6872 * </tr>
6873 * <tr>
6874 * <td>String</td>
6875 * <td>{@link #JOB_DESCRIPTION}</td>
6876 * <td>{@link #DATA6}</td>
6877 * <td></td>
6878 * </tr>
6879 * <tr>
6880 * <td>String</td>
6881 * <td>{@link #SYMBOL}</td>
6882 * <td>{@link #DATA7}</td>
6883 * <td></td>
6884 * </tr>
6885 * <tr>
6886 * <td>String</td>
6887 * <td>{@link #PHONETIC_NAME}</td>
6888 * <td>{@link #DATA8}</td>
6889 * <td></td>
6890 * </tr>
6891 * <tr>
6892 * <td>String</td>
6893 * <td>{@link #OFFICE_LOCATION}</td>
6894 * <td>{@link #DATA9}</td>
6895 * <td></td>
6896 * </tr>
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006897 * <tr>
6898 * <td>String</td>
6899 * <td>PHONETIC_NAME_STYLE</td>
6900 * <td>{@link #DATA10}</td>
6901 * <td></td>
6902 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006903 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07006904 */
Yorke Lee94c87612014-07-18 18:57:17 -07006905 public static final class Organization implements DataColumnsWithJoins, CommonColumns,
6906 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05006907 /**
6908 * This utility class cannot be instantiated
6909 */
Evan Millar088b2912009-05-28 15:24:37 -07006910 private Organization() {}
6911
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07006912 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07006913 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
6914
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006915 public static final int TYPE_WORK = 1;
6916 public static final int TYPE_OTHER = 2;
Evan Millar088b2912009-05-28 15:24:37 -07006917
6918 /**
6919 * The company as the user entered it.
6920 * <P>Type: TEXT</P>
6921 */
Dmitri Plotnikov761ef2a2009-07-17 10:51:06 -07006922 public static final String COMPANY = DATA;
Evan Millar088b2912009-05-28 15:24:37 -07006923
6924 /**
6925 * The position title at this company as the user entered it.
6926 * <P>Type: TEXT</P>
6927 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006928 public static final String TITLE = DATA4;
Fred Quintana8851e162009-08-05 21:06:45 -07006929
6930 /**
6931 * The department at this company as the user entered it.
6932 * <P>Type: TEXT</P>
6933 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006934 public static final String DEPARTMENT = DATA5;
Fred Quintana8851e162009-08-05 21:06:45 -07006935
6936 /**
6937 * The job description at this company as the user entered it.
6938 * <P>Type: TEXT</P>
6939 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006940 public static final String JOB_DESCRIPTION = DATA6;
Fred Quintana8851e162009-08-05 21:06:45 -07006941
6942 /**
6943 * The symbol of this company as the user entered it.
6944 * <P>Type: TEXT</P>
6945 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006946 public static final String SYMBOL = DATA7;
Fred Quintana8851e162009-08-05 21:06:45 -07006947
6948 /**
6949 * The phonetic name of this company as the user entered it.
6950 * <P>Type: TEXT</P>
6951 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07006952 public static final String PHONETIC_NAME = DATA8;
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006953
6954 /**
Jeff Sharkeyff18bbf2009-09-27 16:55:00 -07006955 * The office location of this organization.
6956 * <P>Type: TEXT</P>
6957 */
6958 public static final String OFFICE_LOCATION = DATA9;
6959
6960 /**
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006961 * The alphabet used for capturing the phonetic name.
6962 * See {@link ContactsContract.PhoneticNameStyle}.
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08006963 */
6964 public static final String PHONETIC_NAME_STYLE = DATA10;
6965
6966 /**
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006967 * Return the string resource that best describes the given
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006968 * {@link #TYPE}. Will always return a valid resource.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006969 */
6970 public static final int getTypeLabelResource(int type) {
6971 switch (type) {
6972 case TYPE_WORK: return com.android.internal.R.string.orgTypeWork;
6973 case TYPE_OTHER: return com.android.internal.R.string.orgTypeOther;
6974 default: return com.android.internal.R.string.orgTypeCustom;
6975 }
6976 }
6977
6978 /**
6979 * Return a {@link CharSequence} that best describes the given type,
Jeff Hamiltonf8526982009-09-24 11:34:58 -05006980 * possibly substituting the given {@link #LABEL} value
6981 * for {@link #TYPE_CUSTOM}.
Jeff Sharkey88a83d32009-09-20 17:10:47 -07006982 */
6983 public static final CharSequence getTypeLabel(Resources res, int type,
6984 CharSequence label) {
6985 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
6986 return label;
6987 } else {
6988 final int labelRes = getTypeLabelResource(type);
6989 return res.getText(labelRes);
6990 }
6991 }
Fred Quintana8851e162009-08-05 21:06:45 -07006992 }
6993
6994 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08006995 * <p>
6996 * A data kind representing a relation.
6997 * </p>
6998 * <p>
6999 * You can use all columns defined for {@link ContactsContract.Data} as
7000 * well as the following aliases.
7001 * </p>
7002 * <h2>Column aliases</h2>
7003 * <table class="jd-sumtable">
7004 * <tr>
7005 * <th>Type</th>
7006 * <th>Alias</th><th colspan='2'>Data column</th>
7007 * </tr>
7008 * <tr>
7009 * <td>String</td>
7010 * <td>{@link #NAME}</td>
7011 * <td>{@link #DATA1}</td>
7012 * <td></td>
7013 * </tr>
7014 * <tr>
7015 * <td>int</td>
7016 * <td>{@link #TYPE}</td>
7017 * <td>{@link #DATA2}</td>
7018 * <td>Allowed values are:
7019 * <p>
7020 * <ul>
7021 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7022 * <li>{@link #TYPE_ASSISTANT}</li>
7023 * <li>{@link #TYPE_BROTHER}</li>
7024 * <li>{@link #TYPE_CHILD}</li>
7025 * <li>{@link #TYPE_DOMESTIC_PARTNER}</li>
7026 * <li>{@link #TYPE_FATHER}</li>
7027 * <li>{@link #TYPE_FRIEND}</li>
7028 * <li>{@link #TYPE_MANAGER}</li>
7029 * <li>{@link #TYPE_MOTHER}</li>
7030 * <li>{@link #TYPE_PARENT}</li>
7031 * <li>{@link #TYPE_PARTNER}</li>
7032 * <li>{@link #TYPE_REFERRED_BY}</li>
7033 * <li>{@link #TYPE_RELATIVE}</li>
7034 * <li>{@link #TYPE_SISTER}</li>
7035 * <li>{@link #TYPE_SPOUSE}</li>
7036 * </ul>
7037 * </p>
7038 * </td>
7039 * </tr>
7040 * <tr>
7041 * <td>String</td>
7042 * <td>{@link #LABEL}</td>
7043 * <td>{@link #DATA3}</td>
7044 * <td></td>
7045 * </tr>
7046 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07007047 */
Yorke Lee94c87612014-07-18 18:57:17 -07007048 public static final class Relation implements DataColumnsWithJoins, CommonColumns,
7049 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007050 /**
7051 * This utility class cannot be instantiated
7052 */
Fred Quintana8851e162009-08-05 21:06:45 -07007053 private Relation() {}
7054
7055 /** MIME type used when storing this in data table. */
7056 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/relation";
7057
7058 public static final int TYPE_ASSISTANT = 1;
7059 public static final int TYPE_BROTHER = 2;
7060 public static final int TYPE_CHILD = 3;
7061 public static final int TYPE_DOMESTIC_PARTNER = 4;
7062 public static final int TYPE_FATHER = 5;
7063 public static final int TYPE_FRIEND = 6;
7064 public static final int TYPE_MANAGER = 7;
7065 public static final int TYPE_MOTHER = 8;
7066 public static final int TYPE_PARENT = 9;
7067 public static final int TYPE_PARTNER = 10;
7068 public static final int TYPE_REFERRED_BY = 11;
7069 public static final int TYPE_RELATIVE = 12;
7070 public static final int TYPE_SISTER = 13;
7071 public static final int TYPE_SPOUSE = 14;
7072
7073 /**
7074 * The name of the relative as the user entered it.
7075 * <P>Type: TEXT</P>
7076 */
7077 public static final String NAME = DATA;
Daniel Lehmann1fb39f02010-10-28 13:40:38 -07007078
7079 /**
7080 * Return the string resource that best describes the given
7081 * {@link #TYPE}. Will always return a valid resource.
7082 */
7083 public static final int getTypeLabelResource(int type) {
7084 switch (type) {
7085 case TYPE_ASSISTANT: return com.android.internal.R.string.relationTypeAssistant;
7086 case TYPE_BROTHER: return com.android.internal.R.string.relationTypeBrother;
7087 case TYPE_CHILD: return com.android.internal.R.string.relationTypeChild;
7088 case TYPE_DOMESTIC_PARTNER:
7089 return com.android.internal.R.string.relationTypeDomesticPartner;
7090 case TYPE_FATHER: return com.android.internal.R.string.relationTypeFather;
7091 case TYPE_FRIEND: return com.android.internal.R.string.relationTypeFriend;
7092 case TYPE_MANAGER: return com.android.internal.R.string.relationTypeManager;
7093 case TYPE_MOTHER: return com.android.internal.R.string.relationTypeMother;
7094 case TYPE_PARENT: return com.android.internal.R.string.relationTypeParent;
7095 case TYPE_PARTNER: return com.android.internal.R.string.relationTypePartner;
7096 case TYPE_REFERRED_BY:
7097 return com.android.internal.R.string.relationTypeReferredBy;
7098 case TYPE_RELATIVE: return com.android.internal.R.string.relationTypeRelative;
7099 case TYPE_SISTER: return com.android.internal.R.string.relationTypeSister;
7100 case TYPE_SPOUSE: return com.android.internal.R.string.relationTypeSpouse;
7101 default: return com.android.internal.R.string.orgTypeCustom;
7102 }
7103 }
7104
7105 /**
7106 * Return a {@link CharSequence} that best describes the given type,
7107 * possibly substituting the given {@link #LABEL} value
7108 * for {@link #TYPE_CUSTOM}.
7109 */
7110 public static final CharSequence getTypeLabel(Resources res, int type,
7111 CharSequence label) {
7112 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7113 return label;
7114 } else {
7115 final int labelRes = getTypeLabelResource(type);
7116 return res.getText(labelRes);
7117 }
7118 }
Fred Quintana8851e162009-08-05 21:06:45 -07007119 }
7120
7121 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007122 * <p>
7123 * A data kind representing an event.
7124 * </p>
7125 * <p>
7126 * You can use all columns defined for {@link ContactsContract.Data} as
7127 * well as the following aliases.
7128 * </p>
7129 * <h2>Column aliases</h2>
7130 * <table class="jd-sumtable">
7131 * <tr>
7132 * <th>Type</th>
7133 * <th>Alias</th><th colspan='2'>Data column</th>
7134 * </tr>
7135 * <tr>
7136 * <td>String</td>
7137 * <td>{@link #START_DATE}</td>
7138 * <td>{@link #DATA1}</td>
7139 * <td></td>
7140 * </tr>
7141 * <tr>
7142 * <td>int</td>
7143 * <td>{@link #TYPE}</td>
7144 * <td>{@link #DATA2}</td>
7145 * <td>Allowed values are:
7146 * <p>
7147 * <ul>
7148 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7149 * <li>{@link #TYPE_ANNIVERSARY}</li>
7150 * <li>{@link #TYPE_OTHER}</li>
7151 * <li>{@link #TYPE_BIRTHDAY}</li>
7152 * </ul>
7153 * </p>
7154 * </td>
7155 * </tr>
7156 * <tr>
7157 * <td>String</td>
7158 * <td>{@link #LABEL}</td>
7159 * <td>{@link #DATA3}</td>
7160 * <td></td>
7161 * </tr>
7162 * </table>
Fred Quintana8851e162009-08-05 21:06:45 -07007163 */
Yorke Lee94c87612014-07-18 18:57:17 -07007164 public static final class Event implements DataColumnsWithJoins, CommonColumns,
7165 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007166 /**
7167 * This utility class cannot be instantiated
7168 */
Fred Quintana8851e162009-08-05 21:06:45 -07007169 private Event() {}
7170
7171 /** MIME type used when storing this in data table. */
Fred Quintanac868acf2009-09-30 18:17:47 -07007172 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_event";
Fred Quintana8851e162009-08-05 21:06:45 -07007173
7174 public static final int TYPE_ANNIVERSARY = 1;
7175 public static final int TYPE_OTHER = 2;
Fred Quintanac868acf2009-09-30 18:17:47 -07007176 public static final int TYPE_BIRTHDAY = 3;
Dmitri Plotnikovd4e0b572009-08-06 20:19:29 -07007177
Fred Quintana8851e162009-08-05 21:06:45 -07007178 /**
7179 * The event start date as the user entered it.
7180 * <P>Type: TEXT</P>
7181 */
7182 public static final String START_DATE = DATA;
Fred Quintanac868acf2009-09-30 18:17:47 -07007183
7184 /**
7185 * Return the string resource that best describes the given
7186 * {@link #TYPE}. Will always return a valid resource.
7187 */
7188 public static int getTypeResource(Integer type) {
7189 if (type == null) {
7190 return com.android.internal.R.string.eventTypeOther;
7191 }
7192 switch (type) {
7193 case TYPE_ANNIVERSARY:
7194 return com.android.internal.R.string.eventTypeAnniversary;
7195 case TYPE_BIRTHDAY: return com.android.internal.R.string.eventTypeBirthday;
7196 case TYPE_OTHER: return com.android.internal.R.string.eventTypeOther;
Daniel Lehmanndd384a72010-11-01 18:40:50 -07007197 default: return com.android.internal.R.string.eventTypeCustom;
Fred Quintanac868acf2009-09-30 18:17:47 -07007198 }
7199 }
Paul Soulos6b2dd632014-07-24 17:17:42 -07007200
7201 /**
7202 * Return a {@link CharSequence} that best describes the given type,
7203 * possibly substituting the given {@link #LABEL} value
7204 * for {@link #TYPE_CUSTOM}.
7205 */
7206 public static final CharSequence getTypeLabel(Resources res, int type,
7207 CharSequence label) {
7208 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7209 return label;
7210 } else {
7211 final int labelRes = getTypeResource(type);
7212 return res.getText(labelRes);
7213 }
7214 }
Evan Millar088b2912009-05-28 15:24:37 -07007215 }
7216
7217 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007218 * <p>
Dave Santoroa5282372011-06-29 00:25:16 -07007219 * A data kind representing a photo for the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007220 * </p>
7221 * <p>
7222 * Some sync adapters will choose to download photos in a separate
7223 * pass. A common pattern is to use columns {@link ContactsContract.Data#SYNC1}
7224 * through {@link ContactsContract.Data#SYNC4} to store temporary
7225 * data, e.g. the image URL or ID, state of download, server-side version
7226 * of the image. It is allowed for the {@link #PHOTO} to be null.
7227 * </p>
7228 * <p>
7229 * You can use all columns defined for {@link ContactsContract.Data} as
7230 * well as the following aliases.
7231 * </p>
7232 * <h2>Column aliases</h2>
7233 * <table class="jd-sumtable">
7234 * <tr>
7235 * <th>Type</th>
7236 * <th>Alias</th><th colspan='2'>Data column</th>
7237 * </tr>
7238 * <tr>
Dave Santoroa5282372011-06-29 00:25:16 -07007239 * <td>NUMBER</td>
7240 * <td>{@link #PHOTO_FILE_ID}</td>
7241 * <td>{@link #DATA14}</td>
7242 * <td>ID of the hi-res photo file.</td>
7243 * </tr>
7244 * <tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007245 * <td>BLOB</td>
7246 * <td>{@link #PHOTO}</td>
7247 * <td>{@link #DATA15}</td>
Dave Santoroa5282372011-06-29 00:25:16 -07007248 * <td>By convention, binary data is stored in DATA15. The thumbnail of the
7249 * photo is stored in this column.</td>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007250 * </tr>
7251 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07007252 */
Yorke Lee94c87612014-07-18 18:57:17 -07007253 public static final class Photo implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007254 /**
7255 * This utility class cannot be instantiated
7256 */
Evan Millar088b2912009-05-28 15:24:37 -07007257 private Photo() {}
7258
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007259 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07007260 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
7261
7262 /**
Dave Santoroa5282372011-06-29 00:25:16 -07007263 * Photo file ID for the display photo of the raw contact.
7264 * See {@link ContactsContract.DisplayPhoto}.
7265 * <p>
7266 * Type: NUMBER
7267 */
7268 public static final String PHOTO_FILE_ID = DATA14;
7269
7270 /**
Dmitri Plotnikovfacbbb32009-07-27 15:18:19 -07007271 * Thumbnail photo of the raw contact. This is the raw bytes of an image
Dmitri Plotnikovf22fc122009-09-22 13:46:11 -07007272 * that could be inflated using {@link android.graphics.BitmapFactory}.
Evan Millar088b2912009-05-28 15:24:37 -07007273 * <p>
7274 * Type: BLOB
7275 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007276 public static final String PHOTO = DATA15;
Evan Millar088b2912009-05-28 15:24:37 -07007277 }
7278
7279 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007280 * <p>
Evan Millar088b2912009-05-28 15:24:37 -07007281 * Notes about the contact.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007282 * </p>
7283 * <p>
7284 * You can use all columns defined for {@link ContactsContract.Data} as
7285 * well as the following aliases.
7286 * </p>
7287 * <h2>Column aliases</h2>
7288 * <table class="jd-sumtable">
7289 * <tr>
7290 * <th>Type</th>
7291 * <th>Alias</th><th colspan='2'>Data column</th>
7292 * </tr>
7293 * <tr>
7294 * <td>String</td>
7295 * <td>{@link #NOTE}</td>
7296 * <td>{@link #DATA1}</td>
7297 * <td></td>
7298 * </tr>
7299 * </table>
Evan Millar088b2912009-05-28 15:24:37 -07007300 */
Yorke Lee94c87612014-07-18 18:57:17 -07007301 public static final class Note implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007302 /**
7303 * This utility class cannot be instantiated
7304 */
Evan Millar088b2912009-05-28 15:24:37 -07007305 private Note() {}
7306
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007307 /** MIME type used when storing this in data table. */
Evan Millar088b2912009-05-28 15:24:37 -07007308 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
7309
7310 /**
7311 * The note text.
7312 * <P>Type: TEXT</P>
7313 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007314 public static final String NOTE = DATA1;
Evan Millar088b2912009-05-28 15:24:37 -07007315 }
Dmitri Plotnikov56927772009-05-28 17:23:39 -07007316
Dmitri Plotnikovc9260542009-05-28 17:55:12 -07007317 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007318 * <p>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007319 * Group Membership.
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007320 * </p>
7321 * <p>
7322 * You can use all columns defined for {@link ContactsContract.Data} as
7323 * well as the following aliases.
7324 * </p>
7325 * <h2>Column aliases</h2>
7326 * <table class="jd-sumtable">
7327 * <tr>
7328 * <th>Type</th>
7329 * <th>Alias</th><th colspan='2'>Data column</th>
7330 * </tr>
7331 * <tr>
7332 * <td>long</td>
7333 * <td>{@link #GROUP_ROW_ID}</td>
7334 * <td>{@link #DATA1}</td>
7335 * <td></td>
7336 * </tr>
7337 * <tr>
7338 * <td>String</td>
7339 * <td>{@link #GROUP_SOURCE_ID}</td>
7340 * <td>none</td>
7341 * <td>
7342 * <p>
7343 * The sourceid of the group that this group membership refers to.
7344 * Exactly one of this or {@link #GROUP_ROW_ID} must be set when
7345 * inserting a row.
7346 * </p>
7347 * <p>
7348 * If this field is specified, the provider will first try to
7349 * look up a group with this {@link Groups Groups.SOURCE_ID}. If such a group
7350 * is found, it will use the corresponding row id. If the group is not
7351 * found, it will create one.
7352 * </td>
7353 * </tr>
7354 * </table>
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007355 */
Yorke Lee94c87612014-07-18 18:57:17 -07007356 public static final class GroupMembership implements DataColumnsWithJoins, ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007357 /**
7358 * This utility class cannot be instantiated
7359 */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007360 private GroupMembership() {}
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007361
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007362 /** MIME type used when storing this in data table. */
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007363 public static final String CONTENT_ITEM_TYPE =
7364 "vnd.android.cursor.item/group_membership";
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007365
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007366 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07007367 * The row id of the group that this group membership refers to. Exactly one of
7368 * this or {@link #GROUP_SOURCE_ID} must be set when inserting a row.
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007369 * <P>Type: INTEGER</P>
7370 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007371 public static final String GROUP_ROW_ID = DATA1;
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007372
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007373 /**
Fred Quintanaffc34c12009-07-14 16:02:58 -07007374 * The sourceid of the group that this group membership refers to. Exactly one of
7375 * this or {@link #GROUP_ROW_ID} must be set when inserting a row.
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007376 * <P>Type: TEXT</P>
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007377 */
Fred Quintanaffc34c12009-07-14 16:02:58 -07007378 public static final String GROUP_SOURCE_ID = "group_sourceid";
Fred Quintanad8dfeb52009-06-04 10:28:49 -07007379 }
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007380
7381 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007382 * <p>
7383 * A data kind representing a website related to the contact.
7384 * </p>
7385 * <p>
7386 * You can use all columns defined for {@link ContactsContract.Data} as
7387 * well as the following aliases.
7388 * </p>
7389 * <h2>Column aliases</h2>
7390 * <table class="jd-sumtable">
7391 * <tr>
7392 * <th>Type</th>
7393 * <th>Alias</th><th colspan='2'>Data column</th>
7394 * </tr>
7395 * <tr>
7396 * <td>String</td>
7397 * <td>{@link #URL}</td>
7398 * <td>{@link #DATA1}</td>
7399 * <td></td>
7400 * </tr>
7401 * <tr>
7402 * <td>int</td>
7403 * <td>{@link #TYPE}</td>
7404 * <td>{@link #DATA2}</td>
7405 * <td>Allowed values are:
7406 * <p>
7407 * <ul>
7408 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7409 * <li>{@link #TYPE_HOMEPAGE}</li>
7410 * <li>{@link #TYPE_BLOG}</li>
7411 * <li>{@link #TYPE_PROFILE}</li>
7412 * <li>{@link #TYPE_HOME}</li>
7413 * <li>{@link #TYPE_WORK}</li>
7414 * <li>{@link #TYPE_FTP}</li>
7415 * <li>{@link #TYPE_OTHER}</li>
7416 * </ul>
7417 * </p>
7418 * </td>
7419 * </tr>
7420 * <tr>
7421 * <td>String</td>
7422 * <td>{@link #LABEL}</td>
7423 * <td>{@link #DATA3}</td>
7424 * <td></td>
7425 * </tr>
7426 * </table>
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007427 */
Yorke Lee94c87612014-07-18 18:57:17 -07007428 public static final class Website implements DataColumnsWithJoins, CommonColumns,
7429 ContactCounts {
Jeff Hamilton85abdc52009-09-22 12:41:45 -05007430 /**
7431 * This utility class cannot be instantiated
7432 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007433 private Website() {}
7434
7435 /** MIME type used when storing this in data table. */
7436 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/website";
7437
Fred Quintana8851e162009-08-05 21:06:45 -07007438 public static final int TYPE_HOMEPAGE = 1;
7439 public static final int TYPE_BLOG = 2;
7440 public static final int TYPE_PROFILE = 3;
7441 public static final int TYPE_HOME = 4;
7442 public static final int TYPE_WORK = 5;
7443 public static final int TYPE_FTP = 6;
7444 public static final int TYPE_OTHER = 7;
7445
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007446 /**
7447 * The website URL string.
7448 * <P>Type: TEXT</P>
7449 */
Dmitri Plotnikov15e26692009-09-20 07:56:06 -07007450 public static final String URL = DATA;
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007451 }
David Brown846eb302010-08-23 17:40:51 -07007452
7453 /**
7454 * <p>
7455 * A data kind representing a SIP address for the contact.
7456 * </p>
7457 * <p>
7458 * You can use all columns defined for {@link ContactsContract.Data} as
7459 * well as the following aliases.
7460 * </p>
7461 * <h2>Column aliases</h2>
7462 * <table class="jd-sumtable">
7463 * <tr>
7464 * <th>Type</th>
7465 * <th>Alias</th><th colspan='2'>Data column</th>
7466 * </tr>
7467 * <tr>
7468 * <td>String</td>
7469 * <td>{@link #SIP_ADDRESS}</td>
7470 * <td>{@link #DATA1}</td>
7471 * <td></td>
7472 * </tr>
David Brown747c6152010-09-15 13:34:13 -07007473 * <tr>
7474 * <td>int</td>
7475 * <td>{@link #TYPE}</td>
7476 * <td>{@link #DATA2}</td>
7477 * <td>Allowed values are:
7478 * <p>
7479 * <ul>
7480 * <li>{@link #TYPE_CUSTOM}. Put the actual type in {@link #LABEL}.</li>
7481 * <li>{@link #TYPE_HOME}</li>
7482 * <li>{@link #TYPE_WORK}</li>
7483 * <li>{@link #TYPE_OTHER}</li>
7484 * </ul>
7485 * </p>
7486 * </td>
7487 * </tr>
7488 * <tr>
7489 * <td>String</td>
7490 * <td>{@link #LABEL}</td>
7491 * <td>{@link #DATA3}</td>
7492 * <td></td>
7493 * </tr>
David Brown846eb302010-08-23 17:40:51 -07007494 * </table>
7495 */
Yorke Lee94c87612014-07-18 18:57:17 -07007496 public static final class SipAddress implements DataColumnsWithJoins, CommonColumns,
7497 ContactCounts {
David Brown846eb302010-08-23 17:40:51 -07007498 /**
7499 * This utility class cannot be instantiated
7500 */
7501 private SipAddress() {}
7502
7503 /** MIME type used when storing this in data table. */
7504 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/sip_address";
7505
David Brown747c6152010-09-15 13:34:13 -07007506 public static final int TYPE_HOME = 1;
7507 public static final int TYPE_WORK = 2;
7508 public static final int TYPE_OTHER = 3;
7509
David Brown846eb302010-08-23 17:40:51 -07007510 /**
7511 * The SIP address.
7512 * <P>Type: TEXT</P>
7513 */
7514 public static final String SIP_ADDRESS = DATA1;
David Brown747c6152010-09-15 13:34:13 -07007515 // ...and TYPE and LABEL come from the CommonColumns interface.
7516
7517 /**
7518 * Return the string resource that best describes the given
7519 * {@link #TYPE}. Will always return a valid resource.
7520 */
7521 public static final int getTypeLabelResource(int type) {
7522 switch (type) {
7523 case TYPE_HOME: return com.android.internal.R.string.sipAddressTypeHome;
7524 case TYPE_WORK: return com.android.internal.R.string.sipAddressTypeWork;
7525 case TYPE_OTHER: return com.android.internal.R.string.sipAddressTypeOther;
7526 default: return com.android.internal.R.string.sipAddressTypeCustom;
7527 }
7528 }
7529
7530 /**
7531 * Return a {@link CharSequence} that best describes the given type,
7532 * possibly substituting the given {@link #LABEL} value
7533 * for {@link #TYPE_CUSTOM}.
7534 */
7535 public static final CharSequence getTypeLabel(Resources res, int type,
7536 CharSequence label) {
7537 if (type == TYPE_CUSTOM && !TextUtils.isEmpty(label)) {
7538 return label;
7539 } else {
7540 final int labelRes = getTypeLabelResource(type);
7541 return res.getText(labelRes);
7542 }
7543 }
David Brown846eb302010-08-23 17:40:51 -07007544 }
Fred Quintana4923f1d2011-08-05 15:58:17 -07007545
7546 /**
7547 * A data kind representing an Identity related to the contact.
7548 * <p>
7549 * This can be used as a signal by the aggregator to combine raw contacts into
7550 * contacts, e.g. if two contacts have Identity rows with
7551 * the same NAMESPACE and IDENTITY values the aggregator can know that they refer
7552 * to the same person.
7553 * </p>
7554 */
Yorke Lee94c87612014-07-18 18:57:17 -07007555 public static final class Identity implements DataColumnsWithJoins, ContactCounts {
Fred Quintana4923f1d2011-08-05 15:58:17 -07007556 /**
7557 * This utility class cannot be instantiated
7558 */
7559 private Identity() {}
7560
7561 /** MIME type used when storing this in data table. */
7562 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/identity";
7563
7564 /**
7565 * The identity string.
7566 * <P>Type: TEXT</P>
7567 */
7568 public static final String IDENTITY = DataColumns.DATA1;
7569
7570 /**
7571 * The namespace of the identity string, e.g. "com.google"
7572 * <P>Type: TEXT</P>
7573 */
7574 public static final String NAMESPACE = DataColumns.DATA2;
7575 }
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007576
7577 /**
7578 * <p>
7579 * Convenient functionalities for "callable" data. Note that, this is NOT a separate data
7580 * kind.
7581 * </p>
7582 * <p>
7583 * This URI allows the ContactsProvider to return a unified result for "callable" data
7584 * that users can use for calling purposes. {@link Phone} and {@link SipAddress} are the
7585 * current examples for "callable", but may be expanded to the other types.
7586 * </p>
7587 * <p>
7588 * Each returned row may have a different MIMETYPE and thus different interpretation for
7589 * each column. For example the meaning for {@link Phone}'s type is different than
7590 * {@link SipAddress}'s.
7591 * </p>
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007592 */
Yorke Lee94c87612014-07-18 18:57:17 -07007593 public static final class Callable implements DataColumnsWithJoins, CommonColumns,
7594 ContactCounts {
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007595 /**
7596 * Similar to {@link Phone#CONTENT_URI}, but returns callable data instead of only
7597 * phone numbers.
7598 */
7599 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7600 "callables");
7601 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07007602 * <p>Similar to {@link Phone#CONTENT_FILTER_URI}, but allows users to filter callable
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007603 * data.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07007604 *
7605 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
7606 * sorts results based on contacts frequency. For more information, see the
7607 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
7608 * page.
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007609 */
7610 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
7611 "filter");
Victor Chang3d47ceb2015-12-01 16:30:43 +00007612
7613 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07007614 * <p>Similar to {@link Phone#ENTERPRISE_CONTENT_FILTER_URI}, but allows users to filter
Victor Chang3d47ceb2015-12-01 16:30:43 +00007615 * callable data. This URI requires {@link ContactsContract#DIRECTORY_PARAM_KEY} in
Ricky Wai149a6c92016-04-25 12:14:53 +01007616 * parameters, otherwise it will throw IllegalArgumentException.
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07007617 *
7618 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
7619 * sorts results based on contacts frequency. For more information, see the
7620 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
7621 * page.</p>
Victor Chang3d47ceb2015-12-01 16:30:43 +00007622 */
7623 public static final Uri ENTERPRISE_CONTENT_FILTER_URI = Uri.withAppendedPath(
7624 CONTENT_URI, "filter_enterprise");
Daisuke Miyakawa3d340e72011-10-23 10:46:30 -07007625 }
Yorke Lee4f401eb2013-03-06 17:17:17 -08007626
7627 /**
7628 * A special class of data items, used to refer to types of data that can be used to attempt
7629 * to start communicating with a person ({@link Phone} and {@link Email}). Note that this
7630 * is NOT a separate data kind.
7631 *
7632 * This URI allows the ContactsProvider to return a unified result for data items that users
7633 * can use to initiate communications with another contact. {@link Phone} and {@link Email}
7634 * are the current data types in this category.
7635 */
Yorke Lee94c87612014-07-18 18:57:17 -07007636 public static final class Contactables implements DataColumnsWithJoins, CommonColumns,
7637 ContactCounts {
Yorke Lee4f401eb2013-03-06 17:17:17 -08007638 /**
7639 * The content:// style URI for these data items, which requests a directory of data
7640 * rows matching the selection criteria.
7641 */
7642 public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
7643 "contactables");
7644
7645 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07007646 * <p>The content:// style URI for these data items, which allows for a query parameter
7647 * to be appended onto the end to filter for data items matching the query.
7648 *
7649 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this field no longer
7650 * sorts results based on contacts frequency. For more information, see the
7651 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
7652 * page.
Yorke Lee4f401eb2013-03-06 17:17:17 -08007653 */
7654 public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(
7655 Contactables.CONTENT_URI, "filter");
7656
7657 /**
7658 * A boolean parameter for {@link Data#CONTENT_URI}.
7659 * This specifies whether or not the returned data items should be filtered to show
7660 * data items belonging to visible contacts only.
7661 */
7662 public static final String VISIBLE_CONTACTS_ONLY = "visible_contacts_only";
7663 }
Dmitri Plotnikovceaafa52009-06-03 10:46:44 -07007664 }
Fred Quintana435e4272009-06-04 17:30:28 -07007665
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007666 /**
7667 * @see Groups
7668 */
Dmitri Plotnikov6e144ad2009-10-13 18:08:25 -07007669 protected interface GroupsColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007670 /**
Dave Santorod7bdc182011-06-24 15:39:39 -07007671 * The data set within the account that this group belongs to. This allows
7672 * multiple sync adapters for the same account type to distinguish between
7673 * each others' group data.
7674 *
7675 * This is empty by default, and is completely optional. It only needs to
7676 * be populated if multiple sync adapters are entering distinct group data
7677 * for the same account type and account name.
7678 * <P>Type: TEXT</P>
7679 */
7680 public static final String DATA_SET = "data_set";
7681
7682 /**
Dave Santoro1d55c332011-07-25 16:44:45 -07007683 * A concatenation of the account type and data set (delimited by a forward
7684 * slash) - if the data set is empty, this will be the same as the account
7685 * type. For applications that need to be aware of the data set, this can
7686 * be used instead of account type to distinguish sets of data. This is
7687 * never intended to be used for specifying accounts.
7688 * @hide
7689 */
7690 public static final String ACCOUNT_TYPE_AND_DATA_SET = "account_type_and_data_set";
7691
7692 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007693 * The display title of this group.
7694 * <p>
7695 * Type: TEXT
7696 */
7697 public static final String TITLE = "title";
7698
7699 /**
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007700 * The package name to use when creating {@link Resources} objects for
7701 * this group. This value is only designed for use when building user
7702 * interfaces, and should not be used to infer the owner.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007703 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007704 public static final String RES_PACKAGE = "res_package";
7705
7706 /**
7707 * The display title of this group to load as a resource from
7708 * {@link #RES_PACKAGE}, which may be localized.
7709 * <P>Type: TEXT</P>
7710 */
7711 public static final String TITLE_RES = "title_res";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007712
7713 /**
Dmitri Plotnikov02c5b452009-07-22 15:13:08 -07007714 * Notes about the group.
7715 * <p>
7716 * Type: TEXT
7717 */
7718 public static final String NOTES = "notes";
7719
7720 /**
7721 * The ID of this group if it is a System Group, i.e. a group that has a special meaning
7722 * to the sync adapter, null otherwise.
7723 * <P>Type: TEXT</P>
7724 */
7725 public static final String SYSTEM_ID = "system_id";
7726
7727 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007728 * The total number of {@link Contacts} that have
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007729 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value that is only
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007730 * present when querying {@link Groups#CONTENT_SUMMARY_URI}.
7731 * <p>
7732 * Type: INTEGER
7733 */
7734 public static final String SUMMARY_COUNT = "summ_count";
7735
7736 /**
Daisuke Miyakawa15dec392011-07-23 11:39:23 -07007737 * A boolean query parameter that can be used with {@link Groups#CONTENT_SUMMARY_URI}.
7738 * It will additionally return {@link #SUMMARY_GROUP_COUNT_PER_ACCOUNT}.
7739 *
7740 * @hide
7741 */
7742 public static final String PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT =
7743 "return_group_count_per_account";
7744
7745 /**
7746 * The total number of groups of the account that a group belongs to.
7747 * This column is available only when the parameter
7748 * {@link #PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT} is specified in
7749 * {@link Groups#CONTENT_SUMMARY_URI}.
7750 *
7751 * For example, when the account "A" has two groups "group1" and "group2", and the account
7752 * "B" has a group "group3", the rows for "group1" and "group2" return "2" and the row for
7753 * "group3" returns "1" for this column.
7754 *
7755 * Note: This counts only non-favorites, non-auto-add, and not deleted groups.
7756 *
7757 * Type: INTEGER
7758 * @hide
7759 */
7760 public static final String SUMMARY_GROUP_COUNT_PER_ACCOUNT = "group_count_per_account";
7761
7762 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07007763 * The total number of {@link Contacts} that have both
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07007764 * {@link CommonDataKinds.GroupMembership} in this group, and also have phone numbers.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007765 * Read-only value that is only present when querying
7766 * {@link Groups#CONTENT_SUMMARY_URI}.
7767 * <p>
7768 * Type: INTEGER
7769 */
7770 public static final String SUMMARY_WITH_PHONES = "summ_phones";
7771
7772 /**
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007773 * Flag indicating if the contacts belonging to this group should be
7774 * visible in any user interface.
7775 * <p>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07007776 * Type: INTEGER (boolean)
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007777 */
7778 public static final String GROUP_VISIBLE = "group_visible";
Fred Quintana00c89f62009-08-10 14:43:24 -07007779
7780 /**
7781 * The "deleted" flag: "0" by default, "1" if the row has been marked
7782 * for deletion. When {@link android.content.ContentResolver#delete} is
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007783 * called on a group, it is marked for deletion. The sync adaptor
7784 * deletes the group on the server and then calls ContactResolver.delete
7785 * once more, this time setting the the
7786 * {@link ContactsContract#CALLER_IS_SYNCADAPTER} query parameter to
7787 * finalize the data removal.
Fred Quintana00c89f62009-08-10 14:43:24 -07007788 * <P>Type: INTEGER</P>
7789 */
7790 public static final String DELETED = "deleted";
Jeff Sharkey403d7ac2009-08-16 16:34:35 -07007791
7792 /**
7793 * Whether this group should be synced if the SYNC_EVERYTHING settings
7794 * is false for this group's account.
7795 * <p>
7796 * Type: INTEGER (boolean)
7797 */
7798 public static final String SHOULD_SYNC = "should_sync";
Fred Quintanaa31a9452010-04-13 14:52:20 -07007799
7800 /**
7801 * Any newly created contacts will automatically be added to groups that have this
7802 * flag set to true.
7803 * <p>
7804 * Type: INTEGER (boolean)
7805 */
7806 public static final String AUTO_ADD = "auto_add";
7807
7808 /**
7809 * When a contacts is marked as a favorites it will be automatically added
7810 * to the groups that have this flag set, and when it is removed from favorites
7811 * it will be removed from these groups.
7812 * <p>
7813 * Type: INTEGER (boolean)
7814 */
7815 public static final String FAVORITES = "favorites";
Dmitri Plotnikov4ccf33a2010-11-19 11:10:43 -08007816
7817 /**
7818 * The "read-only" flag: "0" by default, "1" if the row cannot be modified or
7819 * deleted except by a sync adapter. See {@link ContactsContract#CALLER_IS_SYNCADAPTER}.
7820 * <P>Type: INTEGER</P>
7821 */
7822 public static final String GROUP_IS_READ_ONLY = "group_is_read_only";
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007823 }
7824
7825 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007826 * Constants for the groups table. Only per-account groups are supported.
7827 * <h2>Columns</h2>
7828 * <table class="jd-sumtable">
7829 * <tr>
7830 * <th colspan='4'>Groups</th>
7831 * </tr>
7832 * <tr>
7833 * <td>long</td>
7834 * <td>{@link #_ID}</td>
7835 * <td>read-only</td>
7836 * <td>Row ID. Sync adapter should try to preserve row IDs during updates.
7837 * In other words, it would be a really bad idea to delete and reinsert a
7838 * group. A sync adapter should always do an update instead.</td>
7839 * </tr>
Dave Santorod7bdc182011-06-24 15:39:39 -07007840 # <tr>
7841 * <td>String</td>
7842 * <td>{@link #DATA_SET}</td>
7843 * <td>read/write-once</td>
7844 * <td>
7845 * <p>
7846 * The data set within the account that this group belongs to. This allows
7847 * multiple sync adapters for the same account type to distinguish between
7848 * each others' group data. The combination of {@link #ACCOUNT_TYPE},
7849 * {@link #ACCOUNT_NAME}, and {@link #DATA_SET} identifies a set of data
7850 * that is associated with a single sync adapter.
7851 * </p>
7852 * <p>
7853 * This is empty by default, and is completely optional. It only needs to
7854 * be populated if multiple sync adapters are entering distinct data for
7855 * the same account type and account name.
7856 * </p>
7857 * <p>
7858 * It should be set at the time the group is inserted and never changed
7859 * afterwards.
7860 * </p>
7861 * </td>
7862 * </tr>
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007863 * <tr>
7864 * <td>String</td>
7865 * <td>{@link #TITLE}</td>
7866 * <td>read/write</td>
7867 * <td>The display title of this group.</td>
7868 * </tr>
7869 * <tr>
7870 * <td>String</td>
7871 * <td>{@link #NOTES}</td>
7872 * <td>read/write</td>
7873 * <td>Notes about the group.</td>
7874 * </tr>
7875 * <tr>
7876 * <td>String</td>
7877 * <td>{@link #SYSTEM_ID}</td>
7878 * <td>read/write</td>
7879 * <td>The ID of this group if it is a System Group, i.e. a group that has a
7880 * special meaning to the sync adapter, null otherwise.</td>
7881 * </tr>
7882 * <tr>
7883 * <td>int</td>
7884 * <td>{@link #SUMMARY_COUNT}</td>
7885 * <td>read-only</td>
7886 * <td>The total number of {@link Contacts} that have
7887 * {@link CommonDataKinds.GroupMembership} in this group. Read-only value
7888 * that is only present when querying {@link Groups#CONTENT_SUMMARY_URI}.</td>
7889 * </tr>
7890 * <tr>
7891 * <td>int</td>
7892 * <td>{@link #SUMMARY_WITH_PHONES}</td>
7893 * <td>read-only</td>
7894 * <td>The total number of {@link Contacts} that have both
7895 * {@link CommonDataKinds.GroupMembership} in this group, and also have
7896 * phone numbers. Read-only value that is only present when querying
7897 * {@link Groups#CONTENT_SUMMARY_URI}.</td>
7898 * </tr>
7899 * <tr>
7900 * <td>int</td>
7901 * <td>{@link #GROUP_VISIBLE}</td>
7902 * <td>read-only</td>
7903 * <td>Flag indicating if the contacts belonging to this group should be
7904 * visible in any user interface. Allowed values: 0 and 1.</td>
7905 * </tr>
7906 * <tr>
7907 * <td>int</td>
7908 * <td>{@link #DELETED}</td>
7909 * <td>read/write</td>
7910 * <td>The "deleted" flag: "0" by default, "1" if the row has been marked
7911 * for deletion. When {@link android.content.ContentResolver#delete} is
7912 * called on a group, it is marked for deletion. The sync adaptor deletes
7913 * the group on the server and then calls ContactResolver.delete once more,
7914 * this time setting the the {@link ContactsContract#CALLER_IS_SYNCADAPTER}
7915 * query parameter to finalize the data removal.</td>
7916 * </tr>
7917 * <tr>
7918 * <td>int</td>
7919 * <td>{@link #SHOULD_SYNC}</td>
7920 * <td>read/write</td>
7921 * <td>Whether this group should be synced if the SYNC_EVERYTHING settings
7922 * is false for this group's account.</td>
7923 * </tr>
7924 * </table>
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007925 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007926 public static final class Groups implements BaseColumns, GroupsColumns, SyncColumns {
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007927 /**
7928 * This utility class cannot be instantiated
7929 */
Jeff Sharkey8a0193e2009-07-20 23:28:23 -07007930 private Groups() {
7931 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007932
7933 /**
7934 * The content:// style URI for this table
7935 */
7936 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "groups");
7937
7938 /**
7939 * The content:// style URI for this table joined with details data from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007940 * {@link ContactsContract.Data}.
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007941 */
7942 public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
7943 "groups_summary");
7944
7945 /**
7946 * The MIME type of a directory of groups.
7947 */
7948 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/group";
7949
7950 /**
7951 * The MIME type of a single group.
7952 */
7953 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/group";
Fred Quintana328c0e72009-12-07 14:52:28 -08007954
7955 public static EntityIterator newEntityIterator(Cursor cursor) {
7956 return new EntityIteratorImpl(cursor);
7957 }
7958
7959 private static class EntityIteratorImpl extends CursorEntityIterator {
7960 public EntityIteratorImpl(Cursor cursor) {
7961 super(cursor);
7962 }
7963
Dmitri Plotnikovb4413fa2009-12-17 20:05:50 -08007964 @Override
Fred Quintana328c0e72009-12-07 14:52:28 -08007965 public Entity getEntityAndIncrementCursor(Cursor cursor) throws RemoteException {
7966 // we expect the cursor is already at the row we need to read from
7967 final ContentValues values = new ContentValues();
7968 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, _ID);
7969 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_NAME);
7970 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, ACCOUNT_TYPE);
7971 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DIRTY);
7972 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, VERSION);
7973 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SOURCE_ID);
7974 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, RES_PACKAGE);
7975 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE);
7976 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, TITLE_RES);
7977 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, GROUP_VISIBLE);
7978 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC1);
7979 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC2);
7980 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC3);
7981 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYNC4);
7982 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SYSTEM_ID);
7983 DatabaseUtils.cursorLongToContentValuesIfPresent(cursor, values, DELETED);
7984 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, NOTES);
7985 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, SHOULD_SYNC);
Fred Quintanaa31a9452010-04-13 14:52:20 -07007986 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, FAVORITES);
7987 DatabaseUtils.cursorStringToContentValuesIfPresent(cursor, values, AUTO_ADD);
Fred Quintana328c0e72009-12-07 14:52:28 -08007988 cursor.moveToNext();
7989 return new Entity(values);
7990 }
7991 }
Jeff Sharkeyb2909eb2009-06-16 16:55:31 -07007992 }
7993
Fred Quintana435e4272009-06-04 17:30:28 -07007994 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007995 * <p>
Fred Quintana435e4272009-06-04 17:30:28 -07007996 * Constants for the contact aggregation exceptions table, which contains
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08007997 * aggregation rules overriding those used by automatic aggregation. This
7998 * type only supports query and update. Neither insert nor delete are
7999 * supported.
8000 * </p>
8001 * <h2>Columns</h2>
8002 * <table class="jd-sumtable">
8003 * <tr>
8004 * <th colspan='4'>AggregationExceptions</th>
8005 * </tr>
8006 * <tr>
8007 * <td>int</td>
8008 * <td>{@link #TYPE}</td>
8009 * <td>read/write</td>
8010 * <td>The type of exception: {@link #TYPE_KEEP_TOGETHER},
8011 * {@link #TYPE_KEEP_SEPARATE} or {@link #TYPE_AUTOMATIC}.</td>
8012 * </tr>
8013 * <tr>
8014 * <td>long</td>
8015 * <td>{@link #RAW_CONTACT_ID1}</td>
8016 * <td>read/write</td>
8017 * <td>A reference to the {@link RawContacts#_ID} of the raw contact that
8018 * the rule applies to.</td>
8019 * </tr>
8020 * <tr>
8021 * <td>long</td>
8022 * <td>{@link #RAW_CONTACT_ID2}</td>
8023 * <td>read/write</td>
8024 * <td>A reference to the other {@link RawContacts#_ID} of the raw contact
8025 * that the rule applies to.</td>
8026 * </tr>
8027 * </table>
Fred Quintana435e4272009-06-04 17:30:28 -07008028 */
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07008029 public static final class AggregationExceptions implements BaseColumns {
Fred Quintana435e4272009-06-04 17:30:28 -07008030 /**
8031 * This utility class cannot be instantiated
8032 */
8033 private AggregationExceptions() {}
8034
8035 /**
8036 * The content:// style URI for this table
8037 */
8038 public static final Uri CONTENT_URI =
8039 Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
8040
8041 /**
8042 * The MIME type of {@link #CONTENT_URI} providing a directory of data.
8043 */
8044 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
8045
8046 /**
Dmitri Plotnikov0918bf02009-06-10 16:13:08 -07008047 * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
8048 */
8049 public static final String CONTENT_ITEM_TYPE =
8050 "vnd.android.cursor.item/aggregation_exception";
8051
8052 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008053 * The type of exception: {@link #TYPE_KEEP_TOGETHER}, {@link #TYPE_KEEP_SEPARATE} or
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07008054 * {@link #TYPE_AUTOMATIC}.
Fred Quintana435e4272009-06-04 17:30:28 -07008055 *
8056 * <P>Type: INTEGER</P>
8057 */
8058 public static final String TYPE = "type";
8059
Fred Quintana435e4272009-06-04 17:30:28 -07008060 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008061 * Allows the provider to automatically decide whether the specified raw contacts should
8062 * be included in the same aggregate contact or not.
Fred Quintana435e4272009-06-04 17:30:28 -07008063 */
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07008064 public static final int TYPE_AUTOMATIC = 0;
Fred Quintana435e4272009-06-04 17:30:28 -07008065
8066 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008067 * Makes sure that the specified raw contacts are included in the same
8068 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07008069 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008070 public static final int TYPE_KEEP_TOGETHER = 1;
8071
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07008072 /**
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008073 * Makes sure that the specified raw contacts are NOT included in the same
8074 * aggregate contact.
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07008075 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008076 public static final int TYPE_KEEP_SEPARATE = 2;
8077
Dmitri Plotnikov9d044512009-06-16 13:21:23 -07008078 /**
Dmitri Plotnikov7cca5f82009-07-27 20:25:59 -07008079 * A reference to the {@link RawContacts#_ID} of the raw contact that the rule applies to.
Fred Quintana435e4272009-06-04 17:30:28 -07008080 */
Dmitri Plotnikov84ba0652009-09-04 15:59:05 -07008081 public static final String RAW_CONTACT_ID1 = "raw_contact_id1";
8082
8083 /**
8084 * A reference to the other {@link RawContacts#_ID} of the raw contact that the rule
8085 * applies to.
8086 */
8087 public static final String RAW_CONTACT_ID2 = "raw_contact_id2";
Fred Quintana435e4272009-06-04 17:30:28 -07008088 }
Jeff Sharkey28b68e52009-06-10 15:26:58 -07008089
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008090 /**
8091 * @see Settings
8092 */
Dmitri Plotnikovfe4c8712009-10-14 00:28:48 -07008093 protected interface SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008094 /**
8095 * The name of the account instance to which this row belongs.
8096 * <P>Type: TEXT</P>
8097 */
8098 public static final String ACCOUNT_NAME = "account_name";
8099
8100 /**
8101 * The type of account to which this row belongs, which when paired with
8102 * {@link #ACCOUNT_NAME} identifies a specific account.
8103 * <P>Type: TEXT</P>
8104 */
8105 public static final String ACCOUNT_TYPE = "account_type";
8106
8107 /**
Dave Santoro7c4479f2011-09-07 16:52:27 -07008108 * The data set within the account that this row belongs to. This allows
8109 * multiple sync adapters for the same account type to distinguish between
8110 * each others' data.
8111 *
8112 * This is empty by default, and is completely optional. It only needs to
8113 * be populated if multiple sync adapters are entering distinct data for
8114 * the same account type and account name.
8115 * <P>Type: TEXT</P>
8116 */
8117 public static final String DATA_SET = "data_set";
8118
8119 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07008120 * Depending on the mode defined by the sync-adapter, this flag controls
8121 * the top-level sync behavior for this data source.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008122 * <p>
8123 * Type: INTEGER (boolean)
8124 */
8125 public static final String SHOULD_SYNC = "should_sync";
8126
8127 /**
Dmitri Plotnikov31f5dd32009-08-21 13:44:47 -07008128 * Flag indicating if contacts without any {@link CommonDataKinds.GroupMembership}
Jeff Sharkeya6597442009-08-19 09:23:33 -07008129 * entries should be visible in any user interface.
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008130 * <p>
8131 * Type: INTEGER (boolean)
8132 */
8133 public static final String UNGROUPED_VISIBLE = "ungrouped_visible";
Jeff Sharkey06a03232009-08-21 17:37:56 -07008134
8135 /**
Jeff Sharkey97bda4c2009-09-15 23:15:23 -07008136 * Read-only flag indicating if this {@link #SHOULD_SYNC} or any
8137 * {@link Groups#SHOULD_SYNC} under this account have been marked as
8138 * unsynced.
8139 */
8140 public static final String ANY_UNSYNCED = "any_unsynced";
8141
8142 /**
Jeff Sharkey06a03232009-08-21 17:37:56 -07008143 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07008144 * no {@link CommonDataKinds.GroupMembership} entries.
Jeff Sharkey06a03232009-08-21 17:37:56 -07008145 * <p>
8146 * Type: INTEGER
8147 */
8148 public static final String UNGROUPED_COUNT = "summ_count";
8149
8150 /**
8151 * Read-only count of {@link Contacts} from a specific source that have
Dmitri Plotnikovb87d0e02009-08-27 10:38:14 -07008152 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone numbers.
Jeff Sharkey06a03232009-08-21 17:37:56 -07008153 * <p>
8154 * Type: INTEGER
8155 */
8156 public static final String UNGROUPED_WITH_PHONES = "summ_phones";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008157 }
8158
8159 /**
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008160 * <p>
8161 * Contacts-specific settings for various {@link Account}'s.
8162 * </p>
8163 * <h2>Columns</h2>
8164 * <table class="jd-sumtable">
8165 * <tr>
8166 * <th colspan='4'>Settings</th>
8167 * </tr>
8168 * <tr>
8169 * <td>String</td>
8170 * <td>{@link #ACCOUNT_NAME}</td>
8171 * <td>read/write-once</td>
8172 * <td>The name of the account instance to which this row belongs.</td>
8173 * </tr>
8174 * <tr>
8175 * <td>String</td>
8176 * <td>{@link #ACCOUNT_TYPE}</td>
8177 * <td>read/write-once</td>
8178 * <td>The type of account to which this row belongs, which when paired with
8179 * {@link #ACCOUNT_NAME} identifies a specific account.</td>
8180 * </tr>
8181 * <tr>
8182 * <td>int</td>
8183 * <td>{@link #SHOULD_SYNC}</td>
8184 * <td>read/write</td>
8185 * <td>Depending on the mode defined by the sync-adapter, this flag controls
8186 * the top-level sync behavior for this data source.</td>
8187 * </tr>
8188 * <tr>
8189 * <td>int</td>
8190 * <td>{@link #UNGROUPED_VISIBLE}</td>
8191 * <td>read/write</td>
8192 * <td>Flag indicating if contacts without any
8193 * {@link CommonDataKinds.GroupMembership} entries should be visible in any
8194 * user interface.</td>
8195 * </tr>
8196 * <tr>
8197 * <td>int</td>
8198 * <td>{@link #ANY_UNSYNCED}</td>
8199 * <td>read-only</td>
8200 * <td>Read-only flag indicating if this {@link #SHOULD_SYNC} or any
8201 * {@link Groups#SHOULD_SYNC} under this account have been marked as
8202 * unsynced.</td>
8203 * </tr>
8204 * <tr>
8205 * <td>int</td>
8206 * <td>{@link #UNGROUPED_COUNT}</td>
8207 * <td>read-only</td>
8208 * <td>Read-only count of {@link Contacts} from a specific source that have
8209 * no {@link CommonDataKinds.GroupMembership} entries.</td>
8210 * </tr>
8211 * <tr>
8212 * <td>int</td>
8213 * <td>{@link #UNGROUPED_WITH_PHONES}</td>
8214 * <td>read-only</td>
8215 * <td>Read-only count of {@link Contacts} from a specific source that have
8216 * no {@link CommonDataKinds.GroupMembership} entries, and also have phone
8217 * numbers.</td>
8218 * </tr>
8219 * </table>
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008220 */
Jeff Sharkey06a03232009-08-21 17:37:56 -07008221 public static final class Settings implements SettingsColumns {
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008222 /**
8223 * This utility class cannot be instantiated
8224 */
8225 private Settings() {
8226 }
8227
8228 /**
8229 * The content:// style URI for this table
8230 */
8231 public static final Uri CONTENT_URI =
8232 Uri.withAppendedPath(AUTHORITY_URI, "settings");
8233
8234 /**
8235 * The MIME-type of {@link #CONTENT_URI} providing a directory of
8236 * settings.
8237 */
8238 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/setting";
8239
8240 /**
8241 * The MIME-type of {@link #CONTENT_URI} providing a single setting.
8242 */
8243 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/setting";
Jeff Sharkey7b6771a2009-08-17 01:59:54 -07008244 }
8245
Evan Millardc2da5f2009-06-18 16:07:13 -07008246 /**
Brian Attwellcc4b2f72015-01-08 14:58:15 -08008247 * API for inquiring about the general status of the provider.
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008248 */
8249 public static final class ProviderStatus {
8250
8251 /**
8252 * Not instantiable.
8253 */
8254 private ProviderStatus() {
8255 }
8256
8257 /**
8258 * The content:// style URI for this table. Requests to this URI can be
8259 * performed on the UI thread because they are always unblocking.
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008260 */
8261 public static final Uri CONTENT_URI =
8262 Uri.withAppendedPath(AUTHORITY_URI, "provider_status");
8263
8264 /**
8265 * The MIME-type of {@link #CONTENT_URI} providing a directory of
8266 * settings.
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008267 */
8268 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/provider_status";
8269
8270 /**
8271 * An integer representing the current status of the provider.
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008272 */
8273 public static final String STATUS = "status";
8274
8275 /**
8276 * Default status of the provider.
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008277 */
8278 public static final int STATUS_NORMAL = 0;
8279
8280 /**
Brian Attwellb36ad5d2015-05-28 19:25:21 -07008281 * The provider won't respond to queries. It is in the middle of a long running task, such
8282 * as a database upgrade or locale change.
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008283 */
Brian Attwellb36ad5d2015-05-28 19:25:21 -07008284 public static final int STATUS_BUSY = 1;
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008285
8286 /**
Dmitri Plotnikov37c34862010-11-12 16:12:53 -08008287 * The status that indicates that there are no accounts and no contacts
8288 * on the device.
Dmitri Plotnikov37c34862010-11-12 16:12:53 -08008289 */
Brian Attwellb36ad5d2015-05-28 19:25:21 -07008290 public static final int STATUS_EMPTY = 2;
Makoto Onuki729a87b2017-01-11 13:40:06 -08008291
8292 /**
8293 * Timestamp (milliseconds since epoch) of when the provider's database was created.
8294 *
8295 * <P>Type: long
8296 */
8297 public static final String DATABASE_CREATION_TIMESTAMP = "database_creation_timestamp";
Dmitri Plotnikov4a8a3102010-03-08 19:40:19 -08008298 }
8299
8300 /**
Kevin Hufnagle94b9e052018-10-01 07:04:44 -07008301 * <p class="caution"><b>Caution: </b>As of January 7, 2019, this class is obsolete. For
8302 * more information, see the
8303 * <a href="/guide/topics/providers/contacts-provider#ObsoleteData">Contacts Provider</a>
8304 * page.
8305 * </p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008306 * <p>
8307 * API allowing applications to send usage information for each {@link Data} row to the
Makoto Onukib0d22992012-04-12 17:09:58 -07008308 * Contacts Provider. Applications can also clear all usage information.
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008309 * </p>
8310 * <p>
8311 * With the feedback, Contacts Provider may return more contextually appropriate results for
8312 * Data listing, typically supplied with
8313 * {@link ContactsContract.Contacts#CONTENT_FILTER_URI},
8314 * {@link ContactsContract.CommonDataKinds.Email#CONTENT_FILTER_URI},
8315 * {@link ContactsContract.CommonDataKinds.Phone#CONTENT_FILTER_URI}, and users can benefit
8316 * from better ranked (sorted) lists in applications that show auto-complete list.
8317 * </p>
8318 * <p>
8319 * There is no guarantee for how this feedback is used, or even whether it is used at all.
8320 * The ranking algorithm will make best efforts to use the feedback data, but the exact
8321 * implementation, the storage data structures as well as the resulting sort order is device
8322 * and version specific and can change over time.
8323 * </p>
8324 * <p>
8325 * When updating usage information, users of this API need to use
8326 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} with a Uri constructed
8327 * from {@link DataUsageFeedback#FEEDBACK_URI}. The Uri must contain one or more data id(s) as
8328 * its last path. They also need to append a query parameter to the Uri, to specify the type of
8329 * the communication, which enables the Contacts Provider to differentiate between kinds of
8330 * interactions using the same contact data field (for example a phone number can be used to
8331 * make phone calls or send SMS).
8332 * </p>
8333 * <p>
8334 * Selection and selectionArgs are ignored and must be set to null. To get data ids,
8335 * you may need to call {@link ContentResolver#query(Uri, String[], String, String[], String)}
8336 * toward {@link Data#CONTENT_URI}.
8337 * </p>
8338 * <p>
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07008339 * {@link ContentResolver#update(Uri, ContentValues, String, String[])} returns a positive
8340 * integer when successful, and returns 0 if no contact with that id was found.
8341 * </p>
8342 * <p>
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008343 * Example:
8344 * <pre>
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07008345 * Uri uri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008346 * .appendPath(TextUtils.join(",", dataIds))
Daisuke Miyakawa52e38232011-06-14 10:56:46 -07008347 * .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
8348 * DataUsageFeedback.USAGE_TYPE_CALL)
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008349 * .build();
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07008350 * boolean successful = resolver.update(uri, new ContentValues(), null, null) > 0;
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008351 * </pre>
8352 * </p>
Makoto Onukib0d22992012-04-12 17:09:58 -07008353 * <p>
8354 * Applications can also clear all usage information with:
8355 * <pre>
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07008356 * boolean successful = resolver.delete(DataUsageFeedback.DELETE_USAGE_URI, null, null) > 0;
Makoto Onukib0d22992012-04-12 17:09:58 -07008357 * </pre>
8358 * </p>
Makoto Onukiaa2dd622018-07-30 11:14:12 -07008359 *
8360 * @deprecated Contacts affinity information is no longer supported as of
8361 * Android version {@link android.os.Build.VERSION_CODES#Q}.
8362 * Both update and delete calls are always ignored.
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008363 */
Makoto Onukiaa2dd622018-07-30 11:14:12 -07008364 @Deprecated
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008365 public static final class DataUsageFeedback {
8366
8367 /**
8368 * The content:// style URI for sending usage feedback.
8369 * Must be used with {@link ContentResolver#update(Uri, ContentValues, String, String[])}.
8370 */
8371 public static final Uri FEEDBACK_URI =
8372 Uri.withAppendedPath(Data.CONTENT_URI, "usagefeedback");
8373
8374 /**
Makoto Onuki7ebbfd02012-04-13 12:56:42 -07008375 * The content:// style URI for deleting all usage information.
8376 * Must be used with {@link ContentResolver#delete(Uri, String, String[])}.
8377 * The {@code where} and {@code selectionArgs} parameters are ignored.
8378 */
8379 public static final Uri DELETE_USAGE_URI =
8380 Uri.withAppendedPath(Contacts.CONTENT_URI, "delete_usage");
8381
8382 /**
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008383 * <p>
8384 * Name for query parameter specifying the type of data usage.
8385 * </p>
8386 */
Daisuke Miyakawa63b709d2011-06-09 11:00:19 -07008387 public static final String USAGE_TYPE = "type";
Daisuke Miyakawab2b651f2011-06-06 17:28:09 -07008388
8389 /**
8390 * <p>
8391 * Type of usage for voice interaction, which includes phone call, voice chat, and
8392 * video chat.
8393 * </p>
8394 */
8395 public static final String USAGE_TYPE_CALL = "call";
8396
8397 /**
8398 * <p>
8399 * Type of usage for text interaction involving longer messages, which includes email.
8400 * </p>
8401 */
8402 public static final String USAGE_TYPE_LONG_TEXT = "long_text";
8403
8404 /**
8405 * <p>
8406 * Type of usage for text interaction involving shorter messages, which includes SMS,
8407 * text chat with email addresses.
8408 * </p>
8409 */
8410 public static final String USAGE_TYPE_SHORT_TEXT = "short_text";
8411 }
8412
8413 /**
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008414 * <p>
Yorke Leecadbe4c2014-06-20 11:52:27 -07008415 * Contact-specific information about whether or not a contact has been pinned by the user
8416 * at a particular position within the system contact application's user interface.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008417 * </p>
8418 *
8419 * <p>
8420 * This pinning information can be used by individual applications to customize how
8421 * they order particular pinned contacts. For example, a Dialer application could
8422 * use pinned information to order user-pinned contacts in a top row of favorites.
8423 * </p>
8424 *
8425 * <p>
8426 * It is possible for two or more contacts to occupy the same pinned position (due
8427 * to aggregation and sync), so this pinning information should be used on a best-effort
8428 * basis to order contacts in-application rather than an absolute guide on where a contact
8429 * should be positioned. Contacts returned by the ContactsProvider will not be ordered based
8430 * on this information, so it is up to the client application to reorder these contacts within
8431 * their own UI adhering to (or ignoring as appropriate) information stored in the pinned
8432 * column.
8433 * </p>
8434 *
8435 * <p>
8436 * By default, unpinned contacts will have a pinned position of
Yorke Lee7d246792014-07-25 10:05:55 -07008437 * {@link PinnedPositions#UNPINNED}. Client-provided pinned positions can be positive
8438 * integers that are greater than 1.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008439 * </p>
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008440 */
8441 public static final class PinnedPositions {
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008442 /**
Yorke Lee0e040b02014-06-18 15:02:44 -07008443 * The method to invoke in order to undemote a formerly demoted contact. The contact id of
8444 * the contact must be provided as an argument. If the contact was not previously demoted,
8445 * nothing will be done.
Yorke Lee94c87612014-07-18 18:57:17 -07008446 * @hide
Yorke Lee0e040b02014-06-18 15:02:44 -07008447 */
Jeff Sharkeycb269aac2019-01-25 11:15:38 -07008448 @TestApi
Yorke Lee0e040b02014-06-18 15:02:44 -07008449 public static final String UNDEMOTE_METHOD = "undemote";
8450
8451 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008452 * Undemotes a formerly demoted contact. If the contact was not previously demoted, nothing
8453 * will be done.
8454 *
8455 * @param contentResolver to perform the undemote operation on.
8456 * @param contactId the id of the contact to undemote.
8457 */
8458 public static void undemote(ContentResolver contentResolver, long contactId) {
8459 contentResolver.call(ContactsContract.AUTHORITY_URI, PinnedPositions.UNDEMOTE_METHOD,
8460 String.valueOf(contactId), null);
8461 }
8462
8463 /**
Yorke Leeb31c8ab2014-08-26 17:13:02 -07008464 * Pins a contact at a provided position, or unpins a contact.
8465 *
8466 * @param contentResolver to perform the pinning operation on.
8467 * @param pinnedPosition the position to pin the contact at. To unpin a contact, use
8468 * {@link PinnedPositions#UNPINNED}.
8469 */
8470 public static void pin(
8471 ContentResolver contentResolver, long contactId, int pinnedPosition) {
8472 final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_URI, String.valueOf(contactId));
8473 final ContentValues values = new ContentValues();
8474 values.put(Contacts.PINNED, pinnedPosition);
8475 contentResolver.update(uri, values, null, null);
8476 }
8477
8478 /**
Yorke Lee94c87612014-07-18 18:57:17 -07008479 * Default value for the pinned position of an unpinned contact.
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008480 */
Yorke Lee7d246792014-07-25 10:05:55 -07008481 public static final int UNPINNED = 0;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008482
8483 /**
Yorke Lee3585e1a2013-07-31 18:53:31 -07008484 * Value of pinned position for a contact that a user has indicated should be considered
8485 * of the lowest priority. It is up to the client application to determine how to present
8486 * such a contact - for example all the way at the bottom of a contact list, or simply
8487 * just hidden from view.
8488 */
8489 public static final int DEMOTED = -1;
Yorke Lee6acfa5d2013-07-17 09:55:26 -07008490 }
8491
8492 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008493 * Helper methods to display QuickContact dialogs that display all the information belonging to
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008494 * a specific {@link Contacts} entry.
8495 */
Evan Millare3ec9972009-09-30 19:37:36 -07008496 public static final class QuickContact {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008497 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008498 * Action used to launch the system contacts application and bring up a QuickContact dialog
8499 * for the provided {@link Contacts} entry.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008500 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06008501 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Evan Millar5042f7e2009-09-30 21:28:33 -07008502 public static final String ACTION_QUICK_CONTACT =
Yorke Lee78814622014-09-04 16:07:50 -07008503 "android.provider.action.QUICK_CONTACT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008504
8505 /**
8506 * Extra used to specify pivot dialog location in screen coordinates.
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008507 * @deprecated Use {@link Intent#setSourceBounds(Rect)} instead.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008508 * @hide
8509 */
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008510 @Deprecated
Makoto Onuki0e917332014-08-26 14:06:30 -07008511 public static final String EXTRA_TARGET_RECT = "android.provider.extra.TARGET_RECT";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008512
8513 /**
Brian Attwell029e6812015-02-02 16:10:39 -08008514 * Extra used to specify size of QuickContacts. Not all implementations of QuickContacts
8515 * will respect this extra's value.
8516 *
8517 * One of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008518 */
Makoto Onuki0e917332014-08-26 14:06:30 -07008519 public static final String EXTRA_MODE = "android.provider.extra.MODE";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008520
8521 /**
Brian Attwell7035f2b2015-02-25 20:06:08 -08008522 * Extra used to specify which mimetype should be prioritized in the QuickContacts UI.
8523 * For example, passing the value {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can
8524 * cause phone numbers to be displayed more prominently in QuickContacts.
8525 */
8526 public static final String EXTRA_PRIORITIZED_MIMETYPE
8527 = "android.provider.extra.PRIORITIZED_MIMETYPE";
8528
8529 /**
Yorke Leef8aadf32014-06-23 17:51:16 -07008530 * Extra used to indicate a list of specific MIME-types to exclude and not display in the
8531 * QuickContacts dialog. Stored as a {@link String} array.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008532 */
Makoto Onuki0e917332014-08-26 14:06:30 -07008533 public static final String EXTRA_EXCLUDE_MIMES = "android.provider.extra.EXCLUDE_MIMES";
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008534
8535 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008536 * Small QuickContact mode, usually presented with minimal actions.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008537 */
8538 public static final int MODE_SMALL = 1;
8539
8540 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008541 * Medium QuickContact mode, includes actions and light summary describing
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008542 * the {@link Contacts} entry being shown. This may include social
8543 * status and presence details.
8544 */
8545 public static final int MODE_MEDIUM = 2;
8546
8547 /**
Evan Millare3ec9972009-09-30 19:37:36 -07008548 * Large QuickContact mode, includes actions and larger, card-like summary
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008549 * of the {@link Contacts} entry being shown. This may include detailed
8550 * information, such as a photo.
8551 */
8552 public static final int MODE_LARGE = 3;
8553
Makoto Onuki1040da12015-03-19 11:24:00 -07008554 /** @hide */
8555 public static final int MODE_DEFAULT = MODE_LARGE;
8556
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008557 /**
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008558 * Constructs the QuickContacts intent with a view's rect.
8559 * @hide
8560 */
8561 public static Intent composeQuickContactsIntent(Context context, View target, Uri lookupUri,
8562 int mode, String[] excludeMimes) {
8563 // Find location and bounds of target view, adjusting based on the
8564 // assumed local density.
8565 final float appScale = context.getResources().getCompatibilityInfo().applicationScale;
8566 final int[] pos = new int[2];
8567 target.getLocationOnScreen(pos);
8568
8569 final Rect rect = new Rect();
8570 rect.left = (int) (pos[0] * appScale + 0.5f);
8571 rect.top = (int) (pos[1] * appScale + 0.5f);
8572 rect.right = (int) ((pos[0] + target.getWidth()) * appScale + 0.5f);
8573 rect.bottom = (int) ((pos[1] + target.getHeight()) * appScale + 0.5f);
8574
8575 return composeQuickContactsIntent(context, rect, lookupUri, mode, excludeMimes);
8576 }
8577
8578 /**
8579 * Constructs the QuickContacts intent.
8580 * @hide
8581 */
Mathew Inwood6750f2e2018-08-10 09:29:25 +01008582 @UnsupportedAppUsage
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008583 public static Intent composeQuickContactsIntent(Context context, Rect target,
8584 Uri lookupUri, int mode, String[] excludeMimes) {
8585 // When launching from an Activiy, we don't want to start a new task, but otherwise
8586 // we *must* start a new task. (Otherwise startActivity() would crash.)
8587 Context actualContext = context;
8588 while ((actualContext instanceof ContextWrapper)
8589 && !(actualContext instanceof Activity)) {
8590 actualContext = ((ContextWrapper) actualContext).getBaseContext();
8591 }
Brian Attwell9ee66402014-08-11 22:42:26 -07008592 final int intentFlags = ((actualContext instanceof Activity)
8593 ? 0 : Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK)
8594 // Workaround for b/16898764. Declaring singleTop in manifest doesn't work.
8595 | Intent.FLAG_ACTIVITY_SINGLE_TOP;
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008596
8597 // Launch pivot dialog through intent for now
8598 final Intent intent = new Intent(ACTION_QUICK_CONTACT).addFlags(intentFlags);
8599
Makoto Onuki1040da12015-03-19 11:24:00 -07008600 // NOTE: This logic and rebuildManagedQuickContactsIntent() must be in sync.
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008601 intent.setData(lookupUri);
8602 intent.setSourceBounds(target);
8603 intent.putExtra(EXTRA_MODE, mode);
8604 intent.putExtra(EXTRA_EXCLUDE_MIMES, excludeMimes);
8605 return intent;
8606 }
8607
8608 /**
Makoto Onuki1040da12015-03-19 11:24:00 -07008609 * Constructs a QuickContacts intent based on an incoming intent for DevicePolicyManager
8610 * to strip off anything not necessary.
Etan Cohen534a65d2015-05-01 11:03:24 -07008611 *
Makoto Onuki1040da12015-03-19 11:24:00 -07008612 * @hide
8613 */
8614 public static Intent rebuildManagedQuickContactsIntent(String lookupKey, long contactId,
Victor Chang97bdacc2016-01-21 22:24:11 +00008615 boolean isContactIdIgnored, long directoryId, Intent originalIntent) {
Makoto Onuki1040da12015-03-19 11:24:00 -07008616 final Intent intent = new Intent(ACTION_QUICK_CONTACT);
8617 // Rebuild the URI from a lookup key and a contact ID.
Victor Chang97bdacc2016-01-21 22:24:11 +00008618 Uri uri = null;
8619 if (!TextUtils.isEmpty(lookupKey)) {
8620 uri = isContactIdIgnored
8621 ? Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey)
8622 : Contacts.getLookupUri(contactId, lookupKey);
8623 }
Ricky Wai494b95d2015-11-20 16:07:15 +00008624 if (uri != null && directoryId != Directory.DEFAULT) {
8625 uri = uri.buildUpon().appendQueryParameter(
8626 ContactsContract.DIRECTORY_PARAM_KEY, String.valueOf(directoryId)).build();
8627 }
8628 intent.setData(uri);
Makoto Onuki1040da12015-03-19 11:24:00 -07008629
8630 // Copy flags and always set NEW_TASK because it won't have a parent activity.
8631 intent.setFlags(originalIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
8632
8633 // Copy extras.
8634 intent.setSourceBounds(originalIntent.getSourceBounds());
8635 intent.putExtra(EXTRA_MODE, originalIntent.getIntExtra(EXTRA_MODE, MODE_DEFAULT));
8636 intent.putExtra(EXTRA_EXCLUDE_MIMES,
8637 originalIntent.getStringArrayExtra(EXTRA_EXCLUDE_MIMES));
8638 return intent;
8639 }
8640
8641
8642 /**
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008643 * Trigger a dialog that lists the various methods of interacting with
8644 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008645 * {@link ContactsContract.Data} rows under that contact, and may also
8646 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008647 *
8648 * @param context The parent {@link Context} that may be used as the
8649 * parent for this dialog.
8650 * @param target Specific {@link View} from your layout that this dialog
8651 * should be centered around. In particular, if the dialog
8652 * has a "callout" arrow, it will be pointed and centered
8653 * around this {@link View}.
Evan Millar772722e2009-09-30 22:24:07 -07008654 * @param lookupUri A {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008655 * {@link Uri} that describes a specific contact to feature
Tony Mak935dafe2016-03-07 20:27:53 +00008656 * in this dialog. A work lookup uri is supported here,
8657 * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8658 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008659 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8660 * {@link #MODE_LARGE}, indicating the desired dialog size,
8661 * when supported.
8662 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8663 * to exclude when showing this dialog. For example, when
8664 * already viewing the contact details card, this can be used
8665 * to omit the details entry from the dialog.
8666 */
Evan Millare3ec9972009-09-30 19:37:36 -07008667 public static void showQuickContact(Context context, View target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008668 String[] excludeMimes) {
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008669 // Trigger with obtained rectangle
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008670 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8671 excludeMimes);
Makoto Onuki1040da12015-03-19 11:24:00 -07008672 ContactsInternal.startQuickContactWithErrorToast(context, intent);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008673 }
8674
8675 /**
8676 * Trigger a dialog that lists the various methods of interacting with
8677 * the requested {@link Contacts} entry. This may be based on available
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08008678 * {@link ContactsContract.Data} rows under that contact, and may also
8679 * include social status and presence details.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008680 *
8681 * @param context The parent {@link Context} that may be used as the
8682 * parent for this dialog.
8683 * @param target Specific {@link Rect} that this dialog should be
8684 * centered around, in screen coordinates. In particular, if
8685 * the dialog has a "callout" arrow, it will be pointed and
Jeff Sharkeya503f6f2009-12-08 21:50:14 -08008686 * centered around this {@link Rect}. If you are running at a
8687 * non-native density, you need to manually adjust using
8688 * {@link DisplayMetrics#density} before calling.
Jeff Sharkey223bd7a2009-12-21 14:51:19 -08008689 * @param lookupUri A
8690 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008691 * {@link Uri} that describes a specific contact to feature
Tony Mak935dafe2016-03-07 20:27:53 +00008692 * in this dialog. A work lookup uri is supported here,
8693 * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8694 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008695 * @param mode Any of {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or
8696 * {@link #MODE_LARGE}, indicating the desired dialog size,
8697 * when supported.
8698 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8699 * to exclude when showing this dialog. For example, when
8700 * already viewing the contact details card, this can be used
8701 * to omit the details entry from the dialog.
8702 */
Evan Millare3ec9972009-09-30 19:37:36 -07008703 public static void showQuickContact(Context context, Rect target, Uri lookupUri, int mode,
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008704 String[] excludeMimes) {
Winson Chung9fc6b8c2012-09-28 11:37:41 -07008705 Intent intent = composeQuickContactsIntent(context, target, lookupUri, mode,
8706 excludeMimes);
Makoto Onuki1040da12015-03-19 11:24:00 -07008707 ContactsInternal.startQuickContactWithErrorToast(context, intent);
Yorke Lee4fc601a2013-12-06 16:35:29 -08008708 }
8709
Brian Attwell7035f2b2015-02-25 20:06:08 -08008710 /**
8711 * Trigger a dialog that lists the various methods of interacting with
8712 * the requested {@link Contacts} entry. This may be based on available
8713 * {@link ContactsContract.Data} rows under that contact, and may also
8714 * include social status and presence details.
8715 *
8716 * @param context The parent {@link Context} that may be used as the
8717 * parent for this dialog.
8718 * @param target Specific {@link View} from your layout that this dialog
8719 * should be centered around. In particular, if the dialog
8720 * has a "callout" arrow, it will be pointed and centered
8721 * around this {@link View}.
8722 * @param lookupUri A
8723 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
8724 * {@link Uri} that describes a specific contact to feature
Tony Mak935dafe2016-03-07 20:27:53 +00008725 * in this dialog. A work lookup uri is supported here,
8726 * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8727 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
Brian Attwell7035f2b2015-02-25 20:06:08 -08008728 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8729 * to exclude when showing this dialog. For example, when
8730 * already viewing the contact details card, this can be used
8731 * to omit the details entry from the dialog.
8732 * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
8733 * For example, passing the value
8734 * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
8735 * displayed more prominently in QuickContacts.
8736 */
8737 public static void showQuickContact(Context context, View target, Uri lookupUri,
8738 String[] excludeMimes, String prioritizedMimeType) {
8739 // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
8740 // values defined in ContactsContract only affect very old implementations
8741 // of QuickContacts.
Makoto Onuki1040da12015-03-19 11:24:00 -07008742 Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
Brian Attwell7035f2b2015-02-25 20:06:08 -08008743 excludeMimes);
8744 intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
Makoto Onuki1040da12015-03-19 11:24:00 -07008745 ContactsInternal.startQuickContactWithErrorToast(context, intent);
Brian Attwell7035f2b2015-02-25 20:06:08 -08008746 }
8747
8748 /**
8749 * Trigger a dialog that lists the various methods of interacting with
8750 * the requested {@link Contacts} entry. This may be based on available
8751 * {@link ContactsContract.Data} rows under that contact, and may also
8752 * include social status and presence details.
8753 *
8754 * @param context The parent {@link Context} that may be used as the
8755 * parent for this dialog.
8756 * @param target Specific {@link Rect} that this dialog should be
8757 * centered around, in screen coordinates. In particular, if
8758 * the dialog has a "callout" arrow, it will be pointed and
8759 * centered around this {@link Rect}. If you are running at a
8760 * non-native density, you need to manually adjust using
8761 * {@link DisplayMetrics#density} before calling.
8762 * @param lookupUri A
8763 * {@link ContactsContract.Contacts#CONTENT_LOOKUP_URI} style
8764 * {@link Uri} that describes a specific contact to feature
Tony Mak935dafe2016-03-07 20:27:53 +00008765 * in this dialog. A work lookup uri is supported here,
8766 * see {@link CommonDataKinds.Email#ENTERPRISE_CONTENT_LOOKUP_URI} and
8767 * {@link PhoneLookup#ENTERPRISE_CONTENT_FILTER_URI}.
Brian Attwell7035f2b2015-02-25 20:06:08 -08008768 * @param excludeMimes Optional list of {@link Data#MIMETYPE} MIME-types
8769 * to exclude when showing this dialog. For example, when
8770 * already viewing the contact details card, this can be used
8771 * to omit the details entry from the dialog.
8772 * @param prioritizedMimeType This mimetype should be prioritized in the QuickContacts UI.
8773 * For example, passing the value
8774 * {@link CommonDataKinds.Phone#CONTENT_ITEM_TYPE} can cause phone numbers to be
8775 * displayed more prominently in QuickContacts.
8776 */
8777 public static void showQuickContact(Context context, Rect target, Uri lookupUri,
8778 String[] excludeMimes, String prioritizedMimeType) {
8779 // Use MODE_LARGE instead of accepting mode as a parameter. The different mode
8780 // values defined in ContactsContract only affect very old implementations
8781 // of QuickContacts.
Makoto Onuki1040da12015-03-19 11:24:00 -07008782 Intent intent = composeQuickContactsIntent(context, target, lookupUri, MODE_DEFAULT,
Brian Attwell7035f2b2015-02-25 20:06:08 -08008783 excludeMimes);
8784 intent.putExtra(EXTRA_PRIORITIZED_MIMETYPE, prioritizedMimeType);
Makoto Onuki1040da12015-03-19 11:24:00 -07008785 ContactsInternal.startQuickContactWithErrorToast(context, intent);
Jeff Sharkey6449eb02009-09-16 21:41:51 -07008786 }
8787 }
8788
8789 /**
Dave Santoroa5282372011-06-29 00:25:16 -07008790 * Helper class for accessing full-size photos by photo file ID.
8791 * <p>
8792 * Usage example:
8793 * <dl>
8794 * <dt>Retrieving a full-size photo by photo file ID (see
8795 * {@link ContactsContract.ContactsColumns#PHOTO_FILE_ID})
8796 * </dt>
8797 * <dd>
8798 * <pre>
8799 * public InputStream openDisplayPhoto(long photoFileId) {
8800 * Uri displayPhotoUri = ContentUris.withAppendedId(DisplayPhoto.CONTENT_URI, photoKey);
8801 * try {
Dave Santoro040e6b32011-07-15 15:14:08 -07008802 * AssetFileDescriptor fd = getContentResolver().openAssetFileDescriptor(
8803 * displayPhotoUri, "r");
Dave Santoroa5282372011-06-29 00:25:16 -07008804 * return fd.createInputStream();
Dave Santoro040e6b32011-07-15 15:14:08 -07008805 * } catch (IOException e) {
Dave Santoroa5282372011-06-29 00:25:16 -07008806 * return null;
8807 * }
8808 * }
8809 * </pre>
8810 * </dd>
8811 * </dl>
8812 * </p>
8813 */
8814 public static final class DisplayPhoto {
8815 /**
8816 * no public constructor since this is a utility class
8817 */
8818 private DisplayPhoto() {}
8819
8820 /**
8821 * The content:// style URI for this class, which allows access to full-size photos,
8822 * given a key.
8823 */
8824 public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "display_photo");
8825
8826 /**
8827 * This URI allows the caller to query for the maximum dimensions of a display photo
8828 * or thumbnail. Requests to this URI can be performed on the UI thread because
8829 * they are always unblocking.
8830 */
8831 public static final Uri CONTENT_MAX_DIMENSIONS_URI =
8832 Uri.withAppendedPath(AUTHORITY_URI, "photo_dimensions");
8833
8834 /**
8835 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8836 * contain this column, populated with the maximum height and width (in pixels)
8837 * that will be stored for a display photo. Larger photos will be down-sized to
8838 * fit within a square of this many pixels.
8839 */
8840 public static final String DISPLAY_MAX_DIM = "display_max_dim";
8841
8842 /**
8843 * Queries to {@link ContactsContract.DisplayPhoto#CONTENT_MAX_DIMENSIONS_URI} will
8844 * contain this column, populated with the height and width (in pixels) for photo
8845 * thumbnails.
8846 */
8847 public static final String THUMBNAIL_MAX_DIM = "thumbnail_max_dim";
8848 }
8849
8850 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008851 * Contains helper classes used to create or manage {@link android.content.Intent Intents}
8852 * that involve contacts.
8853 */
8854 public static final class Intents {
8855 /**
8856 * This is the intent that is fired when a search suggestion is clicked on.
8857 */
8858 public static final String SEARCH_SUGGESTION_CLICKED =
8859 "android.provider.Contacts.SEARCH_SUGGESTION_CLICKED";
8860
8861 /**
8862 * This is the intent that is fired when a search suggestion for dialing a number
8863 * is clicked on.
8864 */
8865 public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED =
8866 "android.provider.Contacts.SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED";
8867
8868 /**
8869 * This is the intent that is fired when a search suggestion for creating a contact
8870 * is clicked on.
8871 */
8872 public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED =
8873 "android.provider.Contacts.SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED";
8874
8875 /**
Chiao Cheng2355d132013-03-20 16:54:06 -07008876 * This is the intent that is fired when the contacts database is created. <p> The
8877 * READ_CONTACT permission is required to receive these broadcasts.
Makoto Onuki729a87b2017-01-11 13:40:06 -08008878 *
Makoto Onuki2a615372017-01-30 11:59:46 -08008879 * <p>Because this is an implicit broadcast, apps targeting Android O will no longer
8880 * receive this broadcast via a manifest broadcast receiver. (Broadcast receivers
8881 * registered at runtime with
8882 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)} will still receive it.)
8883 * Instead, an app can use {@link ProviderStatus#DATABASE_CREATION_TIMESTAMP} to see if the
8884 * contacts database has been initialized when it starts.
Chiao Cheng2355d132013-03-20 16:54:06 -07008885 */
8886 public static final String CONTACTS_DATABASE_CREATED =
8887 "android.provider.Contacts.DATABASE_CREATED";
8888
8889 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008890 * Starts an Activity that lets the user pick a contact to attach an image to.
8891 * After picking the contact it launches the image cropper in face detection mode.
8892 */
8893 public static final String ATTACH_IMAGE =
8894 "com.android.contacts.action.ATTACH_IMAGE";
8895
8896 /**
Makoto Onuki85a01a6b2011-07-21 15:16:31 -07008897 * This is the intent that is fired when the user clicks the "invite to the network" button
8898 * on a contact. Only sent to an activity which is explicitly registered by a contact
8899 * provider which supports the "invite to the network" feature.
8900 * <p>
8901 * {@link Intent#getData()} contains the lookup URI for the contact.
8902 */
8903 public static final String INVITE_CONTACT =
8904 "com.android.contacts.action.INVITE_CONTACT";
8905
8906 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07008907 * Takes as input a data URI with a mailto: or tel: scheme. If a single
8908 * contact exists with the given data it will be shown. If no contact
8909 * exists, a dialog will ask the user if they want to create a new
8910 * contact with the provided details filled in. If multiple contacts
8911 * share the data the user will be prompted to pick which contact they
8912 * want to view.
8913 * <p>
8914 * For <code>mailto:</code> URIs, the scheme specific portion must be a
8915 * raw email address, such as one built using
8916 * {@link Uri#fromParts(String, String, String)}.
8917 * <p>
8918 * For <code>tel:</code> URIs, the scheme specific portion is compared
8919 * to existing numbers using the standard caller ID lookup algorithm.
8920 * The number must be properly encoded, for example using
8921 * {@link Uri#fromParts(String, String, String)}.
8922 * <p>
8923 * Any extras from the {@link Insert} class will be passed along to the
8924 * create activity if there are no contacts to show.
8925 * <p>
8926 * Passing true for the {@link #EXTRA_FORCE_CREATE} extra will skip
8927 * prompting the user when the contact doesn't exist.
8928 */
8929 public static final String SHOW_OR_CREATE_CONTACT =
8930 "com.android.contacts.action.SHOW_OR_CREATE_CONTACT";
8931
8932 /**
Renat Aksitov799da392016-01-21 14:58:58 -08008933 * Activity Action: Initiate a message to someone by voice. The message could be text,
8934 * audio, video or image(photo). This action supports messaging with a specific contact
8935 * regardless of the underlying messaging protocol used.
8936 * <p>
8937 * The action could be originated from the Voice Assistant as a voice interaction. In such
8938 * case, a receiving activity that supports {@link android.content.Intent#CATEGORY_VOICE}
8939 * could check return value of {@link android.app.Activity#isVoiceInteractionRoot} before
8940 * proceeding. By doing this check the activity verifies that the action indeed was
8941 * initiated by Voice Assistant and could send a message right away, without any further
8942 * input from the user. This allows for a smooth user experience when sending a message by
8943 * voice. Note: this activity must also support the {@link
8944 * android.content.Intent#CATEGORY_DEFAULT} so it can be found by {@link
8945 * android.service.voice.VoiceInteractionSession#startVoiceActivity}.
8946 * <p>
8947 * When the action was not initiated by Voice Assistant or when the receiving activity does
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07008948 * not support {@link android.content.Intent#CATEGORY_VOICE}, the activity must confirm
Renat Aksitov799da392016-01-21 14:58:58 -08008949 * with the user before sending the message (because in this case it is unknown which app
8950 * sent the intent, it could be malicious).
8951 * <p>
8952 * To allow the Voice Assistant to help users with contacts disambiguation, the messaging
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07008953 * app may choose to integrate with the Contacts Provider. You will need to specify a new
8954 * MIME type in order to store your app’s unique contact IDs and optional human readable
8955 * labels in the Data table. The Voice Assistant needs to know this MIME type and {@link
8956 * RawContacts#ACCOUNT_TYPE} that you are using in order to provide the smooth contact
8957 * disambiguation user experience. The following convention should be met when performing
8958 * such integration:
Renat Aksitov799da392016-01-21 14:58:58 -08008959 * <ul>
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07008960 * <li>This activity should have a string meta-data field associated with it, {@link
8961 * #METADATA_ACCOUNT_TYPE}, which defines {@link RawContacts#ACCOUNT_TYPE} for your Contacts
8962 * Provider implementation. The account type should be globally unique, for example you can
8963 * use your app package name as the account type.</li>
8964 * <li>This activity should have a string meta-data field associated with it, {@link
8965 * #METADATA_MIMETYPE}, which defines {@link DataColumns#MIMETYPE} for your Contacts
8966 * Provider implementation. For example, you can use
8967 * "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li>
8968 * <li>When filling Data table row for METADATA_MIMETYPE, column {@link DataColumns#DATA1}
8969 * should store the unique contact ID as understood by the app. This value will be used in
8970 * the {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID}.</li>
8971 * <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column {@link
8972 * DataColumns#DATA3} could store a human readable label for the ID. For example it could be
8973 * phone number or human readable username/user_id like "a_super_cool_user_name". This label
8974 * may be shown below the Contact Name by the Voice Assistant as the user completes the
8975 * voice action. If DATA3 is empty, the ID in DATA1 may be shown instead.</li>
Renat Aksitov799da392016-01-21 14:58:58 -08008976 * <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will
8977 * already get the Contact Name from the RawContact’s display_name.</em></li>
8978 * <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1.
8979 * If this applies to you and you’d like phone number to be shown below the Contact Name by
8980 * the Voice Assistant, then you may choose to leave DATA3 empty.</em></li>
Renat Aksitov72ddba12016-02-20 19:16:46 -08008981 * <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App,
8982 * make sure it does not include prefix text such as "Message +<phone>" or "Free Message
8983 * +<phone>", etc. If you must show the prefix text in the Contacts App, please use a
8984 * different DATA# column, and update your contacts.xml to point to this new column. </em>
8985 * </li>
Renat Aksitov799da392016-01-21 14:58:58 -08008986 * </ul>
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07008987 * If the app chooses not to integrate with the Contacts Provider (in particular, when
8988 * either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant
8989 * will use existing phone number entries as contact ID's for such app.
Renat Aksitov799da392016-01-21 14:58:58 -08008990 * <p>
8991 * Input: {@link android.content.Intent#getType} is the MIME type of the data being sent.
8992 * The intent sender will always put the concrete mime type in the intent type, like
8993 * "text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to
8994 * sent will be provided via {@link android.content.Intent#EXTRA_TEXT} as a styled
8995 * CharSequence. Otherwise, the message content will be supplied through {@link
8996 * android.content.Intent#setClipData(ClipData)} as a content provider URI(s). In the latter
8997 * case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages
8998 * ClipData will contain URI of a recording and EXTRA_TEXT could contain the text
8999 * transcription of this recording.
9000 * <p>
9001 * The message can have n recipients. The n-th recipient of the message will be provided as
9002 * n-th elements of {@link #EXTRA_RECIPIENT_CONTACT_URI}, {@link
9003 * #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and {@link #EXTRA_RECIPIENT_CONTACT_NAME} (as a
9004 * consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and
9005 * EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements
9006 * is provided (e.g. all 3 are null) for the recipient or if the information provided is
9007 * ambiguous then the activity should prompt the user for the recipient to send the message
9008 * to.
9009 * <p>
9010 * Output: nothing
9011 *
9012 * @see #EXTRA_RECIPIENT_CONTACT_URI
9013 * @see #EXTRA_RECIPIENT_CONTACT_CHAT_ID
9014 * @see #EXTRA_RECIPIENT_CONTACT_NAME
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07009015 * @see #METADATA_ACCOUNT_TYPE
9016 * @see #METADATA_MIMETYPE
Renat Aksitov799da392016-01-21 14:58:58 -08009017 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06009018 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Renat Aksitov799da392016-01-21 14:58:58 -08009019 public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS =
9020 "android.provider.action.VOICE_SEND_MESSAGE_TO_CONTACTS";
9021
9022 /**
9023 * This extra specifies a content provider uri(s) for the contact(s) (if the contacts were
9024 * located in the Contacts Provider), used with {@link
9025 * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this
9026 * extra is a {@code String[]}. The number of elements in the array should be equal to
9027 * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_CHAT_ID} and
9028 * {@link #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular
9029 * recipient is absent, it will be set to null.
9030 * <p>
9031 * <em>Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging
9032 * platform, so this may be ambiguous. E.g., one contact “John Smith” could have two
9033 * accounts on the same messaging app.</em>
9034 * <p>
9035 * <em>Example value: {"content://com.android.contacts/contacts/16"}</em>
9036 */
9037 public static final String EXTRA_RECIPIENT_CONTACT_URI =
9038 "android.provider.extra.RECIPIENT_CONTACT_URI";
9039
9040 /**
9041 * This extra specifies a messaging app’s unique ID(s) for the contact(s), used with {@link
9042 * #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient(s). The value of this
9043 * extra is a {@code String[]}. The number of elements in the array should be equal to
9044 * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link
9045 * #EXTRA_RECIPIENT_CONTACT_NAME}). When the value of the element for the particular
9046 * recipient is absent, it will be set to null.
9047 * <p>
9048 * The value of the elements comes from the {@link DataColumns#DATA1} column in Contacts
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07009049 * Provider with {@link DataColumns#MIMETYPE} from {@link #METADATA_MIMETYPE} (if both
9050 * {@link #METADATA_ACCOUNT_TYPE} and {@link #METADATA_MIMETYPE} are specified by the app;
9051 * otherwise, the value will be a phone number), and should be the unambiguous contact
9052 * endpoint. This value is app-specific, it could be some proprietary ID or a phone number.
Renat Aksitov799da392016-01-21 14:58:58 -08009053 */
9054 public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID =
9055 "android.provider.extra.RECIPIENT_CONTACT_CHAT_ID";
9056
9057 /**
9058 * This extra specifies the contact name (full name from the Contacts Provider), used with
9059 * {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} to supply the recipient. The value of this
9060 * extra is a {@code String[]}. The number of elements in the array should be equal to
9061 * number of recipients (and consistent with {@link #EXTRA_RECIPIENT_CONTACT_URI} and {@link
9062 * #EXTRA_RECIPIENT_CONTACT_CHAT_ID}). When the value of the element for the particular
9063 * recipient is absent, it will be set to null.
9064 * <p>
9065 * The value of the elements comes from RawContact's display_name column.
9066 * <p>
9067 * <em>Example value: {"Jane Doe"}</em>
9068 */
9069 public static final String EXTRA_RECIPIENT_CONTACT_NAME =
9070 "android.provider.extra.RECIPIENT_CONTACT_NAME";
9071
9072 /**
Renat Aksitovc8dd93d2016-05-01 16:31:28 -07009073 * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity
9074 * describing {@link RawContacts#ACCOUNT_TYPE} for the corresponding Contacts Provider
9075 * implementation.
9076 */
9077 public static final String METADATA_ACCOUNT_TYPE = "android.provider.account_type";
9078
9079 /**
9080 * A string associated with an {@link #ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS} activity
9081 * describing {@link DataColumns#MIMETYPE} for the corresponding Contacts Provider
9082 * implementation.
9083 */
9084 public static final String METADATA_MIMETYPE = "android.provider.mimetype";
9085
9086 /**
Bai Taofc7838b2010-01-22 03:34:56 +08009087 * Starts an Activity that lets the user select the multiple phones from a
9088 * list of phone numbers which come from the contacts or
9089 * {@link #EXTRA_PHONE_URIS}.
9090 * <p>
9091 * The phone numbers being passed in through {@link #EXTRA_PHONE_URIS}
9092 * could belong to the contacts or not, and will be selected by default.
9093 * <p>
9094 * The user's selection will be returned from
9095 * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)}
Fred Quintanaa31a9452010-04-13 14:52:20 -07009096 * if the resultCode is
Bai Taofc7838b2010-01-22 03:34:56 +08009097 * {@link android.app.Activity#RESULT_OK}, the array of picked phone
9098 * numbers are in the Intent's
9099 * {@link #EXTRA_PHONE_URIS}; otherwise, the
9100 * {@link android.app.Activity#RESULT_CANCELED} is returned if the user
9101 * left the Activity without changing the selection.
9102 *
9103 * @hide
9104 */
9105 public static final String ACTION_GET_MULTIPLE_PHONES =
9106 "com.android.contacts.action.GET_MULTIPLE_PHONES";
9107
9108 /**
Makoto Onuki90ddc902012-09-11 18:22:53 -07009109 * A broadcast action which is sent when any change has been made to the profile, such
9110 * as the profile name or the picture. A receiver must have
9111 * the android.permission.READ_PROFILE permission.
9112 *
9113 * @hide
9114 */
9115 public static final String ACTION_PROFILE_CHANGED =
9116 "android.provider.Contacts.PROFILE_CHANGED";
9117
9118 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07009119 * Used with {@link #SHOW_OR_CREATE_CONTACT} to force creating a new
9120 * contact if no matching contact found. Otherwise, default behavior is
9121 * to prompt user with dialog before creating.
9122 * <p>
9123 * Type: BOOLEAN
9124 */
9125 public static final String EXTRA_FORCE_CREATE =
9126 "com.android.contacts.action.FORCE_CREATE";
9127
9128 /**
9129 * Used with {@link #SHOW_OR_CREATE_CONTACT} to specify an exact
9130 * description to be shown when prompting user about creating a new
9131 * contact.
9132 * <p>
9133 * Type: STRING
9134 */
9135 public static final String EXTRA_CREATE_DESCRIPTION =
9136 "com.android.contacts.action.CREATE_DESCRIPTION";
9137
9138 /**
Bai Taofc7838b2010-01-22 03:34:56 +08009139 * Used with {@link #ACTION_GET_MULTIPLE_PHONES} as the input or output value.
9140 * <p>
9141 * The phone numbers want to be picked by default should be passed in as
9142 * input value. These phone numbers could belong to the contacts or not.
9143 * <p>
9144 * The phone numbers which were picked by the user are returned as output
9145 * value.
9146 * <p>
9147 * Type: array of URIs, the tel URI is used for the phone numbers which don't
9148 * belong to any contact, the content URI is used for phone id in contacts.
Fred Quintanaa31a9452010-04-13 14:52:20 -07009149 *
Bai Taofc7838b2010-01-22 03:34:56 +08009150 * @hide
9151 */
9152 public static final String EXTRA_PHONE_URIS =
9153 "com.android.contacts.extra.PHONE_URIS";
9154
9155 /**
Jeff Sharkey11322002009-06-04 17:25:51 -07009156 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
9157 * dialog location using screen coordinates. When not specified, the
9158 * dialog will be centered.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05009159 *
9160 * @hide
Jeff Sharkey11322002009-06-04 17:25:51 -07009161 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07009162 @Deprecated
Jeff Sharkey11322002009-06-04 17:25:51 -07009163 public static final String EXTRA_TARGET_RECT = "target_rect";
9164
9165 /**
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009166 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to specify a
9167 * desired dialog style, usually a variation on size. One of
9168 * {@link #MODE_SMALL}, {@link #MODE_MEDIUM}, or {@link #MODE_LARGE}.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05009169 *
9170 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009171 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07009172 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009173 public static final String EXTRA_MODE = "mode";
9174
9175 /**
9176 * Value for {@link #EXTRA_MODE} to show a small-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05009177 *
9178 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009179 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07009180 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009181 public static final int MODE_SMALL = 1;
9182
9183 /**
9184 * Value for {@link #EXTRA_MODE} to show a medium-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05009185 *
9186 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009187 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07009188 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009189 public static final int MODE_MEDIUM = 2;
9190
9191 /**
9192 * Value for {@link #EXTRA_MODE} to show a large-sized dialog.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05009193 *
9194 * @hide
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009195 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07009196 @Deprecated
Jeff Sharkey6bfe14d2009-08-05 15:49:48 -07009197 public static final int MODE_LARGE = 3;
9198
9199 /**
Jeff Sharkey84235ee2009-08-23 14:07:02 -07009200 * Optional extra used with {@link #SHOW_OR_CREATE_CONTACT} to indicate
9201 * a list of specific MIME-types to exclude and not display. Stored as a
9202 * {@link String} array.
Jeff Hamilton85abdc52009-09-22 12:41:45 -05009203 *
9204 * @hide
Jeff Sharkey84235ee2009-08-23 14:07:02 -07009205 */
Jeff Sharkey6449eb02009-09-16 21:41:51 -07009206 @Deprecated
Jeff Sharkey84235ee2009-08-23 14:07:02 -07009207 public static final String EXTRA_EXCLUDE_MIMES = "exclude_mimes";
9208
9209 /**
Evan Millardc2da5f2009-06-18 16:07:13 -07009210 * Convenience class that contains string constants used
9211 * to create contact {@link android.content.Intent Intents}.
9212 */
9213 public static final class Insert {
9214 /** The action code to use when adding a contact */
9215 public static final String ACTION = Intent.ACTION_INSERT;
9216
9217 /**
9218 * If present, forces a bypass of quick insert mode.
9219 */
9220 public static final String FULL_MODE = "full_mode";
9221
9222 /**
9223 * The extra field for the contact name.
9224 * <P>Type: String</P>
9225 */
9226 public static final String NAME = "name";
9227
9228 // TODO add structured name values here.
9229
9230 /**
9231 * The extra field for the contact phonetic name.
9232 * <P>Type: String</P>
9233 */
9234 public static final String PHONETIC_NAME = "phonetic_name";
9235
9236 /**
9237 * The extra field for the contact company.
9238 * <P>Type: String</P>
9239 */
9240 public static final String COMPANY = "company";
9241
9242 /**
9243 * The extra field for the contact job title.
9244 * <P>Type: String</P>
9245 */
9246 public static final String JOB_TITLE = "job_title";
9247
9248 /**
9249 * The extra field for the contact notes.
9250 * <P>Type: String</P>
9251 */
9252 public static final String NOTES = "notes";
9253
9254 /**
9255 * The extra field for the contact phone number.
9256 * <P>Type: String</P>
9257 */
9258 public static final String PHONE = "phone";
9259
9260 /**
9261 * The extra field for the contact phone number type.
9262 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009263 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07009264 * or a string specifying a custom label.</P>
9265 */
9266 public static final String PHONE_TYPE = "phone_type";
9267
9268 /**
9269 * The extra field for the phone isprimary flag.
9270 * <P>Type: boolean</P>
9271 */
9272 public static final String PHONE_ISPRIMARY = "phone_isprimary";
9273
9274 /**
9275 * The extra field for an optional second contact phone number.
9276 * <P>Type: String</P>
9277 */
9278 public static final String SECONDARY_PHONE = "secondary_phone";
9279
9280 /**
9281 * The extra field for an optional second contact phone number type.
9282 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009283 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07009284 * or a string specifying a custom label.</P>
9285 */
9286 public static final String SECONDARY_PHONE_TYPE = "secondary_phone_type";
9287
9288 /**
9289 * The extra field for an optional third contact phone number.
9290 * <P>Type: String</P>
9291 */
9292 public static final String TERTIARY_PHONE = "tertiary_phone";
9293
9294 /**
9295 * The extra field for an optional third contact phone number type.
9296 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009297 * {@link CommonDataKinds.Phone},
Evan Millardc2da5f2009-06-18 16:07:13 -07009298 * or a string specifying a custom label.</P>
9299 */
9300 public static final String TERTIARY_PHONE_TYPE = "tertiary_phone_type";
9301
9302 /**
9303 * The extra field for the contact email address.
9304 * <P>Type: String</P>
9305 */
9306 public static final String EMAIL = "email";
9307
9308 /**
9309 * The extra field for the contact email type.
9310 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009311 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07009312 * or a string specifying a custom label.</P>
9313 */
9314 public static final String EMAIL_TYPE = "email_type";
9315
9316 /**
9317 * The extra field for the email isprimary flag.
9318 * <P>Type: boolean</P>
9319 */
9320 public static final String EMAIL_ISPRIMARY = "email_isprimary";
9321
9322 /**
9323 * The extra field for an optional second contact email address.
9324 * <P>Type: String</P>
9325 */
9326 public static final String SECONDARY_EMAIL = "secondary_email";
9327
9328 /**
9329 * The extra field for an optional second contact email type.
9330 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009331 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07009332 * or a string specifying a custom label.</P>
9333 */
9334 public static final String SECONDARY_EMAIL_TYPE = "secondary_email_type";
9335
9336 /**
9337 * The extra field for an optional third contact email address.
9338 * <P>Type: String</P>
9339 */
9340 public static final String TERTIARY_EMAIL = "tertiary_email";
9341
9342 /**
9343 * The extra field for an optional third contact email type.
9344 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009345 * {@link CommonDataKinds.Email}
Evan Millardc2da5f2009-06-18 16:07:13 -07009346 * or a string specifying a custom label.</P>
9347 */
9348 public static final String TERTIARY_EMAIL_TYPE = "tertiary_email_type";
9349
9350 /**
9351 * The extra field for the contact postal address.
9352 * <P>Type: String</P>
9353 */
9354 public static final String POSTAL = "postal";
9355
9356 /**
9357 * The extra field for the contact postal address type.
9358 * <P>Type: Either an integer value from
Dmitri Plotnikovdbe449e2009-11-11 18:48:19 -08009359 * {@link CommonDataKinds.StructuredPostal}
Evan Millardc2da5f2009-06-18 16:07:13 -07009360 * or a string specifying a custom label.</P>
9361 */
9362 public static final String POSTAL_TYPE = "postal_type";
9363
9364 /**
9365 * The extra field for the postal isprimary flag.
9366 * <P>Type: boolean</P>
9367 */
9368 public static final String POSTAL_ISPRIMARY = "postal_isprimary";
9369
9370 /**
9371 * The extra field for an IM handle.
9372 * <P>Type: String</P>
9373 */
9374 public static final String IM_HANDLE = "im_handle";
9375
9376 /**
9377 * The extra field for the IM protocol
Evan Millardc2da5f2009-06-18 16:07:13 -07009378 */
9379 public static final String IM_PROTOCOL = "im_protocol";
9380
9381 /**
9382 * The extra field for the IM isprimary flag.
9383 * <P>Type: boolean</P>
9384 */
9385 public static final String IM_ISPRIMARY = "im_isprimary";
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07009386
9387 /**
9388 * The extra field that allows the client to supply multiple rows of
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07009389 * arbitrary data for a single contact created using the {@link Intent#ACTION_INSERT}
9390 * or edited using {@link Intent#ACTION_EDIT}. It is an ArrayList of
9391 * {@link ContentValues}, one per data row. Supplying this extra is
9392 * similar to inserting multiple rows into the {@link Data} table,
9393 * except the user gets a chance to see and edit them before saving.
9394 * Each ContentValues object must have a value for {@link Data#MIMETYPE}.
9395 * If supplied values are not visible in the editor UI, they will be
9396 * dropped. Duplicate data will dropped. Some fields
9397 * like {@link CommonDataKinds.Email#TYPE Email.TYPE} may be automatically
9398 * adjusted to comply with the constraints of the specific account type.
9399 * For example, an Exchange contact can only have one phone numbers of type Home,
9400 * so the contact editor may choose a different type for this phone number to
9401 * avoid dropping the valueable part of the row, which is the phone number.
9402 * <p>
9403 * Example:
9404 * <pre>
9405 * ArrayList&lt;ContentValues&gt; data = new ArrayList&lt;ContentValues&gt;();
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07009406 *
Dmitri Plotnikovbeb21782010-10-21 10:02:12 -07009407 * ContentValues row1 = new ContentValues();
9408 * row1.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
9409 * row1.put(Organization.COMPANY, "Android");
9410 * data.add(row1);
9411 *
9412 * ContentValues row2 = new ContentValues();
9413 * row2.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
9414 * row2.put(Email.TYPE, Email.TYPE_CUSTOM);
9415 * row2.put(Email.LABEL, "Green Bot");
9416 * row2.put(Email.ADDRESS, "android@android.com");
9417 * data.add(row2);
9418 *
9419 * Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
9420 * intent.putParcelableArrayListExtra(Insert.DATA, data);
9421 *
9422 * startActivity(intent);
9423 * </pre>
Dmitri Plotnikovbb549292010-10-18 20:37:02 -07009424 */
9425 public static final String DATA = "data";
Daniel Lehmanncde1ac62010-10-21 20:40:11 -07009426
9427 /**
9428 * Used to specify the account in which to create the new contact.
9429 * <p>
9430 * If this value is not provided, the user is presented with a disambiguation
9431 * dialog to chose an account
9432 * <p>
9433 * Type: {@link Account}
Daniel Lehmanncde1ac62010-10-21 20:40:11 -07009434 */
Brian Attwell63f859b2015-01-26 15:57:10 -08009435 public static final String EXTRA_ACCOUNT = "android.provider.extra.ACCOUNT";
Dave Santoro1d55c332011-07-25 16:44:45 -07009436
9437 /**
9438 * Used to specify the data set within the account in which to create the
9439 * new contact.
9440 * <p>
9441 * This value is optional - if it is not specified, the contact will be
9442 * created in the base account, with no data set.
9443 * <p>
9444 * Type: String
Dave Santoro1d55c332011-07-25 16:44:45 -07009445 */
Brian Attwell63f859b2015-01-26 15:57:10 -08009446 public static final String EXTRA_DATA_SET = "android.provider.extra.DATA_SET";
Evan Millardc2da5f2009-06-18 16:07:13 -07009447 }
9448 }
Tingting Wang20f14382015-04-21 12:04:04 -07009449
9450 /**
9451 * @hide
9452 */
Zheng Fu7997bee2015-06-09 16:50:02 -07009453 @SystemApi
Tingting Wang20f14382015-04-21 12:04:04 -07009454 protected interface MetadataSyncColumns {
9455
9456 /**
9457 * The raw contact backup id.
9458 * A reference to the {@link ContactsContract.RawContacts#BACKUP_ID} that save the
9459 * persistent unique id for each raw contact within its source system.
Tingting Wang20f14382015-04-21 12:04:04 -07009460 */
9461 public static final String RAW_CONTACT_BACKUP_ID = "raw_contact_backup_id";
9462
9463 /**
9464 * The account type to which the raw_contact of this item is associated. See
9465 * {@link RawContacts#ACCOUNT_TYPE}
Tingting Wang20f14382015-04-21 12:04:04 -07009466 */
9467 public static final String ACCOUNT_TYPE = "account_type";
9468
9469 /**
9470 * The account name to which the raw_contact of this item is associated. See
9471 * {@link RawContacts#ACCOUNT_NAME}
Tingting Wang20f14382015-04-21 12:04:04 -07009472 */
9473 public static final String ACCOUNT_NAME = "account_name";
9474
9475 /**
9476 * The data set within the account that the raw_contact of this row belongs to. This allows
9477 * multiple sync adapters for the same account type to distinguish between
9478 * each others' data.
9479 * {@link RawContacts#DATA_SET}
Tingting Wang20f14382015-04-21 12:04:04 -07009480 */
9481 public static final String DATA_SET = "data_set";
9482
9483 /**
9484 * A text column contains the Json string got from People API. The Json string contains
9485 * all the metadata related to the raw contact, i.e., all the data fields and
9486 * aggregation exceptions.
9487 *
9488 * Here is an example of the Json string got from the actual schema.
9489 * <pre>
9490 * {
9491 * "unique_contact_id": {
9492 * "account_type": "CUSTOM_ACCOUNT",
9493 * "custom_account_type": "facebook",
9494 * "account_name": "android-test",
9495 * "contact_id": "1111111",
9496 * "data_set": "FOCUS"
9497 * },
9498 * "contact_prefs": {
9499 * "send_to_voicemail": true,
9500 * "starred": false,
9501 * "pinned": 2
9502 * },
9503 * "aggregation_data": [
9504 * {
9505 * "type": "TOGETHER",
9506 * "contact_ids": [
9507 * {
9508 * "account_type": "GOOGLE_ACCOUNT",
9509 * "account_name": "android-test2",
9510 * "contact_id": "2222222",
9511 * "data_set": "GOOGLE_PLUS"
9512 * },
9513 * {
9514 * "account_type": "GOOGLE_ACCOUNT",
9515 * "account_name": "android-test3",
9516 * "contact_id": "3333333",
9517 * "data_set": "CUSTOM",
9518 * "custom_data_set": "custom type"
9519 * }
9520 * ]
9521 * }
9522 * ],
9523 * "field_data": [
9524 * {
9525 * "field_data_id": "1001",
9526 * "field_data_prefs": {
9527 * "is_primary": true,
9528 * "is_super_primary": true
9529 * },
9530 * "usage_stats": [
9531 * {
9532 * "usage_type": "CALL",
9533 * "last_time_used": 10000001,
9534 * "usage_count": 10
9535 * }
9536 * ]
9537 * }
9538 * ]
9539 * }
9540 * </pre>
Tingting Wang20f14382015-04-21 12:04:04 -07009541 */
9542 public static final String DATA = "data";
9543
9544 /**
9545 * The "deleted" flag: "0" by default, "1" if the row has been marked
9546 * for deletion. When {@link android.content.ContentResolver#delete} is
9547 * called on a raw contact, updating MetadataSync table to set the flag of the raw contact
9548 * as "1", then metadata sync adapter deletes the raw contact metadata on the server.
9549 * <P>Type: INTEGER</P>
Tingting Wang20f14382015-04-21 12:04:04 -07009550 */
9551 public static final String DELETED = "deleted";
9552 }
9553
9554 /**
9555 * Constants for the metadata sync table. This table is used to cache the metadata_sync data
9556 * from server before it is merged into other CP2 tables.
9557 *
9558 * @hide
9559 */
Zheng Fu7997bee2015-06-09 16:50:02 -07009560 @SystemApi
Tingting Wang20f14382015-04-21 12:04:04 -07009561 public static final class MetadataSync implements BaseColumns, MetadataSyncColumns {
9562
9563 /** The authority for the contacts metadata */
9564 public static final String METADATA_AUTHORITY = "com.android.contacts.metadata";
9565
9566 /** A content:// style uri to the authority for the contacts metadata */
9567 public static final Uri METADATA_AUTHORITY_URI = Uri.parse(
9568 "content://" + METADATA_AUTHORITY);
9569
9570 /**
9571 * This utility class cannot be instantiated
9572 */
9573 private MetadataSync() {
9574 }
9575
9576 /**
9577 * The content:// style URI for this table.
9578 */
9579 public static final Uri CONTENT_URI = Uri.withAppendedPath(METADATA_AUTHORITY_URI,
9580 "metadata_sync");
Zheng Fuc37ba122015-04-23 16:46:45 -07009581
9582 /**
9583 * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata
9584 */
9585 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contact_metadata";
9586
9587 /**
9588 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata.
9589 */
9590 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact_metadata";
Tingting Wang20f14382015-04-21 12:04:04 -07009591 }
Zheng Fuae678b82015-08-07 13:28:50 -07009592
9593 /**
9594 * @hide
9595 */
9596 @SystemApi
9597 protected interface MetadataSyncStateColumns {
9598
9599 /**
9600 * A reference to the name of the account to which this state belongs
9601 * <P>Type: STRING</P>
9602 */
9603 public static final String ACCOUNT_TYPE = "account_type";
9604
9605 /**
9606 * A reference to the type of the account to which this state belongs
9607 * <P>Type: STRING</P>
9608 */
9609 public static final String ACCOUNT_NAME = "account_name";
9610
9611 /**
9612 * A reference to the data set within the account to which this state belongs
9613 * <P>Type: STRING</P>
9614 */
9615 public static final String DATA_SET = "data_set";
9616
9617 /**
9618 * The sync state associated with this account.
9619 * <P>Type: Blob</P>
9620 */
9621 public static final String STATE = "state";
9622 }
9623
9624 /**
9625 * Constants for the metadata_sync_state table. This table is used to store the metadata
9626 * sync state for a set of accounts.
9627 *
9628 * @hide
9629 */
9630 @SystemApi
9631 public static final class MetadataSyncState implements BaseColumns, MetadataSyncStateColumns {
9632
9633 /**
9634 * This utility class cannot be instantiated
9635 */
9636 private MetadataSyncState() {
9637 }
9638
9639 /**
9640 * The content:// style URI for this table.
9641 */
9642 public static final Uri CONTENT_URI =
9643 Uri.withAppendedPath(MetadataSync.METADATA_AUTHORITY_URI, "metadata_sync_state");
9644
9645 /**
9646 * The MIME type of {@link #CONTENT_URI} providing a directory of contact metadata sync
9647 * states.
9648 */
9649 public static final String CONTENT_TYPE =
9650 "vnd.android.cursor.dir/contact_metadata_sync_state";
9651
9652 /**
9653 * The MIME type of a {@link #CONTENT_URI} subdirectory of a single contact metadata sync
9654 * state.
9655 */
9656 public static final String CONTENT_ITEM_TYPE =
9657 "vnd.android.cursor.item/contact_metadata_sync_state";
9658 }
Evan Millar088b2912009-05-28 15:24:37 -07009659}