diff options
author | Zheng Fu <zhengfu@google.com> | 2015-07-14 00:14:51 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-14 00:14:51 +0000 |
commit | c4de8153f8ec59e13adad16ca6db58888874495b (patch) | |
tree | 9323f9996dc47f6c58b7cc0d5302a5b9f4e435ac | |
parent | 78f804957632a1de5fbb892da03928d9ffa87cd8 (diff) | |
parent | ee3253caf8b9800a32186b78f980a9ede85dcab9 (diff) | |
download | packages_providers_ContactsProvider-c4de8153f8ec59e13adad16ca6db58888874495b.zip packages_providers_ContactsProvider-c4de8153f8ec59e13adad16ca6db58888874495b.tar.gz packages_providers_ContactsProvider-c4de8153f8ec59e13adad16ca6db58888874495b.tar.bz2 |
am ee3253ca: am 43f9a00c: am cc9ce6b1: Dealing with some edge cases with soft deleted contacts. 1. Exlude soft deleted contacts for aggregator algorithm upgrade. 2. Make sure to update the contacts.name_raw_contact_id column for soft deleted raw contact.
* commit 'ee3253caf8b9800a32186b78f980a9ede85dcab9':
Dealing with some edge cases with soft deleted contacts. 1. Exlude soft deleted contacts for aggregator algorithm upgrade. 2. Make sure to update the contacts.name_raw_contact_id column for soft deleted raw contact.
3 files changed, 11 insertions, 6 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java index 02e9c52..80f7c5b 100644 --- a/src/com/android/providers/contacts/ContactsProvider2.java +++ b/src/com/android/providers/contacts/ContactsProvider2.java @@ -3739,17 +3739,20 @@ public class ContactsProvider2 extends AbstractContactsProvider // 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. - ContactsTableUtil.deleteContactIfSingleton(db, rawContactId); + 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); - mAggregator.get().updateAggregateData(mTransactionContext.get(), contactId); mTransactionContext.get().markRawContactChangedOrDeletedOrInserted(rawContactId); return count; } - ContactsTableUtil.deleteContactIfSingleton(db, rawContactId); + if (ContactsTableUtil.deleteContactIfSingleton(db, rawContactId) == 0) { + mAggregator.get().updateAggregateData(mTransactionContext.get(), contactId); + } return markRawContactAsDeleted(db, rawContactId, callerIsSyncAdapter); } diff --git a/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java b/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java index cfbad32..c18c1d6 100644 --- a/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java +++ b/src/com/android/providers/contacts/aggregation/AbstractContactAggregator.java @@ -602,7 +602,8 @@ public abstract class AbstractContactAggregator { final int count; final Cursor cursor = db.rawQuery("SELECT " + RawContacts._ID + " FROM " + Tables.RAW_CONTACTS + - " WHERE " + RawContactsColumns.AGGREGATION_NEEDED + "=1", null); + " WHERE " + RawContactsColumns.AGGREGATION_NEEDED + "=1 AND " + + RawContacts.DELETED + "=0", null); try { count = cursor.getCount(); cursor.moveToPosition(-1); diff --git a/src/com/android/providers/contacts/database/ContactsTableUtil.java b/src/com/android/providers/contacts/database/ContactsTableUtil.java index dbc3d3e..bb29f90 100644 --- a/src/com/android/providers/contacts/database/ContactsTableUtil.java +++ b/src/com/android/providers/contacts/database/ContactsTableUtil.java @@ -118,7 +118,7 @@ public class ContactsTableUtil { * Delete the aggregate contact if it has no constituent raw contacts other than the supplied * one. */ - public static void deleteContactIfSingleton(SQLiteDatabase db, long rawContactId) { + public static int deleteContactIfSingleton(SQLiteDatabase db, long rawContactId) { // This query will find a contact id if the contact has a raw contacts other than the one // passed in. final String sql = "select " + ContactsContract.RawContacts.CONTACT_ID + ", count(1)" @@ -136,11 +136,12 @@ public class ContactsTableUtil { if (numRawContacts == 1) { // Only one raw contact, we can delete the parent. - deleteContact(db, contactId); + return deleteContact(db, contactId); } } } finally { MoreCloseables.closeQuietly(cursor); } + return 0; } } |