AI 149140: Automated g4 rollback of changelist 148333.

*** Reason for rollback ***
  Rollback global lock because bug (now fixed) was not caused by
  threading/concurrency.
  *** Original change description ***
  Evidence from failures, and inspection of source, leads me to believe
  that SharedPreferences has some non-thread-safe paths.  As a quick,
  brute-force workaround, I'm putting a global lock around our use of it.
  This is a bit inefficient, but cases of multiple threads writing to it
  should be very rare.
  Note, we don't have an explicit test for this (I will think about
  finding a way to write one), but the evidence of this failure is that
  after some amount of activity in the Email app, we see corrup
  ... description truncated by g4 rollback ...

Automated import of CL 149140
This commit is contained in:
Andy Stadler 2009-05-21 10:39:04 -07:00 committed by The Android Open Source Project
parent f9edef8dee
commit c2887cd81d

View File

@ -112,13 +112,6 @@ public class Account implements Serializable {
public void refresh(Preferences preferences) {
mPreferences = preferences;
/**
* Note: Until we have resolved the potential for synchronization failures in
* SharedPreferences, we're going to do a global lock around the read and write
* functions.
*/
synchronized (Account.class) {
mStoreUri = Utility.base64Decode(preferences.mSharedPreferences.getString(mUuid
+ ".storeUri", null));
mLocalStoreUri = preferences.mSharedPreferences.getString(mUuid + ".localStoreUri", null);
@ -165,7 +158,6 @@ public class Account implements Serializable {
mSyncWindow = preferences.mSharedPreferences.getInt(mUuid + KEY_SYNC_WINDOW,
SYNC_WINDOW_USER);
}
}
public String getUuid() {
return mUuid;
@ -228,12 +220,6 @@ public class Account implements Serializable {
}
public void delete(Preferences preferences) {
/**
* Note: Until we have resolved the potential for synchronization failures in
* SharedPreferences, we're going to do a global lock around the read and write
* functions.
*/
synchronized (Account.class) {
String[] uuids = preferences.mSharedPreferences.getString("accountUuids", "").split(",");
StringBuffer sb = new StringBuffer();
for (int i = 0, length = uuids.length; i < length; i++) {
@ -272,17 +258,10 @@ public class Account implements Serializable {
editor.commit();
}
}
public void save(Preferences preferences) {
mPreferences = preferences;
/**
* Note: Until we have resolved the potential for synchronization failures in
* SharedPreferences, we're going to do a global lock around the read and write
* functions.
*/
synchronized (Account.class) {
if (!preferences.mSharedPreferences.getString("accountUuids", "").contains(mUuid)) {
/*
* When the account is first created we assign it a unique account number. The
@ -346,7 +325,6 @@ public class Account implements Serializable {
editor.commit();
}
}
@Override
public String toString() {