From 2e757d904e62dbf5bc0b028626fa9319ccc38c45 Mon Sep 17 00:00:00 2001 From: Debashish Chatterjee Date: Tue, 9 Aug 2011 10:35:07 +0100 Subject: Notify callog uri if a change is made through voicemail provider. DbModifierWithVmNotification till now only notified to voicemail uri content observers for change made through call log provider. We need the otherway round as well so that any change made to a voicemail entry through the voicemail provider should be notified to listeners of calllog uri. This is needed to make call log auto refresh work when a new voicemail is inserted. DbModifierWithVmNotification is now renamed to DbModifierWithNotification and suports both ways notification. Notifications generated by call log provider as well is now routed through this class. Bug: 5055868 Change-Id: I2de8c9867445bcb86ce94a8600acc726266c8008 --- .../providers/contacts/CallLogProvider.java | 33 +++++++++------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'src/com/android/providers/contacts/CallLogProvider.java') diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java index 24bfbbc..f37e62b 100644 --- a/src/com/android/providers/contacts/CallLogProvider.java +++ b/src/com/android/providers/contacts/CallLogProvider.java @@ -182,7 +182,6 @@ public class CallLogProvider extends ContentProvider { } long rowId = getDatabaseModifier(mCallsInserter).insert(values); if (rowId > 0) { - notifyChange(); return ContentUris.withAppendedId(uri, rowId); } return null; @@ -214,12 +213,8 @@ public class CallLogProvider extends ContentProvider { throw new UnsupportedOperationException("Cannot update URL: " + uri); } - int count = getDatabaseModifier(db).update(Tables.CALLS, values, - selectionBuilder.build(), selectionArgs); - if (count > 0) { - notifyChange(); - } - return count; + return getDatabaseModifier(db).update(Tables.CALLS, values, selectionBuilder.build(), + selectionArgs); } @Override @@ -231,35 +226,33 @@ public class CallLogProvider extends ContentProvider { final int matchedUriId = sURIMatcher.match(uri); switch (matchedUriId) { case CALLS: - int count = getDatabaseModifier(db).delete(Tables.CALLS, + return getDatabaseModifier(db).delete(Tables.CALLS, selectionBuilder.build(), selectionArgs); - if (count > 0) { - notifyChange(); - } - return count; - default: throw new UnsupportedOperationException("Cannot delete that URL: " + uri); } } - protected void notifyChange() { - getContext().getContentResolver().notifyChange(CallLog.CONTENT_URI, null, - false /* wake up sync adapters */); - } - // Work around to let the test code override the context. getContext() is final so cannot be // overridden. protected Context context() { return getContext(); } + /** + * Returns a {@link DatabaseModifier} that takes care of sending necessary notifications + * after the operation is performed. + */ private DatabaseModifier getDatabaseModifier(SQLiteDatabase db) { - return new DbModifierWithVmNotification(Tables.CALLS, db, context()); + return new DbModifierWithNotification(Tables.CALLS, db, context()); } + /** + * Same as {@link #getDatabaseModifier(SQLiteDatabase)} but used for insert helper operations + * only. + */ private DatabaseModifier getDatabaseModifier(DatabaseUtils.InsertHelper insertHelper) { - return new DbModifierWithVmNotification(Tables.CALLS, insertHelper, context()); + return new DbModifierWithNotification(Tables.CALLS, insertHelper, context()); } private boolean hasVoicemailValue(ContentValues values) { -- cgit v1.1