diff options
Diffstat (limited to 'java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java')
-rw-r--r-- | java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java index 68298e356..825e84f91 100644 --- a/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java +++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java @@ -38,6 +38,7 @@ import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.Coa import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import java.util.ArrayList; +import java.util.Arrays; /** {@link ContentProvider} for the annotated call log. */ public class AnnotatedCallLogContentProvider extends ContentProvider { @@ -51,7 +52,8 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { private static final int ANNOTATED_CALL_LOG_TABLE_CODE = 1; private static final int ANNOTATED_CALL_LOG_TABLE_ID_CODE = 2; - private static final int COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE = 3; + private static final int ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE = 3; + private static final int COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE = 4; private static final UriMatcher uriMatcher = new UriMatcher(UriMatcher.NO_MATCH); @@ -64,6 +66,10 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { ANNOTATED_CALL_LOG_TABLE_ID_CODE); uriMatcher.addURI( AnnotatedCallLogContract.AUTHORITY, + AnnotatedCallLog.DISTINCT_PHONE_NUMBERS, + ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE); + uriMatcher.addURI( + AnnotatedCallLogContract.AUTHORITY, CoalescedAnnotatedCallLog.TABLE, COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE); } @@ -101,8 +107,6 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { switch (match) { case ANNOTATED_CALL_LOG_TABLE_ID_CODE: queryBuilder.appendWhere(AnnotatedCallLog._ID + "=" + ContentUris.parseId(uri)); - // fall through - case ANNOTATED_CALL_LOG_TABLE_CODE: Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder); if (cursor != null) { @@ -112,6 +116,31 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { LogUtil.w("AnnotatedCallLogContentProvider.query", "cursor was null"); } return cursor; + case ANNOTATED_CALL_LOG_TABLE_CODE: + cursor = + queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder); + if (cursor != null) { + cursor.setNotificationUri( + getContext().getContentResolver(), AnnotatedCallLog.CONTENT_URI); + } else { + LogUtil.w("AnnotatedCallLogContentProvider.query", "cursor was null"); + } + return cursor; + case ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE: + Assert.checkArgument( + Arrays.equals(projection, new String[] {AnnotatedCallLog.NUMBER}), + "only NUMBER supported for projection for distinct phone number query, got: %s", + Arrays.toString(projection)); + queryBuilder.setDistinct(true); + cursor = + queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder); + if (cursor != null) { + cursor.setNotificationUri( + getContext().getContentResolver(), AnnotatedCallLog.CONTENT_URI); + } else { + LogUtil.w("AnnotatedCallLogContentProvider.query", "cursor was null"); + } + return cursor; case COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE: Assert.checkArgument( projection == CoalescedAnnotatedCallLog.ALL_COLUMNS, @@ -170,6 +199,8 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { values.put(AnnotatedCallLog._ID, idFromUri); } break; + case ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE: + throw new UnsupportedOperationException(); case COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE: throw new UnsupportedOperationException("coalesced call log does not support inserting"); default: @@ -206,6 +237,8 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { Assert.checkArgument(id != -1, "error parsing id from uri %s", uri); selection = getSelectionWithId(id); break; + case ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE: + throw new UnsupportedOperationException(); case COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE: throw new UnsupportedOperationException("coalesced call log does not support deleting"); default: @@ -244,8 +277,10 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { selectionArgs == null, "Do not specify selection args when updating by ID"); selection = getSelectionWithId(ContentUris.parseId(uri)); break; + case ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE: + throw new UnsupportedOperationException(); case COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE: - throw new UnsupportedOperationException("coalesced call log does not support updating"); + throw new UnsupportedOperationException(); default: throw new IllegalArgumentException("Unknown uri: " + uri); } @@ -287,6 +322,8 @@ public class AnnotatedCallLogContentProvider extends ContentProvider { case ANNOTATED_CALL_LOG_TABLE_ID_CODE: // These are allowed values, continue. break; + case ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE: + throw new UnsupportedOperationException(); case COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE: throw new UnsupportedOperationException( "coalesced call log does not support applyBatch"); |