Look up missed call contact info in cache.
am: 4f84f9c23d

* commit '4f84f9c23d1175800a4575097ce3acb1b958a35a':
  Look up missed call contact info in cache.
diff --git a/src/com/android/dialer/calllog/CallLogNotificationsHelper.java b/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
index df08e4d..64ccd5f 100644
--- a/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
+++ b/src/com/android/dialer/calllog/CallLogNotificationsHelper.java
@@ -31,6 +31,7 @@
 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 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 @@
     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 @@
 
     /**
      * 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 @@
         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 ad9af42..8811baf 100644
--- a/src/com/android/dialer/calllog/MissedCallNotifier.java
+++ b/src/com/android/dialer/calllog/MissedCallNotifier.java
@@ -26,7 +26,6 @@
 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 @@
                     .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 =