From 7d6d8c87f86a17cae59af645637458b17e72c716 Mon Sep 17 00:00:00 2001 From: Martin Hibdon Date: Tue, 17 Sep 2013 16:43:07 -0700 Subject: [PATCH] Clear exchange sync keys upon app upgrade b/10211620 The problem here is that on app upgrade, we need to change the types of all email accounts. To do this, we have to create new accounts and delete the old ones. This resulted in calendar and contacts data getting deleted. But we were copying over the last sync keys from the old account, so on the next sync, we would only get new data. This means that all of the data that we had gotten on a previous sync would never be sent again, so calendar events and contacts would be missing forever. Now, we just don't migrate the old sync keys. This means that on the next sync, we'll get all data, and restore our original state. This is still not ideal, because it means that any locally created data that has not yet been synced will be lost (b/10805685), but it's much better than it was. Change-Id: I150c4dbdf490a8f3880261e2469795896ebfeab5 --- src/com/android/email/service/EmailServiceUtils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java index 473afff3e..3894de6da 100644 --- a/src/com/android/email/service/EmailServiceUtils.java +++ b/src/com/android/email/service/EmailServiceUtils.java @@ -403,6 +403,12 @@ public class EmailServiceUtils { finishAccountManagerBlocker(amFuture); LogUtils.w(Logging.LOG_TAG, "Created new AccountManager account"); + + // XXX: + // It would be nice if we could copy or move all of the old account's data over + // to the new account here. b/10805685 + + // Delete the AccountManager account amFuture = AccountManager.get(context) .removeAccount(amAccount, null, null); @@ -410,6 +416,10 @@ public class EmailServiceUtils { LogUtils.w(Logging.LOG_TAG, "Deleted old AccountManager account"); // Restore sync keys for contacts/calendar + // XXX See b/10211620 + // Disable this for now. We want to clear the sync keys so that the next + // sync will get everything. +/* // TODO: Clean up how we determine the type. final String accountType = protocolMap.get(hostAuth.mProtocol + "_type"); if (accountType != null && @@ -443,6 +453,7 @@ public class EmailServiceUtils { LogUtils.w(Logging.LOG_TAG, "Set contacts key FAILED"); } } +*/ // That's all folks! LogUtils.w(Logging.LOG_TAG, "Account update completed.");