summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Android (Google) Code Review <android-gerrit@google.com> 2009-09-22 23:20:25 -0400
committer Android (Google) Code Review <android-gerrit@google.com> 2009-09-22 23:20:25 -0400
commit3de07024c80fb8a983d4a804ff6d14a49b3f7979 (patch)
tree76a1d24ddc78f9b49f36f3c5dcc2ba61d5f6b2ae
parent32f76f34075450c03c68fc1f65e395d5eddd6d51 (diff)
parente00a31155b95686eecc6e1999e904472f8f300ca (diff)
Merge change 26456 into eclair
* changes: - make an AccountManager per context, not one per process - enhance the comment for addOnAccountsUpdatedListener()
-rw-r--r--core/java/android/accounts/AccountManager.java4
-rw-r--r--core/java/android/app/ApplicationContext.java10
2 files changed, 9 insertions, 5 deletions
diff --git a/core/java/android/accounts/AccountManager.java b/core/java/android/accounts/AccountManager.java
index 9afeb74b02f4..1ee7f60fb9ce 100644
--- a/core/java/android/accounts/AccountManager.java
+++ b/core/java/android/accounts/AccountManager.java
@@ -807,6 +807,10 @@ public class AccountManager {
* Add a {@link OnAccountsUpdatedListener} to this instance of the {@link AccountManager}.
* The listener is guaranteed to be invoked on the thread of the Handler that is passed
* in or the main thread's Handler if handler is null.
+ * <p>
+ * You must remove this listener before the context that was used to retrieve this
+ * {@link AccountManager} instance goes away. This generally means when the Activity
+ * or Service you are running is stopped.
* @param listener the listener to add
* @param handler the Handler whose thread will be used to invoke the listener. If null
* the AccountManager context's main thread will be used.
diff --git a/core/java/android/app/ApplicationContext.java b/core/java/android/app/ApplicationContext.java
index afafe64c5602..8896015cd781 100644
--- a/core/java/android/app/ApplicationContext.java
+++ b/core/java/android/app/ApplicationContext.java
@@ -153,7 +153,6 @@ class ApplicationContext extends Context {
private final static boolean DEBUG_ICONS = false;
private static final Object sSync = new Object();
- private static AccountManager sAccountManager;
private static AlarmManager sAlarmManager;
private static PowerManager sPowerManager;
private static ConnectivityManager sConnectivityManager;
@@ -186,6 +185,7 @@ class ApplicationContext extends Context {
private boolean mIsBluetoothAdapterCached = false;
private BluetoothAdapter mBluetoothAdapter;
private boolean mRestricted;
+ private AccountManager mAccountManager; // protected by mSync
private final Object mSync = new Object();
@@ -908,14 +908,14 @@ class ApplicationContext extends Context {
}
private AccountManager getAccountManager() {
- synchronized (sSync) {
- if (sAccountManager == null) {
+ synchronized (mSync) {
+ if (mAccountManager == null) {
IBinder b = ServiceManager.getService(ACCOUNT_SERVICE);
IAccountManager service = IAccountManager.Stub.asInterface(b);
- sAccountManager = new AccountManager(this, service);
+ mAccountManager = new AccountManager(this, service);
}
+ return mAccountManager;
}
- return sAccountManager;
}
private ActivityManager getActivityManager() {