Delete PIM data during folder sync/reset
Bug: 3361000 Change-Id: I95305467c17c5c4b75b96dfb06c3c3511eb3f15a
This commit is contained in:
parent
d0e795af73
commit
67d7a741cf
|
@ -462,24 +462,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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -514,6 +500,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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue