diff options
author | Jay Shrauner <shrauner@google.com> | 2015-11-13 18:24:53 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-11-13 18:24:53 +0000 |
commit | b1b5d18a6447b9a3f57e0a8616f84346bc3c77ce (patch) | |
tree | 77ab9ad09fd5eda75aa7cf187c9474a70cdea787 /src | |
parent | 7ae965c7fa9748eeb240912eb0f5835944ad0afa (diff) | |
parent | cbed581719fdd31daa0f7aa096bb2ca7d40456d3 (diff) |
Catch work profile CP2 lookup exception
am: cbed581719
* commit 'cbed581719fdd31daa0f7aa096bb2ca7d40456d3':
Catch work profile CP2 lookup exception
Diffstat (limited to 'src')
-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 5d88efee2..52d143784 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; } /** |