From 3b7a93e8bbeda13e49ef17b45ba7b46fe8284dee Mon Sep 17 00:00:00 2001 From: Andy Stadler Date: Wed, 6 May 2009 17:42:22 -0700 Subject: [PATCH] AI 148375: Explicitly remove deleted accounts from the Store cache. This resolves possible bugs when an account is deleted and recreated. BUG=1740626 Automated import of CL 148375 --- src/com/android/email/activity/Accounts.java | 2 ++ src/com/android/email/mail/Store.java | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/com/android/email/activity/Accounts.java b/src/com/android/email/activity/Accounts.java index 73717c1ae..682e4b66a 100644 --- a/src/com/android/email/activity/Accounts.java +++ b/src/com/android/email/activity/Accounts.java @@ -180,6 +180,8 @@ public class Accounts extends ListActivity implements OnItemClickListener, OnCli mSelectedContextAccount.getStoreUri(), getApplication(), localStore.getPersistentCallbacks()).delete(); + // Remove the Store instance from cache. + Store.removeInstance(mSelectedContextAccount.getStoreUri()); // If no error, then delete LocalStore localStore.delete(); } catch (Exception e) { diff --git a/src/com/android/email/mail/Store.java b/src/com/android/email/mail/Store.java index 3e62b8e3a..9709b20ab 100644 --- a/src/com/android/email/mail/Store.java +++ b/src/com/android/email/mail/Store.java @@ -185,6 +185,17 @@ public abstract class Store { return store; } + + /** + * Delete an instance of a mail store. + * + * The store should have been notified already by calling delete(), and the caller should + * also take responsibility for deleting the matching LocalStore, etc. + * @param storeUri the store to be removed + */ + public synchronized static void removeInstance(String storeUri) { + mStores.remove(storeUri); + } /** * Get class of SettingActivity for this Store class.