From f3d2981b53b7d4715da1d35f5425b19766a92f8b Mon Sep 17 00:00:00 2001 From: Zheng Fu Date: Fri, 17 Jul 2015 14:55:48 -0700 Subject: Should update aggregate data after marking raw contact deleted. Bug:22564056 Change-Id: Ic9ea29ee9fd72ff12a977565fba4f4e9be285b23 --- .../android/providers/contacts/ContactsProvider2.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') 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; } /** -- cgit v1.1