am 0db900d6: Merge "Allow setting of the sync window for IMAP accounts" into ub-mail-algol
* commit '0db900d62247b66b3de2eb665145e239141e670e': Allow setting of the sync window for IMAP accounts
This commit is contained in:
commit
3ec20d5eeb
|
@ -45,6 +45,7 @@ import com.android.email.service.EmailServiceUtils;
|
|||
import com.android.emailcommon.VendorPolicyLoader;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.service.SyncWindow;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -102,6 +103,10 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||
private static final String EXTRA_CREATE_ACCOUNT_PASSWORD = "PASSWORD";
|
||||
private static final String EXTRA_CREATE_ACCOUNT_INCOMING = "INCOMING";
|
||||
private static final String EXTRA_CREATE_ACCOUNT_OUTGOING = "OUTGOING";
|
||||
private static final String EXTRA_CREATE_ACCOUNT_SYNC_LOOKBACK = "SYNC_LOOKBACK";
|
||||
|
||||
private static final String CREATE_ACCOUNT_SYNC_ALL_VALUE = "ALL";
|
||||
|
||||
private static final Boolean DEBUG_ALLOW_NON_TEST_HARNESS_CREATION = false;
|
||||
|
||||
protected static final String ACTION_JUMP_TO_INCOMING = "jumpToIncoming";
|
||||
|
@ -279,6 +284,13 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||
final String password = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_PASSWORD);
|
||||
final String incoming = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_INCOMING);
|
||||
final String outgoing = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_OUTGOING);
|
||||
final String syncLookbackText = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_SYNC_LOOKBACK);
|
||||
final int syncLookback;
|
||||
if (TextUtils.equals(syncLookbackText, CREATE_ACCOUNT_SYNC_ALL_VALUE)) {
|
||||
syncLookback = SyncWindow.SYNC_WINDOW_ALL;
|
||||
} else {
|
||||
syncLookback = -1;
|
||||
}
|
||||
// If we've been explicitly provided with all the details to fill in the account, we
|
||||
// can use them
|
||||
final boolean explicitForm = !(TextUtils.isEmpty(user) ||
|
||||
|
@ -328,6 +340,12 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||
}
|
||||
|
||||
populateSetupData(user, email);
|
||||
// We need to do this after calling populateSetupData(), because that will
|
||||
// overwrite it with the default values.
|
||||
if (syncLookback >= SyncWindow.SYNC_WINDOW_ACCOUNT &&
|
||||
syncLookback <= SyncWindow.SYNC_WINDOW_ALL) {
|
||||
account.mSyncLookback = syncLookback;
|
||||
}
|
||||
}
|
||||
|
||||
mState = STATE_OPTIONS;
|
||||
|
|
|
@ -58,6 +58,7 @@ import com.android.emailcommon.provider.EmailContent.SyncColumns;
|
|||
import com.android.emailcommon.provider.Mailbox;
|
||||
import com.android.emailcommon.service.EmailServiceStatus;
|
||||
import com.android.emailcommon.service.SearchParams;
|
||||
import com.android.emailcommon.service.SyncWindow;
|
||||
import com.android.emailcommon.utility.AttachmentUtilities;
|
||||
import com.android.mail.providers.UIProvider;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
|
@ -379,7 +380,11 @@ public class ImapService extends Service {
|
|||
final boolean fullSync = (uiRefresh || loadMore ||
|
||||
timeSinceLastFullSync >= FULL_SYNC_INTERVAL_MILLIS || timeSinceLastFullSync < 0);
|
||||
|
||||
if (fullSync) {
|
||||
if (account.mSyncLookback == SyncWindow.SYNC_WINDOW_ALL) {
|
||||
// This is really for testing. There is no UI that allows setting the sync window for
|
||||
// IMAP, but it can be set by sending a special intent to AccountSetupFinal activity.
|
||||
endDate = 0;
|
||||
} else if (fullSync) {
|
||||
// Find the oldest message in the local store. We need our time window to include
|
||||
// all messages that are currently present locally.
|
||||
endDate = System.currentTimeMillis() - FULL_SYNC_WINDOW_MILLIS;
|
||||
|
|
Loading…
Reference in New Issue