summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-12-12 23:18:50 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-12-12 23:18:50 +0000
commit888e6b1499f7be68f2d33f870a57cd7e2a58dd93 (patch)
tree85148446a15528867fba0d7353b024081d9e0a5a /java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
parentab544521b21566b12a42e539d119c76dd5243a2d (diff)
parent75d67f5d83bdb28c6254cf064d09ac24fc9ae928 (diff)
Merge changes I45978ea4,Ia85b1008,I9e68c561,I9255dd3c
* changes: BEGIN_PUBLIC Automated rollback of changelist 172683494 BEGIN_PUBLIC Automated rollback of changelist 172956409 Download and play voicemails from server when not locally available. Updated writing of PhoneLookup columns in annotated call log.
Diffstat (limited to 'java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java')
-rw-r--r--java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java31
1 files changed, 23 insertions, 8 deletions
diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
index fa7d3be16..93e841409 100644
--- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java
@@ -32,6 +32,7 @@ import com.android.dialer.DialerPhoneNumber;
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog;
import com.android.dialer.calllog.datasources.CallLogDataSource;
import com.android.dialer.calllog.datasources.CallLogMutations;
+import com.android.dialer.calllog.datasources.util.RowCombiner;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
import com.android.dialer.common.concurrent.Annotations.LightweightExecutor;
@@ -260,8 +261,13 @@ public final class PhoneLookupDataSource implements CallLogDataSource {
@WorkerThread
@Override
public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) {
- // TODO(zachh): Implementation.
- return new ContentValues();
+ return new RowCombiner(individualRowsSortedByTimestampDesc)
+ .useMostRecentString(AnnotatedCallLog.NAME)
+ .useMostRecentString(AnnotatedCallLog.NUMBER_TYPE_LABEL)
+ .useMostRecentString(AnnotatedCallLog.PHOTO_URI)
+ .useMostRecentLong(AnnotatedCallLog.PHOTO_ID)
+ .useMostRecentString(AnnotatedCallLog.LOOKUP_URI)
+ .combine();
}
@MainThread
@@ -434,7 +440,7 @@ public final class PhoneLookupDataSource implements CallLogDataSource {
PhoneLookupInfo phoneLookupInfo = existingInfo.get(id);
// Existing info might be missing if data was cleared or for other reasons.
if (phoneLookupInfo != null) {
- contentValues.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo));
+ updateContentValues(contentValues, phoneLookupInfo);
}
}
}
@@ -474,17 +480,17 @@ public final class PhoneLookupDataSource implements CallLogDataSource {
* mutations from PhoneLookupHistory; in this case "John" would be copied during
* populateInserts() and there wouldn't be further updates needed here.
*/
- contentValuesToInsert.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo));
+ updateContentValues(contentValuesToInsert, phoneLookupInfo);
continue;
}
ContentValues contentValuesToUpdate = mutations.getUpdates().get(id);
if (contentValuesToUpdate != null) {
- contentValuesToUpdate.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo));
+ updateContentValues(contentValuesToUpdate, phoneLookupInfo);
continue;
}
// Else this row is not already scheduled for insert or update and we need to schedule it.
ContentValues contentValues = new ContentValues();
- contentValues.put(AnnotatedCallLog.NAME, selectName(phoneLookupInfo));
+ updateContentValues(contentValues, phoneLookupInfo);
mutations.getUpdates().put(id, contentValues);
}
}
@@ -525,8 +531,17 @@ public final class PhoneLookupDataSource implements CallLogDataSource {
return normalizedNumbersToDelete;
}
- private static String selectName(PhoneLookupInfo phoneLookupInfo) {
- return PhoneLookupSelector.selectName(phoneLookupInfo);
+ private static void updateContentValues(
+ ContentValues contentValues, PhoneLookupInfo phoneLookupInfo) {
+ contentValues.put(AnnotatedCallLog.NAME, PhoneLookupSelector.selectName(phoneLookupInfo));
+ contentValues.put(
+ AnnotatedCallLog.PHOTO_URI, PhoneLookupSelector.selectPhotoUri(phoneLookupInfo));
+ contentValues.put(
+ AnnotatedCallLog.PHOTO_ID, PhoneLookupSelector.selectPhotoId(phoneLookupInfo));
+ contentValues.put(
+ AnnotatedCallLog.LOOKUP_URI, PhoneLookupSelector.selectLookupUri(phoneLookupInfo));
+ contentValues.put(
+ AnnotatedCallLog.NUMBER_TYPE_LABEL, PhoneLookupSelector.selectNumberLabel(phoneLookupInfo));
}
private static Uri numberUri(String number) {