Merge "Adjust display name of call log for 4G conference call" into atel.lnx.2.0-dev
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 48b4f55..4a55b8f 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -524,8 +524,11 @@
ContactInfo info = ContactInfo.EMPTY;
if (PhoneNumberUtil.canPlaceCallsTo(number, numberPresentation) && !isVoicemailNumber) {
// Lookup contacts with this number
- info = mContactInfoCache.getValue(number + postDialDigits,
- countryIso, cachedContactInfo);
+ boolean isConfCallLog = num != null && num.length > 1
+ && DialerUtils.isConferenceURICallLog(phoneNumber, postDialDigits);
+ String queryNumber = isConfCallLog ? phoneNumber : number + postDialDigits;
+ info = mContactInfoCache.getValue(queryNumber,
+ countryIso, cachedContactInfo, isConfCallLog);
}
CharSequence formattedNumber = info.formattedNumber == null
? null : PhoneNumberUtilsCompat.createTtsSpannable(info.formattedNumber);
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
index 34b2f0e..426615a 100644
--- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
+++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
@@ -41,6 +41,7 @@
import com.android.dialer.util.AsyncTaskExecutor;
import com.android.dialer.util.AsyncTaskExecutors;
import com.android.dialer.util.PhoneNumberUtil;
+import com.android.dialer.util.DialerUtils;
import com.android.dialer.util.TelecomUtil;
import java.util.ArrayList;
@@ -209,7 +210,8 @@
ContactInfo info = ContactInfo.EMPTY;
if (shouldLookupNumber) {
- ContactInfo lookupInfo = contactInfoHelper.lookupNumber(number, countryIso);
+ ContactInfo lookupInfo = contactInfoHelper.lookupNumber(number, countryIso,
+ DialerUtils.isConferenceURICallLog(number, postDialDigits));
info = lookupInfo != null ? lookupInfo : ContactInfo.EMPTY;
}
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java
index b0ef0ab..07db044 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -43,6 +43,8 @@
import com.android.dialer.util.TelecomUtil;
import com.android.dialerbind.ObjectFactory;
+import java.util.regex.Pattern;
+
import org.json.JSONException;
import org.json.JSONObject;
@@ -76,6 +78,24 @@
*/
@Nullable
public ContactInfo lookupNumber(String number, String countryIso) {
+ return lookupNumber(number, countryIso, false);
+ }
+
+ /**
+ * Returns the contact information for the given number.
+ * <p>
+ * If the number does not match any contact, returns a contact info containing only the number
+ * and the formatted number.
+ * <p>
+ * If an error occurs during the lookup, it returns null.
+ *
+ * @param number the number to look up
+ * @param countryIso the country associated with this number
+ * @param isConfUrlLog whether call log is for Conference URL call
+ */
+ @Nullable
+ public ContactInfo lookupNumber(String number, String countryIso, boolean isConfUrlCallLog) {
+
if (TextUtils.isEmpty(number)) {
return null;
}
@@ -89,12 +109,13 @@
// If lookup failed, check if the "username" of the SIP address is a phone number.
String username = PhoneNumberHelper.getUsernameFromUriNumber(number);
if (PhoneNumberUtils.isGlobalPhoneNumber(username)) {
- info = queryContactInfoForPhoneNumber(username, countryIso, true);
+ info = queryContactInfoForPhoneNumber(username, countryIso, true,
+ isConfUrlCallLog);
}
}
} else {
// Look for a contact that has the given phone number.
- info = queryContactInfoForPhoneNumber(number, countryIso, false);
+ info = queryContactInfoForPhoneNumber(number, countryIso, false, isConfUrlCallLog);
}
final ContactInfo updatedInfo;
@@ -245,12 +266,38 @@
* If the lookup fails for some other reason, it returns null.
*/
private ContactInfo queryContactInfoForPhoneNumber(String number, String countryIso,
- boolean isSip) {
+ boolean isSip, boolean isConfUrlLog) {
if (TextUtils.isEmpty(number)) {
return null;
}
ContactInfo info = lookupContactFromUri(getContactInfoLookupUri(number), isSip);
+ if (isConfUrlLog) {
+ Pattern pattern = Pattern.compile("[,;]");
+ String[] nums = pattern.split(number);
+ if (nums != null && nums.length > 1) {
+ if (info == null || info == ContactInfo.EMPTY) {
+ info = new ContactInfo();
+ info.number = number;
+ info.formattedNumber = formatPhoneNumber(number, null, countryIso);
+ info.lookupUri = createTemporaryContactUri(info.formattedNumber);
+ info.normalizedNumber = PhoneNumberUtils.formatNumberToE164(number,
+ countryIso);
+ }
+ String combName = "";
+ for (String num : nums) {
+ ContactInfo singleCi = lookupContactFromUri(getContactInfoLookupUri(num),
+ isSip);
+ if (TextUtils.isEmpty(singleCi.name)) {
+ singleCi.name = formatPhoneNumber(num, null, countryIso);
+ }
+ combName += singleCi.name + ";";
+ }
+ if (!TextUtils.isEmpty(combName) && combName.length() > 1) {
+ info.name = combName.substring(0, combName.length() - 1);
+ }
+ }
+ }
if (info != null && info != ContactInfo.EMPTY) {
info.formattedNumber = formatPhoneNumber(number, null, countryIso);
} else if (mCachedNumberLookupService != null) {
diff --git a/src/com/android/dialer/contactinfo/ContactInfoCache.java b/src/com/android/dialer/contactinfo/ContactInfoCache.java
index 1e24579..af30c10 100644
--- a/src/com/android/dialer/contactinfo/ContactInfoCache.java
+++ b/src/com/android/dialer/contactinfo/ContactInfoCache.java
@@ -76,7 +76,8 @@
if (req != null) {
// Process the request. If the lookup succeeds, schedule a redraw.
- needRedraw |= queryContactInfo(req.number, req.countryIso, req.callLogInfo);
+ needRedraw |= queryContactInfo(req.number, req.countryIso, req.callLogInfo,
+ req.isConf);
} else {
// Throttle redraw rate by only sending them when there are
// more requests.
@@ -145,6 +146,11 @@
}
public ContactInfo getValue(String number, String countryIso, ContactInfo cachedContactInfo) {
+ return getValue(number, countryIso, cachedContactInfo, false);
+ }
+
+ public ContactInfo getValue(String number, String countryIso, ContactInfo cachedContactInfo,
+ boolean isConf) {
NumberWithCountryIso numberCountryIso = new NumberWithCountryIso(number, countryIso);
ExpirableCache.CachedValue<ContactInfo> cachedInfo =
mCache.getCachedValue(numberCountryIso);
@@ -155,19 +161,19 @@
info = cachedContactInfo;
// The db request should happen on a non-UI thread.
// Request the contact details immediately since they are currently missing.
- enqueueRequest(number, countryIso, cachedContactInfo, true);
+ enqueueRequest(number, countryIso, cachedContactInfo, true, isConf);
// We will format the phone number when we make the background request.
} else {
if (cachedInfo.isExpired()) {
// The contact info is no longer up to date, we should request it. However, we
// do not need to request them immediately.
- enqueueRequest(number, countryIso, cachedContactInfo, false);
+ enqueueRequest(number, countryIso, cachedContactInfo, false, isConf);
} else if (!callLogInfoMatches(cachedContactInfo, info)) {
// The call log information does not match the one we have, look it up again.
// We could simply update the call log directly, but that needs to be done in a
// background thread, so it is easier to simply request a new lookup, which will, as
// a side-effect, update the call log.
- enqueueRequest(number, countryIso, cachedContactInfo, false);
+ enqueueRequest(number, countryIso, cachedContactInfo, false, isConf);
}
if (info == ContactInfo.EMPTY) {
@@ -189,8 +195,9 @@
* It returns true if it updated the content of the cache and we should therefore tell the
* view to update its content.
*/
- private boolean queryContactInfo(String number, String countryIso, ContactInfo callLogInfo) {
- final ContactInfo info = mContactInfoHelper.lookupNumber(number, countryIso);
+ private boolean queryContactInfo(String number, String countryIso, ContactInfo callLogInfo,
+ boolean isConf) {
+ final ContactInfo info = mContactInfoHelper.lookupNumber(number, countryIso, isConf);
if (info == null) {
// The lookup failed, just return without requesting to update the view.
@@ -293,7 +300,23 @@
*/
protected void enqueueRequest(String number, String countryIso, ContactInfo callLogInfo,
boolean immediate) {
- ContactInfoRequest request = new ContactInfoRequest(number, countryIso, callLogInfo);
+ enqueueRequest(number, countryIso, callLogInfo, immediate, false);
+ }
+
+ /**
+ * Enqueues a request to look up the contact details for the given phone number.
+ * <p>
+ * It also provides the current contact info stored in the call log for this number.
+ * <p>
+ * If the {@code immediate} parameter is true, it will start immediately the thread that looks
+ * up the contact information (if it has not been already started). Otherwise, it will be
+ * started with a delay. See {@link #START_PROCESSING_REQUESTS_DELAY_MILLIS}.
+ * @param isConf indicate whether call log is for Conference Url call
+ */
+ protected void enqueueRequest(String number, String countryIso, ContactInfo callLogInfo,
+ boolean immediate, boolean isConf) {
+ ContactInfoRequest request = new ContactInfoRequest(number, countryIso, callLogInfo,
+ isConf);
synchronized (mRequests) {
if (!mRequests.contains(request)) {
mRequests.add(request);
diff --git a/src/com/android/dialer/contactinfo/ContactInfoRequest.java b/src/com/android/dialer/contactinfo/ContactInfoRequest.java
index ec5c119..1171dcf 100644
--- a/src/com/android/dialer/contactinfo/ContactInfoRequest.java
+++ b/src/com/android/dialer/contactinfo/ContactInfoRequest.java
@@ -31,11 +31,18 @@
public final String countryIso;
/** The cached contact information stored in the call log. */
public final ContactInfo callLogInfo;
+ public final boolean isConf;
public ContactInfoRequest(String number, String countryIso, ContactInfo callLogInfo) {
+ this(number, countryIso, callLogInfo, false);
+ }
+
+ public ContactInfoRequest(String number, String countryIso, ContactInfo callLogInfo,
+ boolean isConf) {
this.number = number;
this.countryIso = countryIso;
this.callLogInfo = callLogInfo;
+ this.isConf = isConf;
}
@Override