blob: 4a9cf21813e10685e989fef238bf79d904ecb730 [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
linyuh6f78d932017-10-17 13:31:27 -0700195 * @param cursor the first matching 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();
Eric Erfanianccca3152017-02-22 16:32:36 -0800201 info.cachedPhoto = null;
Eric Erfanianccca3152017-02-22 16:32:36 -0800202 info.contactExists = false;
linyuh6f78d932017-10-17 13:31:27 -0700203 info.contactRefUri = contactRef;
204 info.isCachedPhotoCurrent = false;
205 info.name = null;
206 info.needUpdate = false;
207 info.numberLabel = null;
208 info.numberType = 0;
209 info.phoneLabel = null;
210 info.photoResource = 0;
Eric Erfanianccca3152017-02-22 16:32:36 -0800211 info.userType = ContactsUtils.USER_TYPE_CURRENT;
212
213 Log.v(TAG, "getCallerInfo() based on cursor...");
214
linyuh6f78d932017-10-17 13:31:27 -0700215 if (cursor == null || !cursor.moveToFirst()) {
216 return info;
Eric Erfanianccca3152017-02-22 16:32:36 -0800217 }
218
linyuh6f78d932017-10-17 13:31:27 -0700219 // TODO: photo_id is always available but not taken
220 // care of here. Maybe we should store it in the
221 // CallerInfo object as well.
222
223 long contactId = 0L;
224 int columnIndex;
225
226 // If the cursor has the phone number column, find the one that matches the lookup number in the
227 // URI.
228 columnIndex = cursor.getColumnIndex(PhoneLookup.NUMBER);
229 if (columnIndex != -1 && contactRef != null) {
230 cursor = PhoneNumberHelper.getCursorMatchForContactLookupUri(cursor, columnIndex, contactRef);
231 if (cursor != null) {
232 info.phoneNumber = cursor.getString(columnIndex);
233 } else {
234 return info;
235 }
236 }
237
238 // Look for the name
239 columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
240 if (columnIndex != -1) {
241 info.name = normalize(cursor.getString(columnIndex));
242 }
243
244 // Look for the normalized number
245 columnIndex = cursor.getColumnIndex(PhoneLookup.NORMALIZED_NUMBER);
246 if (columnIndex != -1) {
247 info.normalizedNumber = cursor.getString(columnIndex);
248 }
249
250 // Look for the label/type combo
251 columnIndex = cursor.getColumnIndex(PhoneLookup.LABEL);
252 if (columnIndex != -1) {
253 int typeColumnIndex = cursor.getColumnIndex(PhoneLookup.TYPE);
254 if (typeColumnIndex != -1) {
255 info.numberType = cursor.getInt(typeColumnIndex);
256 info.numberLabel = cursor.getString(columnIndex);
257 info.phoneLabel =
258 Phone.getTypeLabel(context.getResources(), info.numberType, info.numberLabel)
259 .toString();
260 }
261 }
262
263 // cache the lookup key for later use to create lookup URIs
264 columnIndex = cursor.getColumnIndex(PhoneLookup.LOOKUP_KEY);
265 if (columnIndex != -1) {
266 info.lookupKeyOrNull = cursor.getString(columnIndex);
267 }
268
269 // Look for the person_id.
270 columnIndex = getColumnIndexForPersonId(contactRef, cursor);
271 if (columnIndex != -1) {
272 contactId = cursor.getLong(columnIndex);
273 // QuickContacts in M doesn't support enterprise contact id
274 if (contactId != 0
275 && (VERSION.SDK_INT >= VERSION_CODES.N || !Contacts.isEnterpriseContactId(contactId))) {
276 info.contactIdOrZero = contactId;
277 Log.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero);
278 }
279 } else {
280 // No valid columnIndex, so we can't look up person_id.
281 Log.v(TAG, "Couldn't find contactId column for " + contactRef);
282 // Watch out: this means that anything that depends on
283 // person_id will be broken (like contact photo lookups in
284 // the in-call UI, for example.)
285 }
286
287 // Display photo URI.
288 columnIndex = cursor.getColumnIndex(PhoneLookup.PHOTO_URI);
289 if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
290 info.contactDisplayPhotoUri = Uri.parse(cursor.getString(columnIndex));
291 } else {
292 info.contactDisplayPhotoUri = null;
293 }
294
295 // look for the custom ringtone, create from the string stored
296 // in the database.
297 columnIndex = cursor.getColumnIndex(PhoneLookup.CUSTOM_RINGTONE);
298 if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
299 if (TextUtils.isEmpty(cursor.getString(columnIndex))) {
300 // make it consistent with frameworks/base/.../CallerInfo.java
301 info.contactRingtoneUri = Uri.EMPTY;
302 } else {
303 info.contactRingtoneUri = Uri.parse(cursor.getString(columnIndex));
304 }
305 } else {
306 info.contactRingtoneUri = null;
307 }
308
309 // look for the send to voicemail flag, set it to true only
310 // under certain circumstances.
311 columnIndex = cursor.getColumnIndex(PhoneLookup.SEND_TO_VOICEMAIL);
312 info.shouldSendToVoicemail = (columnIndex != -1) && ((cursor.getInt(columnIndex)) == 1);
313 info.contactExists = true;
314
315 // Determine userType by directoryId and contactId
316 final String directory =
317 contactRef == null
318 ? null
319 : contactRef.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY);
320 Long directoryId = null;
321 if (directory != null) {
322 try {
323 directoryId = Long.parseLong(directory);
324 } catch (NumberFormatException e) {
325 // do nothing
326 }
327 }
328 info.userType = ContactsUtils.determineUserType(directoryId, contactId);
329
330 info.nameAlternative =
331 ContactInfoHelper.lookUpDisplayNameAlternative(
332 context, info.lookupKeyOrNull, info.userType, directoryId);
333 cursor.close();
Eric Erfanianccca3152017-02-22 16:32:36 -0800334
335 return info;
336 }
337
338 /**
339 * getCallerInfo given a URI, look up in the call-log database for the uri unique key.
340 *
341 * @param context the context used to get the ContentResolver
342 * @param contactRef the URI used to lookup caller id
343 * @return the CallerInfo which contains the caller id for the given number. The returned
344 * CallerInfo is null if no number is supplied.
345 */
346 private static CallerInfo getCallerInfo(Context context, Uri contactRef) {
347
348 return getCallerInfo(
349 context,
350 contactRef,
351 context.getContentResolver().query(contactRef, null, null, null, null));
352 }
353
354 /**
355 * Performs another lookup if previous lookup fails and it's a SIP call and the peer's username is
356 * all numeric. Look up the username as it could be a PSTN number in the contact database.
357 *
358 * @param context the query context
359 * @param number the original phone number, could be a SIP URI
360 * @param previousResult the result of previous lookup
361 * @return previousResult if it's not the case
362 */
363 static CallerInfo doSecondaryLookupIfNecessary(
364 Context context, String number, CallerInfo previousResult) {
365 if (!previousResult.contactExists && PhoneNumberHelper.isUriNumber(number)) {
366 String username = PhoneNumberHelper.getUsernameFromUriNumber(number);
367 if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
368 previousResult =
369 getCallerInfo(
370 context,
371 Uri.withAppendedPath(
372 PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI, Uri.encode(username)));
373 }
374 }
375 return previousResult;
376 }
377
378 // Accessors
379
380 private static String normalize(String s) {
381 if (s == null || s.length() > 0) {
382 return s;
383 } else {
384 return null;
385 }
386 }
387
388 /**
389 * Returns the column index to use to find the "person_id" field in the specified cursor, based on
390 * the contact URI that was originally queried.
391 *
392 * <p>This is a helper function for the getCallerInfo() method that takes a Cursor. Looking up the
393 * person_id is nontrivial (compared to all the other CallerInfo fields) since the column we need
394 * to use depends on what query we originally ran.
395 *
396 * <p>Watch out: be sure to not do any database access in this method, since it's run from the UI
397 * thread (see comments below for more info.)
398 *
399 * @return the columnIndex to use (with cursor.getLong()) to get the person_id, or -1 if we
400 * couldn't figure out what colum to use.
401 * <p>TODO: Add a unittest for this method. (This is a little tricky to test, since we'll need
402 * a live contacts database to test against, preloaded with at least some phone numbers and
403 * SIP addresses. And we'll probably have to hardcode the column indexes we expect, so the
404 * test might break whenever the contacts schema changes. But we can at least make sure we
405 * handle all the URI patterns we claim to, and that the mime types match what we expect...)
406 */
407 private static int getColumnIndexForPersonId(Uri contactRef, Cursor cursor) {
408 // TODO: This is pretty ugly now, see bug 2269240 for
409 // more details. The column to use depends upon the type of URL:
410 // - content://com.android.contacts/data/phones ==> use the "contact_id" column
411 // - content://com.android.contacts/phone_lookup ==> use the "_ID" column
412 // - content://com.android.contacts/data ==> use the "contact_id" column
413 // If it's none of the above, we leave columnIndex=-1 which means
414 // that the person_id field will be left unset.
415 //
416 // The logic here *used* to be based on the mime type of contactRef
417 // (for example Phone.CONTENT_ITEM_TYPE would tell us to use the
418 // RawContacts.CONTACT_ID column). But looking up the mime type requires
419 // a call to context.getContentResolver().getType(contactRef), which
420 // isn't safe to do from the UI thread since it can cause an ANR if
421 // the contacts provider is slow or blocked (like during a sync.)
422 //
423 // So instead, figure out the column to use for person_id by just
424 // looking at the URI itself.
425
426 Log.v(TAG, "- getColumnIndexForPersonId: contactRef URI = '" + contactRef + "'...");
427 // Warning: Do not enable the following logging (due to ANR risk.)
428 // if (VDBG) Rlog.v(TAG, "- MIME type: "
429 // + context.getContentResolver().getType(contactRef));
430
431 String url = contactRef.toString();
432 String columnName = null;
433 if (url.startsWith("content://com.android.contacts/data/phones")) {
434 // Direct lookup in the Phone table.
435 // MIME type: Phone.CONTENT_ITEM_TYPE (= "vnd.android.cursor.item/phone_v2")
436 Log.v(TAG, "'data/phones' URI; using RawContacts.CONTACT_ID");
437 columnName = RawContacts.CONTACT_ID;
438 } else if (url.startsWith("content://com.android.contacts/data")) {
439 // Direct lookup in the Data table.
440 // MIME type: Data.CONTENT_TYPE (= "vnd.android.cursor.dir/data")
441 Log.v(TAG, "'data' URI; using Data.CONTACT_ID");
442 // (Note Data.CONTACT_ID and RawContacts.CONTACT_ID are equivalent.)
443 columnName = Data.CONTACT_ID;
444 } else if (url.startsWith("content://com.android.contacts/phone_lookup")) {
445 // Lookup in the PhoneLookup table, which provides "fuzzy matching"
446 // for phone numbers.
447 // MIME type: PhoneLookup.CONTENT_TYPE (= "vnd.android.cursor.dir/phone_lookup")
448 Log.v(TAG, "'phone_lookup' URI; using PhoneLookup._ID");
449 columnName = PhoneLookupUtil.getContactIdColumnNameForUri(contactRef);
450 } else {
451 Log.v(TAG, "Unexpected prefix for contactRef '" + url + "'");
452 }
453 int columnIndex = (columnName != null) ? cursor.getColumnIndex(columnName) : -1;
454 Log.v(
455 TAG,
456 "==> Using column '"
457 + columnName
458 + "' (columnIndex = "
459 + columnIndex
460 + ") for person_id lookup...");
461 return columnIndex;
462 }
463
464 /** @return true if the caller info is an emergency number. */
465 public boolean isEmergencyNumber() {
466 return mIsEmergency;
467 }
468
469 /** @return true if the caller info is a voicemail number. */
470 public boolean isVoiceMailNumber() {
471 return mIsVoiceMail;
472 }
473
474 /**
475 * Mark this CallerInfo as an emergency call.
476 *
477 * @param context To lookup the localized 'Emergency Number' string.
478 * @return this instance.
479 */
480 /* package */ CallerInfo markAsEmergency(Context context) {
481 name = context.getString(R.string.emergency_call_dialog_number_for_display);
482 phoneNumber = null;
483
Eric Erfanianccca3152017-02-22 16:32:36 -0800484 mIsEmergency = true;
485 return this;
486 }
487
488 /**
489 * Mark this CallerInfo as a voicemail call. The voicemail label is obtained from the telephony
490 * manager. Caller must hold the READ_PHONE_STATE permission otherwise the phoneNumber will be set
491 * to null.
492 *
493 * @return this instance.
494 */
495 /* package */ CallerInfo markAsVoiceMail(Context context) {
496 mIsVoiceMail = true;
497
498 try {
499 // For voicemail calls, we display the voice mail tag
500 // instead of the real phone number in the "number"
501 // field.
502 name = TelephonyManagerUtils.getVoiceMailAlphaTag(context);
503 phoneNumber = null;
504 } catch (SecurityException se) {
505 // Should never happen: if this process does not have
506 // permission to retrieve VM tag, it should not have
507 // permission to retrieve VM number and would not call
508 // this method.
509 // Leave phoneNumber untouched.
510 Log.e(TAG, "Cannot access VoiceMail.", se);
511 }
512 // TODO: There is no voicemail picture?
Eric Erfanian938468d2017-10-24 14:05:52 -0700513
Eric Erfanianccca3152017-02-22 16:32:36 -0800514 // photoResource = android.R.drawable.badge_voicemail;
515 return this;
516 }
517
518 /**
519 * Updates this CallerInfo's geoDescription field, based on the raw phone number in the
520 * phoneNumber field.
521 *
522 * <p>(Note that the various getCallerInfo() methods do *not* set the geoDescription
523 * automatically; you need to call this method explicitly to get it.)
524 *
525 * @param context the context used to look up the current locale / country
526 * @param fallbackNumber if this CallerInfo's phoneNumber field is empty, this specifies a
527 * fallback number to use instead.
528 */
529 public void updateGeoDescription(Context context, String fallbackNumber) {
530 String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber;
wangqi1420a222017-09-21 09:37:40 -0700531 geoDescription = PhoneNumberHelper.getGeoDescription(context, number, countryIso);
Eric Erfanianccca3152017-02-22 16:32:36 -0800532 }
533
534 /** @return a string debug representation of this instance. */
535 @Override
536 public String toString() {
537 // Warning: never check in this file with VERBOSE_DEBUG = true
538 // because that will result in PII in the system log.
539 final boolean VERBOSE_DEBUG = false;
540
541 if (VERBOSE_DEBUG) {
542 return new StringBuilder(384)
543 .append(super.toString() + " { ")
544 .append("\nname: " + name)
545 .append("\nphoneNumber: " + phoneNumber)
546 .append("\nnormalizedNumber: " + normalizedNumber)
547 .append("\forwardingNumber: " + forwardingNumber)
548 .append("\ngeoDescription: " + geoDescription)
549 .append("\ncnapName: " + cnapName)
550 .append("\nnumberPresentation: " + numberPresentation)
551 .append("\nnamePresentation: " + namePresentation)
552 .append("\ncontactExists: " + contactExists)
553 .append("\nphoneLabel: " + phoneLabel)
554 .append("\nnumberType: " + numberType)
555 .append("\nnumberLabel: " + numberLabel)
556 .append("\nphotoResource: " + photoResource)
557 .append("\ncontactIdOrZero: " + contactIdOrZero)
558 .append("\nneedUpdate: " + needUpdate)
559 .append("\ncontactRefUri: " + contactRefUri)
560 .append("\ncontactRingtoneUri: " + contactRingtoneUri)
561 .append("\ncontactDisplayPhotoUri: " + contactDisplayPhotoUri)
562 .append("\nshouldSendToVoicemail: " + shouldSendToVoicemail)
563 .append("\ncachedPhoto: " + cachedPhoto)
564 .append("\nisCachedPhotoCurrent: " + isCachedPhotoCurrent)
565 .append("\nemergency: " + mIsEmergency)
566 .append("\nvoicemail: " + mIsVoiceMail)
567 .append("\nuserType: " + userType)
568 .append(" }")
569 .toString();
570 } else {
571 return new StringBuilder(128)
572 .append(super.toString() + " { ")
573 .append("name " + ((name == null) ? "null" : "non-null"))
574 .append(", phoneNumber " + ((phoneNumber == null) ? "null" : "non-null"))
575 .append(" }")
576 .toString();
577 }
578 }
579}