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