summaryrefslogtreecommitdiffstats
path: root/provider_src
diff options
context:
space:
mode:
authorRicardo Cerqueira <ricardo@cyngn.com>2014-11-10 02:45:50 +0000
committerSteve Kondik <steve@cyngn.com>2015-10-18 14:02:20 -0700
commit7fbf9f957cf1d27de60f1b06e6c14e07ea7d63cc (patch)
tree29e925a920cf1aafcbf88e6fe035c6534f89b593 /provider_src
parent11f225299457f1c1a5ce2f5b8bdbcbf71a304c7d (diff)
downloadandroid_packages_apps_Email-7fbf9f957cf1d27de60f1b06e6c14e07ea7d63cc.tar.gz
android_packages_apps_Email-7fbf9f957cf1d27de60f1b06e6c14e07ea7d63cc.tar.bz2
android_packages_apps_Email-7fbf9f957cf1d27de60f1b06e6c14e07ea7d63cc.zip
DBHelper: Support upgrades from CM11
Add the new columns when coming from v126, add the old ones when coming from any other value (or creating) so that they're there when the feature gets reintroduced Change-Id: I48ec042b30afbcefd43bdad0042147b6b0d2249f
Diffstat (limited to 'provider_src')
-rw-r--r--provider_src/com/android/email/provider/DBHelper.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/provider_src/com/android/email/provider/DBHelper.java b/provider_src/com/android/email/provider/DBHelper.java
index dbeca637c..f6a0f2de3 100644
--- a/provider_src/com/android/email/provider/DBHelper.java
+++ b/provider_src/com/android/email/provider/DBHelper.java
@@ -184,7 +184,7 @@ public final class DBHelper {
// Version 126: Decode address lists for To, From, Cc, Bcc and Reply-To columns in Message.
// Version 127: Force mFlags to contain the correct flags for EAS accounts given a protocol
// version above 12.0
- public static final int DATABASE_VERSION = 127;
+ public static final int DATABASE_VERSION = 128;
// Any changes to the database format *must* include update-in-place code.
// Original version: 2
@@ -517,6 +517,7 @@ public final class DBHelper {
+ AccountColumns.POLICY_KEY + " integer, "
+ AccountColumns.MAX_ATTACHMENT_SIZE + " integer, "
+ AccountColumns.PING_DURATION + " integer"
+ + AccountColumns.AUTO_FETCH_ATTACHMENTS + " integer"
+ ");";
db.execSQL("create table " + Account.TABLE_NAME + s);
// Deleting an account deletes associated Mailboxes and HostAuth's
@@ -868,6 +869,9 @@ public final class DBHelper {
@Override
@SuppressWarnings("deprecation")
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+
+ boolean fromCM11 = false;
+
// For versions prior to 5, delete all data
// Versions >= 5 require that data be preserved!
if (oldVersion < 5) {
@@ -1453,7 +1457,11 @@ public final class DBHelper {
}
}
- if (oldVersion <= 124) {
+ if (oldVersion == 126) {
+ fromCM11 = true;
+ }
+
+ if (oldVersion <= 124 || fromCM11) {
createCredentialsTable(db);
// Add the credentialKey column, and set it to -1 for all pre-existing hostAuths.
db.execSQL("alter table " + HostAuth.TABLE_NAME
@@ -1462,13 +1470,26 @@ public final class DBHelper {
+ HostAuthColumns.CREDENTIAL_KEY + "=-1");
}
- if (oldVersion <= 125) {
+ if (oldVersion <= 125 || fromCM11) {
upgradeFromVersion125ToVersion126(db);
}
- if (oldVersion <= 126) {
+ if (oldVersion <= 126 || fromCM11) {
upgradeFromVersion126ToVersion127(mContext, db);
}
+ if (oldVersion <= 127 && !fromCM11) {
+ try {
+ db.execSQL("alter table " + Account.TABLE_NAME
+ + " add column " + AccountColumns.AUTO_FETCH_ATTACHMENTS
+ + " integer" + ";");
+ final ContentValues cv = new ContentValues(1);
+ cv.put(AccountColumns.AUTO_FETCH_ATTACHMENTS, 0);
+ db.update(Account.TABLE_NAME, cv, null, null);
+ } catch (final SQLException e) {
+ // Shouldn't be needed unless we're debugging and interrupt the process
+ LogUtils.w(TAG, "Exception upgrading EmailProvider.db from v127 to v128", e);
+ }
+ }
}
@Override