blob: 6f8d1921e5ca0581939e7e59fc063389bc838b58 [file] [log] [blame]
Eric Erfanianccca3152017-02-22 16:32:36 -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
17package com.android.incallui;
18
19import android.content.Context;
20import android.database.Cursor;
21import android.graphics.Bitmap;
22import android.graphics.drawable.Drawable;
23import android.net.Uri;
24import android.os.Build.VERSION;
25import android.os.Build.VERSION_CODES;
26import android.provider.ContactsContract;
27import android.provider.ContactsContract.CommonDataKinds.Phone;
28import android.provider.ContactsContract.Contacts;
29import android.provider.ContactsContract.Data;
30import android.provider.ContactsContract.PhoneLookup;
31import android.provider.ContactsContract.RawContacts;
32import android.support.annotation.RequiresApi;
33import android.telephony.PhoneNumberUtils;
34import android.text.TextUtils;
35import com.android.contacts.common.ContactsUtils;
36import com.android.contacts.common.ContactsUtils.UserType;
37import com.android.contacts.common.util.TelephonyManagerUtils;
38import com.android.dialer.phonenumbercache.ContactInfoHelper;
39import com.android.dialer.phonenumbercache.PhoneLookupUtil;
40import com.android.dialer.phonenumberutil.PhoneNumberHelper;
41
42/**
43 * Looks up caller information for the given phone number. This is intermediate data and should NOT
44 * be used by any UI.
45 */
46public class CallerInfo {
47
48 private static final String TAG = "CallerInfo";
49
50 // We should always use this projection starting from N onward.
51 @RequiresApi(VERSION_CODES.N)
52 private static final String[] DEFAULT_PHONELOOKUP_PROJECTION =
53 new String[] {
54 PhoneLookup.CONTACT_ID,
55 PhoneLookup.DISPLAY_NAME,
56 PhoneLookup.LOOKUP_KEY,
57 PhoneLookup.NUMBER,
58 PhoneLookup.NORMALIZED_NUMBER,
59 PhoneLookup.LABEL,
60 PhoneLookup.TYPE,
61 PhoneLookup.PHOTO_URI,
62 PhoneLookup.CUSTOM_RINGTONE,
63 PhoneLookup.SEND_TO_VOICEMAIL
64 };
65
66 // In pre-N, contact id is stored in {@link PhoneLookup._ID} in non-sip query.
67 private static final String[] BACKWARD_COMPATIBLE_NON_SIP_DEFAULT_PHONELOOKUP_PROJECTION =
68 new String[] {
69 PhoneLookup._ID,
70 PhoneLookup.DISPLAY_NAME,
71 PhoneLookup.LOOKUP_KEY,
72 PhoneLookup.NUMBER,
73 PhoneLookup.NORMALIZED_NUMBER,
74 PhoneLookup.LABEL,
75 PhoneLookup.TYPE,
76 PhoneLookup.PHOTO_URI,
77 PhoneLookup.CUSTOM_RINGTONE,
78 PhoneLookup.SEND_TO_VOICEMAIL
79 };
80 /**
81 * Please note that, any one of these member variables can be null, and any accesses to them
82 * should be prepared to handle such a case.
83 *
84 * <p>Also, it is implied that phoneNumber is more often populated than name is, (think of calls
85 * being dialed/received using numbers where names are not known to the device), so phoneNumber
86 * should serve as a dependable fallback when name is unavailable.
87 *
88 * <p>One other detail here is that this CallerInfo object reflects information found on a
89 * connection, it is an OUTPUT that serves mainly to display information to the user. In no way is
90 * this object used as input to make a connection, so we can choose to display whatever
91 * human-readable text makes sense to the user for a connection. This is especially relevant for
92 * the phone number field, since it is the one field that is most likely exposed to the user.
93 *
94 * <p>As an example: 1. User dials "911" 2. Device recognizes that this is an emergency number 3.
95 * We use the "Emergency Number" string instead of "911" in the phoneNumber field.
96 *
97 * <p>What we're really doing here is treating phoneNumber as an essential field here, NOT name.
98 * We're NOT always guaranteed to have a name for a connection, but the number should be
99 * displayable.
100 */
101 public String name;
102
103 public String nameAlternative;
104 public String phoneNumber;
105 public String normalizedNumber;
106 public String forwardingNumber;
107 public String geoDescription;
Eric Erfaniand8046e52017-04-06 09:41:50 -0700108 boolean shouldShowGeoDescription;
Eric Erfanianccca3152017-02-22 16:32:36 -0800109 public String cnapName;
110 public int numberPresentation;
111 public int namePresentation;
112 public boolean contactExists;
113 public String phoneLabel;
114 /* Split up the phoneLabel into number type and label name */
115 public int numberType;
116 public String numberLabel;
117 public int photoResource;
118 // Contact ID, which will be 0 if a contact comes from the corp CP2.
119 public long contactIdOrZero;
120 public String lookupKeyOrNull;
121 public boolean needUpdate;
122 public Uri contactRefUri;
123 public @UserType long userType;
124 /**
125 * Contact display photo URI. If a contact has no display photo but a thumbnail, it'll be the
126 * thumbnail URI instead.
127 */
128 public Uri contactDisplayPhotoUri;
129 // fields to hold individual contact preference data,
130 // including the send to voicemail flag and the ringtone
131 // uri reference.
132 public Uri contactRingtoneUri;
133 public boolean shouldSendToVoicemail;
134 /**
135 * Drawable representing the caller image. This is essentially a cache for the image data tied
136 * into the connection / callerinfo object.
137 *
138 * <p>This might be a high resolution picture which is more suitable for full-screen image view
139 * than for smaller icons used in some kinds of notifications.
140 *
141 * <p>The {@link #isCachedPhotoCurrent} flag indicates if the image data needs to be reloaded.
142 */
143 public Drawable cachedPhoto;
144 /**
145 * Bitmap representing the caller image which has possibly lower resolution than {@link
146 * #cachedPhoto} and thus more suitable for icons (like notification icons).
147 *
148 * <p>In usual cases this is just down-scaled image of {@link #cachedPhoto}. If the down-scaling
149 * fails, this will just become null.
150 *
151 * <p>The {@link #isCachedPhotoCurrent} flag indicates if the image data needs to be reloaded.
152 */
153 public Bitmap cachedPhotoIcon;
154 /**
155 * Boolean which indicates if {@link #cachedPhoto} and {@link #cachedPhotoIcon} is fresh enough.
156 * If it is false, those images aren't pointing to valid objects.
157 */
158 public boolean isCachedPhotoCurrent;
159 /**
160 * String which holds the call subject sent as extra from the lower layers for this call. This is
161 * used to display the no-caller ID reason for restricted/unknown number presentation.
162 */
163 public String callSubject;
164
wangqi1420a222017-09-21 09:37:40 -0700165 public String countryIso;
166
Eric Erfanianccca3152017-02-22 16:32:36 -0800167 private boolean mIsEmergency;
168 private boolean mIsVoiceMail;
169
170 public CallerInfo() {
171 // TODO: Move all the basic initialization here?
172 mIsEmergency = false;
173 mIsVoiceMail = false;
174 userType = ContactsUtils.USER_TYPE_CURRENT;
175 }
176
177 public static String[] getDefaultPhoneLookupProjection(Uri phoneLookupUri) {
178 if (VERSION.SDK_INT >= VERSION_CODES.N) {
179 return DEFAULT_PHONELOOKUP_PROJECTION;
180 }
181 // Pre-N
182 boolean isSip =
183 phoneLookupUri.getBooleanQueryParameter(
184 ContactsContract.PhoneLookup.QUERY_PARAMETER_SIP_ADDRESS, false);
185 return (isSip)
186 ? DEFAULT_PHONELOOKUP_PROJECTION
187 : BACKWARD_COMPATIBLE_NON_SIP_DEFAULT_PHONELOOKUP_PROJECTION;
188 }
189
190 /**
191 * getCallerInfo given a Cursor.
192 *
193 * @param context the context used to retrieve string constants
194 * @param contactRef the URI to attach to this CallerInfo object
linyuhbdef88b2017-12-12 14:30:08 -0800195 * @param cursor the first object in the cursor is used to build the CallerInfo object.
Eric Erfanianccca3152017-02-22 16:32:36 -0800196 * @return the CallerInfo which contains the caller id for the given number. The returned
197 * CallerInfo is null if no number is supplied.
198 */
199 public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) {
200 CallerInfo info = new CallerInfo();
linyuh6f78d932017-10-17 13:31:27 -0700201 info.photoResource = 0;
linyuhbdef88b2017-12-12 14:30:08 -0800202 info.phoneLabel = null;
203 info.numberType = 0;
204 info.numberLabel = null;
205 info.cachedPhoto = null;
206 info.isCachedPhotoCurrent = false;
207 info.contactExists = false;
Eric Erfanianccca3152017-02-22 16:32:36 -0800208 info.userType = ContactsUtils.USER_TYPE_CURRENT;
209
210 Log.v(TAG, "getCallerInfo() based on cursor...");
211
linyuhbdef88b2017-12-12 14:30:08 -0800212 if (cursor != null) {
213 if (cursor.moveToFirst()) {
214 // TODO: photo_id is always available but not taken
215 // care of here. Maybe we should store it in the
216 // CallerInfo object as well.
Eric Erfanianccca3152017-02-22 16:32:36 -0800217
linyuhbdef88b2017-12-12 14:30:08 -0800218 long contactId = 0L;
219 int columnIndex;
linyuh6f78d932017-10-17 13:31:27 -0700220
linyuhbdef88b2017-12-12 14:30:08 -0800221 // Look for the name
222 columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
223 if (columnIndex != -1) {
224 info.name = cursor.getString(columnIndex);
225 }
linyuh6f78d932017-10-17 13:31:27 -0700226
linyuhbdef88b2017-12-12 14:30:08 -0800227 // Look for the number
228 columnIndex = cursor.getColumnIndex(PhoneLookup.NUMBER);
229 if (columnIndex != -1) {
230 info.phoneNumber = cursor.getString(columnIndex);
231 }
232
233 // Look for the normalized number
234 columnIndex = cursor.getColumnIndex(PhoneLookup.NORMALIZED_NUMBER);
235 if (columnIndex != -1) {
236 info.normalizedNumber = cursor.getString(columnIndex);
237 }
238
239 // Look for the label/type combo
240 columnIndex = cursor.getColumnIndex(PhoneLookup.LABEL);
241 if (columnIndex != -1) {
242 int typeColumnIndex = cursor.getColumnIndex(PhoneLookup.TYPE);
243 if (typeColumnIndex != -1) {
244 info.numberType = cursor.getInt(typeColumnIndex);
245 info.numberLabel = cursor.getString(columnIndex);
246 info.phoneLabel =
247 Phone.getTypeLabel(context.getResources(), info.numberType, info.numberLabel)
248 .toString();
249 }
250 }
251
252 // cache the lookup key for later use to create lookup URIs
253 columnIndex = cursor.getColumnIndex(PhoneLookup.LOOKUP_KEY);
254 if (columnIndex != -1) {
255 info.lookupKeyOrNull = cursor.getString(columnIndex);
256 }
257
258 // Look for the person_id.
259 columnIndex = getColumnIndexForPersonId(contactRef, cursor);
260 if (columnIndex != -1) {
261 contactId = cursor.getLong(columnIndex);
262 // QuickContacts in M doesn't support enterprise contact id
263 if (contactId != 0
264 && (VERSION.SDK_INT >= VERSION_CODES.N
265 || !Contacts.isEnterpriseContactId(contactId))) {
266 info.contactIdOrZero = contactId;
267 Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero);
268 }
269 } else {
270 // No valid columnIndex, so we can't look up person_id.
271 Log.v(TAG, "Couldn't find contactId column for " + contactRef);
272 // Watch out: this means that anything that depends on
273 // person_id will be broken (like contact photo lookups in
274 // the in-call UI, for example.)
275 }
276
277 // Display photo URI.
278 columnIndex = cursor.getColumnIndex(PhoneLookup.PHOTO_URI);
279 if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
280 info.contactDisplayPhotoUri = Uri.parse(cursor.getString(columnIndex));
281 } else {
282 info.contactDisplayPhotoUri = null;
283 }
284
285 // look for the custom ringtone, create from the string stored
286 // in the database.
287 columnIndex = cursor.getColumnIndex(PhoneLookup.CUSTOM_RINGTONE);
288 if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
289 if (TextUtils.isEmpty(cursor.getString(columnIndex))) {
290 // make it consistent with frameworks/base/.../CallerInfo.java
291 info.contactRingtoneUri = Uri.EMPTY;
292 } else {
293 info.contactRingtoneUri = Uri.parse(cursor.getString(columnIndex));
294 }
295 } else {
296 info.contactRingtoneUri = null;
297 }
298
299 // look for the send to voicemail flag, set it to true only
300 // under certain circumstances.
301 columnIndex = cursor.getColumnIndex(PhoneLookup.SEND_TO_VOICEMAIL);
302 info.shouldSendToVoicemail = (columnIndex != -1) && ((cursor.getInt(columnIndex)) == 1);
303 info.contactExists = true;
304
305 // Determine userType by directoryId and contactId
306 final String directory =
307 contactRef == null
308 ? null
309 : contactRef.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY);
310 Long directoryId = null;
311 if (directory != null) {
312 try {
313 directoryId = Long.parseLong(directory);
314 } catch (NumberFormatException e) {
315 // do nothing
316 }
317 }
318 info.userType = ContactsUtils.determineUserType(directoryId, contactId);
319
320 info.nameAlternative =
321 ContactInfoHelper.lookUpDisplayNameAlternative(
322 context, info.lookupKeyOrNull, info.userType, directoryId);
linyuh6f78d932017-10-17 13:31:27 -0700323 }
linyuhbdef88b2017-12-12 14:30:08 -0800324 cursor.close();
linyuh6f78d932017-10-17 13:31:27 -0700325 }
326
linyuhbdef88b2017-12-12 14:30:08 -0800327 info.needUpdate = false;
328 info.name = normalize(info.name);
329 info.contactRefUri = contactRef;
Eric Erfanianccca3152017-02-22 16:32:36 -0800330
331 return info;
332 }
333
334 /**
335 * getCallerInfo given a URI, look up in the call-log database for the uri unique key.
336 *
337 * @param context the context used to get the ContentResolver
338 * @param contactRef the URI used to lookup caller id
339 * @return the CallerInfo which contains the caller id for the given number. The returned
340 * CallerInfo is null if no number is supplied.
341 */
342 private static CallerInfo getCallerInfo(Context context, Uri contactRef) {
343
344 return getCallerInfo(
345 context,
346 contactRef,
347 context.getContentResolver().query(contactRef, null, null, null, null));
348 }
349
350 /**
351 * Performs another lookup if previous lookup fails and it's a SIP call and the peer's username is
352 * all numeric. Look up the username as it could be a PSTN number in the contact database.
353 *
354 * @param context the query context
355 * @param number the original phone number, could be a SIP URI
356 * @param previousResult the result of previous lookup
357 * @return previousResult if it's not the case
358 */
359 static CallerInfo doSecondaryLookupIfNecessary(
360 Context context, String number, CallerInfo previousResult) {
361 if (!previousResult.contactExists && PhoneNumberHelper.isUriNumber(number)) {
362 String username = PhoneNumberHelper.getUsernameFromUriNumber(number);
363 if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
364 previousResult =
365 getCallerInfo(
366 context,
367 Uri.withAppendedPath(
368 PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(username)));
369 }
370 }
371 return previousResult;
372 }
373
374 // Accessors
375
376 private static String normalize(String s) {
377 if (s == null || s.length() > 0) {
378 return s;
379 } else {
380 return null;
381 }
382 }
383
384 /**
385 * Returns the column index to use to find the "person_id" field in the specified cursor, based on
386 * the contact URI that was originally queried.
387 *
388 * <p>This is a helper function for the getCallerInfo() method that takes a Cursor. Looking up the
389 * person_id is nontrivial (compared to all the other CallerInfo fields) since the column we need
390 * to use depends on what query we originally ran.
391 *
392 * <p>Watch out: be sure to not do any database access in this method, since it's run from the UI
393 * thread (see comments below for more info.)
394 *
395 * @return the columnIndex to use (with cursor.getLong()) to get the person_id, or -1 if we
396 * couldn't figure out what colum to use.
397 * <p>TODO: Add a unittest for this method. (This is a little tricky to test, since we'll need
398 * a live contacts database to test against, preloaded with at least some phone numbers and
399 * SIP addresses. And we'll probably have to hardcode the column indexes we expect, so the
400 * test might break whenever the contacts schema changes. But we can at least make sure we
401 * handle all the URI patterns we claim to, and that the mime types match what we expect...)
402 */
403 private static int getColumnIndexForPersonId(Uri contactRef, Cursor cursor) {
404 // TODO: This is pretty ugly now, see bug 2269240 for
405 // more details. The column to use depends upon the type of URL:
406 // - content://com.android.contacts/data/phones ==> use the "contact_id" column
407 // - content://com.android.contacts/phone_lookup ==> use the "_ID" column
408 // - content://com.android.contacts/data ==> use the "contact_id" column
409 // If it's none of the above, we leave columnIndex=-1 which means
410 // that the person_id field will be left unset.
411 //
412 // The logic here *used* to be based on the mime type of contactRef
413 // (for example Phone.CONTENT_ITEM_TYPE would tell us to use the
414 // RawContacts.CONTACT_ID column). But looking up the mime type requires
415 // a call to context.getContentResolver().getType(contactRef), which
416 // isn't safe to do from the UI thread since it can cause an ANR if
417 // the contacts provider is slow or blocked (like during a sync.)
418 //
419 // So instead, figure out the column to use for person_id by just
420 // looking at the URI itself.
421
422 Log.v(TAG, "- getColumnIndexForPersonId: contactRef URI = '" + contactRef + "'...");
423 // Warning: Do not enable the following logging (due to ANR risk.)
424 // if (VDBG) Rlog.v(TAG, "- MIME type: "
425 // + context.getContentResolver().getType(contactRef));
426
427 String url = contactRef.toString();
428 String columnName = null;
429 if (url.startsWith("content://com.android.contacts/data/phones")) {
430 // Direct lookup in the Phone table.
431 // MIME type: Phone.CONTENT_ITEM_TYPE (= "vnd.android.cursor.item/phone_v2")
432 Log.v(TAG, "'data/phones' URI; using RawContacts.CONTACT_ID");
433 columnName = RawContacts.CONTACT_ID;
434 } else if (url.startsWith("content://com.android.contacts/data")) {
435 // Direct lookup in the Data table.
436 // MIME type: Data.CONTENT_TYPE (= "vnd.android.cursor.dir/data")
437 Log.v(TAG, "'data' URI; using Data.CONTACT_ID");
438 // (Note Data.CONTACT_ID and RawContacts.CONTACT_ID are equivalent.)
439 columnName = Data.CONTACT_ID;
440 } else if (url.startsWith("content://com.android.contacts/phone_lookup")) {
441 // Lookup in the PhoneLookup table, which provides "fuzzy matching"
442 // for phone numbers.
443 // MIME type: PhoneLookup.CONTENT_TYPE (= "vnd.android.cursor.dir/phone_lookup")
444 Log.v(TAG, "'phone_lookup' URI; using PhoneLookup._ID");
445 columnName = PhoneLookupUtil.getContactIdColumnNameForUri(contactRef);
446 } else {
447 Log.v(TAG, "Unexpected prefix for contactRef '" + url + "'");
448 }
449 int columnIndex = (columnName != null) ? cursor.getColumnIndex(columnName) : -1;
450 Log.v(
451 TAG,
452 "==> Using column '"
453 + columnName
454 + "' (columnIndex = "
455 + columnIndex
456 + ") for person_id lookup...");
457 return columnIndex;
458 }
459
460 /** @return true if the caller info is an emergency number. */
461 public boolean isEmergencyNumber() {
462 return mIsEmergency;
463 }
464
465 /** @return true if the caller info is a voicemail number. */
466 public boolean isVoiceMailNumber() {
467 return mIsVoiceMail;
468 }
469
470 /**
471 * Mark this CallerInfo as an emergency call.
472 *
473 * @param context To lookup the localized 'Emergency Number' string.
474 * @return this instance.
475 */
476 /* package */ CallerInfo markAsEmergency(Context context) {
477 name = context.getString(R.string.emergency_call_dialog_number_for_display);
478 phoneNumber = null;
479
Eric Erfanianccca3152017-02-22 16:32:36 -0800480 mIsEmergency = true;
481 return this;
482 }
483
484 /**
485 * Mark this CallerInfo as a voicemail call. The voicemail label is obtained from the telephony
486 * manager. Caller must hold the READ_PHONE_STATE permission otherwise the phoneNumber will be set
487 * to null.
488 *
489 * @return this instance.
490 */
491 /* package */ CallerInfo markAsVoiceMail(Context context) {
492 mIsVoiceMail = true;
493
494 try {
495 // For voicemail calls, we display the voice mail tag
496 // instead of the real phone number in the "number"
497 // field.
498 name = TelephonyManagerUtils.getVoiceMailAlphaTag(context);
499 phoneNumber = null;
500 } catch (SecurityException se) {
501 // Should never happen: if this process does not have
502 // permission to retrieve VM tag, it should not have
503 // permission to retrieve VM number and would not call
504 // this method.
505 // Leave phoneNumber untouched.
506 Log.e(TAG, "Cannot access VoiceMail.", se);
507 }
508 // TODO: There is no voicemail picture?
Eric Erfanianccca3152017-02-22 16:32:36 -0800509 // photoResource = android.R.drawable.badge_voicemail;
510 return this;
511 }
512
513 /**
514 * Updates this CallerInfo's geoDescription field, based on the raw phone number in the
515 * phoneNumber field.
516 *
517 * <p>(Note that the various getCallerInfo() methods do *not* set the geoDescription
518 * automatically; you need to call this method explicitly to get it.)
519 *
520 * @param context the context used to look up the current locale / country
521 * @param fallbackNumber if this CallerInfo's phoneNumber field is empty, this specifies a
522 * fallback number to use instead.
523 */
524 public void updateGeoDescription(Context context, String fallbackNumber) {
525 String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber;
wangqi1420a222017-09-21 09:37:40 -0700526 geoDescription = PhoneNumberHelper.getGeoDescription(context, number, countryIso);
Eric Erfanianccca3152017-02-22 16:32:36 -0800527 }
528
529 /** @return a string debug representation of this instance. */
530 @Override
531 public String toString() {
532 // Warning: never check in this file with VERBOSE_DEBUG = true
533 // because that will result in PII in the system log.
534 final boolean VERBOSE_DEBUG = false;
535
536 if (VERBOSE_DEBUG) {
537 return new StringBuilder(384)
538 .append(super.toString() + " { ")
539 .append("\nname: " + name)
540 .append("\nphoneNumber: " + phoneNumber)
541 .append("\nnormalizedNumber: " + normalizedNumber)
542 .append("\forwardingNumber: " + forwardingNumber)
543 .append("\ngeoDescription: " + geoDescription)
544 .append("\ncnapName: " + cnapName)
545 .append("\nnumberPresentation: " + numberPresentation)
546 .append("\nnamePresentation: " + namePresentation)
547 .append("\ncontactExists: " + contactExists)
548 .append("\nphoneLabel: " + phoneLabel)
549 .append("\nnumberType: " + numberType)
550 .append("\nnumberLabel: " + numberLabel)
551 .append("\nphotoResource: " + photoResource)
552 .append("\ncontactIdOrZero: " + contactIdOrZero)
553 .append("\nneedUpdate: " + needUpdate)
554 .append("\ncontactRefUri: " + contactRefUri)
555 .append("\ncontactRingtoneUri: " + contactRingtoneUri)
556 .append("\ncontactDisplayPhotoUri: " + contactDisplayPhotoUri)
557 .append("\nshouldSendToVoicemail: " + shouldSendToVoicemail)
558 .append("\ncachedPhoto: " + cachedPhoto)
559 .append("\nisCachedPhotoCurrent: " + isCachedPhotoCurrent)
560 .append("\nemergency: " + mIsEmergency)
561 .append("\nvoicemail: " + mIsVoiceMail)
562 .append("\nuserType: " + userType)
563 .append(" }")
564 .toString();
565 } else {
566 return new StringBuilder(128)
567 .append(super.toString() + " { ")
568 .append("name " + ((name == null) ? "null" : "non-null"))
569 .append(", phoneNumber " + ((phoneNumber == null) ? "null" : "non-null"))
570 .append(" }")
571 .toString();
572 }
573 }
574}