Set "supports settings" on EAS folders (database upgrade)

Change-Id: I19324d25846e8f12a5e4783c427291d4fc13bd3d
This commit is contained in:
Marc Blank 2012-04-04 14:20:24 -07:00
parent 3dc2a77d4f
commit d52710242e
3 changed files with 27 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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