From b3cb475fd29f827002b9743822b2a99ff85d1b38 Mon Sep 17 00:00:00 2001 From: Yu Ping Hu Date: Tue, 23 Jul 2013 21:00:09 -0700 Subject: [PATCH] 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 --- .../com/android/emailcommon/service/SyncWindow.java | 4 ++-- src/com/android/email/provider/DBHelper.java | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/service/SyncWindow.java b/emailcommon/src/com/android/emailcommon/service/SyncWindow.java index c3658e369..8dfe4ad2e 100644 --- a/emailcommon/src/com/android/emailcommon/service/SyncWindow.java +++ b/emailcommon/src/com/android/emailcommon/service/SyncWindow.java @@ -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; } diff --git a/src/com/android/email/provider/DBHelper.java b/src/com/android/email/provider/DBHelper.java index 626b55554..1a9e5de6e 100644 --- a/src/com/android/email/provider/DBHelper.java +++ b/src/com/android/email/provider/DBHelper.java @@ -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) {