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.os.Build.VERSION; 20 import android.os.Build.VERSION_CODES; 21 import android.provider.CallLog; 22 import android.provider.CallLog.Calls; 23 import android.support.annotation.NonNull; 24 import android.support.annotation.RequiresApi; 25 import java.util.ArrayList; 26 import java.util.Arrays; 27 import java.util.List; 28 29 /** The query for the call log table. */ 30 public final class CallLogQuery { 31 32 public static final int ID = 0; 33 public static final int NUMBER = 1; 34 public static final int DATE = 2; 35 public static final int DURATION = 3; 36 public static final int CALL_TYPE = 4; 37 public static final int COUNTRY_ISO = 5; 38 public static final int VOICEMAIL_URI = 6; 39 public static final int GEOCODED_LOCATION = 7; 40 public static final int CACHED_NAME = 8; 41 public static final int CACHED_NUMBER_TYPE = 9; 42 public static final int CACHED_NUMBER_LABEL = 10; 43 public static final int CACHED_LOOKUP_URI = 11; 44 public static final int CACHED_MATCHED_NUMBER = 12; 45 public static final int CACHED_NORMALIZED_NUMBER = 13; 46 public static final int CACHED_PHOTO_ID = 14; 47 public static final int CACHED_FORMATTED_NUMBER = 15; 48 public static final int IS_READ = 16; 49 public static final int NUMBER_PRESENTATION = 17; 50 public static final int ACCOUNT_COMPONENT_NAME = 18; 51 public static final int ACCOUNT_ID = 19; 52 public static final int FEATURES = 20; 53 public static final int DATA_USAGE = 21; 54 public static final int TRANSCRIPTION = 22; 55 public static final int CACHED_PHOTO_URI = 23; 56 57 @RequiresApi(VERSION_CODES.N) 58 public static final int POST_DIAL_DIGITS = 24; 59 60 @RequiresApi(VERSION_CODES.N) 61 public static final int VIA_NUMBER = 25; 62 63 private static final String[] PROJECTION_M = 64 new String[] { 65 Calls._ID, // 0 66 Calls.NUMBER, // 1 67 Calls.DATE, // 2 68 Calls.DURATION, // 3 69 Calls.TYPE, // 4 70 Calls.COUNTRY_ISO, // 5 71 Calls.VOICEMAIL_URI, // 6 72 Calls.GEOCODED_LOCATION, // 7 73 Calls.CACHED_NAME, // 8 74 Calls.CACHED_NUMBER_TYPE, // 9 75 Calls.CACHED_NUMBER_LABEL, // 10 76 Calls.CACHED_LOOKUP_URI, // 11 77 Calls.CACHED_MATCHED_NUMBER, // 12 78 Calls.CACHED_NORMALIZED_NUMBER, // 13 79 Calls.CACHED_PHOTO_ID, // 14 80 Calls.CACHED_FORMATTED_NUMBER, // 15 81 Calls.IS_READ, // 16 82 Calls.NUMBER_PRESENTATION, // 17 83 Calls.PHONE_ACCOUNT_COMPONENT_NAME, // 18 84 Calls.PHONE_ACCOUNT_ID, // 19 85 Calls.FEATURES, // 20 86 Calls.DATA_USAGE, // 21 87 Calls.TRANSCRIPTION, // 22 88 Calls.CACHED_PHOTO_URI, // 23 89 }; 90 91 private static final String[] PROJECTION_N; 92 93 static { 94 List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_M)); 95 projectionList.add(CallLog.Calls.POST_DIAL_DIGITS); 96 projectionList.add(CallLog.Calls.VIA_NUMBER); 97 PROJECTION_N = projectionList.toArray(new String[projectionList.size()]); 98 } 99 100 @NonNull 101 public static String[] getProjection() { 102 if (VERSION.SDK_INT >= VERSION_CODES.N) { 103 return PROJECTION_N; 104 } 105 return PROJECTION_M; 106 } 107 } 108