summaryrefslogtreecommitdiffstats
path: root/java/com/android/dialer/phonenumbercache
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/phonenumbercache')
-rw-r--r--java/com/android/dialer/phonenumbercache/CachedNumberLookupService.java17
-rw-r--r--java/com/android/dialer/phonenumbercache/ContactInfo.java3
-rw-r--r--java/com/android/dialer/phonenumbercache/ContactInfoHelper.java9
3 files changed, 25 insertions, 4 deletions
diff --git a/java/com/android/dialer/phonenumbercache/CachedNumberLookupService.java b/java/com/android/dialer/phonenumbercache/CachedNumberLookupService.java
index f443d56fb..e589a6882 100644
--- a/java/com/android/dialer/phonenumbercache/CachedNumberLookupService.java
+++ b/java/com/android/dialer/phonenumbercache/CachedNumberLookupService.java
@@ -18,10 +18,13 @@ package com.android.dialer.phonenumbercache;
import android.content.Context;
import android.net.Uri;
+import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import java.io.InputStream;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
public interface CachedNumberLookupService {
@@ -66,11 +69,23 @@ public interface CachedNumberLookupService {
int SOURCE_TYPE_PLACES = 3;
int SOURCE_TYPE_PROFILE = 4;
int SOURCE_TYPE_CNAP = 5;
+ int SOURCE_TYPE_CEQUINT_CALLER_ID = 6;
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ SOURCE_TYPE_DIRECTORY,
+ SOURCE_TYPE_EXTENDED,
+ SOURCE_TYPE_PLACES,
+ SOURCE_TYPE_PROFILE,
+ SOURCE_TYPE_CNAP,
+ SOURCE_TYPE_CEQUINT_CALLER_ID
+ })
+ public @interface ContactSourceType {}
@NonNull
ContactInfo getContactInfo();
- void setSource(int sourceType, String name, long directoryId);
+ void setSource(@ContactSourceType int sourceType, String name, long directoryId);
void setDirectorySource(String name, long directoryId);
diff --git a/java/com/android/dialer/phonenumbercache/ContactInfo.java b/java/com/android/dialer/phonenumbercache/ContactInfo.java
index 03240cc62..dab5e4b4c 100644
--- a/java/com/android/dialer/phonenumbercache/ContactInfo.java
+++ b/java/com/android/dialer/phonenumbercache/ContactInfo.java
@@ -20,6 +20,7 @@ import android.net.Uri;
import android.text.TextUtils;
import com.android.contacts.common.ContactsUtils.UserType;
import com.android.contacts.common.util.UriUtils;
+import com.android.dialer.phonenumbercache.CachedNumberLookupService.CachedContactInfo.ContactSourceType;
/** Information for a contact as needed by the Call Log. */
public class ContactInfo {
@@ -57,7 +58,7 @@ public class ContactInfo {
public boolean isBadData;
public String objectId;
public @UserType long userType;
- public int sourceType = 0;
+ public @ContactSourceType int sourceType = 0;
/** @see android.provider.ContactsContract.CommonDataKinds.Phone#CARRIER_PRESENCE */
public int carrierPresence;
diff --git a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java
index 66ddd06fd..dc11c1b21 100644
--- a/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java
+++ b/java/com/android/dialer/phonenumbercache/ContactInfoHelper.java
@@ -31,6 +31,7 @@ import android.provider.ContactsContract.Directory;
import android.provider.ContactsContract.DisplayNameSources;
import android.provider.ContactsContract.PhoneLookup;
import android.support.annotation.Nullable;
+import android.support.annotation.WorkerThread;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import com.android.contacts.common.ContactsUtils;
@@ -38,6 +39,7 @@ import com.android.contacts.common.ContactsUtils.UserType;
import com.android.contacts.common.compat.DirectoryCompat;
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.UriUtils;
+import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.oem.CequintCallerIdManager;
import com.android.dialer.oem.CequintCallerIdManager.CequintCallerIdContact;
@@ -596,7 +598,9 @@ public class ContactInfoHelper {
* Update ContactInfo by querying to Cequint Caller ID. Only name, geoDescription and photo uri
* will be updated if available.
*/
+ @WorkerThread
public void updateFromCequintCallerId(ContactInfo info, String number) {
+ Assert.isWorkerThread();
if (!CequintCallerIdManager.isCequintCallerIdEnabled(mContext)) {
return;
}
@@ -605,13 +609,14 @@ public class ContactInfoHelper {
if (cequintCallerIdContact == null) {
return;
}
- if (!TextUtils.isEmpty(cequintCallerIdContact.name)) {
+ if (TextUtils.isEmpty(info.name) && !TextUtils.isEmpty(cequintCallerIdContact.name)) {
info.name = cequintCallerIdContact.name;
}
if (!TextUtils.isEmpty(cequintCallerIdContact.geoDescription)) {
info.geoDescription = cequintCallerIdContact.geoDescription;
+ info.sourceType = CachedContactInfo.SOURCE_TYPE_CEQUINT_CALLER_ID;
}
- if (cequintCallerIdContact.imageUrl != null) {
+ if (info.photoUri == null && cequintCallerIdContact.imageUrl != null) {
info.photoUri = UriUtils.parseUriOrNull(cequintCallerIdContact.imageUrl);
}
}