From f119f904ed4c2d2089df3d9243488cd1de04e405 Mon Sep 17 00:00:00 2001 From: Jorge Ruesga Date: Fri, 20 Mar 2015 03:16:23 +0100 Subject: [PATCH] email: don't block extras database This will call other setences (like delete accoutns) to block access. Just integrate in the normal database transactions Change-Id: I48d7028f2ceddcdfbc170acd1a1fe32f0322b6e6 Signed-off-by: Jorge Ruesga --- .../android/email/provider/EmailProvider.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/provider_src/com/android/email/provider/EmailProvider.java b/provider_src/com/android/email/provider/EmailProvider.java index ee5fe860a..338c9fc4b 100644 --- a/provider_src/com/android/email/provider/EmailProvider.java +++ b/provider_src/com/android/email/provider/EmailProvider.java @@ -750,7 +750,7 @@ public class EmailProvider extends ContentProvider notifyUI(UIPROVIDER_ALL_ACCOUNTS_NOTIFIER, null); // Delete account suggested contacts - mExtrasDatabase.delete(SuggestedContact.TABLE_NAME, + db.delete(SuggestedContact.TABLE_NAME, SuggestedContact.ACCOUNT_KEY + " = ?", new String[]{id}); } else if (match == MAILBOX_ID) { @@ -781,7 +781,7 @@ public class EmailProvider extends ContentProvider if (match == ACCOUNT) { // TODO extract account deleted // As a fallback clean all suggested contacts - mExtrasDatabase.delete(SuggestedContact.TABLE_NAME, null, null); + db.delete(SuggestedContact.TABLE_NAME, null, null); } break; case MESSAGE_MOVE: @@ -6204,14 +6204,8 @@ public class EmailProvider extends ContentProvider } // Update or insert every suggested contact - mExtrasDatabase.beginTransactionNonExclusive(); - try { - for (Address suggestedContact : suggestedContacts) { - addOrUpdateSuggestedContact(accountId, suggestedContact); - } - mExtrasDatabase.setTransactionSuccessful(); - } finally { - mExtrasDatabase.endTransaction(); + for (Address suggestedContact : suggestedContacts) { + addOrUpdateSuggestedContact(accountId, suggestedContact); } } @@ -6232,14 +6226,14 @@ public class EmailProvider extends ContentProvider ? emailAddress : address.getPersonal()); values.put(SuggestedContact.DISPLAY_NAME, address.toString()); values.put(SuggestedContact.LAST_SEEN, System.currentTimeMillis()); - long affectedRecords = mExtrasDatabase.update( + long affectedRecords = mDatabase.update( SuggestedContact.TABLE_NAME, values, where, args); // Insert if (affectedRecords == 0) { values.put(SuggestedContact.ACCOUNT_KEY, accountId); values.put(SuggestedContact.ADDRESS, emailAddress); - mExtrasDatabase.insertOrThrow(SuggestedContact.TABLE_NAME, null, values); + mDatabase.insertOrThrow(SuggestedContact.TABLE_NAME, null, values); } } catch (SQLException ex) {