Catch work profile CP2 lookup exception am: cbed581719
am: b1b5d18a64

* commit 'b1b5d18a6447b9a3f57e0a8616f84346bc3c77ce':
  Catch work profile CP2 lookup exception
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java
index 5d88efe..52d1437 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -198,23 +198,26 @@
             return null;
         }
 
-        Uri uri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey);
+        final 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;
-        }
-
+        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;
     }
 
     /**