diff options
author | Debashish Chatterjee <debashishc@google.com> | 2011-08-09 10:35:07 +0100 |
---|---|---|
committer | Debashish Chatterjee <debashishc@google.com> | 2011-08-10 10:54:26 +0100 |
commit | 2e757d904e62dbf5bc0b028626fa9319ccc38c45 (patch) | |
tree | bbc8a6ede11e85427615ff1cdbad7c8559432076 /src/com/android/providers/contacts/CallLogProvider.java | |
parent | 13a121b7252020fb9226ce3d2bfe4973e2c682cd (diff) | |
download | packages_providers_ContactsProvider-2e757d904e62dbf5bc0b028626fa9319ccc38c45.zip packages_providers_ContactsProvider-2e757d904e62dbf5bc0b028626fa9319ccc38c45.tar.gz packages_providers_ContactsProvider-2e757d904e62dbf5bc0b028626fa9319ccc38c45.tar.bz2 |
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
Diffstat (limited to 'src/com/android/providers/contacts/CallLogProvider.java')
-rw-r--r-- | src/com/android/providers/contacts/CallLogProvider.java | 33 |
1 files changed, 13 insertions, 20 deletions
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) { |