Use the content of the call log to predict the contact info.
This change re-instroduces the cache stored in the call log table for
the contact info associated with a call.
This is the first part of the necessary changes. In this change, I also
use the stored information, I do not update it when the contact is
actually looked up in the call log.
Bug: 5101753
Change-Id: Ib906e9af06410c2cc295192cd4623b011fa0ad09
diff --git a/src/com/android/contacts/calllog/CallLogAdapter.java b/src/com/android/contacts/calllog/CallLogAdapter.java
index cbe075b..7e934b6 100644
--- a/src/com/android/contacts/calllog/CallLogAdapter.java
+++ b/src/com/android/contacts/calllog/CallLogAdapter.java
@@ -541,6 +541,8 @@
final String formattedNumber;
final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
+ final ContactInfo cachedContactInfo = getContactInfoFromCallLog(c);
+
views.primaryActionView.setTag(
IntentProvider.getCallDetailIntentProvider(
this, c.getPosition(), c.getLong(CallLogQuery.ID), count));
@@ -592,6 +594,10 @@
}
}
+ if (info == null || info == ContactInfo.EMPTY) {
+ info = cachedContactInfo;
+ }
+
final long personId = info.personId;
final String name = info.name;
final int ntype = info.type;
@@ -623,6 +629,22 @@
}
}
+ /** Returns the contact information as stored in the call log. */
+ private ContactInfo getContactInfoFromCallLog(Cursor c) {
+ ContactInfo info = new ContactInfo();
+ info.personId = -1;
+ info.name = c.getString(CallLogQuery.CACHED_NAME);
+ info.type = c.getInt(CallLogQuery.CACHED_NUMBER_TYPE);
+ info.label = c.getString(CallLogQuery.CACHED_NUMBER_LABEL);
+ // TODO: This should be added to the call log cached values.
+ info.number = c.getString(CallLogQuery.NUMBER);
+ info.formattedNumber = info.number;
+ info.normalizedNumber = info.number;
+ info.thumbnailUri = null;
+ info.lookupKey = null;
+ return info;
+ }
+
/**
* Returns the call types for the given number of items in the cursor.
* <p>
diff --git a/src/com/android/contacts/calllog/CallLogQuery.java b/src/com/android/contacts/calllog/CallLogQuery.java
index 4422a35..f596032 100644
--- a/src/com/android/contacts/calllog/CallLogQuery.java
+++ b/src/com/android/contacts/calllog/CallLogQuery.java
@@ -34,6 +34,9 @@
Calls.COUNTRY_ISO,
Calls.VOICEMAIL_URI,
Calls.GEOCODED_LOCATION,
+ Calls.CACHED_NAME,
+ Calls.CACHED_NUMBER_TYPE,
+ Calls.CACHED_NUMBER_LABEL,
};
public static final int ID = 0;
@@ -44,6 +47,9 @@
public static final int COUNTRY_ISO = 5;
public static final int VOICEMAIL_URI = 6;
public static final int GEOCODED_LOCATION = 7;
+ public static final int CACHED_NAME = 8;
+ public static final int CACHED_NUMBER_TYPE = 9;
+ public static final int CACHED_NUMBER_LABEL = 10;
/**
* The name of the synthetic "section" column.
@@ -53,7 +59,7 @@
*/
public static final String SECTION_NAME = "section";
/** The index of the "section" column in the projection. */
- public static final int SECTION = 8;
+ public static final int SECTION = 11;
/** The value of the "section" column for the header of the new section. */
public static final int SECTION_NEW_HEADER = 0;
/** The value of the "section" column for the items of the new section. */
diff --git a/src/com/android/contacts/calllog/CallLogQueryHandler.java b/src/com/android/contacts/calllog/CallLogQueryHandler.java
index bf9a7da..b87a850 100644
--- a/src/com/android/contacts/calllog/CallLogQueryHandler.java
+++ b/src/com/android/contacts/calllog/CallLogQueryHandler.java
@@ -105,7 +105,7 @@
new MatrixCursor(CallLogQuery.EXTENDED_PROJECTION);
// The values in this row correspond to default values for _PROJECTION from CallLogQuery
// plus the section value.
- matrixCursor.addRow(new Object[]{ -1L, "", 0L, 0L, 0, "", "", "", section });
+ matrixCursor.addRow(new Object[]{ -1L, "", 0L, 0L, 0, "", "", "", null, 0, null, section });
return matrixCursor;
}
diff --git a/tests/src/com/android/contacts/activities/CallLogActivityTests.java b/tests/src/com/android/contacts/activities/CallLogActivityTests.java
index 1e3ac0e..a0fce2d 100644
--- a/tests/src/com/android/contacts/activities/CallLogActivityTests.java
+++ b/tests/src/com/android/contacts/activities/CallLogActivityTests.java
@@ -62,17 +62,6 @@
@LargeTest
public class CallLogActivityTests
extends ActivityInstrumentationTestCase2<CallLogActivity> {
- private static final String[] EXTENDED_CALL_LOG_PROJECTION = new String[] {
- Calls._ID,
- Calls.NUMBER,
- Calls.DATE,
- Calls.DURATION,
- Calls.TYPE,
- Calls.COUNTRY_ISO,
- Calls.VOICEMAIL_URI,
- Calls.GEOCODED_LOCATION,
- CallLogQuery.SECTION_NAME,
- };
private static final int RAND_DURATION = -1;
private static final long NOW = -1L;
@@ -133,7 +122,7 @@
mAdapter.disableRequestProcessingForTest();
mAdapter.stopRequestProcessing();
mParentView = new FrameLayout(mActivity);
- mCursor = new MatrixCursor(EXTENDED_CALL_LOG_PROJECTION);
+ mCursor = new MatrixCursor(CallLogQuery.EXTENDED_PROJECTION);
buildIconMap();
}
@@ -508,6 +497,9 @@
row.add(TEST_COUNTRY_ISO); // country ISO
row.add(null); // voicemail_uri
row.add(null); // geocoded_location
+ row.add(null); // cached_name
+ row.add(0); // cached_number_type
+ row.add(null); // cached_number_label
row.add(CallLogQuery.SECTION_OLD_ITEM); // section
}
@@ -539,6 +531,9 @@
row.add(TEST_COUNTRY_ISO); // country ISO
row.add(voicemailUri); // voicemail_uri
row.add(null); // geocoded_location
+ row.add(null); // cached_name
+ row.add(0); // cached_number_type
+ row.add(null); // cached_number_label
row.add(CallLogQuery.SECTION_OLD_ITEM); // section
}
diff --git a/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java b/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java
index 8e97fe3..67b72dd 100644
--- a/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java
+++ b/tests/src/com/android/contacts/calllog/CallLogGroupBuilderTest.java
@@ -18,7 +18,6 @@
import static com.google.android.collect.Lists.newArrayList;
-
import android.database.MatrixCursor;
import android.provider.CallLog.Calls;
import android.test.AndroidTestCase;
@@ -223,7 +222,7 @@
}
mCursor.moveToNext();
mCursor.addRow(new Object[]{
- mCursor.getPosition(), number, 0L, 0L, type, "", "", "", section
+ mCursor.getPosition(), number, 0L, 0L, type, "", "", "", null, 0, null, section
});
}
@@ -244,7 +243,9 @@
throw new IllegalArgumentException("not a header section: " + section);
}
mCursor.moveToNext();
- mCursor.addRow(new Object[]{ mCursor.getPosition(), "", 0L, 0L, 0, "", "", "", section });
+ mCursor.addRow(new Object[]{
+ mCursor.getPosition(), "", 0L, 0L, 0, "", "", "", null, 0, null, section
+ });
}
/** Asserts that the group matches the given values. */