am 3dda4c4f: Merge "Delete PIM data during folder sync/reset" into honeycomb

* commit '3dda4c4fdd343e2e2610fd7d10d9faa38ef6dfb4':
  Delete PIM data during folder sync/reset
This commit is contained in:
Marc Blank 2011-01-17 12:49:19 -08:00 committed by Android Git Automerger
commit 21835e20be
2 changed files with 25 additions and 17 deletions

View File

@ -460,24 +460,10 @@ public class ExchangeService extends Service implements Runnable {
* @throws RemoteException
*/
public void deleteAccountPIMData(long accountId) throws RemoteException {
ExchangeService exchangeService = INSTANCE;
if (exchangeService == null) return;
// Stop any running syncs
exchangeService.stopAccountSyncs(accountId, true);
Mailbox mailbox =
Mailbox.restoreMailboxOfType(exchangeService, accountId, Mailbox.TYPE_CONTACTS);
if (mailbox != null) {
EasSyncService service = new EasSyncService(exchangeService, mailbox);
ContactsSyncAdapter adapter = new ContactsSyncAdapter(service);
adapter.wipe();
}
mailbox =
Mailbox.restoreMailboxOfType(exchangeService, accountId, Mailbox.TYPE_CALENDAR);
if (mailbox != null) {
EasSyncService service = new EasSyncService(exchangeService, mailbox);
CalendarSyncAdapter adapter = new CalendarSyncAdapter(service);
adapter.wipe();
}
ExchangeService.stopAccountSyncs(accountId);
// Delete the data
ExchangeService.deleteAccountPIMData(accountId);
}
};
@ -512,6 +498,25 @@ public class ExchangeService extends Service implements Runnable {
}
}
public static void deleteAccountPIMData(long accountId) {
ExchangeService exchangeService = INSTANCE;
if (exchangeService == null) return;
Mailbox mailbox =
Mailbox.restoreMailboxOfType(exchangeService, accountId, Mailbox.TYPE_CONTACTS);
if (mailbox != null) {
EasSyncService service = new EasSyncService(exchangeService, mailbox);
ContactsSyncAdapter adapter = new ContactsSyncAdapter(service);
adapter.wipe();
}
mailbox =
Mailbox.restoreMailboxOfType(exchangeService, accountId, Mailbox.TYPE_CALENDAR);
if (mailbox != null) {
EasSyncService service = new EasSyncService(exchangeService, mailbox);
CalendarSyncAdapter adapter = new CalendarSyncAdapter(service);
adapter.wipe();
}
}
class AccountObserver extends ContentObserver {
String mSyncableEasMailboxSelector = null;
String mEasAccountSelector = null;

View File

@ -129,6 +129,9 @@ public class FolderSyncParser extends AbstractSyncParser {
if (status == Eas.FOLDER_STATUS_INVALID_KEY) {
mAccount.mSyncKey = "0";
mService.errorLog("Bad sync key; RESET and delete all folders");
// Delete PIM data first
ExchangeService.deleteAccountPIMData(mAccountId);
// Then, delete mailboxes
mContentResolver.delete(Mailbox.CONTENT_URI, ALL_BUT_ACCOUNT_MAILBOX,
new String[] {Long.toString(mAccountId)});
// Stop existing syncs and reconstruct _main