1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.dialer.phonenumbercache;
18 
19 import android.provider.ContactsContract.CommonDataKinds.Phone;
20 import android.provider.ContactsContract.Contacts;
21 import android.provider.ContactsContract.PhoneLookup;
22 
23 /** The queries to look up the {@link ContactInfo} for a given number in the Call Log. */
24 final class PhoneQuery {
25 
26   static final int PERSON_ID = 0;
27   static final int NAME = 1;
28   static final int PHONE_TYPE = 2;
29   static final int LABEL = 3;
30   static final int MATCHED_NUMBER = 4;
31   static final int NORMALIZED_NUMBER = 5;
32   static final int PHOTO_ID = 6;
33   static final int LOOKUP_KEY = 7;
34   static final int PHOTO_URI = 8;
35   /** Projection to look up a contact's DISPLAY_NAME_ALTERNATIVE */
36   static final String[] DISPLAY_NAME_ALTERNATIVE_PROJECTION =
37       new String[] {
38         Contacts.DISPLAY_NAME_ALTERNATIVE,
39       };
40 
41   static final int NAME_ALTERNATIVE = 0;
42 
43   static final String[] ADDITIONAL_CONTACT_INFO_PROJECTION =
44       new String[] {Phone.DISPLAY_NAME_ALTERNATIVE, Phone.CARRIER_PRESENCE};
45   static final int ADDITIONAL_CONTACT_INFO_DISPLAY_NAME_ALTERNATIVE = 0;
46   static final int ADDITIONAL_CONTACT_INFO_CARRIER_PRESENCE = 1;
47 
48   /**
49    * Projection to look up the ContactInfo. Does not include DISPLAY_NAME_ALTERNATIVE as that column
50    * isn't available in ContactsCommon.PhoneLookup. We should always use this projection starting
51    * from NYC onward.
52    */
53   private static final String[] PHONE_LOOKUP_PROJECTION =
54       new String[] {
55         PhoneLookup.CONTACT_ID,
56         PhoneLookup.DISPLAY_NAME,
57         PhoneLookup.TYPE,
58         PhoneLookup.LABEL,
59         PhoneLookup.NUMBER,
60         PhoneLookup.NORMALIZED_NUMBER,
61         PhoneLookup.PHOTO_ID,
62         PhoneLookup.LOOKUP_KEY,
63         PhoneLookup.PHOTO_URI
64       };
65 
getPhoneLookupProjection()66   static String[] getPhoneLookupProjection() {
67       return PHONE_LOOKUP_PROJECTION;
68   }
69 }
70