summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllog/datasources
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2017-10-12 17:17:50 -0700
committerEric Erfanian <erfanian@google.com>2017-10-13 07:30:56 -0700
commit6037deb60e9ef708da2ddcf84a5ef5ccc27d7237 (patch)
treeeb704214aaa229fb264c8ab0e2ac5173973a9ee9 /java/com/android/dialer/calllog/datasources
parentcf83cae3d3cc0d6a53498da88a9ad834fb2ab589 (diff)
Use CONTENT_URI_WITH_VOICEMAIL for SystemCallLogDataSource
Currently the SystemCallLogDataSource queries the call log table with CONTENT_URI. This works for the call log tab, but will not work for the voicemail tab. To allow the voicemail tab to query annotated call log for voicemail information, we need to surface up voicemail data from the system call log data source into the annotated call log. Bug: 64882313,33006245 Test: Unit tests, also verified that in the call log only the non-voicemail entries show PiperOrigin-RevId: 172036196 Change-Id: Ieac855ae854a043207c9ae668280391c790ac33d
Diffstat (limited to 'java/com/android/dialer/calllog/datasources')
-rw-r--r--java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
index 0a965f63e..681a86da7 100644
--- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
@@ -88,7 +88,7 @@ public class SystemCallLogDataSource implements CallLogDataSource {
appContext
.getContentResolver()
.registerContentObserver(
- CallLog.Calls.CONTENT_URI,
+ CallLog.Calls.CONTENT_URI_WITH_VOICEMAIL,
true,
new CallLogObserver(
ThreadUtil.getUiThreadHandler(), appContext, contentObserverCallbacks));
@@ -152,6 +152,9 @@ public class SystemCallLogDataSource implements CallLogDataSource {
@Override
public ContentValues coalesce(List<ContentValues> individualRowsSortedByTimestampDesc) {
// TODO(zachh): Complete implementation.
+
+ assertNoVoicemailsInRows(individualRowsSortedByTimestampDesc);
+
return new RowCombiner(individualRowsSortedByTimestampDesc)
.useMostRecentLong(AnnotatedCallLog.TIMESTAMP)
.useMostRecentLong(AnnotatedCallLog.NEW)
@@ -174,6 +177,15 @@ public class SystemCallLogDataSource implements CallLogDataSource {
.combine();
}
+ private void assertNoVoicemailsInRows(List<ContentValues> individualRowsSortedByTimestampDesc) {
+ for (ContentValues contentValue : individualRowsSortedByTimestampDesc) {
+ if (contentValue.getAsLong(AnnotatedCallLog.CALL_TYPE) != null) {
+ Assert.checkArgument(
+ contentValue.getAsLong(AnnotatedCallLog.CALL_TYPE) != Calls.VOICEMAIL_TYPE);
+ }
+ }
+ }
+
@TargetApi(Build.VERSION_CODES.M) // Uses try-with-resources
private void handleInsertsAndUpdates(
Context appContext, CallLogMutations mutations, Set<Long> existingAnnotatedCallLogIds) {
@@ -189,7 +201,7 @@ public class SystemCallLogDataSource implements CallLogDataSource {
appContext
.getContentResolver()
.query(
- Calls.CONTENT_URI, // Excludes voicemail
+ Calls.CONTENT_URI_WITH_VOICEMAIL,
new String[] {
Calls._ID,
Calls.DATE,
@@ -414,7 +426,12 @@ public class SystemCallLogDataSource implements CallLogDataSource {
try (Cursor cursor =
appContext
.getContentResolver()
- .query(Calls.CONTENT_URI, new String[] {Calls._ID}, whereClause, whereArgs, null)) {
+ .query(
+ Calls.CONTENT_URI_WITH_VOICEMAIL,
+ new String[] {Calls._ID},
+ whereClause,
+ whereArgs,
+ null)) {
if (cursor == null) {
LogUtil.e("SystemCallLogDataSource.getIdsFromSystemCallLog", "null cursor");