summaryrefslogtreecommitdiffstats
path: root/provider_src/com/android/email/provider/DBHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'provider_src/com/android/email/provider/DBHelper.java')
-rw-r--r--provider_src/com/android/email/provider/DBHelper.java53
1 files changed, 51 insertions, 2 deletions
diff --git a/provider_src/com/android/email/provider/DBHelper.java b/provider_src/com/android/email/provider/DBHelper.java
index 18a4548fe..fa70e6f4f 100644
--- a/provider_src/com/android/email/provider/DBHelper.java
+++ b/provider_src/com/android/email/provider/DBHelper.java
@@ -58,6 +58,7 @@ import com.android.emailcommon.provider.MessageStateChange;
import com.android.emailcommon.provider.Policy;
import com.android.emailcommon.provider.QuickResponse;
import com.android.emailcommon.provider.SuggestedContact;
+import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.LegacyPolicySet;
import com.android.emailcommon.service.SyncWindow;
import com.android.mail.providers.UIProvider;
@@ -187,7 +188,8 @@ public final class DBHelper {
// Version 127: Force mFlags to contain the correct flags for EAS accounts given a protocol
// version above 12.0
// Version 129: Update all IMAP INBOX mailboxes to force synchronization
- public static final int DATABASE_VERSION = 129;
+ // Version 130: Account capabilities (check EmailServiceProxy#CAPABILITY_*)
+ public static final int DATABASE_VERSION = 130;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@@ -525,7 +527,8 @@ public final class DBHelper {
+ AccountColumns.POLICY_KEY + " integer, "
+ AccountColumns.MAX_ATTACHMENT_SIZE + " integer, "
+ AccountColumns.PING_DURATION + " integer, "
- + AccountColumns.AUTO_FETCH_ATTACHMENTS + " integer"
+ + AccountColumns.AUTO_FETCH_ATTACHMENTS + " integer, "
+ + AccountColumns.CAPABILITIES + " integer default 0"
+ ");";
db.execSQL("create table " + Account.TABLE_NAME + s);
// Deleting an account deletes associated Mailboxes and HostAuth's
@@ -1562,6 +1565,52 @@ public final class DBHelper {
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + "='imap'));");
}
+ if (oldVersion <= 130) {
+ //Account capabilities (check EmailServiceProxy#CAPABILITY_*)
+ try {
+ // Create capabilities field
+ db.execSQL("alter table " + Account.TABLE_NAME
+ + " add column " + AccountColumns.CAPABILITIES
+ + " integer" + " default 0;");
+
+ // Update all accounts with the appropriate capabilities
+ Cursor c = db.rawQuery("select " + Account.TABLE_NAME + "."
+ + AccountColumns._ID + ", " + HostAuth.TABLE_NAME + "."
+ + HostAuthColumns.PROTOCOL + " from " + Account.TABLE_NAME + ", "
+ + HostAuth.TABLE_NAME + " where " + Account.TABLE_NAME + "."
+ + AccountColumns.HOST_AUTH_KEY_RECV + " = " + HostAuth.TABLE_NAME
+ + "." + HostAuthColumns._ID + ";", null);
+ if (c != null) {
+ try {
+ while(c.moveToNext()) {
+ long id = c.getLong(c.getColumnIndexOrThrow(AccountColumns._ID));
+ String protocol = c.getString(c.getColumnIndexOrThrow(
+ HostAuthColumns.PROTOCOL));
+
+ int capabilities = 0;
+ if (protocol.equals(LEGACY_SCHEME_IMAP)
+ || protocol.equals(LEGACY_SCHEME_EAS)) {
+ // Don't know yet if the imap server supports the IDLE
+ // capability, but since this is upgrading the account,
+ // just assume that all imap servers supports the push
+ // capability and let disable it by the IMAP service
+ capabilities |= EmailServiceProxy.CAPABILITY_PUSH;
+ }
+ final ContentValues cv = new ContentValues(1);
+ cv.put(AccountColumns.CAPABILITIES, capabilities);
+ db.update(Account.TABLE_NAME, cv, AccountColumns._ID + " = ?",
+ new String[]{String.valueOf(id)});
+ }
+ } finally {
+ c.close();
+ }
+ }
+ } catch (final SQLException e) {
+ // Shouldn't be needed unless we're debugging and interrupt the process
+ LogUtils.w(TAG, "Exception upgrading EmailProvider.db from v129 to v130", e);
+ }
+ }
+
// Due to a bug in commit 44a064e5f16ddaac25f2acfc03c118f65bc48aec,
// AUTO_FETCH_ATTACHMENTS column could not be available in the Account table.
// Since cm12 and up doesn't use this column, we are leave as is it. In case