summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2016-02-01 19:54:33 +0000
committerVictor Chang <vichang@google.com>2016-02-04 14:45:09 +0000
commit1dbbda3b035f2e1e581bb8c403b1d351d2ccdbc9 (patch)
treedcc338ab7a444fde92e2f249add6ca34378c1317 /src/com/android/dialer/calllog/CallLogNotificationsHelper.java
parent44d31642d0549c56737b58c7e7a5b92b0bc5ffcd (diff)
Show work call title for missed call notification
1. return complete ContactInfo in CallLogNotificationsHelper 2. use ContactInfo.userType to decide use work call title or not BUG=26902076 Change-Id: Ic58fea1002de053ba69bc0aff06691b8a8605e64
Diffstat (limited to 'src/com/android/dialer/calllog/CallLogNotificationsHelper.java')
-rw-r--r--src/com/android/dialer/calllog/CallLogNotificationsHelper.java63
1 files changed, 44 insertions, 19 deletions
diff --git a/src/com/android/dialer/calllog/CallLogNotificationsHelper.java b/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
index 64ccd5f88..6abf241b4 100644
--- a/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
+++ b/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
@@ -26,6 +26,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.PhoneLookup;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
@@ -104,37 +105,61 @@ public class CallLogNotificationsHelper {
*/
public String getName(@Nullable String number, int numberPresentation,
@Nullable String countryIso) {
- String name = PhoneNumberDisplayUtil.getDisplayName(
+ return getContactInfo(number, numberPresentation, countryIso).name;
+ }
+
+ /**
+ * Given a number and number information (presentation and country ISO), get
+ * {@link ContactInfo}. If the name is empty but we have a special presentation, display that.
+ * Otherwise attempt to look it up in the database or the cache.
+ * If that fails, fall back to displaying the number.
+ */
+ public @NonNull ContactInfo getContactInfo(@Nullable String number, int numberPresentation,
+ @Nullable String countryIso) {
+ if (countryIso == null) {
+ countryIso = mCurrentCountryIso;
+ }
+
+ ContactInfo contactInfo = new ContactInfo();
+ contactInfo.number = number;
+ contactInfo.formattedNumber = PhoneNumberUtils.formatNumber(number, countryIso);
+ // contactInfo.normalizedNumber is not PhoneNumberUtils.normalizeNumber. Read ContactInfo.
+ contactInfo.normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
+
+ // 1. Special number representation.
+ contactInfo.name = PhoneNumberDisplayUtil.getDisplayName(
mContext,
number,
numberPresentation,
false).toString();
- if (!TextUtils.isEmpty(name)) {
- return name;
+ if (!TextUtils.isEmpty(contactInfo.name)) {
+ return contactInfo;
}
- // Look it up in the database.
- name = mNameLookupQuery.query(number);
- if (!TextUtils.isEmpty(name)) {
- return name;
- }
-
- if (countryIso == null) {
- countryIso = mCurrentCountryIso;
+ // 2. Personal ContactsProvider phonelookup query.
+ contactInfo.name = mNameLookupQuery.query(number);
+ if (!TextUtils.isEmpty(contactInfo.name)) {
+ return contactInfo;
}
- // Look it up in the cache
- ContactInfo contactInfo = mContactInfoHelper.lookupNumber(number, countryIso);
+ // 3. Look it up in the cache.
+ ContactInfo cachedContactInfo = mContactInfoHelper.lookupNumber(number, countryIso);
- if (contactInfo != null && !TextUtils.isEmpty(contactInfo.name)) {
- return contactInfo.name;
+ if (cachedContactInfo != null && !TextUtils.isEmpty(cachedContactInfo.name)) {
+ return cachedContactInfo;
}
- if (!TextUtils.isEmpty(number)) {
- // If we cannot lookup the contact, use the number instead.
- return PhoneNumberUtils.formatNumber(number, countryIso);
+ if (!TextUtils.isEmpty(contactInfo.formattedNumber)) {
+ // 4. If we cannot lookup the contact, use the formatted number instead.
+ contactInfo.name = contactInfo.formattedNumber;
+ } else if (!TextUtils.isEmpty(number)) {
+ // 5. If number can't be formatted, use number.
+ contactInfo.name = number;
+ } else {
+ // 6. Otherwise, it's unknown number.
+ contactInfo.name = mContext.getResources().getString(R.string.unknown);
}
- return mContext.getResources().getString(R.string.unknown);
+ return contactInfo;
}
/** Removes the missed call notifications. */