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