Merge "Fix Exchange directory lookup for phone queries." into jb-ub-mail-ur10
diff --git a/src/com/android/exchange/provider/ExchangeDirectoryProvider.java b/src/com/android/exchange/provider/ExchangeDirectoryProvider.java
index 9f04a95..6eea16e 100644
--- a/src/com/android/exchange/provider/ExchangeDirectoryProvider.java
+++ b/src/com/android/exchange/provider/ExchangeDirectoryProvider.java
@@ -474,6 +474,12 @@
                 row[contactIdIndex] = contactId;
             }
 
+            if (lookupIndex != -1) {
+                // We use the packed string as our lookup key; it contains ALL of the gal data
+                // We do this because we are not able to provide a stable id to ContactsProvider
+                row[lookupIndex] = Uri.encode(galDataRow.toPackedString());
+            }
+
             if (isPhoneFilter) {
                 final Set<String> uniqueNumbers = new HashSet<String>();
 
@@ -505,11 +511,6 @@
                 if (idIndex != -1) {
                     row[idIndex] = id;
                 }
-                if (lookupIndex != -1) {
-                    // We use the packed string as our lookup key; it contains ALL of the gal data
-                    // We do this because we are not able to provide a stable id to ContactsProvider
-                    row[lookupIndex] = Uri.encode(galDataRow.toPackedString());
-                }
                 sortedResultsMap.put(new GalSortKey(sortName, id), row.clone());
                 id++;
             }
@@ -524,7 +525,7 @@
     }
 
     private void addPhoneInfo(List<PhoneInfo> phones, String number, int type) {
-        if (number != null) {
+        if (!TextUtils.isEmpty(number)) {
             phones.add(new PhoneInfo(number, type));
         }
     }