From 4b33b983d74c42af893e3f532f10b35b02bf5fac Mon Sep 17 00:00:00 2001 From: Anthony Lee Date: Thu, 6 Mar 2014 15:27:54 -0800 Subject: [PATCH] b/9564335. Add support for a maxAttachmentSize column in the Account table and connect the data to the Settings object in the existing location (SettingsColumns.MAX_ATTACHMENT_SIZE). Change-Id: Iaf48995757511e1dfb65aa35ff6d81bbc47187bd --- .../android/emailcommon/provider/Account.java | 4 +++- .../emailcommon/provider/EmailContent.java | 2 ++ src/com/android/email/provider/DBHelper.java | 17 ++++++++++++++++- .../android/email/provider/EmailProvider.java | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/provider/Account.java b/emailcommon/src/com/android/emailcommon/provider/Account.java index 1f152cf83..bd9998c7d 100755 --- a/emailcommon/src/com/android/emailcommon/provider/Account.java +++ b/emailcommon/src/com/android/emailcommon/provider/Account.java @@ -166,6 +166,7 @@ public final class Account extends EmailContent implements AccountColumns, Parce public static final int CONTENT_SIGNATURE_COLUMN = 15; public static final int CONTENT_POLICY_KEY_COLUMN = 16; public static final int CONTENT_PING_DURATION_COLUMN = 17; + public static final int CONTENT_MAX_ATTACHMENT_SIZE_COLUMN = 18; public static final String[] CONTENT_PROJECTION = new String[] { RECORD_ID, AccountColumns.DISPLAY_NAME, @@ -175,7 +176,8 @@ public final class Account extends EmailContent implements AccountColumns, Parce AccountColumns.COMPATIBILITY_UUID, AccountColumns.SENDER_NAME, AccountColumns.RINGTONE_URI, AccountColumns.PROTOCOL_VERSION, AccountColumns.NEW_MESSAGE_COUNT, AccountColumns.SECURITY_SYNC_KEY, - AccountColumns.SIGNATURE, AccountColumns.POLICY_KEY, AccountColumns.PING_DURATION + AccountColumns.SIGNATURE, AccountColumns.POLICY_KEY, AccountColumns.PING_DURATION, + AccountColumns.MAX_ATTACHMENT_SIZE }; public static final int CONTENT_MAILBOX_TYPE_COLUMN = 1; diff --git a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java index 0abaa7975..936fcca39 100755 --- a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java +++ b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java @@ -1619,6 +1619,8 @@ public abstract class EmailContent { public static final String SIGNATURE = "signature"; // A foreign key into the Policy table public static final String POLICY_KEY = "policyKey"; + // Max upload attachment size. + public static final String MAX_ATTACHMENT_SIZE = "maxAttachmentSize"; // Current duration of the Exchange ping public static final String PING_DURATION = "pingDuration"; } diff --git a/src/com/android/email/provider/DBHelper.java b/src/com/android/email/provider/DBHelper.java index 3a29c4a31..c9c0cf046 100644 --- a/src/com/android/email/provider/DBHelper.java +++ b/src/com/android/email/provider/DBHelper.java @@ -163,7 +163,8 @@ public final class DBHelper { // Version 122: Need to update Message_Updates and Message_Deletes to match previous. // Version 123: Changed the duplicateMesage deletion trigger to ignore accounts that aren't // exchange accounts. - public static final int DATABASE_VERSION = 123; + // Version 124: Added MAX_ATTACHMENT_SIZE to the account table + public static final int DATABASE_VERSION = 124; // Any changes to the database format *must* include update-in-place code. // Original version: 2 @@ -481,6 +482,7 @@ public final class DBHelper { + AccountColumns.SECURITY_SYNC_KEY + " text, " + AccountColumns.SIGNATURE + " text, " + AccountColumns.POLICY_KEY + " integer, " + + AccountColumns.MAX_ATTACHMENT_SIZE + " integer, " + AccountColumns.PING_DURATION + " integer" + ");"; db.execSQL("create table " + Account.TABLE_NAME + s); @@ -1317,6 +1319,19 @@ public final class DBHelper { } createDeleteDuplicateMessagesTrigger(mContext, db); } + + if (oldVersion <= 123) { + try { + db.execSQL("alter table " + Account.TABLE_NAME + + " add column " + AccountColumns.MAX_ATTACHMENT_SIZE +" integer" + ";"); + final ContentValues cv = new ContentValues(1); + cv.put(AccountColumns.MAX_ATTACHMENT_SIZE, 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 v123 to v124", e); + } + } } @Override diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 9555fcc3e..165cc0f01 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -2463,6 +2463,8 @@ public class EmailProvider extends ContentProvider { .add(UIProvider.AccountColumns.SettingsColumns.CONFIRM_ARCHIVE, "0") .add(UIProvider.AccountColumns.SettingsColumns.CONVERSATION_VIEW_MODE, Integer.toString(UIProvider.ConversationViewMode.UNDEFINED)) + .add(UIProvider.AccountColumns.SettingsColumns.MAX_ATTACHMENT_SIZE, + AccountColumns.MAX_ATTACHMENT_SIZE) .add(UIProvider.AccountColumns.SettingsColumns.VEILED_ADDRESS_PATTERN, null); final String feedbackUri = context.getString(R.string.email_feedback_uri);