• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   public static final int POST_DIAL_DIGITS = 24;
57   public static final int VIA_NUMBER = 25;
58 
59   @RequiresApi(VERSION_CODES.O)
60   public static final int TRANSCRIPTION_STATE = 26;
61 
62   private static final String[] PROJECTION_N =
63       new String[] {
64         Calls._ID, // 0
65         Calls.NUMBER, // 1
66         Calls.DATE, // 2
67         Calls.DURATION, // 3
68         Calls.TYPE, // 4
69         Calls.COUNTRY_ISO, // 5
70         Calls.VOICEMAIL_URI, // 6
71         Calls.GEOCODED_LOCATION, // 7
72         Calls.CACHED_NAME, // 8
73         Calls.CACHED_NUMBER_TYPE, // 9
74         Calls.CACHED_NUMBER_LABEL, // 10
75         Calls.CACHED_LOOKUP_URI, // 11
76         Calls.CACHED_MATCHED_NUMBER, // 12
77         Calls.CACHED_NORMALIZED_NUMBER, // 13
78         Calls.CACHED_PHOTO_ID, // 14
79         Calls.CACHED_FORMATTED_NUMBER, // 15
80         Calls.IS_READ, // 16
81         Calls.NUMBER_PRESENTATION, // 17
82         Calls.PHONE_ACCOUNT_COMPONENT_NAME, // 18
83         Calls.PHONE_ACCOUNT_ID, // 19
84         Calls.FEATURES, // 20
85         Calls.DATA_USAGE, // 21
86         Calls.TRANSCRIPTION, // 22
87         Calls.CACHED_PHOTO_URI, // 23
88         CallLog.Calls.POST_DIAL_DIGITS, // 24
89         CallLog.Calls.VIA_NUMBER // 25
90       };
91 
92   private static final String[] PROJECTION_O;
93 
94   // TODO(mdooley): remove when this becomes a public api
95   // Copied from android.provider.CallLog.Calls
96   private static final String TRANSCRIPTION_STATE_COLUMN = "transcription_state";
97 
98   static {
99     List<String> projectionList = new ArrayList<>(Arrays.asList(PROJECTION_N));
100     projectionList.add(TRANSCRIPTION_STATE_COLUMN);
101     PROJECTION_O = projectionList.toArray(new String[projectionList.size()]);
102   }
103 
104   @NonNull
getProjection()105   public static String[] getProjection() {
106     return VERSION.SDK_INT >= VERSION_CODES.O ? PROJECTION_O : PROJECTION_N;
107   }
108 }
109