diff options
author | Zheng Fu <zhengfu@google.com> | 2015-07-17 14:55:48 -0700 |
---|---|---|
committer | Zheng Fu <zhengfu@google.com> | 2015-07-17 15:08:10 -0700 |
commit | f3d2981b53b7d4715da1d35f5425b19766a92f8b (patch) | |
tree | f54aeb2658c8755cbdb399368a3c25a1da0fedf8 | |
parent | 8d4e5229580e589cbdc6cc962024ffb830dfecae (diff) | |
download | packages_providers_ContactsProvider-f3d2981b53b7d4715da1d35f5425b19766a92f8b.zip packages_providers_ContactsProvider-f3d2981b53b7d4715da1d35f5425b19766a92f8b.tar.gz packages_providers_ContactsProvider-f3d2981b53b7d4715da1d35f5425b19766a92f8b.tar.bz2 |
Should update aggregate data after marking raw contact deleted.
Bug:22564056
Change-Id: Ic9ea29ee9fd72ff12a977565fba4f4e9be285b23
-rw-r--r-- | src/com/android/providers/contacts/ContactsProvider2.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java index dba3709..200c25c 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -3733,27 +3733,26 @@ public class ContactsProvider2 extends AbstractContactsProvider c.close(); } + final boolean contactIsSingleton = + ContactsTableUtil.deleteContactIfSingleton(db, rawContactId) == 1; + final int count; + if (callerIsSyncAdapter || rawContactIsLocal(rawContactId)) { // When a raw contact is deleted, a SQLite trigger deletes the parent contact. // TODO: all contact deletes was consolidated into ContactTableUtil but this one can't // because it's in a trigger. Consider removing trigger and replacing with java code. // This has to happen before the raw contact is deleted since it relies on the number // of raw contacts. - if (ContactsTableUtil.deleteContactIfSingleton(db, rawContactId) == 0) { - mAggregator.get().updateAggregateData(mTransactionContext.get(), contactId); - } - db.delete(Tables.PRESENCE, PresenceColumns.RAW_CONTACT_ID + "=" + rawContactId, null); - int count = db.delete(Tables.RAW_CONTACTS, RawContacts._ID + "=" + rawContactId, null); - + count = db.delete(Tables.RAW_CONTACTS, RawContacts._ID + "=" + rawContactId, null); mTransactionContext.get().markRawContactChangedOrDeletedOrInserted(rawContactId); - return count; + } else { + count = markRawContactAsDeleted(db, rawContactId, callerIsSyncAdapter); } - - if (ContactsTableUtil.deleteContactIfSingleton(db, rawContactId) == 0) { + if (!contactIsSingleton) { mAggregator.get().updateAggregateData(mTransactionContext.get(), contactId); } - return markRawContactAsDeleted(db, rawContactId, callerIsSyncAdapter); + return count; } /** |