From d52710242e070b87cccb5c27fb775e0c99c6ecdf Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Wed, 4 Apr 2012 14:20:24 -0700 Subject: [PATCH] Set "supports settings" on EAS folders (database upgrade) Change-Id: I19324d25846e8f12a5e4783c427291d4fc13bd3d --- CleanSpec.mk | 2 ++ .../android/emailcommon/provider/Mailbox.java | 2 ++ .../com/android/email/provider/DBHelper.java | 24 ++++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index f62280c72..d974023c3 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -69,6 +69,8 @@ $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Email2_intermedi $(call add-clean-step, rm -rf $(OUT_DIR)/out/target/common/obj/JAVA_LIBRARIES/com.android.emailcommon*) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/EmailGoogle_intermediates) $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Email2_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/out/target/common/obj/JAVA_LIBRARIES/com.android.emailcommon*) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Email*) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST diff --git a/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java b/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java index 4e44ad2fd..6a3019d97 100644 --- a/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java +++ b/email2/emailcommon/src/com/android/emailcommon/provider/Mailbox.java @@ -211,6 +211,8 @@ public class Mailbox extends EmailContent implements SyncColumns, MailboxColumns public static final int FLAG_ACCEPTS_MOVED_MAIL = 1<<4; /** can be used as a target for appending messages */ public static final int FLAG_ACCEPTS_APPENDED_MAIL = 1<<5; + /** has user settings (sync lookback, etc.) */ + public static final int FLAG_SUPPORTS_SETTINGS = 1<<6; // Magic mailbox ID's // NOTE: This is a quick solution for merged mailboxes. I would rather implement this diff --git a/email2/src/com/android/email/provider/DBHelper.java b/email2/src/com/android/email/provider/DBHelper.java index 4339fb754..bc783ab24 100644 --- a/email2/src/com/android/email/provider/DBHelper.java +++ b/email2/src/com/android/email/provider/DBHelper.java @@ -24,6 +24,7 @@ import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; +import android.os.Debug; import android.provider.ContactsContract; import android.util.Log; @@ -119,8 +120,10 @@ public final class DBHelper { // Version 33: Add columns to attachment for ui provider columns // Version 34: Add total count to mailbox // Version 35: Set up defaults for lastTouchedCount for drafts and sent + // Version 36: mblank intentionally left this space + // Version 37: Add flag for settings support in folders - public static final int DATABASE_VERSION = 35; + public static final int DATABASE_VERSION = 37; // Any changes to the database format *must* include update-in-place code. // Original version: 2 @@ -881,6 +884,25 @@ public final class DBHelper { } oldVersion = 35; } + if (oldVersion == 35 || oldVersion == 36) { + try { + // Set "supports settings" for EAS mailboxes + db.execSQL("update " + Mailbox.TABLE_NAME + " set " + + MailboxColumns.FLAGS + "=" + MailboxColumns.FLAGS + "+" + + Mailbox.FLAG_SUPPORTS_SETTINGS + " where (" + + MailboxColumns.FLAGS + "&" + Mailbox.FLAG_HOLDS_MAIL + ")!=0 and " + + MailboxColumns.ACCOUNT_KEY + " IN (SELECT " + Account.TABLE_NAME + + "." + AccountColumns.ID + " from " + Account.TABLE_NAME + "," + + HostAuth.TABLE_NAME + " where " + Account.TABLE_NAME + "." + + AccountColumns.HOST_AUTH_KEY_RECV + "=" + HostAuth.TABLE_NAME + "." + + HostAuthColumns.ID + " and " + HostAuthColumns.PROTOCOL + "='" + + HostAuth.SCHEME_EAS + "')"); + } catch (SQLException e) { + // Shouldn't be needed unless we're debugging and interrupt the process + Log.w(TAG, "Exception upgrading EmailProvider.db from 35 to 36 " + e); + } + oldVersion = 37; + } } @Override