diff --git a/emailcommon/src/com/android/emailcommon/provider/Mailbox.java b/emailcommon/src/com/android/emailcommon/provider/Mailbox.java index 4d32c16fb..68bb35f6d 100644 --- a/emailcommon/src/com/android/emailcommon/provider/Mailbox.java +++ b/emailcommon/src/com/android/emailcommon/provider/Mailbox.java @@ -347,7 +347,9 @@ public class Mailbox extends EmailContent implements MailboxColumns, Parcelable SYNCABLE_TYPES = new SparseBooleanArray(7); SYNCABLE_TYPES.put(TYPE_INBOX, true); SYNCABLE_TYPES.put(TYPE_MAIL, false); - SYNCABLE_TYPES.put(TYPE_DRAFTS, true); + // TODO: b/11158759 + // For now, drafts folders are not syncable. + //SYNCABLE_TYPES.put(TYPE_DRAFTS, true); SYNCABLE_TYPES.put(TYPE_SENT, true); SYNCABLE_TYPES.put(TYPE_TRASH, false); SYNCABLE_TYPES.put(TYPE_CALENDAR, true); diff --git a/src/com/android/email/activity/setup/MailboxSettings.java b/src/com/android/email/activity/setup/MailboxSettings.java index 5ffa5762e..baad944c3 100644 --- a/src/com/android/email/activity/setup/MailboxSettings.java +++ b/src/com/android/email/activity/setup/MailboxSettings.java @@ -192,7 +192,9 @@ public class MailboxSettings extends PreferenceActivity { mSyncEnabledPref.setChecked(mMailbox.mSyncInterval != 0); mSyncLookbackPref.setValue(String.valueOf(mMailbox.mSyncLookback)); onDataLoaded(); - enablePreferences(true); + if (mMailbox.mType != Mailbox.TYPE_DRAFTS) { + enablePreferences(true); + } } } diff --git a/src/com/android/email/provider/DBHelper.java b/src/com/android/email/provider/DBHelper.java index 956749df0..e275f4222 100644 --- a/src/com/android/email/provider/DBHelper.java +++ b/src/com/android/email/provider/DBHelper.java @@ -154,8 +154,8 @@ public final class DBHelper { // Version 116: Add MessageMove & MessageStateChange tables. // Version 117: Add trigger to delete duplicate messages on sync. // Version 118: Set syncInterval to 0 for all IMAP mailboxes - - public static final int DATABASE_VERSION = 118; + // Version 119: Disable syncing of DRAFTS type folders. + public static final int DATABASE_VERSION = 119; // Any changes to the database format *must* include update-in-place code. // Original version: 2 @@ -1211,6 +1211,29 @@ public final class DBHelper { + mContext.getString(R.string.protocol_imap) + "' or " + HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + "='imap'));"); } + + /** + * This statement changes the sync interval column to 0 for all DRAFTS type mailboxes, + * and deletes any messages that are: + * * synced from the server, and + * * in an exchange account draft folder + * + * This is primary for Exchange (b/11158759) but we don't sync draft folders for any + * other account type anyway. + * This will only affect people who used intermediate builds between email1 and email2, + * it should be a no-op for most users. + */ + if (oldVersion <= 118) { + db.execSQL("update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.SYNC_INTERVAL + + "=0 where " + MailboxColumns.TYPE + "=" + Mailbox.TYPE_DRAFTS); + + db.execSQL("delete from " + Message.TABLE_NAME + " where " + + "(" + SyncColumns.SERVER_ID + " not null and " + + SyncColumns.SERVER_ID + "!='') and " + + MessageColumns.MAILBOX_KEY + " in (select " + + MailboxColumns.ID + " from " + Mailbox.TABLE_NAME + " where " + + MailboxColumns.TYPE + "=" + Mailbox.TYPE_DRAFTS + ")"); + } } @Override