diff options
author | Nancy Chen <nancychen@google.com> | 2016-01-27 14:52:29 -0800 |
---|---|---|
committer | Nancy Chen <nancychen@google.com> | 2016-01-27 16:53:24 -0800 |
commit | 4f84f9c23d1175800a4575097ce3acb1b958a35a (patch) | |
tree | bde0071c320a531ac9cf9ad86017ce449d140af2 /src/com/android/dialer/calllog | |
parent | cc42b5953588110cc89b43e72d2b6579757017a1 (diff) |
Look up missed call contact info in cache.
For missed calls that can be identified with Google Caller ID, we want to look
up the contact information in the cache because that's where the
information will be if it was looked up when the call was incoming.
Bug: 22857261
Change-Id: I2563c9f5e99bdc91674b9b46def1eeabeb45794d
Diffstat (limited to 'src/com/android/dialer/calllog')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogNotificationsHelper.java | 31 | ||||
-rw-r--r-- | src/com/android/dialer/calllog/MissedCallNotifier.java | 4 |
2 files changed, 28 insertions, 7 deletions
diff --git a/src/com/android/dialer/calllog/CallLogNotificationsHelper.java b/src/com/android/dialer/calllog/CallLogNotificationsHelper.java index df08e4db9..64ccd5f88 100644 --- a/src/com/android/dialer/calllog/CallLogNotificationsHelper.java +++ b/src/com/android/dialer/calllog/CallLogNotificationsHelper.java @@ -31,6 +31,7 @@ import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; +import com.android.contacts.common.GeoUtil; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.R; import com.android.dialer.util.TelecomUtil; @@ -49,9 +50,12 @@ public class CallLogNotificationsHelper { public static CallLogNotificationsHelper getInstance(Context context) { if (sInstance == null) { ContentResolver contentResolver = context.getContentResolver(); + String countryIso = GeoUtil.getCurrentCountryIso(context); sInstance = new CallLogNotificationsHelper(context, createNewCallsQuery(context, contentResolver), - createNameLookupQuery(context, contentResolver)); + createNameLookupQuery(context, contentResolver), + new ContactInfoHelper(context, countryIso), + countryIso); } return sInstance; } @@ -59,12 +63,17 @@ public class CallLogNotificationsHelper { private final Context mContext; private final NewCallsQuery mNewCallsQuery; private final NameLookupQuery mNameLookupQuery; + private final ContactInfoHelper mContactInfoHelper; + private final String mCurrentCountryIso; CallLogNotificationsHelper(Context context, NewCallsQuery newCallsQuery, - NameLookupQuery nameLookupQuery) { + NameLookupQuery nameLookupQuery, ContactInfoHelper contactInfoHelper, + String countryIso) { mContext = context; mNewCallsQuery = newCallsQuery; mNameLookupQuery = nameLookupQuery; + mContactInfoHelper = contactInfoHelper; + mCurrentCountryIso = countryIso; } /** @@ -89,8 +98,9 @@ public class CallLogNotificationsHelper { /** * Given a number and number information (presentation and country ISO), get the best name - * for display. If the name itself if already available, return that. Otherwise attempt to look - * it up in the database. If that fails, fall back to displaying the number. + * for display. 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 String getName(@Nullable String number, int numberPresentation, @Nullable String countryIso) { @@ -102,11 +112,24 @@ public class CallLogNotificationsHelper { if (!TextUtils.isEmpty(name)) { return name; } + // Look it up in the database. name = mNameLookupQuery.query(number); if (!TextUtils.isEmpty(name)) { return name; } + + if (countryIso == null) { + countryIso = mCurrentCountryIso; + } + + // Look it up in the cache + ContactInfo contactInfo = mContactInfoHelper.lookupNumber(number, countryIso); + + if (contactInfo != null && !TextUtils.isEmpty(contactInfo.name)) { + return contactInfo.name; + } + if (!TextUtils.isEmpty(number)) { // If we cannot lookup the contact, use the number instead. return PhoneNumberUtils.formatNumber(number, countryIso); diff --git a/src/com/android/dialer/calllog/MissedCallNotifier.java b/src/com/android/dialer/calllog/MissedCallNotifier.java index ad9af42b8..8811baff8 100644 --- a/src/com/android/dialer/calllog/MissedCallNotifier.java +++ b/src/com/android/dialer/calllog/MissedCallNotifier.java @@ -26,7 +26,6 @@ import android.provider.CallLog.Calls; import android.text.TextUtils; import android.util.Log; -import com.android.contacts.common.GeoUtil; import com.android.contacts.common.util.PhoneNumberHelper; import com.android.dialer.calllog.CallLogNotificationsHelper.NewCall; import com.android.dialer.DialtactsActivity; @@ -105,8 +104,7 @@ public class MissedCallNotifier { .getName(useCallLog ? newestCall.number : number, useCallLog ? newestCall.numberPresentation : Calls.PRESENTATION_ALLOWED, - useCallLog ? newestCall.countryIso - : GeoUtil.getCurrentCountryIso(mContext)); + useCallLog ? newestCall.countryIso : null); } else { titleResId = R.string.notification_missedCallsTitle; expandedText = |