Merge "Use photo id when available."
diff --git a/src/com/android/contacts/PhoneCallDetails.java b/src/com/android/contacts/PhoneCallDetails.java
index 78ac9b3..547695c 100644
--- a/src/com/android/contacts/PhoneCallDetails.java
+++ b/src/com/android/contacts/PhoneCallDetails.java
@@ -53,6 +53,8 @@
     /**
      * The photo URI of the picture of the contact that is associated with this phone call or
      * null if there is none.
+     * <p>
+     * This is meant to store the high-res photo only.
      */
     public final Uri photoUri;
 
diff --git a/src/com/android/contacts/calllog/CallLogAdapter.java b/src/com/android/contacts/calllog/CallLogAdapter.java
index bed721a..7cd73a5 100644
--- a/src/com/android/contacts/calllog/CallLogAdapter.java
+++ b/src/com/android/contacts/calllog/CallLogAdapter.java
@@ -329,11 +329,8 @@
                 info.number = dataTableCursor.getString(
                         dataTableCursor.getColumnIndex(Data.DATA1));
                 info.normalizedNumber = null;  // meaningless for SIP addresses
-                final String thumbnailUriString = dataTableCursor.getString(
-                        dataTableCursor.getColumnIndex(Data.PHOTO_THUMBNAIL_URI));
-                info.thumbnailUri = thumbnailUriString == null
-                        ? null
-                        : Uri.parse(thumbnailUriString);
+                info.photoId = dataTableCursor.getLong(
+                        dataTableCursor.getColumnIndex(Data.PHOTO_ID));
             } else {
                 info = ContactInfo.EMPTY;
             }
@@ -377,11 +374,7 @@
                         .getString(PhoneQuery.MATCHED_NUMBER);
                 info.normalizedNumber = phonesCursor
                         .getString(PhoneQuery.NORMALIZED_NUMBER);
-                final String thumbnailUriString = phonesCursor.getString(
-                        PhoneQuery.THUMBNAIL_URI);
-                info.thumbnailUri = thumbnailUriString == null
-                        ? null
-                        : Uri.parse(thumbnailUriString);
+                info.photoId = phonesCursor.getLong(PhoneQuery.PHOTO_ID);
             } else {
                 info = ContactInfo.EMPTY;
             }
@@ -635,7 +628,7 @@
         final String name = info.name;
         final int ntype = info.type;
         final String label = info.label;
-        final Uri thumbnailUri = info.thumbnailUri;
+        final long photoId = info.photoId;
         final int[] callTypes = getCallTypes(c, count);
         final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION);
         final PhoneCallDetails details;
@@ -643,15 +636,16 @@
             details = new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
                     callTypes, date, duration);
         } else {
+            // We do not pass a photo id since we do not need the high-res picture.
             details = new PhoneCallDetails(number, formattedNumber, countryIso, geocode,
-                    callTypes, date, duration, name, ntype, label, contactUri , thumbnailUri);
+                    callTypes, date, duration, name, ntype, label, contactUri, null);
         }
 
         final boolean isNew = CallLogQuery.isNewSection(c);
         // New items also use the highlighted version of the text.
         final boolean isHighlighted = isNew;
         mCallLogViewsHelper.setPhoneCallDetails(views, details, isHighlighted);
-        setPhoto(views, thumbnailUri, contactUri);
+        setPhoto(views, photoId, contactUri);
 
         // Listen for the first draw
         if (mPreDrawListener == null) {
@@ -718,7 +712,7 @@
         info.number = c.getString(CallLogQuery.NUMBER);
         info.formattedNumber = info.number;
         info.normalizedNumber = info.number;
-        info.thumbnailUri = null;
+        info.photoId = 0;
         return info;
     }
 
@@ -740,9 +734,9 @@
         return callTypes;
     }
 
-    private void setPhoto(CallLogListItemViews views, Uri thumbnailUri, Uri contactUri) {
+    private void setPhoto(CallLogListItemViews views, long photoId, Uri contactUri) {
         views.quickContactView.assignContactUri(contactUri);
-        mContactPhotoManager.loadPhoto(views.quickContactView, thumbnailUri);
+        mContactPhotoManager.loadPhoto(views.quickContactView, photoId);
     }
 
     /**
diff --git a/src/com/android/contacts/calllog/ContactInfo.java b/src/com/android/contacts/calllog/ContactInfo.java
index 58c5f6a..c28018c 100644
--- a/src/com/android/contacts/calllog/ContactInfo.java
+++ b/src/com/android/contacts/calllog/ContactInfo.java
@@ -32,7 +32,8 @@
     public String number;
     public String formattedNumber;
     public String normalizedNumber;
-    public Uri thumbnailUri;
+    /** The photo for the contact, if available. */
+    public long photoId;
 
     public static ContactInfo EMPTY = new ContactInfo();
 
@@ -61,7 +62,7 @@
         if (!TextUtils.equals(number, other.number)) return false;
         // Ignore formatted number.
         if (!TextUtils.equals(normalizedNumber, other.normalizedNumber)) return false;
-        if (!UriUtils.areEqual(thumbnailUri, other.thumbnailUri)) return false;
+        if (photoId != other.photoId) return false;
         return true;
     }
 }
\ No newline at end of file
diff --git a/src/com/android/contacts/calllog/PhoneQuery.java b/src/com/android/contacts/calllog/PhoneQuery.java
index 52faa8b..a53e5c8 100644
--- a/src/com/android/contacts/calllog/PhoneQuery.java
+++ b/src/com/android/contacts/calllog/PhoneQuery.java
@@ -29,7 +29,7 @@
             PhoneLookup.LABEL,
             PhoneLookup.NUMBER,
             PhoneLookup.NORMALIZED_NUMBER,
-            PhoneLookup.PHOTO_THUMBNAIL_URI,
+            PhoneLookup.PHOTO_ID,
             PhoneLookup.LOOKUP_KEY};
 
     public static final int PERSON_ID = 0;
@@ -38,6 +38,6 @@
     public static final int LABEL = 3;
     public static final int MATCHED_NUMBER = 4;
     public static final int NORMALIZED_NUMBER = 5;
-    public static final int THUMBNAIL_URI = 6;
+    public static final int PHOTO_ID = 6;
     public static final int LOOKUP_KEY = 7;
 }
\ No newline at end of file
diff --git a/src/com/android/contacts/util/UriUtils.java b/src/com/android/contacts/util/UriUtils.java
index 28874f2..7ef8786 100644
--- a/src/com/android/contacts/util/UriUtils.java
+++ b/src/com/android/contacts/util/UriUtils.java
@@ -35,4 +35,12 @@
         }
         return uri1.equals(uri2);
     }
+
+    /** Parses a string into a URI and returns null if the given string is null. */
+    public static Uri parseUriOrNull(String uriString) {
+        if (uriString == null) {
+            return null;
+        }
+        return Uri.parse(uriString);
+    }
 }
diff --git a/tests/src/com/android/contacts/activities/CallLogActivityTests.java b/tests/src/com/android/contacts/activities/CallLogActivityTests.java
index 0f43313..b148121 100644
--- a/tests/src/com/android/contacts/activities/CallLogActivityTests.java
+++ b/tests/src/com/android/contacts/activities/CallLogActivityTests.java
@@ -68,8 +68,6 @@
 
     /** A test value for the URI of a contact. */
     private static final Uri TEST_CONTACT_URI = Uri.parse("content://contacts/2");
-    /** A test value for the photo uri of a contact. */
-    private static final Uri TEST_THUMBNAIL_URI = Uri.parse("something://picture/2");
     /** A test value for the country ISO of the phone number in the call log. */
     private static final String TEST_COUNTRY_ISO = "US";
     /** A phone number to be used in tests. */
@@ -462,7 +460,7 @@
         }
         contactInfo.formattedNumber = formattedNumber;
         contactInfo.normalizedNumber = number;
-        contactInfo.thumbnailUri = TEST_THUMBNAIL_URI;
+        contactInfo.photoId = 0;
         mAdapter.injectContactInfoForTest(number, contactInfo);
     }
 
diff --git a/tests/src/com/android/contacts/calllog/CallLogAdapterTest.java b/tests/src/com/android/contacts/calllog/CallLogAdapterTest.java
index 28db896..42733c9 100644
--- a/tests/src/com/android/contacts/calllog/CallLogAdapterTest.java
+++ b/tests/src/com/android/contacts/calllog/CallLogAdapterTest.java
@@ -21,6 +21,7 @@
 import android.content.Context;
 import android.database.MatrixCursor;
 import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
 import android.view.View;
 
 import java.util.List;
@@ -28,6 +29,7 @@
 /**
  * Unit tests for {@link CallLogAdapter}.
  */
+@SmallTest
 public class CallLogAdapterTest extends AndroidTestCase {
     private static final String TEST_NUMBER = "12345678";
     private static final String TEST_NAME = "name";