diff --git a/emailcommon/src/com/android/emailcommon/provider/Mailbox.java b/emailcommon/src/com/android/emailcommon/provider/Mailbox.java index 13b1b5dfa..4a998209b 100644 --- a/emailcommon/src/com/android/emailcommon/provider/Mailbox.java +++ b/emailcommon/src/com/android/emailcommon/provider/Mailbox.java @@ -210,6 +210,18 @@ public class Mailbox extends EmailContent implements MailboxColumns, Parcelable // A mailbox that holds Messages that are attachments public static final int TYPE_ATTACHMENT = 0x101; + /** + * For each of the following folder types, we expect there to be exactly one folder of that + * type per account. + * Each sync adapter must do the following: + * 1) On initial sync: For each type that was not found from the server, create a local folder. + * 2) On folder delete: If it's of a required type, convert it to local rather than delete. + * 3) On folder add: If it's of a required type, convert the local folder to server. + * 4) When adding a duplicate (either initial sync or folder add): Error. + */ + public static final int[] REQUIRED_FOLDER_TYPES = + { TYPE_INBOX, TYPE_DRAFTS, TYPE_OUTBOX, TYPE_SENT, TYPE_TRASH }; + // Default "touch" time for system mailboxes public static final int DRAFTS_DEFAULT_TOUCH_TIME = 2; public static final int SENT_DEFAULT_TOUCH_TIME = 1; diff --git a/src/com/android/email/service/EmailServiceStub.java b/src/com/android/email/service/EmailServiceStub.java index aef1d8399..6752d8a78 100644 --- a/src/com/android/email/service/EmailServiceStub.java +++ b/src/com/android/email/service/EmailServiceStub.java @@ -79,15 +79,6 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm private static final int MAILBOX_COLUMN_SERVER_ID = 1; private static final int MAILBOX_COLUMN_TYPE = 2; - /** System folders that should always exist. */ - private final int[] DEFAULT_FOLDERS = { - Mailbox.TYPE_INBOX, - Mailbox.TYPE_DRAFTS, - Mailbox.TYPE_OUTBOX, - Mailbox.TYPE_SENT, - Mailbox.TYPE_TRASH - }; - /** Small projection for just the columns required for a sync. */ private static final String[] MAILBOX_PROJECTION = new String[] { MailboxColumns.ID, @@ -351,7 +342,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm Cursor localFolderCursor = null; try { // Step 0: Make sure the default system mailboxes exist. - for (int type : DEFAULT_FOLDERS) { + for (final int type : Mailbox.REQUIRED_FOLDER_TYPES) { if (Mailbox.findMailboxOfType(mContext, accountId, type) == Mailbox.NO_MAILBOX) { Mailbox mailbox = Mailbox.newSystemMailbox(mContext, accountId, type); mailbox.save(mContext);