aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2020-12-03 15:26:58 -0800
committerTyler Gunn <tgunn@google.com>2020-12-04 23:30:53 +0000
commit4c94266286279d545f3a770bad8a641d46164ee4 (patch)
treeedc2995dd9774f5ceaf7e4f5881db590dfad1701
parent6f4ceb405ac18493d5484fc7343b998e12282890 (diff)
downloadContactsProvider-4c94266286279d545f3a770bad8a641d46164ee4.tar.gz
Ensure update/deletes in the call log notify content observers.
Update/delete in CallLogProvider used to use DbModifierWithNotification which took care of this. Due to a change made to CallLogProvider to use a query builder class, DbModifierWithNotification was not being used any more. Made the notifyCallLogChange accessible as a static method and also use it in CallLogProvider on update/delete. There is a bunch of other logic in DbModifierWithNotification in the update method that needs to be migrated over, however this change fixes the immediate bug. Test: Manual test; clear the call log and verify Dialer recents lists updates itself immediately. Test: Manual test: clear a single row in the call log and verify dialer recent list updates itself immediately. Test: Added update/delete CTS tests that verify content observer triggers for update and delete. Fixes: 174243006 Bug: 174211399 Change-Id: Ie716d3d739c6854d7c40a1f94498bff15931b272 Merged-In: Ie716d3d739c6854d7c40a1f94498bff15931b272
-rw-r--r--src/com/android/providers/contacts/CallLogProvider.java12
-rw-r--r--src/com/android/providers/contacts/DbModifierWithNotification.java16
2 files changed, 18 insertions, 10 deletions
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index ebe111f1..7a610151 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -563,7 +563,11 @@ public class CallLogProvider extends ContentProvider {
throw new UnsupportedOperationException("Cannot update URL: " + uri);
}
- return qb.update(db, values, selectionBuilder.build(), selectionArgs);
+ int rowsUpdated = qb.update(db, values, selectionBuilder.build(), selectionArgs);
+ if (rowsUpdated > 0) {
+ DbModifierWithNotification.notifyCallLogChange(getContext());
+ }
+ return rowsUpdated;
}
private int deleteInternal(Uri uri, String selection, String[] selectionArgs) {
@@ -596,7 +600,11 @@ public class CallLogProvider extends ContentProvider {
case CALLS:
// TODO: Special case - We may want to forward the delete request on user 0 to the
// shadow provider too.
- return qb.delete(db, selectionBuilder.build(), selectionArgs);
+ int deletedCount = qb.delete(db, selectionBuilder.build(), selectionArgs);
+ if (deletedCount > 0) {
+ DbModifierWithNotification.notifyCallLogChange(getContext());
+ }
+ return deletedCount;
default:
throw new UnsupportedOperationException("Cannot delete that URL: " + uri);
}
diff --git a/src/com/android/providers/contacts/DbModifierWithNotification.java b/src/com/android/providers/contacts/DbModifierWithNotification.java
index 852301d3..03ebd1f1 100644
--- a/src/com/android/providers/contacts/DbModifierWithNotification.java
+++ b/src/com/android/providers/contacts/DbModifierWithNotification.java
@@ -109,7 +109,7 @@ public class DbModifierWithNotification implements DatabaseModifier {
packagesModified);
}
if (rowId > 0 && mIsCallsTable) {
- notifyCallLogChange();
+ notifyCallLogChange(mContext);
}
return rowId;
}
@@ -126,20 +126,20 @@ public class DbModifierWithNotification implements DatabaseModifier {
ContentUris.withAppendedId(mBaseUri, rowId), packagesModified);
}
if (rowId > 0 && mIsCallsTable) {
- notifyCallLogChange();
+ notifyCallLogChange(mContext);
}
return rowId;
}
- private void notifyCallLogChange() {
- mContext.getContentResolver().notifyChange(Calls.CONTENT_URI, null, false);
+ public static void notifyCallLogChange(Context context) {
+ context.getContentResolver().notifyChange(Calls.CONTENT_URI, null, false);
Intent intent = new Intent("com.android.internal.action.CALL_LOG_CHANGE");
intent.setComponent(new ComponentName("com.android.calllogbackup",
"com.android.calllogbackup.CallLogChangeReceiver"));
- if (!mContext.getPackageManager().queryBroadcastReceivers(intent, 0).isEmpty()) {
- mContext.sendBroadcast(intent);
+ if (!context.getPackageManager().queryBroadcastReceivers(intent, 0).isEmpty()) {
+ context.sendBroadcast(intent);
}
}
@@ -201,7 +201,7 @@ public class DbModifierWithNotification implements DatabaseModifier {
notifyVoicemailChange(mBaseUri, packagesModified);
}
if (count > 0 && mIsCallsTable) {
- notifyCallLogChange();
+ notifyCallLogChange(mContext);
}
if (hasMarkedRead) {
// A "New" voicemail has been marked as read by the server. This voicemail is no longer
@@ -283,7 +283,7 @@ public class DbModifierWithNotification implements DatabaseModifier {
notifyVoicemailChange(mBaseUri, packagesModified);
}
if (count > 0 && mIsCallsTable) {
- notifyCallLogChange();
+ notifyCallLogChange(mContext);
}
return count;
}