Fake syncing while we're waiting for the sync to start

b/10695945

Change-Id: I6a32c45facaa0c2c888726e2276d07b7c5e46689
This commit is contained in:
Tony Mantler 2013-09-19 12:17:24 -07:00
parent 1ced0e3001
commit ef0c53e15f

View File

@ -3362,6 +3362,12 @@ public class EmailProvider extends ContentProvider {
private final FolderList mFolderList;
private final Bundle mExtras = new Bundle();
/**
* When showing a folder, if it's been at least this long since the last sync,
* force a folder refresh.
*/
private static final long AUTO_REFRESH_INTERVAL_MS = 5 * DateUtils.MINUTE_IN_MILLIS;
public EmailConversationCursor(final Context context, final Cursor cursor,
final Folder folder, final long mailboxId) {
super(cursor);
@ -3379,8 +3385,16 @@ public class EmailProvider extends ContentProvider {
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS,
UIProvider.CursorStatus.LOADING);
} else if (mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_NONE) {
if (mailbox.mSyncInterval == 0 &&
System.currentTimeMillis() - mailbox.mSyncTime
> AUTO_REFRESH_INTERVAL_MS) {
// This will be syncing momentarily
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS,
UIProvider.CursorStatus.LOADING);
} else {
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS,
UIProvider.CursorStatus.COMPLETE);
}
} else {
LogUtils.d(Logging.LOG_TAG,
"Unknown mailbox sync status" + mailbox.mUiSyncStatus);
@ -3403,12 +3417,6 @@ public class EmailProvider extends ContentProvider {
return mExtras;
}
/**
* When showing a folder, if it's been at least this long since the last sync,
* force a folder refresh.
*/
private static final long AUTO_REFRESH_INTERVAL_MS = 5 * DateUtils.MINUTE_IN_MILLIS;
@Override
public Bundle respond(Bundle params) {
final String setVisibilityKey =