diff options
author | Yorke Lee <yorkelee@google.com> | 2013-11-18 14:42:47 -0800 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2013-11-18 14:42:47 -0800 |
commit | 1ae0cf68723dfaf05f387f2759b4f59e6271ba6c (patch) | |
tree | 701114b5c0756dc29829857bdb8d6e8048c01ac0 | |
parent | b372f3e5a2b39ecf3949b422b43dbb5ea2a564bf (diff) |
Fix possible NPE in DialerDatabaseHelper
In certain cases (third party contact backup solutions?) it is possible
for raw contacts to end up with null display names, which the Dialer
was crashing on. This fix performs a null check and inserts the default
(No name) contact name if we find that the display name is null.
Bug: 11750613
Change-Id: Ifbaf2861534e6eaf8a86d50d584d11a9fa38b65f
-rw-r--r-- | src/com/android/dialer/database/DialerDatabaseHelper.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/com/android/dialer/database/DialerDatabaseHelper.java b/src/com/android/dialer/database/DialerDatabaseHelper.java index e9d773561..b9e4b9a90 100644 --- a/src/com/android/dialer/database/DialerDatabaseHelper.java +++ b/src/com/android/dialer/database/DialerDatabaseHelper.java @@ -37,6 +37,7 @@ import android.text.TextUtils; import android.util.Log; import com.android.contacts.common.util.StopWatch; +import com.android.dialer.R; import com.android.dialer.dialpad.SmartDialNameMatcher; import com.android.dialer.dialpad.SmartDialPrefix; @@ -631,7 +632,13 @@ public class DialerDatabaseHelper extends SQLiteOpenHelper { insert.bindString(2, updatedContactCursor.getString(PhoneQuery.PHONE_NUMBER)); insert.bindLong(3, updatedContactCursor.getLong(PhoneQuery.PHONE_CONTACT_ID)); insert.bindString(4, updatedContactCursor.getString(PhoneQuery.PHONE_LOOKUP_KEY)); - insert.bindString(5, updatedContactCursor.getString(PhoneQuery.PHONE_DISPLAY_NAME)); + final String displayName = updatedContactCursor.getString( + PhoneQuery.PHONE_DISPLAY_NAME); + if (displayName == null) { + insert.bindString(5, mContext.getResources().getString(R.string.missing_name)); + } else { + insert.bindString(5, displayName); + } insert.bindLong(6, updatedContactCursor.getLong(PhoneQuery.PHONE_PHOTO_ID)); insert.bindLong(7, updatedContactCursor.getLong(PhoneQuery.PHONE_LAST_TIME_USED)); insert.bindLong(8, updatedContactCursor.getInt(PhoneQuery.PHONE_TIMES_USED)); |