summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllog/database
diff options
context:
space:
mode:
authorzachh <zachh@google.com>2017-12-07 17:59:20 -0800
committerCopybara-Service <copybara-piper@google.com>2017-12-07 18:35:07 -0800
commit81a7b490ebbf2d9a4213a79b52e7b999aa076b7f (patch)
tree8cc90871e7cef664d498d359b57a95ff7a1b6a79 /java/com/android/dialer/calllog/database
parent36a384e04fd9b8ba1d53500afb7e0055e4e4bb99 (diff)
Implemented PhoneLookupDataSource#onSuccesfulFill.
Required adding applyBatch functionality to PhoneLookupHistoryContentProvider so that the updates can be performed in a transaction. This code was just copied and modified from AnnotatedCallLogContentProvider. Also removed the trigger which limited the size of the PhoneLookupHistory, since we now delete rows from PhoneLookupHistory when the last occurrence of a number is deleted from AnnotatedCallLog. Since AnnotatedCallLog is bounded to 1000 rows PhoneLookupHistory is now indirectly bounded by that as well. Bug: 34672501 Test: unit PiperOrigin-RevId: 178323464 Change-Id: I233163fe70641b0e4b1d4c5c0e8970ad0b4b167d
Diffstat (limited to 'java/com/android/dialer/calllog/database')
-rw-r--r--java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java40
1 files changed, 23 insertions, 17 deletions
diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java
index 825e84f91..2427624a4 100644
--- a/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java
+++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogContentProvider.java
@@ -245,12 +245,12 @@ public class AnnotatedCallLogContentProvider extends ContentProvider {
throw new IllegalArgumentException("Unknown uri: " + uri);
}
int rows = database.delete(AnnotatedCallLog.TABLE, selection, selectionArgs);
- if (rows > 0) {
- if (!isApplyingBatch()) {
- notifyChange(uri);
- }
- } else {
+ if (rows == 0) {
LogUtil.w("AnnotatedCallLogContentProvider.delete", "no rows deleted");
+ return rows;
+ }
+ if (!isApplyingBatch()) {
+ notifyChange(uri);
}
return rows;
}
@@ -268,7 +268,15 @@ public class AnnotatedCallLogContentProvider extends ContentProvider {
int match = uriMatcher.match(uri);
switch (match) {
case ANNOTATED_CALL_LOG_TABLE_CODE:
- break;
+ int rows = database.update(AnnotatedCallLog.TABLE, values, selection, selectionArgs);
+ if (rows == 0) {
+ LogUtil.w("AnnotatedCallLogContentProvider.update", "no rows updated");
+ return rows;
+ }
+ if (!isApplyingBatch()) {
+ notifyChange(uri);
+ }
+ return rows;
case ANNOTATED_CALL_LOG_TABLE_ID_CODE:
Assert.checkArgument(
!values.containsKey(AnnotatedCallLog._ID), "Do not specify _ID when updating by ID");
@@ -276,23 +284,21 @@ public class AnnotatedCallLogContentProvider extends ContentProvider {
Assert.checkArgument(
selectionArgs == null, "Do not specify selection args when updating by ID");
selection = getSelectionWithId(ContentUris.parseId(uri));
- break;
+ rows = database.update(AnnotatedCallLog.TABLE, values, selection, selectionArgs);
+ if (rows == 0) {
+ LogUtil.w("AnnotatedCallLogContentProvider.update", "no rows updated");
+ return rows;
+ }
+ if (!isApplyingBatch()) {
+ notifyChange(uri);
+ }
+ return rows;
case ANNOTATED_CALL_LOG_TABLE_DISTINCT_NUMBER_CODE:
- throw new UnsupportedOperationException();
case COALESCED_ANNOTATED_CALL_LOG_TABLE_CODE:
throw new UnsupportedOperationException();
default:
throw new IllegalArgumentException("Unknown uri: " + uri);
}
- int rows = database.update(AnnotatedCallLog.TABLE, values, selection, selectionArgs);
- if (rows > 0) {
- if (!isApplyingBatch()) {
- notifyChange(uri);
- }
- } else {
- LogUtil.w("AnnotatedCallLogContentProvider.update", "no rows updated");
- }
- return rows;
}
/**