am 214c6c6c: Fix remote wipe with mobile sync server

Merge commit '214c6c6c8173cf90a3e45615a6896a48dc643e68' into gingerbread-plus-aosp

* commit '214c6c6c8173cf90a3e45615a6896a48dc643e68':
  Fix remote wipe with mobile sync server
This commit is contained in:
Andy Stadler 2010-10-13 16:46:41 -07:00 committed by Android Git Automerger
commit 1e64175c7a
3 changed files with 14 additions and 3 deletions

View File

@ -1282,17 +1282,28 @@ public class EasSyncService extends AbstractSyncService {
} }
if (pp.getRemoteWipe()) { if (pp.getRemoteWipe()) {
// We've gotten a remote wipe command // We've gotten a remote wipe command
SyncManager.alwaysLog("!!! Remote wipe request received");
// Start by setting the account to security hold
sp.setAccountHoldFlag(mAccount, true);
// Force a stop to any running syncs for this account (except this one)
SyncManager.stopNonAccountMailboxSyncsForAccount(mAccount.mId);
// If we're not the admin, we can't do the wipe, so just return // If we're not the admin, we can't do the wipe, so just return
if (!sp.isActiveAdmin()) return false; if (!sp.isActiveAdmin()) {
SyncManager.alwaysLog("!!! Not device admin; can't wipe");
return false;
}
// First, we've got to acknowledge it, but wrap the wipe in try/catch so that // First, we've got to acknowledge it, but wrap the wipe in try/catch so that
// we wipe the device regardless of any errors in acknowledgment // we wipe the device regardless of any errors in acknowledgment
try { try {
SyncManager.alwaysLog("!!! Acknowledging remote wipe to server");
acknowledgeRemoteWipe(pp.getPolicyKey()); acknowledgeRemoteWipe(pp.getPolicyKey());
} catch (Exception e) { } catch (Exception e) {
// Because remote wipe is such a high priority task, we don't want to // Because remote wipe is such a high priority task, we don't want to
// circumvent it if there's an exception in acknowledgment // circumvent it if there's an exception in acknowledgment
} }
// Then, tell SecurityPolicy to wipe the device // Then, tell SecurityPolicy to wipe the device
SyncManager.alwaysLog("!!! Executing remote wipe");
sp.remoteWipe(); sp.remoteWipe();
return false; return false;
} else if (sp.isActive(ps)) { } else if (sp.isActive(ps)) {

View File

@ -1232,7 +1232,7 @@ public class SyncManager extends Service implements Runnable {
* *
* @param acctId * @param acctId
*/ */
static public void folderListReloaded(long acctId) { static public void stopNonAccountMailboxSyncsForAccount(long acctId) {
SyncManager syncManager = INSTANCE; SyncManager syncManager = INSTANCE;
if (syncManager != null) { if (syncManager != null) {
syncManager.stopAccountSyncs(acctId, false); syncManager.stopAccountSyncs(acctId, false);

View File

@ -114,7 +114,7 @@ public class FolderSyncParser extends AbstractSyncParser {
mContentResolver.delete(Mailbox.CONTENT_URI, ALL_BUT_ACCOUNT_MAILBOX, mContentResolver.delete(Mailbox.CONTENT_URI, ALL_BUT_ACCOUNT_MAILBOX,
new String[] {Long.toString(mAccountId)}); new String[] {Long.toString(mAccountId)});
// Stop existing syncs and reconstruct _main // Stop existing syncs and reconstruct _main
SyncManager.folderListReloaded(mAccountId); SyncManager.stopNonAccountMailboxSyncsForAccount(mAccountId);
res = true; res = true;
resetFolders = true; resetFolders = true;
} else { } else {