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