Merge "Fix DB upgrade code to set lookback correctly." into jb-ub-mail-ur10

This commit is contained in:
Yu Ping Hu 2013-07-24 23:17:21 +00:00 committed by Android (Google) Code Review
commit 57b93d2bbe
2 changed files with 11 additions and 6 deletions

View File

@ -18,7 +18,7 @@ package com.android.emailcommon.service;
public class SyncWindow {
public static final int SYNC_WINDOW_USER = -1;
public static final int SYNC_WINDOW_UNKNOWN = 0;
public static final int SYNC_WINDOW_ACCOUNT = 0;
public static final int SYNC_WINDOW_1_DAY = 1;
public static final int SYNC_WINDOW_3_DAYS = 2;
public static final int SYNC_WINDOW_1_WEEK = 3;
@ -40,7 +40,7 @@ public class SyncWindow {
return 30;
case SYNC_WINDOW_ALL:
return 365*10;
case SYNC_WINDOW_UNKNOWN:
case SYNC_WINDOW_ACCOUNT:
default:
return 14;
}

View File

@ -1041,11 +1041,16 @@ public final class DBHelper {
// Fix invalid syncLookback values.
db.execSQL("update " + Account.TABLE_NAME + " set " + AccountColumns.SYNC_LOOKBACK
+ "=null where " + AccountColumns.SYNC_LOOKBACK +"<"
+ SyncWindow.SYNC_WINDOW_1_DAY);
+ "=" + SyncWindow.SYNC_WINDOW_1_WEEK + " where "
+ AccountColumns.SYNC_LOOKBACK + " is null or "
+ AccountColumns.SYNC_LOOKBACK + "<" + SyncWindow.SYNC_WINDOW_1_DAY + " or "
+ AccountColumns.SYNC_LOOKBACK + ">" + SyncWindow.SYNC_WINDOW_ALL);
db.execSQL("update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.SYNC_LOOKBACK
+ "=null where " + MailboxColumns.SYNC_LOOKBACK + "<"
+ SyncWindow.SYNC_WINDOW_1_DAY);
+ "=" + SyncWindow.SYNC_WINDOW_ACCOUNT + " where "
+ MailboxColumns.SYNC_LOOKBACK + " is null or "
+ MailboxColumns.SYNC_LOOKBACK + "<" + SyncWindow.SYNC_WINDOW_1_DAY + " or "
+ MailboxColumns.SYNC_LOOKBACK + ">" + SyncWindow.SYNC_WINDOW_ALL);
oldVersion = 110;
}
if (oldVersion == 110) {