diff options
author | Jay Shrauner <shrauner@google.com> | 2015-11-13 09:36:04 -0800 |
---|---|---|
committer | Jay Shrauner <shrauner@google.com> | 2015-11-13 09:36:04 -0800 |
commit | cbed581719fdd31daa0f7aa096bb2ca7d40456d3 (patch) | |
tree | 784550b6699a23f9f2f112cb7516a4bf9cac9e01 /src/com/android/dialer/calllog/ContactInfoHelper.java | |
parent | f3b23ba40d6c6c60f7e01c84df69712d7ae9bae0 (diff) |
Catch work profile CP2 lookup exception
Catch IllegalArgumentExceptions throw for work profile contact alternative
display name lookups.
Bug:25680927
Change-Id: I1e3245239c8521de6edc5286a898547fc83bd23e
Diffstat (limited to 'src/com/android/dialer/calllog/ContactInfoHelper.java')
-rw-r--r-- | src/com/android/dialer/calllog/ContactInfoHelper.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index e760750b2..2da6840ba 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -198,23 +198,26 @@ public class ContactInfoHelper { return null; } - Uri uri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey); - - Cursor cursor = context.getContentResolver().query(uri, - PhoneQuery.DISPLAY_NAME_ALTERNATIVE_PROJECTION, null, null, null); - - if (cursor == null) { - return null; - } + final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey); + Cursor cursor = null; try { - if (!cursor.moveToFirst()) { - return null; + cursor = context.getContentResolver().query(uri, + PhoneQuery.DISPLAY_NAME_ALTERNATIVE_PROJECTION, null, null, null); + + if (cursor != null && cursor.moveToFirst()) { + return cursor.getString(PhoneQuery.NAME_ALTERNATIVE); } - return cursor.getString(PhoneQuery.NAME_ALTERNATIVE); + } catch (IllegalArgumentException e) { + // Thrown for work profile queries. For those, we don't support + // alternative display names. } finally { - cursor.close(); + if (cursor != null) { + cursor.close(); + } } + + return null; } /** |