blob: 8ac185a939890d08b047e5d60ffadaf980cd8ae9 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 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
Debashish Chatterjee29c15752011-07-04 09:48:13 +010017
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018package android.provider;
19
Yorke Lee158c5e412014-07-16 15:31:25 -070020import android.content.ContentProvider;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.ContentResolver;
22import android.content.ContentValues;
23import android.content.Context;
Yorke Lee1854a602014-07-09 14:11:46 -070024import android.content.Intent;
Yorke Lee158c5e412014-07-16 15:31:25 -070025import android.content.pm.UserInfo;
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -080026import android.database.Cursor;
Shishir Agrawal1ae88e32014-10-27 12:28:52 -070027import android.location.Country;
28import android.location.CountryDetector;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.net.Uri;
Yorke Lee158c5e412014-07-16 15:31:25 -070030import android.os.UserHandle;
31import android.os.UserManager;
Daisuke Miyakawae23362a2012-05-06 16:54:25 -070032import android.provider.ContactsContract.CommonDataKinds.Callable;
Daisuke Miyakawaf4685912011-06-25 12:31:13 -070033import android.provider.ContactsContract.CommonDataKinds.Phone;
Shishir Agrawal1ae88e32014-10-27 12:28:52 -070034import android.provider.ContactsContract.Data;
Daisuke Miyakawaf4685912011-06-25 12:31:13 -070035import android.provider.ContactsContract.DataUsageFeedback;
Santos Cordon204f80e2015-02-11 22:57:14 -080036import android.telecom.PhoneAccount;
Tyler Gunnef9f6f92014-09-12 22:16:17 -070037import android.telecom.PhoneAccountHandle;
Santos Cordon204f80e2015-02-11 22:57:14 -080038import android.telecom.TelecomManager;
Shishir Agrawal1ae88e32014-10-27 12:28:52 -070039import android.telephony.PhoneNumberUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import android.text.TextUtils;
Makoto Onukib5247412016-01-12 12:57:25 -080041import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042
Chiao Cheng509e1f12012-08-01 15:40:55 -070043import com.android.internal.telephony.CallerInfo;
44import com.android.internal.telephony.PhoneConstants;
45
Yorke Lee158c5e412014-07-16 15:31:25 -070046import java.util.List;
47
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048/**
49 * The CallLog provider contains information about placed and received calls.
50 */
51public class CallLog {
Santos Cordonc66f3ba2015-02-27 15:22:07 -080052 private static final String LOG_TAG = "CallLog";
Makoto Onukib5247412016-01-12 12:57:25 -080053 private static final boolean VERBOSE_LOG = false; // DON'T SUBMIT WITH TRUE.
Santos Cordonc66f3ba2015-02-27 15:22:07 -080054
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 public static final String AUTHORITY = "call_log";
56
57 /**
58 * The content:// style URL for this provider
59 */
60 public static final Uri CONTENT_URI =
61 Uri.parse("content://" + AUTHORITY);
62
Makoto Onukib5247412016-01-12 12:57:25 -080063
64 /**
65 * The "shadow" provider stores calllog when the real calllog provider is encrypted. The
66 * real provider will alter copy from it when it starts, and remove the entries in the shadow.
67 *
68 * <p>See the comment in {@link Calls#addCall} for the details.
69 *
70 * @hide
71 */
72 public static final String SHADOW_AUTHORITY = "call_log_shadow";
73
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 /**
75 * Contains the recent calls.
76 */
77 public static class Calls implements BaseColumns {
78 /**
79 * The content:// style URL for this table
80 */
81 public static final Uri CONTENT_URI =
82 Uri.parse("content://call_log/calls");
83
Makoto Onukib5247412016-01-12 12:57:25 -080084 /** @hide */
85 public static final Uri SHADOW_CONTENT_URI =
86 Uri.parse("content://call_log_shadow/calls");
87
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 /**
89 * The content:// style URL for filtering this table on phone numbers
90 */
91 public static final Uri CONTENT_FILTER_URI =
92 Uri.parse("content://call_log/calls/filter");
93
94 /**
Chiao Cheng509e1f12012-08-01 15:40:55 -070095 * Query parameter used to limit the number of call logs returned.
96 * <p>
97 * TYPE: integer
98 */
99 public static final String LIMIT_PARAM_KEY = "limit";
100
101 /**
102 * Query parameter used to specify the starting record to return.
103 * <p>
104 * TYPE: integer
105 */
106 public static final String OFFSET_PARAM_KEY = "offset";
107
108 /**
Flavio Lerda9ef78f02011-06-29 10:51:59 +0100109 * An optional URI parameter which instructs the provider to allow the operation to be
110 * applied to voicemail records as well.
111 * <p>
112 * TYPE: Boolean
113 * <p>
114 * Using this parameter with a value of {@code true} will result in a security error if the
115 * calling package does not have appropriate permissions to access voicemails.
116 *
117 * @hide
118 */
119 public static final String ALLOW_VOICEMAILS_PARAM_KEY = "allow_voicemails";
120
121 /**
Yorke Lee1854a602014-07-09 14:11:46 -0700122 * An optional extra used with {@link #CONTENT_TYPE Calls.CONTENT_TYPE} and
123 * {@link Intent#ACTION_VIEW} to specify that the presented list of calls should be
124 * filtered for a particular call type.
125 *
126 * Applications implementing a call log UI should check for this extra, and display a
127 * filtered list of calls based on the specified call type. If not applicable within the
128 * application's UI, it should be silently ignored.
129 *
130 * <p>
131 * The following example brings up the call log, showing only missed calls.
132 * <pre>
133 * Intent intent = new Intent(Intent.ACTION_VIEW);
134 * intent.setType(CallLog.Calls.CONTENT_TYPE);
135 * intent.putExtra(CallLog.Calls.EXTRA_CALL_TYPE_FILTER, CallLog.Calls.MISSED_TYPE);
136 * startActivity(intent);
137 * </pre>
138 * </p>
139 */
Yorke Lee78814622014-09-04 16:07:50 -0700140 public static final String EXTRA_CALL_TYPE_FILTER =
141 "android.provider.extra.CALL_TYPE_FILTER";
Yorke Lee1854a602014-07-09 14:11:46 -0700142
143 /**
Yorke Lee0a173932013-12-12 17:29:03 -0800144 * Content uri used to access call log entries, including voicemail records. You must have
Yorke Lee624d0d62014-07-23 15:23:47 -0700145 * the READ_CALL_LOG and WRITE_CALL_LOG permissions to read and write to the call log, as
146 * well as READ_VOICEMAIL and WRITE_VOICEMAIL permissions to read and write voicemails.
Flavio Lerda9ef78f02011-06-29 10:51:59 +0100147 */
148 public static final Uri CONTENT_URI_WITH_VOICEMAIL = CONTENT_URI.buildUpon()
149 .appendQueryParameter(ALLOW_VOICEMAILS_PARAM_KEY, "true")
150 .build();
151
152 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153 * The default sort order for this table
154 */
155 public static final String DEFAULT_SORT_ORDER = "date DESC";
156
157 /**
158 * The MIME type of {@link #CONTENT_URI} and {@link #CONTENT_FILTER_URI}
159 * providing a directory of calls.
160 */
161 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/calls";
162
163 /**
164 * The MIME type of a {@link #CONTENT_URI} sub-directory of a single
165 * call.
166 */
167 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/calls";
168
169 /**
Yusuf T. Mobilef6737d32009-05-15 10:56:36 -0700170 * The type of the call (incoming, outgoing or missed).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800171 * <P>Type: INTEGER (int)</P>
Andrew Leef61b1fc2015-09-25 21:11:19 -0700172 *
173 * <p>
174 * Allowed values:
175 * <ul>
176 * <li>{@link #INCOMING_TYPE}</li>
177 * <li>{@link #OUTGOING_TYPE}</li>
178 * <li>{@link #MISSED_TYPE}</li>
179 * <li>{@link #VOICEMAIL_TYPE}</li>
180 * <li>{@link #REJECTED_TYPE}</li>
181 * <li>{@link #BLOCKED_TYPE}</li>
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700182 * <li>{@link #ANSWERED_EXTERNALLY_TYPE}</li>
Andrew Leef61b1fc2015-09-25 21:11:19 -0700183 * </ul>
184 * </p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800185 */
186 public static final String TYPE = "type";
187
Debashish Chatterjee412359f2011-06-06 17:35:59 +0100188 /** Call log type for incoming calls. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800189 public static final int INCOMING_TYPE = 1;
Debashish Chatterjee412359f2011-06-06 17:35:59 +0100190 /** Call log type for outgoing calls. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800191 public static final int OUTGOING_TYPE = 2;
Debashish Chatterjee412359f2011-06-06 17:35:59 +0100192 /** Call log type for missed calls. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 public static final int MISSED_TYPE = 3;
Yorke Leea5f6a932013-11-22 18:17:23 -0800194 /** Call log type for voicemails. */
Debashish Chatterjee412359f2011-06-06 17:35:59 +0100195 public static final int VOICEMAIL_TYPE = 4;
Andrew Leef61b1fc2015-09-25 21:11:19 -0700196 /** Call log type for calls rejected by direct user action. */
197 public static final int REJECTED_TYPE = 5;
198 /** Call log type for calls blocked automatically. */
199 public static final int BLOCKED_TYPE = 6;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700200 /**
201 * Call log type for a call which was answered on another device. Used in situations where
202 * a call rings on multiple devices simultaneously and it ended up being answered on a
203 * device other than the current one.
204 */
205 public static final int ANSWERED_EXTERNALLY_TYPE = 7;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800206
207 /**
Tyler Gunne5daf912014-07-08 15:22:55 -0700208 * Bit-mask describing features of the call (e.g. video).
209 *
210 * <P>Type: INTEGER (int)</P>
211 */
212 public static final String FEATURES = "features";
213
Tyler Gunne5daf912014-07-08 15:22:55 -0700214 /** Call had video. */
215 public static final int FEATURES_VIDEO = 0x1;
216
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700217 /** Call was pulled externally. */
218 public static final int FEATURES_PULLED_EXTERNALLY = 0x2;
219
Tyler Gunne5daf912014-07-08 15:22:55 -0700220 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800221 * The phone number as the user entered it.
222 * <P>Type: TEXT</P>
223 */
224 public static final String NUMBER = "number";
225
226 /**
Yorke Lee49e1cf92013-09-10 14:39:24 -0700227 * The number presenting rules set by the network.
228 *
229 * <p>
230 * Allowed values:
231 * <ul>
232 * <li>{@link #PRESENTATION_ALLOWED}</li>
233 * <li>{@link #PRESENTATION_RESTRICTED}</li>
234 * <li>{@link #PRESENTATION_UNKNOWN}</li>
235 * <li>{@link #PRESENTATION_PAYPHONE}</li>
236 * </ul>
237 * </p>
238 *
Jay Shraunerd88eb712013-06-10 10:10:11 -0700239 * <P>Type: INTEGER</P>
240 */
241 public static final String NUMBER_PRESENTATION = "presentation";
242
243 /** Number is allowed to display for caller id. */
244 public static final int PRESENTATION_ALLOWED = 1;
245 /** Number is blocked by user. */
246 public static final int PRESENTATION_RESTRICTED = 2;
247 /** Number is not specified or unknown by network. */
248 public static final int PRESENTATION_UNKNOWN = 3;
249 /** Number is a pay phone. */
250 public static final int PRESENTATION_PAYPHONE = 4;
251
252 /**
Bai Tao224744c2010-08-31 09:59:13 +0800253 * The ISO 3166-1 two letters country code of the country where the
254 * user received or made the call.
255 * <P>
256 * Type: TEXT
257 * </P>
Bai Tao224744c2010-08-31 09:59:13 +0800258 */
259 public static final String COUNTRY_ISO = "countryiso";
260
261 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 * The date the call occured, in milliseconds since the epoch
263 * <P>Type: INTEGER (long)</P>
264 */
265 public static final String DATE = "date";
266
267 /**
268 * The duration of the call in seconds
269 * <P>Type: INTEGER (long)</P>
270 */
271 public static final String DURATION = "duration";
272
273 /**
Tyler Gunne5daf912014-07-08 15:22:55 -0700274 * The data usage of the call in bytes.
275 * <P>Type: INTEGER (long)</P>
276 */
277 public static final String DATA_USAGE = "data_usage";
278
279 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 * Whether or not the call has been acknowledged
281 * <P>Type: INTEGER (boolean)</P>
282 */
283 public static final String NEW = "new";
284
285 /**
286 * The cached name associated with the phone number, if it exists.
287 * This value is not guaranteed to be current, if the contact information
288 * associated with this number has changed.
289 * <P>Type: TEXT</P>
290 */
291 public static final String CACHED_NAME = "name";
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800292
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 /**
294 * The cached number type (Home, Work, etc) associated with the
295 * phone number, if it exists.
296 * This value is not guaranteed to be current, if the contact information
297 * associated with this number has changed.
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800298 * <P>Type: INTEGER</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800299 */
300 public static final String CACHED_NUMBER_TYPE = "numbertype";
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800301
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800302 /**
303 * The cached number label, for a custom number type, associated with the
304 * phone number, if it exists.
305 * This value is not guaranteed to be current, if the contact information
306 * associated with this number has changed.
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800307 * <P>Type: TEXT</P>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800308 */
309 public static final String CACHED_NUMBER_LABEL = "numberlabel";
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800310
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311 /**
Debashish Chatterjee412359f2011-06-06 17:35:59 +0100312 * URI of the voicemail entry. Populated only for {@link #VOICEMAIL_TYPE}.
313 * <P>Type: TEXT</P>
Debashish Chatterjee412359f2011-06-06 17:35:59 +0100314 */
315 public static final String VOICEMAIL_URI = "voicemail_uri";
316
317 /**
Yorke Lee7a5e5722014-07-23 19:43:39 -0700318 * Transcription of the call or voicemail entry. This will only be populated for call log
319 * entries of type {@link #VOICEMAIL_TYPE} that have valid transcriptions.
320 */
321 public static final String TRANSCRIPTION = "transcription";
322
323 /**
Flavio Lerda651212d2011-07-21 16:53:59 +0100324 * Whether this item has been read or otherwise consumed by the user.
325 * <p>
326 * Unlike the {@link #NEW} field, which requires the user to have acknowledged the
327 * existence of the entry, this implies the user has interacted with the entry.
328 * <P>Type: INTEGER (boolean)</P>
Flavio Lerda651212d2011-07-21 16:53:59 +0100329 */
330 public static final String IS_READ = "is_read";
331
332 /**
Flavio Lerda270f9302011-08-09 12:01:13 +0100333 * A geocoded location for the number associated with this call.
334 * <p>
335 * The string represents a city, state, or country associated with the number.
336 * <P>Type: TEXT</P>
Flavio Lerda270f9302011-08-09 12:01:13 +0100337 */
338 public static final String GEOCODED_LOCATION = "geocoded_location";
339
340 /**
Flavio Lerda2d538d42011-08-16 08:29:06 +0100341 * The cached URI to look up the contact associated with the phone number, if it exists.
Yorke Leea5f6a932013-11-22 18:17:23 -0800342 * This value may not be current if the contact information associated with this number
343 * has changed.
Flavio Lerda2d538d42011-08-16 08:29:06 +0100344 * <P>Type: TEXT</P>
Flavio Lerda2d538d42011-08-16 08:29:06 +0100345 */
346 public static final String CACHED_LOOKUP_URI = "lookup_uri";
347
348 /**
349 * The cached phone number of the contact which matches this entry, if it exists.
Yorke Leea5f6a932013-11-22 18:17:23 -0800350 * This value may not be current if the contact information associated with this number
351 * has changed.
Flavio Lerda2d538d42011-08-16 08:29:06 +0100352 * <P>Type: TEXT</P>
Flavio Lerda2d538d42011-08-16 08:29:06 +0100353 */
354 public static final String CACHED_MATCHED_NUMBER = "matched_number";
355
356 /**
Yorke Leea5f6a932013-11-22 18:17:23 -0800357 * The cached normalized(E164) version of the phone number, if it exists.
358 * This value may not be current if the contact information associated with this number
359 * has changed.
Flavio Lerda2d538d42011-08-16 08:29:06 +0100360 * <P>Type: TEXT</P>
Flavio Lerda2d538d42011-08-16 08:29:06 +0100361 */
362 public static final String CACHED_NORMALIZED_NUMBER = "normalized_number";
363
364 /**
365 * The cached photo id of the picture associated with the phone number, if it exists.
Yorke Leea5f6a932013-11-22 18:17:23 -0800366 * This value may not be current if the contact information associated with this number
367 * has changed.
Flavio Lerda2d538d42011-08-16 08:29:06 +0100368 * <P>Type: INTEGER (long)</P>
Flavio Lerda2d538d42011-08-16 08:29:06 +0100369 */
370 public static final String CACHED_PHOTO_ID = "photo_id";
371
372 /**
Makoto Onukiedb84502015-03-09 13:57:02 -0700373 * The cached photo URI of the picture associated with the phone number, if it exists.
374 * This value may not be current if the contact information associated with this number
375 * has changed.
376 * <P>Type: TEXT (URI)</P>
377 */
378 public static final String CACHED_PHOTO_URI = "photo_uri";
379
380 /**
Yorke Leea5f6a932013-11-22 18:17:23 -0800381 * The cached phone number, formatted with formatting rules based on the country the
382 * user was in when the call was made or received.
383 * This value is not guaranteed to be present, and may not be current if the contact
384 * information associated with this number
385 * has changed.
Flavio Lerda0fce15b2011-10-01 18:55:33 +0100386 * <P>Type: TEXT</P>
Flavio Lerda0fce15b2011-10-01 18:55:33 +0100387 */
388 public static final String CACHED_FORMATTED_NUMBER = "formatted_number";
389
Ihab Awad9c3f1882014-06-30 21:17:13 -0700390 // Note: PHONE_ACCOUNT_* constant values are "subscription_*" due to a historic naming
391 // that was encoded into call log databases.
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700392
393 /**
Santos Cordon204f80e2015-02-11 22:57:14 -0800394 * The component name of the account used to place or receive the call; in string form.
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700395 * <P>Type: TEXT</P>
396 */
Ihab Awad9c3f1882014-06-30 21:17:13 -0700397 public static final String PHONE_ACCOUNT_COMPONENT_NAME = "subscription_component_name";
398
399 /**
Santos Cordon204f80e2015-02-11 22:57:14 -0800400 * The identifier for the account used to place or receive the call.
Ihab Awad9c3f1882014-06-30 21:17:13 -0700401 * <P>Type: TEXT</P>
402 */
403 public static final String PHONE_ACCOUNT_ID = "subscription_id";
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700404
405 /**
Santos Cordon204f80e2015-02-11 22:57:14 -0800406 * The address associated with the account used to place or receive the call; in string
407 * form. For SIM-based calls, this is the user's own phone number.
408 * <P>Type: TEXT</P>
409 *
410 * @hide
411 */
412 public static final String PHONE_ACCOUNT_ADDRESS = "phone_account_address";
413
414 /**
Santos Cordon2d2bc162015-02-27 15:22:07 -0800415 * Indicates that the entry will be hidden from all queries until the associated
416 * {@link android.telecom.PhoneAccount} is registered with the system.
417 * <P>Type: INTEGER</P>
418 *
419 * @hide
420 */
421 public static final String PHONE_ACCOUNT_HIDDEN = "phone_account_hidden";
422
423 /**
Santos Cordon204f80e2015-02-11 22:57:14 -0800424 * The subscription ID used to place this call. This is no longer used and has been
425 * replaced with PHONE_ACCOUNT_COMPONENT_NAME/PHONE_ACCOUNT_ID.
426 * For ContactsProvider internal use only.
Nancy Chen3a780922014-08-27 18:29:59 -0700427 * <P>Type: INTEGER</P>
428 *
Santos Cordon204f80e2015-02-11 22:57:14 -0800429 * @Deprecated
Nancy Chen3a780922014-08-27 18:29:59 -0700430 * @hide
431 */
432 public static final String SUB_ID = "sub_id";
433
434 /**
Hall Liu594c7912015-10-14 15:13:51 -0700435 * The post-dial portion of a dialed number, including any digits dialed after a
436 * {@link TelecomManager#DTMF_CHARACTER_PAUSE} or a {@link
437 * TelecomManager#DTMF_CHARACTER_WAIT} and these characters themselves.
438 * <P>Type: TEXT</P>
439 */
440 public static final String POST_DIAL_DIGITS = "post_dial_digits";
441
442 /**
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700443 * For an incoming call, the secondary line number the call was received via.
444 * When a SIM card has multiple phone numbers associated with it, the via number indicates
445 * which of the numbers associated with the SIM was called.
446 */
447 public static final String VIA_NUMBER = "via_number";
448
449 /**
Tony Makce759a12015-11-25 21:55:52 +0000450 * Indicates that the entry will be copied from primary user to other users.
451 * <P>Type: INTEGER</P>
452 *
453 * @hide
454 */
455 public static final String ADD_FOR_ALL_USERS = "add_for_all_users";
456
457 /**
Ta-wei Yena07707a2015-12-11 11:46:58 -0800458 * The date the row is last inserted, updated, or marked as deleted, in milliseconds
459 * since the epoch. Read only.
460 * <P>Type: INTEGER (long)</P>
461 */
462 public static final String LAST_MODIFIED = "last_modified";
463
464 /**
Yorke Lee3dbc1182014-08-21 09:37:22 -0700465 * If a successful call is made that is longer than this duration, update the phone number
466 * in the ContactsProvider with the normalized version of the number, based on the user's
467 * current country code.
468 */
469 private static final int MIN_DURATION_FOR_NORMALIZED_NUMBER_UPDATE_MS = 1000 * 10;
470
471 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800472 * Adds a call to the call log.
473 *
474 * @param ci the CallerInfo object to get the target contact from. Can be null
475 * if the contact is unknown.
476 * @param context the context used to get the ContentResolver
477 * @param number the phone number to be added to the calls db
Jay Shraunerd88eb712013-06-10 10:10:11 -0700478 * @param presentation enum value from PhoneConstants.PRESENTATION_xxx, which
479 * is set by the network and denotes the number presenting rules for
The Android Open Source Project10592532009-03-18 17:39:46 -0700480 * "allowed", "payphone", "restricted" or "unknown"
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800481 * @param callType enumerated values for "incoming", "outgoing", or "missed"
Tyler Gunne5daf912014-07-08 15:22:55 -0700482 * @param features features of the call (e.g. Video).
Evan Charlton8c8a0622014-07-20 12:31:00 -0700483 * @param accountHandle The accountHandle object identifying the provider of the call
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800484 * @param start time stamp for the call in milliseconds
485 * @param duration call duration in seconds
Tyler Gunne5daf912014-07-08 15:22:55 -0700486 * @param dataUsage data usage for the call in bytes, null if data usage was not tracked for
487 * the call.
Yorke Lee158c5e412014-07-16 15:31:25 -0700488 * @result The URI of the call log entry belonging to the user that made or received this
489 * call.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490 * {@hide}
491 */
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800492 public static Uri addCall(CallerInfo ci, Context context, String number,
Evan Charlton8c8a0622014-07-20 12:31:00 -0700493 int presentation, int callType, int features, PhoneAccountHandle accountHandle,
Evan Charlton6eb262c2014-07-19 18:18:19 -0700494 long start, int duration, Long dataUsage) {
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700495 return addCall(ci, context, number, /* postDialDigits =*/ "", /* viaNumber =*/ "",
496 presentation, callType, features, accountHandle, start, duration,
497 dataUsage, /* addForAllUsers =*/ false, /* userToBeInsertedTo =*/ null,
498 /* is_read =*/ false);
Yorke Lee158c5e412014-07-16 15:31:25 -0700499 }
500
Wink Saville05e6dde2014-08-31 19:24:10 -0700501
Yorke Lee158c5e412014-07-16 15:31:25 -0700502 /**
503 * Adds a call to the call log.
504 *
505 * @param ci the CallerInfo object to get the target contact from. Can be null
506 * if the contact is unknown.
507 * @param context the context used to get the ContentResolver
508 * @param number the phone number to be added to the calls db
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700509 * @param viaNumber the secondary number that the incoming call received with. If the
510 * call was received with the SIM assigned number, then this field must be ''.
Yorke Lee158c5e412014-07-16 15:31:25 -0700511 * @param presentation enum value from PhoneConstants.PRESENTATION_xxx, which
512 * is set by the network and denotes the number presenting rules for
513 * "allowed", "payphone", "restricted" or "unknown"
514 * @param callType enumerated values for "incoming", "outgoing", or "missed"
515 * @param features features of the call (e.g. Video).
516 * @param accountHandle The accountHandle object identifying the provider of the call
517 * @param start time stamp for the call in milliseconds
518 * @param duration call duration in seconds
519 * @param dataUsage data usage for the call in bytes, null if data usage was not tracked for
520 * the call.
521 * @param addForAllUsers If true, the call is added to the call log of all currently
522 * running users. The caller must have the MANAGE_USERS permission if this is true.
Tony Makce759a12015-11-25 21:55:52 +0000523 * @param userToBeInsertedTo {@link UserHandle} of user that the call is going to be
524 * inserted to. null if it is inserted to the current user. The
525 * value is ignored if @{link addForAllUsers} is true.
Yorke Lee158c5e412014-07-16 15:31:25 -0700526 * @result The URI of the call log entry belonging to the user that made or received this
527 * call.
528 * {@hide}
529 */
530 public static Uri addCall(CallerInfo ci, Context context, String number,
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700531 String postDialDigits, String viaNumber, int presentation, int callType,
532 int features, PhoneAccountHandle accountHandle, long start, int duration,
533 Long dataUsage, boolean addForAllUsers, UserHandle userToBeInsertedTo) {
534 return addCall(ci, context, number, postDialDigits, viaNumber, presentation, callType,
535 features, accountHandle, start, duration, dataUsage, addForAllUsers,
536 userToBeInsertedTo, /* is_read =*/ false);
Roshan Pius78b8d4a2015-08-04 13:23:03 -0700537 }
538
539 /**
540 * Adds a call to the call log.
541 *
542 * @param ci the CallerInfo object to get the target contact from. Can be null
543 * if the contact is unknown.
544 * @param context the context used to get the ContentResolver
545 * @param number the phone number to be added to the calls db
Hall Liu594c7912015-10-14 15:13:51 -0700546 * @param postDialDigits the post-dial digits that were dialed after the number,
547 * if it was outgoing. Otherwise it is ''.
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700548 * @param viaNumber the secondary number that the incoming call received with. If the
549 * call was received with the SIM assigned number, then this field must be ''.
Roshan Pius78b8d4a2015-08-04 13:23:03 -0700550 * @param presentation enum value from PhoneConstants.PRESENTATION_xxx, which
551 * is set by the network and denotes the number presenting rules for
552 * "allowed", "payphone", "restricted" or "unknown"
553 * @param callType enumerated values for "incoming", "outgoing", or "missed"
554 * @param features features of the call (e.g. Video).
555 * @param accountHandle The accountHandle object identifying the provider of the call
556 * @param start time stamp for the call in milliseconds
557 * @param duration call duration in seconds
558 * @param dataUsage data usage for the call in bytes, null if data usage was not tracked for
559 * the call.
560 * @param addForAllUsers If true, the call is added to the call log of all currently
561 * running users. The caller must have the MANAGE_USERS permission if this is true.
Tony Makce759a12015-11-25 21:55:52 +0000562 * @param userToBeInsertedTo {@link UserHandle} of user that the call is going to be
563 * inserted to. null if it is inserted to the current user. The
564 * value is ignored if @{link addForAllUsers} is true.
Roshan Pius78b8d4a2015-08-04 13:23:03 -0700565 * @param is_read Flag to show if the missed call log has been read by the user or not.
566 * Used for call log restore of missed calls.
567 *
568 * @result The URI of the call log entry belonging to the user that made or received this
Makoto Onukib5247412016-01-12 12:57:25 -0800569 * call. This could be of the shadow provider. Do not return it to non-system apps,
570 * as they don't have permissions.
Roshan Pius78b8d4a2015-08-04 13:23:03 -0700571 * {@hide}
572 */
573 public static Uri addCall(CallerInfo ci, Context context, String number,
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700574 String postDialDigits, String viaNumber, int presentation, int callType,
575 int features, PhoneAccountHandle accountHandle, long start, int duration,
576 Long dataUsage, boolean addForAllUsers, UserHandle userToBeInsertedTo,
577 boolean is_read) {
Makoto Onukib5247412016-01-12 12:57:25 -0800578 if (VERBOSE_LOG) {
579 Log.v(LOG_TAG, String.format("Add call: number=%s, user=%s, for all=%s",
580 number, userToBeInsertedTo, addForAllUsers));
581 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800582 final ContentResolver resolver = context.getContentResolver();
Jay Shraunerd88eb712013-06-10 10:10:11 -0700583 int numberPresentation = PRESENTATION_ALLOWED;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800584
Santos Cordon204f80e2015-02-11 22:57:14 -0800585 TelecomManager tm = null;
586 try {
587 tm = TelecomManager.from(context);
588 } catch (UnsupportedOperationException e) {}
589
590 String accountAddress = null;
591 if (tm != null && accountHandle != null) {
592 PhoneAccount account = tm.getPhoneAccount(accountHandle);
593 if (account != null) {
Santos Cordon2d2bc162015-02-27 15:22:07 -0800594 Uri address = account.getSubscriptionAddress();
595 if (address != null) {
596 accountAddress = address.getSchemeSpecificPart();
597 }
Santos Cordon204f80e2015-02-11 22:57:14 -0800598 }
599 }
600
Jay Shraunerd88eb712013-06-10 10:10:11 -0700601 // Remap network specified number presentation types
602 // PhoneConstants.PRESENTATION_xxx to calllog number presentation types
603 // Calls.PRESENTATION_xxx, in order to insulate the persistent calllog
604 // from any future radio changes.
605 // If the number field is empty set the presentation type to Unknown.
Wink Savillea639b312012-07-10 12:37:54 -0700606 if (presentation == PhoneConstants.PRESENTATION_RESTRICTED) {
Jay Shraunerd88eb712013-06-10 10:10:11 -0700607 numberPresentation = PRESENTATION_RESTRICTED;
Wink Savillea639b312012-07-10 12:37:54 -0700608 } else if (presentation == PhoneConstants.PRESENTATION_PAYPHONE) {
Jay Shraunerd88eb712013-06-10 10:10:11 -0700609 numberPresentation = PRESENTATION_PAYPHONE;
Pauyl l Bermane1dc2ba2009-07-10 18:27:36 -0400610 } else if (TextUtils.isEmpty(number)
Wink Savillea639b312012-07-10 12:37:54 -0700611 || presentation == PhoneConstants.PRESENTATION_UNKNOWN) {
Jay Shraunerd88eb712013-06-10 10:10:11 -0700612 numberPresentation = PRESENTATION_UNKNOWN;
613 }
614 if (numberPresentation != PRESENTATION_ALLOWED) {
615 number = "";
616 if (ci != null) {
617 ci.name = "";
618 }
Wink Savilledda53912009-05-28 17:32:34 -0700619 }
Pauyl l Bermane1dc2ba2009-07-10 18:27:36 -0400620
Evan Charlton8c8a0622014-07-20 12:31:00 -0700621 // accountHandle information
Ihab Awad9c3f1882014-06-30 21:17:13 -0700622 String accountComponentString = null;
623 String accountId = null;
Evan Charlton8c8a0622014-07-20 12:31:00 -0700624 if (accountHandle != null) {
625 accountComponentString = accountHandle.getComponentName().flattenToString();
626 accountId = accountHandle.getId();
Nancy Chen5ffbfcc2014-06-25 14:22:55 -0700627 }
628
Jay Shraunerd88eb712013-06-10 10:10:11 -0700629 ContentValues values = new ContentValues(6);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800630
631 values.put(NUMBER, number);
Hall Liu594c7912015-10-14 15:13:51 -0700632 values.put(POST_DIAL_DIGITS, postDialDigits);
Brad Ebingerb3e934b2016-03-21 15:00:54 -0700633 values.put(VIA_NUMBER, viaNumber);
Jay Shraunerd88eb712013-06-10 10:10:11 -0700634 values.put(NUMBER_PRESENTATION, Integer.valueOf(numberPresentation));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800635 values.put(TYPE, Integer.valueOf(callType));
Tyler Gunne5daf912014-07-08 15:22:55 -0700636 values.put(FEATURES, features);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800637 values.put(DATE, Long.valueOf(start));
638 values.put(DURATION, Long.valueOf(duration));
Tyler Gunne5daf912014-07-08 15:22:55 -0700639 if (dataUsage != null) {
640 values.put(DATA_USAGE, dataUsage);
641 }
Ihab Awad9c3f1882014-06-30 21:17:13 -0700642 values.put(PHONE_ACCOUNT_COMPONENT_NAME, accountComponentString);
643 values.put(PHONE_ACCOUNT_ID, accountId);
Santos Cordon204f80e2015-02-11 22:57:14 -0800644 values.put(PHONE_ACCOUNT_ADDRESS, accountAddress);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800645 values.put(NEW, Integer.valueOf(1));
Tony Makce759a12015-11-25 21:55:52 +0000646 values.put(ADD_FOR_ALL_USERS, addForAllUsers ? 1 : 0);
Wink Saville05e6dde2014-08-31 19:24:10 -0700647
Debashish Chatterjee4efaf4b2011-08-11 16:47:16 +0100648 if (callType == MISSED_TYPE) {
Roshan Pius78b8d4a2015-08-04 13:23:03 -0700649 values.put(IS_READ, Integer.valueOf(is_read ? 1 : 0));
Debashish Chatterjee4efaf4b2011-08-11 16:47:16 +0100650 }
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800651
Makoto Onukia2295e62014-07-10 15:32:16 -0700652 if ((ci != null) && (ci.contactIdOrZero > 0)) {
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700653 // Update usage information for the number associated with the contact ID.
654 // We need to use both the number and the ID for obtaining a data ID since other
655 // contacts may have the same number.
656
657 final Cursor cursor;
658
659 // We should prefer normalized one (probably coming from
660 // Phone.NORMALIZED_NUMBER column) first. If it isn't available try others.
661 if (ci.normalizedNumber != null) {
662 final String normalizedPhoneNumber = ci.normalizedNumber;
663 cursor = resolver.query(Phone.CONTENT_URI,
664 new String[] { Phone._ID },
665 Phone.CONTACT_ID + " =? AND " + Phone.NORMALIZED_NUMBER + " =?",
Makoto Onukia2295e62014-07-10 15:32:16 -0700666 new String[] { String.valueOf(ci.contactIdOrZero),
667 normalizedPhoneNumber},
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700668 null);
669 } else {
670 final String phoneNumber = ci.phoneNumber != null ? ci.phoneNumber : number;
Daisuke Miyakawae23362a2012-05-06 16:54:25 -0700671 cursor = resolver.query(
672 Uri.withAppendedPath(Callable.CONTENT_FILTER_URI,
673 Uri.encode(phoneNumber)),
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700674 new String[] { Phone._ID },
Daisuke Miyakawae23362a2012-05-06 16:54:25 -0700675 Phone.CONTACT_ID + " =?",
Makoto Onukia2295e62014-07-10 15:32:16 -0700676 new String[] { String.valueOf(ci.contactIdOrZero) },
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700677 null);
678 }
679
680 if (cursor != null) {
681 try {
682 if (cursor.getCount() > 0 && cursor.moveToFirst()) {
Shishir Agrawal1ae88e32014-10-27 12:28:52 -0700683 final String dataId = cursor.getString(0);
684 updateDataUsageStatForData(resolver, dataId);
685 if (duration >= MIN_DURATION_FOR_NORMALIZED_NUMBER_UPDATE_MS
686 && callType == Calls.OUTGOING_TYPE
687 && TextUtils.isEmpty(ci.normalizedNumber)) {
688 updateNormalizedNumber(context, resolver, dataId, number);
689 }
Daisuke Miyakawaf4685912011-06-25 12:31:13 -0700690 }
691 } finally {
692 cursor.close();
693 }
694 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800695 }
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800696
Makoto Onukib5247412016-01-12 12:57:25 -0800697 /*
698 Writing the calllog works in the following way:
699 - All user entries
700 - if user-0 is encrypted, insert to user-0's shadow only.
701 (other users should also be encrypted, so nothing to do for other users.)
702 - if user-0 is decrypted, insert to user-0's real provider, as well as
703 all other users that are running and decrypted and should have calllog.
704
705 - Single user entry.
706 - If the target user is encryted, insert to its shadow.
707 - Otherwise insert to its real provider.
708
709 When the (real) calllog provider starts, it copies entries that it missed from
710 elsewhere.
711 - When user-0's (real) provider starts, it copies from user-0's shadow, and clears
712 the shadow.
713
714 - When other users (real) providers start, unless it shouldn't have calllog entries,
715 - Copy from the user's shadow, and clears the shadow.
716 - Copy from user-0's entries that are FOR_ALL_USERS = 1. (and don't clear it.)
717 */
718
Yorke Lee158c5e412014-07-16 15:31:25 -0700719 Uri result = null;
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800720
Makoto Onukib5247412016-01-12 12:57:25 -0800721 final UserManager userManager = context.getSystemService(UserManager.class);
722 final int currentUserId = userManager.getUserHandle();
723
Yorke Lee158c5e412014-07-16 15:31:25 -0700724 if (addForAllUsers) {
Makoto Onukib5247412016-01-12 12:57:25 -0800725 // First, insert to the system user.
726 final Uri uriForSystem = addEntryAndRemoveExpiredEntries(
727 context, userManager, UserHandle.SYSTEM, values);
728 if (uriForSystem == null
729 || SHADOW_AUTHORITY.equals(uriForSystem.getAuthority())) {
730 // This means the system user is still encrypted and the entry has inserted
731 // into the shadow. This means other users are still all encrypted.
732 // Nothing further to do; just return null.
733 return null;
734 }
735 if (UserHandle.USER_SYSTEM == currentUserId) {
736 result = uriForSystem;
737 }
738
739 // Otherwise, insert to all other users that are running and unlocked.
740
741 final List<UserInfo> users = userManager.getUsers(true);
742
Yorke Lee158c5e412014-07-16 15:31:25 -0700743 final int count = users.size();
744 for (int i = 0; i < count; i++) {
Makoto Onukib5247412016-01-12 12:57:25 -0800745 final UserInfo userInfo = users.get(i);
746 final UserHandle userHandle = userInfo.getUserHandle();
747 final int userId = userHandle.getIdentifier();
748
749 if (userHandle.isSystem()) {
750 // Already written.
751 continue;
752 }
753
754 if (!shouldHaveSharedCallLogEntries(context, userManager, userId)) {
755 // Shouldn't have calllog entries.
756 continue;
757 }
758
759 // For other users, we write only when they're running *and* decrypted.
760 // Other providers will copy from the system user's real provider, when they
761 // start.
Yorke Leea79e2be2014-08-10 13:52:21 -0700762 if (userManager.isUserRunning(userHandle)
Makoto Onukib5247412016-01-12 12:57:25 -0800763 && userManager.isUserUnlocked(userHandle)) {
764 final Uri uri = addEntryAndRemoveExpiredEntries(context, userManager,
765 userHandle, values);
766 if (userId == currentUserId) {
Yorke Lee158c5e412014-07-16 15:31:25 -0700767 result = uri;
768 }
769 }
770 }
771 } else {
Makoto Onukib5247412016-01-12 12:57:25 -0800772 // Single-user entry. Just write to that user, assuming it's running. If the
773 // user is encrypted, we write to the shadow calllog.
774
775 final UserHandle targetUserHandle = userToBeInsertedTo != null
776 ? userToBeInsertedTo
777 : UserHandle.of(currentUserId);
778 result = addEntryAndRemoveExpiredEntries(context, userManager, targetUserHandle,
779 values);
Yorke Lee158c5e412014-07-16 15:31:25 -0700780 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800781 return result;
782 }
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800783
Makoto Onukib5247412016-01-12 12:57:25 -0800784 /** @hide */
785 public static boolean shouldHaveSharedCallLogEntries(Context context,
786 UserManager userManager, int userId) {
787 if (userManager.hasUserRestriction(UserManager.DISALLOW_OUTGOING_CALLS,
788 UserHandle.of(userId))) {
789 return false;
790 }
791 final UserInfo userInfo = userManager.getUserInfo(userId);
792 return userInfo != null && !userInfo.isManagedProfile();
793 }
794
Nicolas Cataniab8a2aaf2010-01-14 10:44:02 -0800795 /**
796 * Query the call log database for the last dialed number.
797 * @param context Used to get the content resolver.
798 * @return The last phone number dialed (outgoing) or an empty
799 * string if none exist yet.
800 */
801 public static String getLastOutgoingCall(Context context) {
802 final ContentResolver resolver = context.getContentResolver();
803 Cursor c = null;
804 try {
805 c = resolver.query(
806 CONTENT_URI,
807 new String[] {NUMBER},
808 TYPE + " = " + OUTGOING_TYPE,
809 null,
810 DEFAULT_SORT_ORDER + " LIMIT 1");
811 if (c == null || !c.moveToFirst()) {
812 return "";
813 }
814 return c.getString(0);
815 } finally {
816 if (c != null) c.close();
817 }
818 }
819
Makoto Onukib5247412016-01-12 12:57:25 -0800820 private static Uri addEntryAndRemoveExpiredEntries(Context context, UserManager userManager,
821 UserHandle user, ContentValues values) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800822 final ContentResolver resolver = context.getContentResolver();
Makoto Onukib5247412016-01-12 12:57:25 -0800823
824 final Uri uri = ContentProvider.maybeAddUserId(
825 userManager.isUserUnlocked(user) ? CONTENT_URI : SHADOW_CONTENT_URI,
826 user.getIdentifier());
827
828 if (VERBOSE_LOG) {
829 Log.v(LOG_TAG, String.format("Inserting to %s", uri));
830 }
831
832 try {
833 final Uri result = resolver.insert(uri, values);
834 resolver.delete(uri, "_id IN " +
835 "(SELECT _id FROM calls ORDER BY " + DEFAULT_SORT_ORDER
836 + " LIMIT -1 OFFSET 500)", null);
837 return result;
838 } catch (IllegalArgumentException e) {
839 Log.w(LOG_TAG, "Failed to insert calllog", e);
840 // Even though we make sure the target user is running and decrypted before calling
841 // this method, there's a chance that the user just got shut down, in which case
842 // we'll still get "IllegalArgumentException: Unknown URL content://call_log/calls".
843 return null;
844 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800845 }
Shishir Agrawal1ae88e32014-10-27 12:28:52 -0700846
847 private static void updateDataUsageStatForData(ContentResolver resolver, String dataId) {
848 final Uri feedbackUri = DataUsageFeedback.FEEDBACK_URI.buildUpon()
849 .appendPath(dataId)
850 .appendQueryParameter(DataUsageFeedback.USAGE_TYPE,
851 DataUsageFeedback.USAGE_TYPE_CALL)
852 .build();
853 resolver.update(feedbackUri, new ContentValues(), null, null);
854 }
855
856 /*
857 * Update the normalized phone number for the given dataId in the ContactsProvider, based
858 * on the user's current country.
859 */
860 private static void updateNormalizedNumber(Context context, ContentResolver resolver,
861 String dataId, String number) {
862 if (TextUtils.isEmpty(number) || TextUtils.isEmpty(dataId)) {
863 return;
864 }
865 final String countryIso = getCurrentCountryIso(context);
866 if (TextUtils.isEmpty(countryIso)) {
867 return;
868 }
869 final String normalizedNumber = PhoneNumberUtils.formatNumberToE164(number,
870 getCurrentCountryIso(context));
871 if (TextUtils.isEmpty(normalizedNumber)) {
872 return;
873 }
874 final ContentValues values = new ContentValues();
875 values.put(Phone.NORMALIZED_NUMBER, normalizedNumber);
876 resolver.update(Data.CONTENT_URI, values, Data._ID + "=?", new String[] {dataId});
877 }
878
879 private static String getCurrentCountryIso(Context context) {
880 String countryIso = null;
881 final CountryDetector detector = (CountryDetector) context.getSystemService(
882 Context.COUNTRY_DETECTOR);
883 if (detector != null) {
884 final Country country = detector.detectCountry();
885 if (country != null) {
886 countryIso = country.getCountryIso();
887 }
888 }
889 return countryIso;
890 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800891 }
892}