Fix DB upgrade code to set lookback correctly.

Rather than use null, just force the valid default value.
Also rename SYNC_WINDOW_UNKNOWN to SYNC_WINDOW_ACCOUNT to
better reflect how it's actually used.

Bug: 9989995
Change-Id: I8d0b466fe3bc2e4c651c309d4815cea201058d22
This commit is contained in:
Yu Ping Hu 2013-07-23 21:00:09 -07:00
parent 1c3ec5f6c0
commit b3cb475fd2
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) {