Skip to content

Commit

Permalink
wtf workaround for annoying crash (see issue jberkel#870)
Browse files Browse the repository at this point in the history
On backup. Some phone numbers trigger a full app crash when reaching
com/zegoggles/smssync/mail/PersonLookup.java:51
Cursor c = mResolver.query(personUri, PHONE_PROJECTION, null, null...
  • Loading branch information
dofer404 committed Apr 9, 2018
1 parent 0311a31 commit 868e1bb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/src/main/java/com/zegoggles/smssync/mail/PersonLookup.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,19 @@ public PersonLookup(ContentResolver resolver) {
} else if (!mPeopleCache.containsKey(address)) {
Uri personUri = Uri.withAppendedPath(CONTENT_FILTER_URI, Uri.encode(address));

Cursor c = mResolver.query(personUri, PHONE_PROJECTION, null, null, null);
Cursor c = null;
try {
// Issue #870
// Some phone numbers trigger a full app crash when reaching this line.
// The reason for the crash...
// Caused by: java.lang.IllegalArgumentException: column 'data1' does not exist
// ...is unknown, hence the try-catch.
// TODO: Find a way to avoid the crash without the need for a try-catch
c = mResolver.query(personUri, PHONE_PROJECTION, null, null, null);
} catch (Exception e) {
Log.wtf(TAG, "Avoided a crash with address: " + address + "; Error Message: \"" + e.getMessage() + "\" in PersonLookup.java in lookupPerson(final String address) in c = mResolver.query(personUri, PHONE_PROJECTION, null, null, null);");
}

final PersonRecord record;
if (c != null && c.moveToFirst()) {
long id = c.getLong(c.getColumnIndex(PHONE_PROJECTION[0]));
Expand Down

0 comments on commit 868e1bb

Please sign in to comment.