ContactsContract.java revision 161dd86394a9733fd7ff303c31481cae7e31e7b4
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package android.provider;
18
19import android.graphics.BitmapFactory;
20import android.net.Uri;
21
22/**
23 * The contract between the contacts provider and applications. Contains definitions
24 * for the supported URIs and columns.
25 *
26 * @hide
27 */
28public final class ContactsContract {
29    /** The authority for the contacts provider */
30    public static final String AUTHORITY = "com.android.contacts";
31    /** A content:// style uri to the authority for the contacts provider */
32    public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY);
33
34    public interface AccountsColumns {
35        /**
36         * The name of this account data
37         * <P>Type: TEXT</P>
38         */
39        public static final String NAME = "name";
40        /**
41         * The name of this account data
42         * <P>Type: TEXT</P>
43         */
44        public static final String TYPE = "type";
45        /**
46         * The name of this account data
47         * <P>Type: TEXT</P>
48         */
49        public static final String DATA1 = "data1";
50
51        /**
52         * The value for this account data
53         * <P>Type: INTEGER</P>
54         */
55        public static final String DATA2 = "data2";
56
57        /**
58         * The value for this account data
59         * <P>Type: INTEGER</P>
60         */
61        public static final String DATA3 = "data3";
62
63        /**
64         * The value for this account data
65         * <P>Type: INTEGER</P>
66         */
67        public static final String DATA4 = "data4";
68
69        /**
70         * The value for this account data
71         * <P>Type: INTEGER</P>
72         */
73        public static final String DATA5 = "data5";
74    }
75
76    /**
77     * Constants for the aggregates table, which contains a record per group
78     * of contact representing the same person.
79     */
80    public static final class Accounts implements BaseColumns, AccountsColumns {
81        /**
82         * This utility class cannot be instantiated
83         */
84        private Accounts()  {}
85
86        /**
87         * The content:// style URI for this table
88         */
89        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "accounts");
90
91        /**
92         * The MIME type of {@link #CONTENT_URI} providing a directory of
93         * account data.
94         */
95        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/contacts_account";
96
97        /**
98         * The MIME type of a {@link #CONTENT_URI} subdirectory of a account
99         */
100        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contacts_account";
101    }
102
103    public interface AggregatesColumns {
104        /**
105         * The display name for the contact.
106         * <P>Type: TEXT</P>
107         */
108        public static final String DISPLAY_NAME = "display_name";
109
110        /**
111         * The number of times a person has been contacted
112         * <P>Type: INTEGER</P>
113         */
114        public static final String TIMES_CONTACTED = "times_contacted";
115
116        /**
117         * The last time a person was contacted.
118         * <P>Type: INTEGER</P>
119         */
120        public static final String LAST_TIME_CONTACTED = "last_time_contacted";
121
122        /**
123         * Is the contact starred?
124         * <P>Type: INTEGER (boolean)</P>
125         */
126        public static final String STARRED = "starred";
127
128        /**
129         * Reference to the row in the data table holding the primary phone number.
130         * <P>Type: INTEGER REFERENCES data(_id)</P>
131         */
132        public static final String PRIMARY_PHONE_ID = "primary_phone_id";
133
134        /**
135         * Reference to the row in the data table holding the primary email address.
136         * <P>Type: INTEGER REFERENCES data(_id)</P>
137         */
138        public static final String PRIMARY_EMAIL_ID = "primary_email_id";
139
140        /**
141         * Reference to the row in the data table holding the photo.
142         * <P>Type: INTEGER REFERENCES data(_id)</P>
143         */
144        public static final String PHOTO_ID = "photo_id";
145
146        /**
147         * Reference to a row containing custom ringtone and send to voicemail information.
148         * <P>Type: INTEGER REFERENCES data(_id)</P>
149         */
150        public static final String CUSTOM_RINGTONE_ID = "custom_ringtone_id";
151    }
152
153    /**
154     * Constants for the aggregates table, which contains a record per group
155     * of contact representing the same person.
156     */
157    public static final class Aggregates implements BaseColumns, AggregatesColumns {
158        /**
159         * This utility class cannot be instantiated
160         */
161        private Aggregates()  {}
162
163        /**
164         * The content:// style URI for this table
165         */
166        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "aggregates");
167
168        /**
169         * The content:// style URI for this table joined with useful data from
170         * {@link Data} and {@link Presence}.
171         */
172        public static final Uri CONTENT_SUMMARY_URI = Uri.withAppendedPath(AUTHORITY_URI,
173                "aggregates_summary");
174        /**
175         * The content:// style URI used for "type-to-filter" functionality on the
176         * {@link CONTENT_SUMMARY_URI} URI. The filter string will be used to match
177         * various parts of the aggregate name. The filter argument should be passed
178         * as an additional path segment after this URI.
179         */
180        public static final Uri CONTENT_SUMMARY_FILTER_URI = Uri.withAppendedPath(
181                CONTENT_SUMMARY_URI, "filter");
182
183        /**
184         * The MIME type of {@link #CONTENT_URI} providing a directory of
185         * people.
186         */
187        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/person_aggregate";
188
189        /**
190         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
191         * person.
192         */
193        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/person_aggregate";
194
195        /**
196         * A sub-directory of a single contact aggregate that contains all of their
197         * {@link Data} rows.
198         */
199        public static final class Data implements BaseColumns, DataColumns {
200            /**
201             * no public constructor since this is a utility class
202             */
203            private Data() {}
204
205            /**
206             * The directory twig for this sub-table
207             */
208            public static final String CONTENT_DIRECTORY = "data";
209        }
210
211        /**
212         * A sub-directory of a single contact aggregate that contains all aggregation suggestions
213         * (other aggregates).  The aggregation suggestions are computed based on approximate
214         * data matches with this aggregate.
215         */
216        public static final class AggregationSuggestions implements BaseColumns, AggregatesColumns {
217            /**
218             * No public constructor since this is a utility class
219             */
220            private AggregationSuggestions() {}
221
222            /**
223             * The directory twig for this sub-table
224             */
225            public static final String CONTENT_DIRECTORY = "suggestions";
226
227            /**
228             * An optional query parameter that can be supplied to limit the number of returned
229             * suggestions.
230             * <p>
231             * Type: INTEGER
232             */
233            public static final String MAX_SUGGESTIONS = "max_suggestions";
234        }
235    }
236
237
238    /**
239     * Constants for the contacts table, which contains the base contact information.
240     */
241    public static final class Contacts implements BaseColumns {
242        /**
243         * This utility class cannot be instantiated
244         */
245        private Contacts()  {}
246
247        /**
248         * A reference to the {@link Accounts#_ID} that this data belongs to.
249         */
250        public static final String ACCOUNTS_ID = "accounts_id";
251
252        /**
253         * A reference to the {@link Aggregates#_ID} that this data belongs to.
254         */
255        public static final String AGGREGATE_ID = "aggregate_id";
256
257        /**
258         * The content:// style URI for this table
259         */
260        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "contacts");
261
262        /**
263         * The content:// style URL for filtering people by email address. The
264         * filter argument should be passed as an additional path segment after
265         * this URI.
266         *
267         * @hide
268         */
269        public static final Uri CONTENT_FILTER_EMAIL_URI = Uri.withAppendedPath(CONTENT_URI, "filter_email");
270
271        /**
272         * The MIME type of {@link #CONTENT_URI} providing a directory of
273         * people.
274         */
275        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/person";
276
277        /**
278         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
279         * person.
280         */
281        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/person";
282
283        /**
284         * A string that uniquely identifies this contact to its source, which is referred to
285         * by the {@link #ACCOUNTS_ID}
286         */
287        public static final String SOURCE_ID = "sourceid";
288
289        /**
290         * An integer that is updated whenever this contact or its data changes.
291         */
292        public static final String VERSION = "version";
293
294        /**
295         * Set to 1 whenever the version changes
296         */
297        public static final String DIRTY = "dirty";
298
299        /**
300         * A sub-directory of a single contact that contains all of their {@link Data} rows.
301         * To access this directory append
302         */
303        public static final class Data implements BaseColumns, DataColumns {
304            /**
305             * no public constructor since this is a utility class
306             */
307            private Data() {}
308
309            /**
310             * The directory twig for this sub-table
311             */
312            public static final String CONTENT_DIRECTORY = "data";
313        }
314    }
315
316    private interface DataColumns {
317        /**
318         * The package name that defines this type of data.
319         */
320        public static final String PACKAGE = "package";
321
322        /**
323         * The mime-type of the item represented by this row.
324         */
325        public static final String MIMETYPE = "mimetype";
326
327        /**
328         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID}
329         * that this data belongs to.
330         */
331        public static final String CONTACT_ID = "contact_id";
332
333        /**
334         * Whether this is the primary entry of its kind for the contact it belongs to
335         * <P>Type: INTEGER (if set, non-0 means true)</P>
336         */
337        public static final String IS_PRIMARY = "is_primary";
338
339        /**
340         * Whether this is the primary entry of its kind for the aggregate it belongs to. Any data
341         * record that is "super primary" must also be "primary".
342         * <P>Type: INTEGER (if set, non-0 means true)</P>
343         */
344        public static final String IS_SUPER_PRIMARY = "is_super_primary";
345
346        /**
347         * Flag indicating that this data entry has been restricted by the owner
348         * {@link #PACKAGE}.
349         */
350        public static final String IS_RESTRICTED = "is_restricted";
351
352        /**
353         * The version of this data record. This is a read-only value. The data column is
354         * guaranteed to not change without the version going up. This value is monotonically
355         * increasing.
356         * <P>Type: INTEGER</P>
357         */
358        public static final String DATA_VERSION = "data_version";
359
360        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
361        public static final String DATA1 = "data1";
362        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
363        public static final String DATA2 = "data2";
364        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
365        public static final String DATA3 = "data3";
366        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
367        public static final String DATA4 = "data4";
368        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
369        public static final String DATA5 = "data5";
370        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
371        public static final String DATA6 = "data6";
372        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
373        public static final String DATA7 = "data7";
374        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
375        public static final String DATA8 = "data8";
376        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
377        public static final String DATA9 = "data9";
378        /** Generic data column, the meaning is {@link #MIMETYPE} specific */
379        public static final String DATA10 = "data10";
380    }
381
382    /**
383     * Constants for the data table, which contains data points tied to a contact.
384     * For example, a phone number or email address. Each row in this table contains a type
385     * definition and some generic columns. Each data type can define the meaning for each of
386     * the generic columns.
387     */
388    public static final class Data implements BaseColumns, DataColumns {
389        /**
390         * This utility class cannot be instantiated
391         */
392        private Data() {}
393
394        /**
395         * The content:// style URI for this table
396         */
397        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "data");
398
399        /**
400         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
401         */
402        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
403    }
404
405    /**
406     * A table that represents the result of looking up a phone number, for example for caller ID.
407     * The table joins that data row for the phone number with the contact that owns the number.
408     * To perform a lookup you must append the number you want to find to {@link #CONTENT_URI}.
409     */
410    public static final class PhoneLookup implements BaseColumns, DataColumns, AggregatesColumns {
411        /**
412         * This utility class cannot be instantiated
413         */
414        private PhoneLookup() {}
415
416        /**
417         * The content:// style URI for this table. Append the phone number you want to lookup
418         * to this URI and query it to perform a lookup. For example:
419         *
420         * {@code
421         * Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);
422         * }
423         */
424        public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(AUTHORITY_URI,
425                "phone_lookup");
426    }
427
428    /**
429     * Additional data mixed in with {@link Im.CommonPresenceColumns} to link
430     * back to specific {@link ContactsContract.Aggregates#_ID} entries.
431     */
432    private interface PresenceColumns {
433        /**
434         * Reference to the {@link Aggregates#_ID} this presence references.
435         */
436        public static final String AGGREGATE_ID = "aggregate_id";
437
438        /**
439         * Reference to the {@link Data#_ID} entry that owns this presence.
440         */
441        public static final String DATA_ID = "data_id";
442
443        /**
444         * The IM service the presence is coming from. Formatted using either
445         * {@link Contacts.ContactMethods#encodePredefinedImProtocol} or
446         * {@link Contacts.ContactMethods#encodeCustomImProtocol}.
447         * <p>
448         * Type: STRING
449         */
450        public static final String IM_PROTOCOL = "im_protocol";
451
452        /**
453         * The IM handle the presence item is for. The handle is scoped to the
454         * {@link #IM_PROTOCOL}.
455         * <p>
456         * Type: STRING
457         */
458        public static final String IM_HANDLE = "im_handle";
459
460        /**
461         * The IM account for the local user that the presence data came from.
462         * <p>
463         * Type: STRING
464         */
465        public static final String IM_ACCOUNT = "im_account";
466    }
467
468    public static final class Presence implements BaseColumns, PresenceColumns,
469            Im.CommonPresenceColumns {
470        /**
471         * This utility class cannot be instantiated
472         */
473        private Presence() {
474        }
475
476        /**
477         * The content:// style URI for this table
478         */
479        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI, "presence");
480
481        /**
482         * Gets the resource ID for the proper presence icon.
483         *
484         * @param status the status to get the icon for
485         * @return the resource ID for the proper presence icon
486         */
487        public static final int getPresenceIconResourceId(int status) {
488            switch (status) {
489                case AVAILABLE:
490                    return android.R.drawable.presence_online;
491                case IDLE:
492                case AWAY:
493                    return android.R.drawable.presence_away;
494                case DO_NOT_DISTURB:
495                    return android.R.drawable.presence_busy;
496                case INVISIBLE:
497                    return android.R.drawable.presence_invisible;
498                case OFFLINE:
499                default:
500                    return android.R.drawable.presence_offline;
501            }
502        }
503
504        /**
505         * The MIME type of {@link #CONTENT_URI} providing a directory of
506         * presence details.
507         */
508        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/im-presence";
509
510        /**
511         * The MIME type of a {@link #CONTENT_URI} subdirectory of a single
512         * presence detail.
513         */
514        public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im-presence";
515    }
516
517    /**
518     * Container for definitions of common data types stored in the {@link Data} table.
519     */
520    public static final class CommonDataKinds {
521        /**
522         * The {@link Data#PACKAGE} value for common data that should be shown
523         * using a default style.
524         */
525        public static final String PACKAGE_COMMON = "common";
526
527        /**
528         * Columns common across the specific types.
529         */
530        private interface BaseCommonColumns {
531            /**
532             * The package name that defines this type of data.
533             */
534            public static final String PACKAGE = "package";
535
536            /**
537             * The mime-type of the item represented by this row.
538             */
539            public static final String MIMETYPE = "mimetype";
540
541            /**
542             * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} that this
543             * data belongs to.
544             */
545            public static final String CONTACT_ID = "contact_id";
546        }
547
548        /**
549         * Columns common across the specific types.
550         */
551        private interface CommonColumns {
552            /**
553             * The type of data, for example Home or Work.
554             * <P>Type: INTEGER</P>
555             */
556            public static final String TYPE = "data1";
557
558            /**
559             * The data for the contact method.
560             * <P>Type: TEXT</P>
561             */
562            public static final String DATA = "data2";
563
564            /**
565             * The user defined label for the the contact method.
566             * <P>Type: TEXT</P>
567             */
568            public static final String LABEL = "data3";
569        }
570
571        /**
572         * The base types that all "Typed" data kinds support.
573         */
574        public interface BaseTypes {
575
576            /**
577             * A custom type. The custom label should be supplied by user.
578             */
579            public static int TYPE_CUSTOM = 0;
580        }
581
582        /**
583         * Parts of the name.
584         */
585        public static final class StructuredName {
586            private StructuredName() {}
587
588            /** Mime-type used when storing this in data table. */
589            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/name";
590
591            /**
592             * The given name for the contact.
593             * <P>Type: TEXT</P>
594             */
595            public static final String GIVEN_NAME = "data1";
596
597            /**
598             * The family name for the contact.
599             * <P>Type: TEXT</P>
600             */
601            public static final String FAMILY_NAME = "data2";
602
603            /**
604             * The contact's honorific prefix, e.g. "Sir"
605             * <P>Type: TEXT</P>
606             */
607            public static final String PREFIX = "data3";
608
609            /**
610             * The contact's middle name
611             * <P>Type: TEXT</P>
612             */
613            public static final String MIDDLE_NAME = "data4";
614
615            /**
616             * The contact's honorific suffix, e.g. "Jr"
617             */
618            public static final String SUFFIX = "data5";
619
620            /**
621             * The phonetic version of the given name for the contact.
622             * <P>Type: TEXT</P>
623             */
624            public static final String PHONETIC_GIVEN_NAME = "data6";
625
626            /**
627             * The phonetic version of the additional name for the contact.
628             * <P>Type: TEXT</P>
629             */
630            public static final String PHONETIC_MIDDLE_NAME = "data7";
631
632            /**
633             * The phonetic version of the family name for the contact.
634             * <P>Type: TEXT</P>
635             */
636            public static final String PHONETIC_FAMILY_NAME = "data8";
637
638            /**
639             * The name that should be used to display the contact.
640             * <P>Type: TEXT</P>
641             */
642            public static final String DISPLAY_NAME = "data9";
643        }
644
645        /**
646         * A nickname.
647         */
648        public static final class Nickname implements BaseTypes {
649            private Nickname() {}
650
651            /** Mime-type used when storing this in data table. */
652            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/nickname";
653
654            /**
655             * The type of data, for example Home or Work.
656             * <P>Type: INTEGER</P>
657             */
658            public static final String TYPE = "data1";
659
660            public static final int TYPE_DEFAULT = 1;
661            public static final int TYPE_OTHER_NAME = 2;
662            public static final int TYPE_MAINDEN_NAME = 3;
663            public static final int TYPE_SHORT_NAME = 4;
664            public static final int TYPE_INITIALS = 5;
665
666            /**
667             * The name itself
668             */
669            public static final String NAME = "data2";
670
671            /**
672             * The user provided label, only used if TYPE is {@link #TYPE_CUSTOM}.
673             * <P>Type: TEXT</P>
674             */
675            public static final String LABEL = "data3";
676        }
677
678        /**
679         * Common data definition for telephone numbers.
680         */
681        public static final class Phone implements BaseCommonColumns, CommonColumns, BaseTypes {
682            private Phone() {}
683
684            /** Mime-type used when storing this in data table. */
685            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/phone";
686
687            /**
688             * The MIME type of {@link #CONTENT_URI} providing a directory of
689             * phones.
690             */
691            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/phone";
692
693            /**
694             * The content:// style URI for all data records of the
695             * {@link Phone.CONTENT_ITEM_TYPE} mimetype, combined with the associated contact
696             * and aggregate data.
697             */
698            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
699                    "phones");
700
701            /**
702             * The content:// style URI for filtering data records of the
703             * {@link Phone.CONTENT_ITEM_TYPE} mimetype, combined with the associated contact
704             * and aggregate data. The filter argument should be passed
705             * as an additional path segment after this URI.
706             */
707            public static final Uri CONTENT_FILTER_URI = Uri.withAppendedPath(CONTENT_URI,
708                    "filter");
709
710            public static final int TYPE_HOME = 1;
711            public static final int TYPE_MOBILE = 2;
712            public static final int TYPE_WORK = 3;
713            public static final int TYPE_FAX_WORK = 4;
714            public static final int TYPE_FAX_HOME = 5;
715            public static final int TYPE_PAGER = 6;
716            public static final int TYPE_OTHER = 7;
717
718            /**
719             * The phone number as the user entered it.
720             * <P>Type: TEXT</P>
721             */
722            public static final String NUMBER = "data2";
723        }
724
725        /**
726         * Common data definition for email addresses.
727         */
728        public static final class Email implements BaseCommonColumns, CommonColumns, BaseTypes {
729            private Email() {}
730
731            /** Mime-type used when storing this in data table. */
732            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/email";
733
734            public static final int TYPE_HOME = 1;
735            public static final int TYPE_WORK = 2;
736            public static final int TYPE_OTHER = 3;
737        }
738
739        /**
740         * Common data definition for postal addresses.
741         */
742        public static final class Postal implements BaseCommonColumns, CommonColumns, BaseTypes {
743            private Postal() {}
744
745            /** Mime-type used when storing this in data table. */
746            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/postal-address";
747
748            /**
749             * The MIME type of {@link #CONTENT_URI} providing a directory of
750             * postal addresses.
751             */
752            public static final String CONTENT_TYPE = "vnd.android.cursor.dir/postal-address";
753
754            /**
755             * The content:// style URI for all data records of the
756             * {@link Postal.CONTENT_ITEM_TYPE} mimetype, combined with the associated contact
757             * and aggregate data.
758             */
759            public static final Uri CONTENT_URI = Uri.withAppendedPath(Data.CONTENT_URI,
760                    "postals");
761
762            public static final int TYPE_HOME = 1;
763            public static final int TYPE_WORK = 2;
764            public static final int TYPE_OTHER = 3;
765        }
766
767       /**
768        * Common data definition for IM addresses.
769        */
770        public static final class Im implements BaseCommonColumns, CommonColumns, BaseTypes {
771            private Im() {}
772
773            /** Mime-type used when storing this in data table. */
774            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/im";
775
776            public static final int TYPE_HOME = 1;
777            public static final int TYPE_WORK = 2;
778            public static final int TYPE_OTHER = 3;
779
780            public static final String PROTOCOL = "data5";
781
782            /**
783             * The predefined IM protocol types. The protocol can either be non-present, one
784             * of these types, or a free-form string. These cases are encoded in the PROTOCOL
785             * column as:
786             * <ul>
787             * <li>null</li>
788             * <li>pre:&lt;an integer, one of the protocols below&gt;</li>
789             * <li>custom:&lt;a string&gt;</li>
790             * </ul>
791             */
792            public static final int PROTOCOL_AIM = 0;
793            public static final int PROTOCOL_MSN = 1;
794            public static final int PROTOCOL_YAHOO = 2;
795            public static final int PROTOCOL_SKYPE = 3;
796            public static final int PROTOCOL_QQ = 4;
797            public static final int PROTOCOL_GOOGLE_TALK = 5;
798            public static final int PROTOCOL_ICQ = 6;
799            public static final int PROTOCOL_JABBER = 7;
800
801            public static String encodePredefinedImProtocol(int protocol) {
802               return "pre:" + protocol;
803            }
804
805            public static String encodeCustomImProtocol(String protocolString) {
806               return "custom:" + protocolString;
807            }
808
809            public static Object decodeImProtocol(String encodedString) {
810               if (encodedString == null) {
811                   return null;
812               }
813
814               if (encodedString.startsWith("pre:")) {
815                   return Integer.parseInt(encodedString.substring(4));
816               }
817
818               if (encodedString.startsWith("custom:")) {
819                   return encodedString.substring(7);
820               }
821
822               throw new IllegalArgumentException(
823                       "the value is not a valid encoded protocol, " + encodedString);
824            }
825        }
826
827        /**
828         * Common data definition for organizations.
829         */
830        public static final class Organization implements BaseCommonColumns, BaseTypes {
831            private Organization() {}
832
833            /** Mime-type used when storing this in data table. */
834            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/organization";
835
836            /**
837             * The type of data, for example Home or Work.
838             * <P>Type: INTEGER</P>
839             */
840            public static final String TYPE = "data1";
841
842            public static final int TYPE_HOME = 1;
843            public static final int TYPE_WORK = 2;
844            public static final int TYPE_OTHER = 3;
845
846            /**
847             * The user provided label, only used if TYPE is {@link #TYPE_CUSTOM}.
848             * <P>Type: TEXT</P>
849             */
850            public static final String LABEL = "data2";
851
852            /**
853             * The company as the user entered it.
854             * <P>Type: TEXT</P>
855             */
856            public static final String COMPANY = "data3";
857
858            /**
859             * The position title at this company as the user entered it.
860             * <P>Type: TEXT</P>
861             */
862            public static final String TITLE = "data4";
863        }
864
865        /**
866         * Photo of the contact.
867         */
868        public static final class Photo implements BaseCommonColumns {
869            private Photo() {}
870
871            /** Mime-type used when storing this in data table. */
872            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/photo";
873
874            /**
875             * Thumbnail photo of the contact. This is the raw bytes of an image
876             * that could be inflated using {@link BitmapFactory}.
877             * <p>
878             * Type: BLOB
879             */
880            public static final String PHOTO = "data1";
881        }
882
883        /**
884         * Notes about the contact.
885         */
886        public static final class Note implements BaseCommonColumns {
887            private Note() {}
888
889            /** Mime-type used when storing this in data table. */
890            public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/note";
891
892            /**
893             * The note text.
894             * <P>Type: TEXT</P>
895             */
896            public static final String NOTE = "data1";
897        }
898
899        /**
900         * Custom ringtone associated with the contact.
901         */
902        public static final class CustomRingtone implements BaseCommonColumns {
903            private CustomRingtone() {}
904
905            public static final String CONTENT_ITEM_TYPE =
906                    "vnd.android.cursor.item/custom_ringtone";
907
908            /**
909             * Whether to send the number to voicemail.
910             * <P>Type: INTEGER (if set, non-0 means true)</P>
911             */
912            public static final String SEND_TO_VOICEMAIL = "data1";
913
914            /**
915             * The ringtone uri.
916             * <P>Type: TEXT</P>
917             */
918            public static final String RINGTONE_URI = "data2";
919        }
920
921        /**
922         * Group Membership.
923         */
924        public static final class GroupMembership implements BaseCommonColumns {
925            private GroupMembership() {}
926
927            /** Mime-type used when storing this in data table. */
928            public static final String CONTENT_ITEM_TYPE =
929                    "vnd.android.cursor.item/group_membership";
930
931            /**
932             * The row id of the group that this group membership refers to. Either this or the
933             * GROUP_SOURCE_ID must be set. If they are both set then they must refer to the same
934             * group.
935             * <P>Type: INTEGER</P>
936             */
937            public static final String GROUP_ROW_ID = "data1";
938
939            /**
940             * The source id of the group that this membership refers to. Either this or the
941             * GROUP_ROW_ID must be set. If they are both set then they must refer to the same
942             * group.
943             * <P>Type: STRING</P>
944             */
945            public static final String GROUP_SOURCE_ID = "data2";
946        }
947    }
948
949    /**
950     * Constants for the contact aggregation exceptions table, which contains
951     * aggregation rules overriding those used by automatic aggregation.
952     */
953    public static final class AggregationExceptions implements BaseColumns {
954        /**
955         * This utility class cannot be instantiated
956         */
957        private AggregationExceptions() {}
958
959        /**
960         * The content:// style URI for this table
961         */
962        public static final Uri CONTENT_URI =
963                Uri.withAppendedPath(AUTHORITY_URI, "aggregation_exceptions");
964
965        /**
966         * The MIME type of {@link #CONTENT_URI} providing a directory of data.
967         */
968        public static final String CONTENT_TYPE = "vnd.android.cursor.dir/aggregation_exception";
969
970        /**
971         * The MIME type of a {@link #CONTENT_URI} subdirectory of an aggregation exception
972         */
973        public static final String CONTENT_ITEM_TYPE =
974                "vnd.android.cursor.item/aggregation_exception";
975
976        /**
977         * The type of exception: {@link #TYPE_NEVER_MATCH} or {@link #TYPE_ALWAYS_MATCH}.
978         *
979         * <P>Type: INTEGER</P>
980         */
981        public static final String TYPE = "type";
982
983        public static final int TYPE_NEVER_MATCH = 0;
984        public static final int TYPE_ALWAYS_MATCH = 1;
985
986        /**
987         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of one of
988         * the contacts that the rule applies to.
989         */
990        public static final String CONTACT_ID1 = "contact_id1";
991
992        /**
993         * A reference to the {@link android.provider.ContactsContract.Contacts#_ID} of the other
994         * contact that the rule applies to.
995         */
996        public static final String CONTACT_ID2 = "contact_id2";
997    }
998
999    private interface RestrictionExceptionsColumns {
1000        /**
1001         * Package name of a specific data provider, which will be matched
1002         * against {@link Data#PACKAGE}.
1003         * <p>
1004         * Type: STRING
1005         */
1006        public static final String PACKAGE_PROVIDER = "package_provider";
1007
1008        /**
1009         * Package name of a specific data client, which will be matched against
1010         * the incoming {@link android.os.Binder#getCallingUid()} to decide if
1011         * the caller can access values with {@link Data#IS_RESTRICTED} flags.
1012         * <p>
1013         * Type: STRING
1014         */
1015        public static final String PACKAGE_CLIENT = "package_client";
1016
1017        /**
1018         * Flag indicating if {@link #PACKAGE_PROVIDER} allows
1019         * {@link #PACKAGE_CLIENT} to access restricted {@link Data} rows.
1020         * <p>
1021         * Type: INTEGER
1022         */
1023        public static final String ALLOW_ACCESS = "allow_access";
1024    }
1025
1026    /**
1027     * Constants for {@link Data} restriction exceptions. Sync adapters who
1028     * insert restricted data can use this table to specify exceptions about
1029     * which additional packages can access that restricted data.You can only
1030     * modify rules for a {@link RestrictionExceptionsColumns#PACKAGE_PROVIDER}
1031     * that your {@link android.os.Binder#getCallingUid()} owns.
1032     */
1033    public static final class RestrictionExceptions implements RestrictionExceptionsColumns {
1034        /**
1035         * This utility class cannot be instantiated
1036         */
1037        private RestrictionExceptions() {}
1038
1039        /**
1040         * The content:// style URI for this table
1041         */
1042        public static final Uri CONTENT_URI = Uri.withAppendedPath(AUTHORITY_URI,
1043                "restriction_exceptions");
1044    }
1045}
1046