From 26c95ddace076ead10d5c42986bcc70b465e9791 Mon Sep 17 00:00:00 2001 From: Andrew Stadler Date: Mon, 8 Feb 2010 16:27:05 -0800 Subject: [PATCH] Update accounts backup when externally deleted Fix the case in which an Email account is deleted in the Account Manager UI, and we delete the provider account, but we did not also update the backups. In some cases, the deleted account would be accidentally restored from the backups. Bug: 2414469 (internal) Bug: 2427663 (external) --- src/com/android/exchange/SyncManager.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 0133aafaf..cc4afed6b 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -1220,6 +1220,7 @@ public class SyncManager extends Service implements Runnable { android.accounts.Account[] accts = AccountManager.get(this).getAccountsByType(Eas.ACCOUNT_MANAGER_TYPE); List easAccounts = getAccountList(); + boolean accountsDeleted = false; for (Account easAccount: easAccounts) { String accountName = easAccount.mEmailAddress; boolean found = false; @@ -1231,12 +1232,18 @@ public class SyncManager extends Service implements Runnable { } if (!found) { // This account has been deleted in the AccountManager! - log("Account deleted in AccountManager; deleting from provider: " + accountName); + alwaysLog("Account deleted in AccountManager; deleting from provider: " + + accountName); // TODO This will orphan downloaded attachments; need to handle this mResolver.delete(ContentUris.withAppendedId(Account.CONTENT_URI, easAccount.mId), null, null); + accountsDeleted = true; } } + // If we changed the list of accounts, refresh the backup + if (accountsDeleted) { + AccountBackupRestore.backupAccounts(getContext()); + } } private void releaseConnectivityLock(String reason) {