summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2016-03-11 23:51:59 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-03-11 23:51:59 +0000
commit235583df88ac91476d6e2c640f12c8b212a67c4c (patch)
tree51f9c9d31be11cb703591e41e5b12bfeb4e69f45 /src/com
parent0143b242b072b10a996994f8554f20a3e0dbb3c0 (diff)
parent769f26fe7488415cb677d4980540bbd7dcfc3ac0 (diff)
Merge "Query lookup uri with work lookup key directly is not allowed" into nyc-dev am: ebfbfa10d9
am: 769f26fe74 * commit '769f26fe7488415cb677d4980540bbd7dcfc3ac0': Query lookup uri with work lookup key directly is not allowed
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/dialer/calllog/ContactInfoHelper.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java
index a9c7651d9..ff7a3f6a5 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -31,6 +31,7 @@ import android.text.TextUtils;
import android.util.Log;
import com.android.contacts.common.ContactsUtils;
+import com.android.contacts.common.ContactsUtils.UserType;
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.common.util.PhoneNumberHelper;
@@ -181,7 +182,8 @@ public class ContactInfoHelper {
}
String lookupKey = phoneLookupCursor.getString(PhoneQuery.LOOKUP_KEY);
ContactInfo contactInfo = createPhoneLookupContactInfo(phoneLookupCursor, lookupKey);
- contactInfo.nameAlternative = lookUpDisplayNameAlternative(mContext, lookupKey);
+ contactInfo.nameAlternative = lookUpDisplayNameAlternative(mContext, lookupKey,
+ contactInfo.userType);
return contactInfo;
} finally {
phoneLookupCursor.close();
@@ -207,13 +209,13 @@ public class ContactInfoHelper {
return info;
}
- public static String lookUpDisplayNameAlternative(Context context, String lookupKey) {
- if (lookupKey == null) {
+ public static String lookUpDisplayNameAlternative(Context context, String lookupKey,
+ @UserType long userType) {
+ // Query {@link Contacts#CONTENT_LOOKUP_URI} directly with work lookup key is not allowed.
+ if (lookupKey == null || userType == ContactsUtils.USER_TYPE_WORK) {
return null;
}
-
final Uri uri = Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey);
-
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri,
@@ -222,9 +224,6 @@ public class ContactInfoHelper {
if (cursor != null && cursor.moveToFirst()) {
return cursor.getString(PhoneQuery.NAME_ALTERNATIVE);
}
- } catch (IllegalArgumentException e) {
- // Thrown for work profile queries. For those, we don't support
- // alternative display names.
} finally {
if (cursor != null) {
cursor.close();