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.calllog; 18 19 import com.google.common.collect.Lists; 20 21 import android.provider.CallLog.Calls; 22 23 import com.android.contacts.common.compat.CompatUtils; 24 import com.android.dialer.compat.CallsSdkCompat; 25 import com.android.dialer.compat.DialerCompatUtils; 26 27 import java.util.List; 28 29 /** 30 * The query for the call log table. 31 */ 32 public final class CallLogQuery { 33 34 private static final String[] _PROJECTION_INTERNAL = new String[] { 35 Calls._ID, // 0 36 Calls.NUMBER, // 1 37 Calls.DATE, // 2 38 Calls.DURATION, // 3 39 Calls.TYPE, // 4 40 Calls.COUNTRY_ISO, // 5 41 Calls.VOICEMAIL_URI, // 6 42 Calls.GEOCODED_LOCATION, // 7 43 Calls.CACHED_NAME, // 8 44 Calls.CACHED_NUMBER_TYPE, // 9 45 Calls.CACHED_NUMBER_LABEL, // 10 46 Calls.CACHED_LOOKUP_URI, // 11 47 Calls.CACHED_MATCHED_NUMBER, // 12 48 Calls.CACHED_NORMALIZED_NUMBER, // 13 49 Calls.CACHED_PHOTO_ID, // 14 50 Calls.CACHED_FORMATTED_NUMBER, // 15 51 Calls.IS_READ, // 16 52 Calls.NUMBER_PRESENTATION, // 17 53 Calls.PHONE_ACCOUNT_COMPONENT_NAME, // 18 54 Calls.PHONE_ACCOUNT_ID, // 19 55 Calls.FEATURES, // 20 56 Calls.DATA_USAGE, // 21 57 Calls.TRANSCRIPTION, // 22 58 }; 59 60 public static final int ID = 0; 61 public static final int NUMBER = 1; 62 public static final int DATE = 2; 63 public static final int DURATION = 3; 64 public static final int CALL_TYPE = 4; 65 public static final int COUNTRY_ISO = 5; 66 public static final int VOICEMAIL_URI = 6; 67 public static final int GEOCODED_LOCATION = 7; 68 public static final int CACHED_NAME = 8; 69 public static final int CACHED_NUMBER_TYPE = 9; 70 public static final int CACHED_NUMBER_LABEL = 10; 71 public static final int CACHED_LOOKUP_URI = 11; 72 public static final int CACHED_MATCHED_NUMBER = 12; 73 public static final int CACHED_NORMALIZED_NUMBER = 13; 74 public static final int CACHED_PHOTO_ID = 14; 75 public static final int CACHED_FORMATTED_NUMBER = 15; 76 public static final int IS_READ = 16; 77 public static final int NUMBER_PRESENTATION = 17; 78 public static final int ACCOUNT_COMPONENT_NAME = 18; 79 public static final int ACCOUNT_ID = 19; 80 public static final int FEATURES = 20; 81 public static final int DATA_USAGE = 21; 82 public static final int TRANSCRIPTION = 22; 83 84 // Indices for columns that may not be available, depending on the Sdk Version 85 /** 86 * Only available in versions >= M 87 * Call {@link DialerCompatUtils#isCallsCachedPhotoUriCompatible()} prior to use 88 */ 89 public static int CACHED_PHOTO_URI = -1; 90 91 /** 92 * Only available in versions > M 93 * Call {@link CompatUtils#isNCompatible()} prior to use 94 */ 95 public static int POST_DIAL_DIGITS = -1; 96 public static int VIA_NUMBER = -1; 97 98 public static final String[] _PROJECTION; 99 100 static { 101 List<String> projectionList = Lists.newArrayList(_PROJECTION_INTERNAL); 102 if (DialerCompatUtils.isCallsCachedPhotoUriCompatible()) { 103 projectionList.add(Calls.CACHED_PHOTO_URI); 104 CACHED_PHOTO_URI = projectionList.size() - 1; 105 } 106 if (CompatUtils.isNCompatible()) { 107 projectionList.add(CallsSdkCompat.POST_DIAL_DIGITS); 108 POST_DIAL_DIGITS = projectionList.size() - 1; 109 projectionList.add(CallsSdkCompat.VIA_NUMBER); 110 VIA_NUMBER = projectionList.size() - 1; 111 } 112 _PROJECTION = projectionList.toArray(new String[projectionList.size()]); 113 } 114 115 } 116