1 /*
2  * Copyright (C) 2017 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.database.contract;
18 
19 import android.net.Uri;
20 import android.os.Build;
21 import android.provider.BaseColumns;
22 import com.android.dialer.compat.android.provider.VoicemailCompat;
23 import com.android.dialer.constants.Constants;
24 
25 /** Contract for the AnnotatedCallLog content provider. */
26 public class AnnotatedCallLogContract {
27   public static final String AUTHORITY = Constants.get().getAnnotatedCallLogProviderAuthority();
28 
29   public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
30 
31   /** AnnotatedCallLog table. */
32   public static final class AnnotatedCallLog implements BaseColumns {
33 
34     public static final String TABLE = "AnnotatedCallLog";
35     public static final String DISTINCT_PHONE_NUMBERS = "DistinctPhoneNumbers";
36 
37     /** The content URI for this table. */
38     public static final Uri CONTENT_URI =
39         Uri.withAppendedPath(AnnotatedCallLogContract.CONTENT_URI, TABLE);
40 
41     /** Content URI for selecting the distinct phone numbers from the AnnotatedCallLog. */
42     public static final Uri DISTINCT_NUMBERS_CONTENT_URI =
43         Uri.withAppendedPath(AnnotatedCallLogContract.CONTENT_URI, DISTINCT_PHONE_NUMBERS);
44 
45     /** The MIME type of a {@link android.content.ContentProvider#getType(Uri)} single entry. */
46     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/annotated_call_log";
47 
48     /**
49      * Timestamp of the entry, in milliseconds.
50      *
51      * <p>Type: INTEGER (long)
52      */
53     public static final String TIMESTAMP = "timestamp";
54 
55     /**
56      * The phone number called or number the call came from, encoded as a {@link
57      * com.android.dialer.DialerPhoneNumber} proto. The number may be empty if it was an incoming
58      * call and the number was unknown.
59      *
60      * <p>Type: BLOB
61      */
62     public static final String NUMBER = "number";
63 
64     /**
65      * The number formatted as it should be displayed to the user. Note that it may not always be
66      * displayed, for example if the number has a corresponding person or business name.
67      *
68      * <p>Type: TEXT
69      */
70     public static final String FORMATTED_NUMBER = "formatted_number";
71 
72     /**
73      * See {@link android.provider.CallLog.Calls#NUMBER_PRESENTATION}.
74      *
75      * <p>Type: INTEGER (int)
76      */
77     public static final String NUMBER_PRESENTATION = "presentation";
78 
79     /**
80      * See {@link android.provider.CallLog.Calls#IS_READ}.
81      *
82      * <p>TYPE: INTEGER (boolean)
83      */
84     public static final String IS_READ = "is_read";
85 
86     /**
87      * See {@link android.provider.CallLog.Calls#NEW}.
88      *
89      * <p>Type: INTEGER (boolean)
90      */
91     public static final String NEW = "new";
92 
93     /**
94      * See {@link android.provider.CallLog.Calls#GEOCODED_LOCATION}.
95      *
96      * <p>TYPE: TEXT
97      */
98     public static final String GEOCODED_LOCATION = "geocoded_location";
99 
100     /**
101      * See {@link android.provider.CallLog.Calls#PHONE_ACCOUNT_COMPONENT_NAME}.
102      *
103      * <p>TYPE: TEXT
104      */
105     public static final String PHONE_ACCOUNT_COMPONENT_NAME = "phone_account_component_name";
106 
107     /**
108      * See {@link android.provider.CallLog.Calls#PHONE_ACCOUNT_ID}.
109      *
110      * <p>TYPE: TEXT
111      */
112     public static final String PHONE_ACCOUNT_ID = "phone_account_id";
113 
114     /**
115      * See {@link android.provider.CallLog.Calls#FEATURES}.
116      *
117      * <p>TYPE: INTEGER (int)
118      */
119     public static final String FEATURES = "features";
120 
121     /**
122      * Additional attributes about the number.
123      *
124      * <p>TYPE: BLOB
125      *
126      * @see com.android.dialer.NumberAttributes
127      */
128     public static final String NUMBER_ATTRIBUTES = "number_attributes";
129 
130     /**
131      * Whether the call is to the voicemail inbox.
132      *
133      * <p>TYPE: INTEGER (boolean)
134      *
135      * @see android.telecom.TelecomManager#isVoiceMailNumber(android.telecom.PhoneAccountHandle,
136      *     String)
137      */
138     public static final String IS_VOICEMAIL_CALL = "is_voicemail_call";
139 
140     /**
141      * The "name" of the voicemail inbox. This is provided by the SIM to show as the caller ID
142      *
143      * <p>TYPE: TEXT
144      *
145      * @see android.telephony.TelephonyManager#getVoiceMailAlphaTag()
146      */
147     public static final String VOICEMAIL_CALL_TAG = "voicemail_call_tag";
148 
149     /**
150      * Copied from {@link android.provider.CallLog.Calls#TYPE}.
151      *
152      * <p>Type: INTEGER (int)
153      */
154     public static final String CALL_TYPE = "call_type";
155 
156     /**
157      * See {@link android.provider.CallLog.Calls#DATA_USAGE}.
158      *
159      * <p>Type: INTEGER (long)
160      */
161     public static final String DATA_USAGE = "data_usage";
162 
163     /**
164      * See {@link android.provider.CallLog.Calls#DURATION}.
165      *
166      * <p>TYPE: INTEGER (long)
167      */
168     public static final String DURATION = "duration";
169 
170     /**
171      * See {@link android.provider.CallLog.Calls#TRANSCRIPTION}.
172      *
173      * <p>TYPE: TEXT
174      */
175     public static final String TRANSCRIPTION = "transcription";
176 
177     /**
178      * See {@link VoicemailCompat#TRANSCRIPTION_STATE}
179      *
180      * <p>Only populated in {@link Build.VERSION_CODES#O} and above
181      *
182      * <p>TYPE: INTEGER
183      */
184     public static final String TRANSCRIPTION_STATE = "transcription_state";
185 
186     /**
187      * See {@link android.provider.CallLog.Calls#VOICEMAIL_URI}.
188      *
189      * <p>TYPE: TEXT
190      */
191     public static final String VOICEMAIL_URI = "voicemail_uri";
192 
193     /**
194      * An unique id to associate this call log row to a {@link android.telecom.Call}.
195      *
196      * <p>For pre-Q device, this is same as {@link #TIMESTAMP}.
197      *
198      * <p>For Q+ device, this will be copied from {@link android.provider.CallLog.Calls}.
199      *
200      * <p>Type: TEXT
201      */
202     public static final String CALL_MAPPING_ID = "call_mapping_id";
203   }
204 }
205