Bug 1408555 p1 - Remove Account pickling. r?Grisha
MozReview-Commit-ID: G2FeJpGSHG2
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AccountPickler.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AccountPickler.java
@@ -128,16 +128,18 @@ public class AccountPickler {
* This operation is synchronized to avoid race condition while deleting the account.
*
* Note that pickling is different from bundling, which involves operations on a
* {@link android.os.Bundle Bundle} object of miscellaneous data associated with the account.
* See {@link AndroidFxAccount#persistBundle} and {@link AndroidFxAccount#unbundle} for more.
*
* @param account the AndroidFxAccount to persist to disk
* @param filename name of file to persist to; must not contain path separators.
+ * @deprecated Pickling/Un-pickling logic will be removed entirely in the future. This method is
+ * still present to make sure un-pickling tests pass.
*/
public synchronized static void pickle(final AndroidFxAccount account, final String filename) {
final ExtendedJSONObject o = toJSON(account, System.currentTimeMillis());
writeToDisk(account.context, filename, o);
}
private static void writeToDisk(final Context context, final String filename,
final ExtendedJSONObject pickle) {
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/authenticator/AndroidFxAccount.java
@@ -588,32 +588,16 @@ public class AndroidFxAccount {
for (String key : userdata.keySet()) {
accountManager.setUserData(account, key, userdata.getString(key));
}
final AndroidFxAccount fxAccount = new AndroidFxAccount(context, account);
if (!fromPickle) {
fxAccount.clearSyncPrefs();
-
- // We can nearly eliminate various pickle races by pickling the account right after creation.
- // These races are an unfortunate by-product of Bug 1368147. The long-term solution is to stop
- // pickling entirely, but for now we just ensure we'll have a pickle file as soon as possible.
- // Pickle in a background thread to avoid strict mode warnings.
- ThreadPool.run(new Runnable() {
- @Override
- public void run() {
- try {
- AccountPickler.pickle(fxAccount, FxAccountConstants.ACCOUNT_PICKLE_FILENAME);
- } catch (Exception e) {
- // Should never happen, but we really don't want to die in a background thread.
- Logger.warn(LOG_TAG, "Got exception pickling current account details; ignoring.", e);
- }
- }
- });
}
fxAccount.setAuthoritiesToSyncAutomaticallyMap(authoritiesToSyncAutomaticallyMap);
return fxAccount;
}
private void clearSyncPrefs() throws UnsupportedEncodingException, GeneralSecurityException {
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/sync/FxAccountSyncAdapter.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/sync/FxAccountSyncAdapter.java
@@ -546,29 +546,16 @@ public class FxAccountSyncAdapter extend
if (this.lastSyncRealtimeMillis > 0L &&
(this.lastSyncRealtimeMillis + MINIMUM_SYNC_DELAY_MILLIS) > SystemClock.elapsedRealtime() &&
!extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_BACKOFF, false)) {
Logger.info(LOG_TAG, "Not syncing FxAccount " + Utils.obfuscateEmail(account.name) +
": minimum interval not met.");
return;
}
- // Pickle in a background thread to avoid strict mode warnings.
- ThreadPool.run(new Runnable() {
- @Override
- public void run() {
- try {
- AccountPickler.pickle(fxAccount, FxAccountConstants.ACCOUNT_PICKLE_FILENAME);
- } catch (Exception e) {
- // Should never happen, but we really don't want to die in a background thread.
- Logger.warn(LOG_TAG, "Got exception pickling current account details; ignoring.", e);
- }
- }
- });
-
final BlockingQueue<Result> latch = new LinkedBlockingQueue<>(1);
Collection<String> knownStageNames = SyncConfiguration.validEngineNames();
Collection<String> stageNamesToSync = Utils.getStagesToSyncFromBundle(knownStageNames, extras);
// If syncing should be rejected due to metered connection preferences
// and we are doing the first sync ever, we should at least sync the
// 'clients' collection to ensure we upload our local client record.