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

* commit '57b93d2bbec3b94f74d4e9f1a4134dcd79f6d007':
  Fix DB upgrade code to set lookback correctly.
This commit is contained in:
Yu Ping Hu 2013-07-24 16:19:51 -07:00 committed by Android Git Automerger
commit 8604504b30
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) {