Cleanup in EmailContent

Change-Id: Ifa251eb206779f59ea003f99395d454c7e407bc2
This commit is contained in:
Tony Mantler 2014-04-11 14:42:28 -07:00
parent 80d7676985
commit 3dd85723a1
18 changed files with 332 additions and 305 deletions

View File

@ -32,15 +32,15 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.provider.BaseColumns;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.utility.Utility;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public final class Account extends EmailContent implements AccountColumns, Parcelable {
public final class Account extends EmailContent implements Parcelable {
public static final String TABLE_NAME = "Account";
// Define all pseudo account IDs here to avoid conflict with one another.
@ -167,8 +167,8 @@ public final class Account extends EmailContent implements AccountColumns, Parce
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,
public static final String[] CONTENT_PROJECTION = {
AttachmentColumns._ID, AccountColumns.DISPLAY_NAME,
AccountColumns.EMAIL_ADDRESS, AccountColumns.SYNC_KEY, AccountColumns.SYNC_LOOKBACK,
AccountColumns.SYNC_INTERVAL, AccountColumns.HOST_AUTH_KEY_RECV,
AccountColumns.HOST_AUTH_KEY_SEND, AccountColumns.FLAGS,
@ -184,14 +184,14 @@ public final class Account extends EmailContent implements AccountColumns, Parce
/**
* This projection is for listing account id's only
*/
public static final String[] ID_TYPE_PROJECTION = new String[] {
RECORD_ID, MailboxColumns.TYPE
public static final String[] ID_TYPE_PROJECTION = {
BaseColumns._ID, MailboxColumns.TYPE
};
public static final int ACCOUNT_FLAGS_COLUMN_ID = 0;
public static final int ACCOUNT_FLAGS_COLUMN_FLAGS = 1;
public static final String[] ACCOUNT_FLAGS_PROJECTION = new String[] {
AccountColumns.ID, AccountColumns.FLAGS};
public static final String[] ACCOUNT_FLAGS_PROJECTION = {
AccountColumns._ID, AccountColumns.FLAGS};
public static final String MAILBOX_SELECTION =
MessageColumns.MAILBOX_KEY + " =?";
@ -202,7 +202,7 @@ public final class Account extends EmailContent implements AccountColumns, Parce
private static final String UUID_SELECTION = AccountColumns.COMPATIBILITY_UUID + " =?";
public static final String SECURITY_NONZERO_SELECTION =
Account.POLICY_KEY + " IS NOT NULL AND " + Account.POLICY_KEY + "!=0";
AccountColumns.POLICY_KEY + " IS NOT NULL AND " + AccountColumns.POLICY_KEY + "!=0";
private static final String FIND_INBOX_SELECTION =
MailboxColumns.TYPE + " = " + Mailbox.TYPE_INBOX +
@ -766,7 +766,7 @@ public final class Account extends EmailContent implements AccountColumns, Parce
b.withValues(mHostAuthRecv.toContentValues());
if (recvCredentialsIndex >= 0) {
final ContentValues cv = new ContentValues();
cv.put(HostAuth.CREDENTIAL_KEY, recvCredentialsIndex);
cv.put(HostAuthColumns.CREDENTIAL_KEY, recvCredentialsIndex);
b.withValueBackReferences(cv);
}
ops.add(b.build());
@ -790,7 +790,7 @@ public final class Account extends EmailContent implements AccountColumns, Parce
b.withValues(mHostAuthSend.toContentValues());
if (sendCredentialsIndex >= 0) {
final ContentValues cv = new ContentValues();
cv.put(HostAuth.CREDENTIAL_KEY, sendCredentialsIndex);
cv.put(HostAuthColumns.CREDENTIAL_KEY, sendCredentialsIndex);
b.withValueBackReferences(cv);
}
ops.add(b.build());
@ -801,10 +801,10 @@ public final class Account extends EmailContent implements AccountColumns, Parce
if (recvIndex >= 0 || sendIndex >= 0) {
cv = new ContentValues();
if (recvIndex >= 0) {
cv.put(Account.HOST_AUTH_KEY_RECV, recvIndex);
cv.put(AccountColumns.HOST_AUTH_KEY_RECV, recvIndex);
}
if (sendIndex >= 0) {
cv.put(Account.HOST_AUTH_KEY_SEND, sendIndex);
cv.put(AccountColumns.HOST_AUTH_KEY_SEND, sendIndex);
}
}

View File

@ -6,13 +6,14 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.BaseColumns;
import android.text.TextUtils;
import com.android.emailcommon.utility.Utility;
import com.android.mail.utils.LogUtils;
import com.google.common.base.Objects;
public class Credential extends EmailContent implements Parcelable {
public class Credential extends EmailContent implements Parcelable, BaseColumns {
public static final String TABLE_NAME = "Credential";
public static Uri CONTENT_URI;
@ -49,7 +50,7 @@ public class Credential extends EmailContent implements Parcelable {
public static final int EXPIRATION_COLUMN_INDEX = 4;
public static final String[] PROJECTION = new String[] {
RECORD_ID,
_ID,
PROVIDER_COLUMN,
ACCESS_TOKEN_COLUMN,
REFRESH_TOKEN_COLUMN,

View File

@ -33,6 +33,7 @@ import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.provider.BaseColumns;
import com.android.emailcommon.utility.TextUtilities;
import com.android.emailcommon.utility.Utility;
@ -58,7 +59,7 @@ import java.util.ArrayList;
* necessarily be cloned for use in these two cases.
*
* Conventions used in naming columns:
* RECORD_ID is the primary key for all Email records
* BaseColumns._ID is the primary key for all Email records
* The SyncColumns interface is used by all classes that are synced to the server directly
* (Mailbox and Email)
*
@ -72,20 +73,20 @@ public abstract class EmailContent {
public static final int NOTIFICATION_MAILBOX_UNSEEN_COUNT_COLUMN = 2;
// All classes share this
// Use BaseColumns._ID instead
@Deprecated
public static final String RECORD_ID = "_id";
public static final String[] COUNT_COLUMNS = new String[]{"count(*)"};
public static final String[] COUNT_COLUMNS = {"count(*)"};
/**
* This projection can be used with any of the EmailContent classes, when all you need
* is a list of id's. Use ID_PROJECTION_COLUMN to access the row data.
*/
public static final String[] ID_PROJECTION = new String[] {
RECORD_ID
};
public static final String[] ID_PROJECTION = { BaseColumns._ID };
public static final int ID_PROJECTION_COLUMN = 0;
public static final String ID_SELECTION = RECORD_ID + " =?";
public static final String ID_SELECTION = BaseColumns._ID + " =?";
public static final String FIELD_COLUMN_NAME = "field";
public static final String ADD_COLUMN_NAME = "add";
@ -394,7 +395,7 @@ public abstract class EmailContent {
*/
static public int count(Context context, Uri uri, String selection, String[] selectionArgs) {
return Utility.getFirstRowLong(context,
uri, COUNT_COLUMNS, selection, selectionArgs, null, 0, Long.valueOf(0)).intValue();
uri, COUNT_COLUMNS, selection, selectionArgs, null, 0, 0L).intValue();
}
/**
@ -416,15 +417,13 @@ public abstract class EmailContent {
}
public interface SyncColumns {
public static final String ID = "_id";
// source id (string) : the source's name of this item
public static final String SERVER_ID = "syncServerId";
// source's timestamp (long) for this item
public static final String SERVER_TIMESTAMP = "syncServerTimeStamp";
}
public interface BodyColumns {
public static final String ID = "_id";
public interface BodyColumns extends BaseColumns {
// Foreign key to the message corresponding to this body
public static final String MESSAGE_KEY = "messageKey";
// The html content itself
@ -448,10 +447,10 @@ public abstract class EmailContent {
public static final String QUOTED_TEXT_START_POS = "quotedTextStartPos";
}
public static final class Body extends EmailContent implements BodyColumns {
public static final class Body extends EmailContent {
public static final String TABLE_NAME = "Body";
public static final String SELECTION_BY_MESSAGE_KEY = MESSAGE_KEY + "=?";
public static final String SELECTION_BY_MESSAGE_KEY = BodyColumns.MESSAGE_KEY + "=?";
public static Uri CONTENT_URI;
@ -473,31 +472,37 @@ public abstract class EmailContent {
public static final int CONTENT_QUOTED_TEXT_START_POS_COLUMN = 8;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, BodyColumns.MESSAGE_KEY, BodyColumns.HTML_CONTENT, BodyColumns.TEXT_CONTENT,
BodyColumns.HTML_REPLY, BodyColumns.TEXT_REPLY, BodyColumns.SOURCE_MESSAGE_KEY,
BodyColumns.INTRO_TEXT, BodyColumns.QUOTED_TEXT_START_POS
BodyColumns._ID,
BodyColumns.MESSAGE_KEY,
BodyColumns.HTML_CONTENT,
BodyColumns.TEXT_CONTENT,
BodyColumns.HTML_REPLY,
BodyColumns.TEXT_REPLY,
BodyColumns.SOURCE_MESSAGE_KEY,
BodyColumns.INTRO_TEXT,
BodyColumns.QUOTED_TEXT_START_POS
};
public static final String[] COMMON_PROJECTION_TEXT = new String[] {
RECORD_ID, BodyColumns.TEXT_CONTENT
BodyColumns._ID, BodyColumns.TEXT_CONTENT
};
public static final String[] COMMON_PROJECTION_HTML = new String[] {
RECORD_ID, BodyColumns.HTML_CONTENT
BodyColumns._ID, BodyColumns.HTML_CONTENT
};
@Deprecated
public static final String[] COMMON_PROJECTION_REPLY_TEXT = new String[] {
RECORD_ID, BodyColumns.TEXT_REPLY
private static final String[] COMMON_PROJECTION_REPLY_TEXT = new String[] {
BodyColumns._ID, BodyColumns.TEXT_REPLY
};
@Deprecated
public static final String[] COMMON_PROJECTION_REPLY_HTML = new String[] {
RECORD_ID, BodyColumns.HTML_REPLY
private static final String[] COMMON_PROJECTION_REPLY_HTML = new String[] {
BodyColumns._ID, BodyColumns.HTML_REPLY
};
@Deprecated
public static final String[] COMMON_PROJECTION_INTRO = new String[] {
RECORD_ID, BodyColumns.INTRO_TEXT
private static final String[] COMMON_PROJECTION_INTRO = new String[] {
BodyColumns._ID, BodyColumns.INTRO_TEXT
};
public static final String[] COMMON_PROJECTION_SOURCE = new String[] {
RECORD_ID, BodyColumns.SOURCE_MESSAGE_KEY
BodyColumns._ID, BodyColumns.SOURCE_MESSAGE_KEY
};
public static final int COMMON_PROJECTION_COLUMN_TEXT = 1;
@ -514,9 +519,7 @@ public abstract class EmailContent {
public int mQuotedTextStartPos;
/**
* Points to the ID of the message being replied to or forwarded. Will always be set,
* even if {@link #mHtmlReply} and {@link #mTextReply} are null (indicating the user doesn't
* want to include quoted text.
* Points to the ID of the message being replied to or forwarded. Will always be set.
*/
public long mSourceKey;
@Deprecated
@ -568,7 +571,7 @@ public abstract class EmailContent {
public static Body restoreBodyWithMessageId(Context context, long messageId) {
Cursor c = context.getContentResolver().query(Body.CONTENT_URI,
Body.CONTENT_PROJECTION, Body.MESSAGE_KEY + "=?",
Body.CONTENT_PROJECTION, BodyColumns.MESSAGE_KEY + "=?",
new String[] {Long.toString(messageId)}, null);
if (c == null) throw new ProviderUnavailableException();
return restoreBodyWithCursor(c);
@ -579,9 +582,8 @@ public abstract class EmailContent {
*/
public static long lookupBodyIdWithMessageId(Context context, long messageId) {
return Utility.getFirstRowLong(context, Body.CONTENT_URI,
ID_PROJECTION, Body.MESSAGE_KEY + "=?",
new String[] {Long.toString(messageId)}, null, ID_PROJECTION_COLUMN,
Long.valueOf(-1));
ID_PROJECTION, BodyColumns.MESSAGE_KEY + "=?",
new String[] {Long.toString(messageId)}, null, ID_PROJECTION_COLUMN, -1L);
}
/**
@ -606,14 +608,14 @@ public abstract class EmailContent {
public static long restoreBodySourceKey(Context context, long messageId) {
return Utility.getFirstRowLong(context, Body.CONTENT_URI,
Body.PROJECTION_SOURCE_KEY,
Body.MESSAGE_KEY + "=?", new String[] {Long.toString(messageId)}, null, 0,
Long.valueOf(0));
BodyColumns.MESSAGE_KEY + "=?", new String[] {Long.toString(messageId)}, null,
0, 0L);
}
private static String restoreTextWithMessageId(Context context, long messageId,
String[] projection) {
Cursor c = context.getContentResolver().query(Body.CONTENT_URI, projection,
Body.MESSAGE_KEY + "=?", new String[] {Long.toString(messageId)}, null);
BodyColumns.MESSAGE_KEY + "=?", new String[] {Long.toString(messageId)}, null);
if (c == null) throw new ProviderUnavailableException();
try {
if (c.moveToFirst()) {
@ -663,8 +665,7 @@ public abstract class EmailContent {
}
}
public interface MessageColumns {
public static final String ID = "_id";
public interface MessageColumns extends BaseColumns, SyncColumns {
// Basic columns used in message list presentation
// The name as shown to the user in a message list
public static final String DISPLAY_NAME = "displayName";
@ -732,7 +733,7 @@ public abstract class EmailContent {
}
public static final class Message extends EmailContent implements SyncColumns, MessageColumns {
public static final class Message extends EmailContent {
private static final String LOG_TAG = "Email";
public static final String TABLE_NAME = "Message";
@ -793,8 +794,8 @@ public abstract class EmailContent {
public static final int CONTENT_FLAG_SEEN_COLUMN = 25;
public static final int CONTENT_MAIN_MAILBOX_KEY_COLUMN = 26;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID,
public static final String[] CONTENT_PROJECTION = {
MessageColumns._ID,
MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
MessageColumns.SUBJECT, MessageColumns.FLAG_READ,
MessageColumns.FLAG_LOADED, MessageColumns.FLAG_FAVORITE,
@ -825,8 +826,8 @@ public abstract class EmailContent {
public static final int LIST_SNIPPET_COLUMN = 12;
// Public projection for common list columns
public static final String[] LIST_PROJECTION = new String[] {
RECORD_ID,
public static final String[] LIST_PROJECTION = {
MessageColumns._ID,
MessageColumns.DISPLAY_NAME, MessageColumns.TIMESTAMP,
MessageColumns.SUBJECT, MessageColumns.FLAG_READ,
MessageColumns.FLAG_LOADED, MessageColumns.FLAG_FAVORITE,
@ -837,16 +838,16 @@ public abstract class EmailContent {
public static final int ID_COLUMNS_ID_COLUMN = 0;
public static final int ID_COLUMNS_SYNC_SERVER_ID = 1;
public static final String[] ID_COLUMNS_PROJECTION = new String[] {
RECORD_ID, SyncColumns.SERVER_ID
public static final String[] ID_COLUMNS_PROJECTION = {
MessageColumns._ID, SyncColumns.SERVER_ID
};
public static final String[] ID_COLUMN_PROJECTION = new String[] { RECORD_ID };
public static final String[] ID_COLUMN_PROJECTION = { MessageColumns._ID };
public static final String ACCOUNT_KEY_SELECTION =
MessageColumns.ACCOUNT_KEY + "=?";
public static final String[] MAILBOX_KEY_PROJECTION = new String[] { MAILBOX_KEY };
public static final String[] MAILBOX_KEY_PROJECTION = { MessageColumns.MAILBOX_KEY };
/**
* Selection for messages that are loaded
@ -864,7 +865,7 @@ public abstract class EmailContent {
public static final String ALL_FAVORITE_SELECTION =
MessageColumns.FLAG_FAVORITE + "=1 AND "
+ MessageColumns.MAILBOX_KEY + " NOT IN ("
+ "SELECT " + MailboxColumns.ID + " FROM " + Mailbox.TABLE_NAME + ""
+ "SELECT " + MailboxColumns._ID + " FROM " + Mailbox.TABLE_NAME + ""
+ " WHERE " + MailboxColumns.TYPE + " = " + Mailbox.TYPE_TRASH
+ ")"
+ " AND " + FLAG_LOADED_SELECTION;
@ -872,7 +873,7 @@ public abstract class EmailContent {
/** Selection to retrieve all messages in "inbox" for any account */
public static final String ALL_INBOX_SELECTION =
MessageColumns.MAILBOX_KEY + " IN ("
+ "SELECT " + MailboxColumns.ID + " FROM " + Mailbox.TABLE_NAME
+ "SELECT " + MailboxColumns._ID + " FROM " + Mailbox.TABLE_NAME
+ " WHERE " + MailboxColumns.TYPE + " = " + Mailbox.TYPE_INBOX
+ ")"
+ " AND " + FLAG_LOADED_SELECTION;
@ -880,7 +881,7 @@ public abstract class EmailContent {
/** Selection to retrieve all messages in "drafts" for any account */
public static final String ALL_DRAFT_SELECTION =
MessageColumns.MAILBOX_KEY + " IN ("
+ "SELECT " + MailboxColumns.ID + " FROM " + Mailbox.TABLE_NAME
+ "SELECT " + MailboxColumns._ID + " FROM " + Mailbox.TABLE_NAME
+ " WHERE " + MailboxColumns.TYPE + " = " + Mailbox.TYPE_DRAFTS
+ ")"
+ " AND " + FLAG_LOADED_SELECTION;
@ -888,7 +889,7 @@ public abstract class EmailContent {
/** Selection to retrieve all messages in "outbox" for any account */
public static final String ALL_OUTBOX_SELECTION =
MessageColumns.MAILBOX_KEY + " IN ("
+ "SELECT " + MailboxColumns.ID + " FROM " + Mailbox.TABLE_NAME
+ "SELECT " + MailboxColumns._ID + " FROM " + Mailbox.TABLE_NAME
+ " WHERE " + MailboxColumns.TYPE + " = " + Mailbox.TYPE_OUTBOX
+ ")"; // NOTE No flag_loaded test for outboxes.
@ -907,7 +908,7 @@ public abstract class EmailContent {
public static final String PER_ACCOUNT_FAVORITE_SELECTION =
ACCOUNT_KEY_SELECTION + " AND " + ALL_FAVORITE_SELECTION;
public static final String MAILBOX_SELECTION = MAILBOX_KEY + "=?";
public static final String MAILBOX_SELECTION = MessageColumns.MAILBOX_KEY + "=?";
// _id field is in AbstractContent
public String mDisplayName;
@ -1183,7 +1184,8 @@ public abstract class EmailContent {
b = ContentProviderOperation.newInsert(mBaseUri);
} else {
b = ContentProviderOperation.newUpdate(mBaseUri)
.withSelection(Message.RECORD_ID + "=?", new String[] {Long.toString(mId)});
.withSelection(MessageColumns._ID + "=?",
new String[] {Long.toString(mId)});
}
// Generate the snippet here, before we create the CPO for Message
if (mText != null) {
@ -1196,16 +1198,16 @@ public abstract class EmailContent {
// Create and save the body
ContentValues cv = new ContentValues();
if (mText != null) {
cv.put(Body.TEXT_CONTENT, mText);
cv.put(BodyColumns.TEXT_CONTENT, mText);
}
if (mHtml != null) {
cv.put(Body.HTML_CONTENT, mHtml);
cv.put(BodyColumns.HTML_CONTENT, mHtml);
}
if (mSourceKey != 0) {
cv.put(Body.SOURCE_MESSAGE_KEY, mSourceKey);
cv.put(BodyColumns.SOURCE_MESSAGE_KEY, mSourceKey);
}
if (mQuotedTextStartPos != 0) {
cv.put(Body.QUOTED_TEXT_START_POS, mQuotedTextStartPos);
cv.put(BodyColumns.QUOTED_TEXT_START_POS, mQuotedTextStartPos);
}
// We'll need this if we're new
int messageBackValue = ops.size() - 1;
@ -1214,13 +1216,13 @@ public abstract class EmailContent {
b = ContentProviderOperation.newInsert(Body.CONTENT_URI);
// Put our message id in the Body
if (!isNew) {
cv.put(Body.MESSAGE_KEY, mId);
cv.put(BodyColumns.MESSAGE_KEY, mId);
}
b.withValues(cv);
// If we're new, create a back value entry
if (isNew) {
ContentValues backValues = new ContentValues();
backValues.put(Body.MESSAGE_KEY, messageBackValue);
backValues.put(BodyColumns.MESSAGE_KEY, messageBackValue);
b.withValueBackReferences(backValues);
}
// And add the Body operation
@ -1236,7 +1238,7 @@ public abstract class EmailContent {
b = ContentProviderOperation.newInsert(Attachment.CONTENT_URI)
.withValues(att.toContentValues());
if (isNew) {
b.withValueBackReference(Attachment.MESSAGE_KEY, messageBackValue);
b.withValueBackReference(AttachmentColumns.MESSAGE_KEY, messageBackValue);
}
ops.add(b.build());
}
@ -1323,8 +1325,7 @@ public abstract class EmailContent {
}
}
public interface AttachmentColumns {
public static final String ID = "_id";
public interface AttachmentColumns extends BaseColumns {
// The display name of the attachment
public static final String FILENAME = "fileName";
// The mime type of the attachment
@ -1361,8 +1362,7 @@ public abstract class EmailContent {
public static final String UI_DOWNLOADED_SIZE = "uiDownloadedSize";
}
public static final class Attachment extends EmailContent
implements AttachmentColumns, Parcelable {
public static final class Attachment extends EmailContent implements Parcelable {
public static final String TABLE_NAME = "Attachment";
public static final String ATTACHMENT_PROVIDER_LEGACY_URI_PREFIX =
"content://com.android.email.attachmentprovider";
@ -1421,8 +1421,8 @@ public abstract class EmailContent {
public static final int CONTENT_UI_STATE_COLUMN = 14;
public static final int CONTENT_UI_DESTINATION_COLUMN = 15;
public static final int CONTENT_UI_DOWNLOADED_SIZE_COLUMN = 16;
public static final String[] CONTENT_PROJECTION = new String[] {
RECORD_ID, AttachmentColumns.FILENAME, AttachmentColumns.MIME_TYPE,
public static final String[] CONTENT_PROJECTION = {
AttachmentColumns._ID, AttachmentColumns.FILENAME, AttachmentColumns.MIME_TYPE,
AttachmentColumns.SIZE, AttachmentColumns.CONTENT_ID, AttachmentColumns.CONTENT_URI,
AttachmentColumns.CACHED_FILE, AttachmentColumns.MESSAGE_KEY,
AttachmentColumns.LOCATION, AttachmentColumns.ENCODING, AttachmentColumns.CONTENT,
@ -1433,11 +1433,11 @@ public abstract class EmailContent {
// All attachments with an empty URI, regardless of mailbox
public static final String PRECACHE_SELECTION =
AttachmentColumns.CONTENT_URI + " isnull AND " + Attachment.FLAGS + "=0";
AttachmentColumns.CONTENT_URI + " isnull AND " + AttachmentColumns.FLAGS + "=0";
// Attachments with an empty URI that are in an inbox
public static final String PRECACHE_INBOX_SELECTION =
PRECACHE_SELECTION + " AND " + AttachmentColumns.MESSAGE_KEY + " IN ("
+ "SELECT " + MessageColumns.ID + " FROM " + Message.TABLE_NAME
+ "SELECT " + MessageColumns._ID + " FROM " + Message.TABLE_NAME
+ " WHERE " + Message.ALL_INBOX_SELECTION
+ ")";
@ -1699,8 +1699,7 @@ public abstract class EmailContent {
}
}
public interface AccountColumns {
public static final String ID = "_id";
public interface AccountColumns extends BaseColumns {
// The display name of the account (user-settable)
public static final String DISPLAY_NAME = "displayName";
// The email address corresponding to this account
@ -1757,15 +1756,16 @@ public abstract class EmailContent {
public static final String PING_DURATION = "pingDuration";
}
public interface QuickResponseColumns {
static final String ID = "_id";
public interface QuickResponseColumns extends BaseColumns {
// The QuickResponse text
static final String TEXT = "quickResponse";
// A foreign key into the Account table owning the QuickResponse
static final String ACCOUNT_KEY = "accountKey";
}
public interface MailboxColumns {
public interface MailboxColumns extends BaseColumns {
// Use _ID instead
@Deprecated
public static final String ID = "_id";
// The display name of this mailbox [INDEX]
static final String DISPLAY_NAME = "displayName";
@ -1830,8 +1830,7 @@ public abstract class EmailContent {
public static final String LAST_FULL_SYNC_TIME = "lastFullSyncTime";
}
public interface HostAuthColumns {
public static final String ID = "_id";
public interface HostAuthColumns extends BaseColumns {
// The protocol (e.g. "imap", "pop3", "eas", "smtp"
static final String PROTOCOL = "protocol";
// The host address
@ -1856,8 +1855,7 @@ public abstract class EmailContent {
static final String CREDENTIAL_KEY = "credentialKey";
}
public interface PolicyColumns {
public static final String ID = "_id";
public interface PolicyColumns extends BaseColumns {
public static final String PASSWORD_MODE = "passwordMode";
public static final String PASSWORD_MIN_LENGTH = "passwordMinLength";
public static final String PASSWORD_EXPIRATION_DAYS = "passwordExpirationDays";

View File

@ -32,7 +32,7 @@ import com.android.emailcommon.utility.Utility;
import java.net.URI;
import java.net.URISyntaxException;
public class HostAuth extends EmailContent implements HostAuthColumns, Parcelable {
public class HostAuth extends EmailContent implements Parcelable {
public static final String TABLE_NAME = "HostAuth";
public static Uri CONTENT_URI;

View File

@ -24,6 +24,7 @@ import android.database.Cursor;
import android.text.TextUtils;
import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.mail.utils.LogUtils;
@ -166,7 +167,7 @@ public class MailboxUtilities {
if (account == null) return;
// Set temporary flag indicating state of update of mailbox list
ContentValues cv = new ContentValues();
cv.put(Account.FLAGS, start ? (account.mFlags | ACCOUNT_MAILBOX_CHANGE_FLAG) :
cv.put(AccountColumns.FLAGS, start ? (account.mFlags | ACCOUNT_MAILBOX_CHANGE_FLAG) :
account.mFlags & ~ACCOUNT_MAILBOX_CHANGE_FLAG);
context.getContentResolver().update(
ContentUris.withAppendedId(Account.CONTENT_URI, account.mId), cv, null, null);
@ -219,7 +220,7 @@ public class MailboxUtilities {
}
private static final String[] HIERARCHY_PROJECTION = new String[] {
MailboxColumns.ID, MailboxColumns.DISPLAY_NAME, MailboxColumns.PARENT_KEY,
MailboxColumns._ID, MailboxColumns.DISPLAY_NAME, MailboxColumns.PARENT_KEY,
MailboxColumns.HIERARCHICAL_NAME
};
private static final int HIERARCHY_ID = 0;

View File

@ -74,7 +74,7 @@ public class SSLUtils {
mHostAuth = hostAuth;
// We must load the server cert manually (the ContentCache won't handle blobs
Cursor c = context.getContentResolver().query(HostAuth.CONTENT_URI,
new String[] {HostAuthColumns.SERVER_CERT}, HostAuth.ID + "=?",
new String[] {HostAuthColumns.SERVER_CERT}, HostAuthColumns._ID + "=?",
new String[] {Long.toString(hostAuth.mId)}, null);
if (c != null) {
try {

View File

@ -131,7 +131,7 @@ public abstract class SyncManager extends Service implements Runnable {
+ Mailbox.TYPE_CALENDAR + ')';
protected static final String WHERE_IN_ACCOUNT_AND_TYPE_INBOX =
MailboxColumns.ACCOUNT_KEY + "=? and type = " + Mailbox.TYPE_INBOX ;
private static final String WHERE_MAILBOX_KEY = Message.MAILBOX_KEY + "=?";
private static final String WHERE_MAILBOX_KEY = MessageColumns.MAILBOX_KEY + "=?";
private static final String WHERE_NOT_INTERVAL_NEVER_AND_ACCOUNT_KEY_IN =
"(" + MailboxColumns.TYPE + '=' + Mailbox.TYPE_OUTBOX
+ " or " + MailboxColumns.SYNC_INTERVAL + "<" + Mailbox.CHECK_INTERVAL_NEVER + ')'
@ -1208,7 +1208,6 @@ public abstract class SyncManager extends Service implements Runnable {
* Starts a service thread and enters it into the service map
* This is the point of instantiation of all sync threads
* @param service the service to start
* @param m the Mailbox on which the service will operate
*/
private void startServiceThread(AbstractSyncService service) {
final Mailbox mailbox = service.mMailbox;
@ -1656,7 +1655,7 @@ public abstract class SyncManager extends Service implements Runnable {
/**
* Check whether an Outbox (referenced by a Cursor) has any messages that can be sent
* @param c the cursor to an Outbox
* @param outboxCursor the cursor to an Outbox
* @return true if there is mail to be sent
*/
private boolean hasSendableMessages(Cursor outboxCursor) {

View File

@ -18,6 +18,7 @@ package com.android.email;
import com.android.emailcommon.internet.MimeUtility;
import com.android.emailcommon.provider.EmailContent.Attachment;
import com.android.emailcommon.provider.EmailContent.AttachmentColumns;
import com.android.emailcommon.utility.AttachmentUtilities;
import com.android.emailcommon.utility.Utility;
@ -39,8 +40,14 @@ import java.util.List;
*/
public class AttachmentInfo {
// Projection which can be used with the constructor taking a Cursor argument
public static final String[] PROJECTION = new String[] {Attachment.RECORD_ID, Attachment.SIZE,
Attachment.FILENAME, Attachment.MIME_TYPE, Attachment.ACCOUNT_KEY, Attachment.FLAGS};
public static final String[] PROJECTION = {
AttachmentColumns._ID,
AttachmentColumns.SIZE,
AttachmentColumns.FILENAME,
AttachmentColumns.MIME_TYPE,
AttachmentColumns.ACCOUNT_KEY,
AttachmentColumns.FLAGS
};
// Offsets into PROJECTION
public static final int COLUMN_ID = 0;
public static final int COLUMN_SIZE = 1;

View File

@ -44,6 +44,7 @@ import com.android.email.R;
import com.android.email.service.EmailServiceUtils;
import com.android.emailcommon.VendorPolicyLoader;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.service.SyncWindow;
import com.android.mail.utils.LogUtils;
@ -400,7 +401,8 @@ public class AccountSetupFinal extends AccountSetupActivity
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new CursorLoader(AccountSetupFinal.this, Account.CONTENT_URI,
new String[] {Account.EMAIL_ADDRESS, Account.DISPLAY_NAME},
new String[] {AccountColumns.EMAIL_ADDRESS,
AccountColumns.DISPLAY_NAME},
null, null, null);
}
@ -413,9 +415,10 @@ public class AccountSetupFinal extends AccountSetupActivity
mExistingAccountsMap = new HashMap<String, String>();
final int emailColumnIndex = data.getColumnIndex(Account.EMAIL_ADDRESS);
final int emailColumnIndex = data.getColumnIndex(
AccountColumns.EMAIL_ADDRESS);
final int displayNameColumnIndex =
data.getColumnIndex(Account.DISPLAY_NAME);
data.getColumnIndex(AccountColumns.DISPLAY_NAME);
while (data.moveToNext()) {
final String email = data.getString(emailColumnIndex);

View File

@ -39,6 +39,7 @@ import android.view.MenuItem;
import com.android.email.R;
import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.provider.Mailbox;
import com.android.emailcommon.provider.Policy;
@ -219,7 +220,7 @@ public class MailboxSettings extends PreferenceActivity {
private static class MailboxLoader extends MailAsyncTaskLoader<Map<String, Object>> {
/** Projection for loading an account's policy key. */
private static final String[] POLICY_KEY_PROJECTION =
{ Account.POLICY_KEY };
{ AccountColumns.POLICY_KEY };
private static final int POLICY_KEY_COLUMN = 0;
/** Projection for loading the max email lookback. */

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.provider.BaseColumns;
import android.provider.CalendarContract;
import android.provider.ContactsContract;
import android.text.TextUtils;
@ -70,37 +71,37 @@ public final class DBHelper {
private static final String LEGACY_SCHEME_EAS = "eas";
private static final String WHERE_ID = EmailContent.RECORD_ID + "=?";
private static final String WHERE_ID = BaseColumns._ID + "=?";
private static final String TRIGGER_MAILBOX_DELETE =
"create trigger mailbox_delete before delete on " + Mailbox.TABLE_NAME +
" begin" +
" delete from " + Message.TABLE_NAME +
" where " + MessageColumns.MAILBOX_KEY + "=old." + EmailContent.RECORD_ID +
" where " + MessageColumns.MAILBOX_KEY + "=old." + BaseColumns._ID +
"; delete from " + Message.UPDATED_TABLE_NAME +
" where " + MessageColumns.MAILBOX_KEY + "=old." + EmailContent.RECORD_ID +
" where " + MessageColumns.MAILBOX_KEY + "=old." + BaseColumns._ID +
"; delete from " + Message.DELETED_TABLE_NAME +
" where " + MessageColumns.MAILBOX_KEY + "=old." + EmailContent.RECORD_ID +
" where " + MessageColumns.MAILBOX_KEY + "=old." + BaseColumns._ID +
"; end";
private static final String TRIGGER_ACCOUNT_DELETE =
"create trigger account_delete before delete on " + Account.TABLE_NAME +
" begin delete from " + Mailbox.TABLE_NAME +
" where " + MailboxColumns.ACCOUNT_KEY + "=old." + EmailContent.RECORD_ID +
" where " + MailboxColumns.ACCOUNT_KEY + "=old." + BaseColumns._ID +
"; delete from " + HostAuth.TABLE_NAME +
" where " + EmailContent.RECORD_ID + "=old." + AccountColumns.HOST_AUTH_KEY_RECV +
" where " + BaseColumns._ID + "=old." + AccountColumns.HOST_AUTH_KEY_RECV +
"; delete from " + HostAuth.TABLE_NAME +
" where " + EmailContent.RECORD_ID + "=old." + AccountColumns.HOST_AUTH_KEY_SEND +
" where " + BaseColumns._ID + "=old." + AccountColumns.HOST_AUTH_KEY_SEND +
"; delete from " + Policy.TABLE_NAME +
" where " + EmailContent.RECORD_ID + "=old." + AccountColumns.POLICY_KEY +
" where " + BaseColumns._ID + "=old." + AccountColumns.POLICY_KEY +
"; end";
private static final String TRIGGER_HOST_AUTH_DELETE =
"create trigger host_auth_delete after delete on " + HostAuth.TABLE_NAME +
" begin delete from " + Credential.TABLE_NAME +
" where " + Credential.RECORD_ID + "=old." + HostAuth.CREDENTIAL_KEY +
" where " + Credential._ID + "=old." + HostAuthColumns.CREDENTIAL_KEY +
" and (select count(*) from " + HostAuth.TABLE_NAME + " where " +
HostAuth.CREDENTIAL_KEY + "=old." + HostAuth.CREDENTIAL_KEY + ")=0" +
HostAuthColumns.CREDENTIAL_KEY + "=old." + HostAuthColumns.CREDENTIAL_KEY + ")=0" +
"; end";
@ -208,7 +209,7 @@ public final class DBHelper {
Message.TABLE_NAME +
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.MESSAGE_COUNT +
'=' + MailboxColumns.MESSAGE_COUNT + "+1" +
" where " + EmailContent.RECORD_ID + "=NEW." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=NEW." + MessageColumns.MAILBOX_KEY +
"; end");
// Delete a message.
@ -216,7 +217,7 @@ public final class DBHelper {
Message.TABLE_NAME +
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.MESSAGE_COUNT +
'=' + MailboxColumns.MESSAGE_COUNT + "-1" +
" where " + EmailContent.RECORD_ID + "=OLD." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=OLD." + MessageColumns.MAILBOX_KEY +
"; end");
// Change a message's mailbox.
@ -224,15 +225,15 @@ public final class DBHelper {
MessageColumns.MAILBOX_KEY + " on " + Message.TABLE_NAME +
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.MESSAGE_COUNT +
'=' + MailboxColumns.MESSAGE_COUNT + "-1" +
" where " + EmailContent.RECORD_ID + "=OLD." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=OLD." + MessageColumns.MAILBOX_KEY +
"; update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.MESSAGE_COUNT +
'=' + MailboxColumns.MESSAGE_COUNT + "+1" +
" where " + EmailContent.RECORD_ID + "=NEW." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=NEW." + MessageColumns.MAILBOX_KEY +
"; end");
}
static void createCredentialsTable(SQLiteDatabase db) {
String s = " (" + Credential.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + Credential._ID + " integer primary key autoincrement, "
+ Credential.PROVIDER_COLUMN + " text,"
+ Credential.ACCESS_TOKEN_COLUMN + " text,"
+ Credential.REFRESH_TOKEN_COLUMN + " text,"
@ -269,21 +270,21 @@ public final class DBHelper {
+ Message.TABLE_NAME + " for each row when new." + SyncColumns.SERVER_ID
+ " is not null and "
+ "(select " + MailboxColumns.TYPE + " from " + Mailbox.TABLE_NAME
+ " where " + MailboxColumns.ID + "=new."
+ " where " + MailboxColumns._ID + "=new."
+ MessageColumns.MAILBOX_KEY + ")!=" + Mailbox.TYPE_SEARCH
+ " and (select "
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + " from "
+ HostAuth.TABLE_NAME + "," + Account.TABLE_NAME
+ " where new." + MessageColumns.ACCOUNT_KEY
+ "=" + Account.TABLE_NAME + "." + AccountColumns.ID
+ "=" + Account.TABLE_NAME + "." + AccountColumns._ID
+ " and " + Account.TABLE_NAME + "." + AccountColumns.HOST_AUTH_KEY_RECV
+ "=" + HostAuth.TABLE_NAME + "." + HostAuthColumns.ID
+ "=" + HostAuth.TABLE_NAME + "." + HostAuthColumns._ID
+ ")='" + context.getString(R.string.protocol_eas) + "'"
+ " begin delete from " + Message.TABLE_NAME + " where new."
+ SyncColumns.SERVER_ID + "=" + SyncColumns.SERVER_ID + " and new."
+ MessageColumns.ACCOUNT_KEY + "=" + MessageColumns.ACCOUNT_KEY
+ " and (select " + Mailbox.TABLE_NAME + "." + MailboxColumns.TYPE + " from "
+ Mailbox.TABLE_NAME + " where " + MailboxColumns.ID + "="
+ Mailbox.TABLE_NAME + " where " + MailboxColumns._ID + "="
+ MessageColumns.MAILBOX_KEY + ")!=" + Mailbox.TYPE_SEARCH +"; end");
}
@ -316,7 +317,7 @@ public final class DBHelper {
// This String and the following String MUST have the same columns, except for the type
// of those columns!
String createString = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String createString = " (" + BaseColumns._ID + " integer primary key autoincrement, "
+ SyncColumns.SERVER_ID + " text, "
+ SyncColumns.SERVER_TIMESTAMP + " integer, "
+ messageColumns;
@ -324,7 +325,7 @@ public final class DBHelper {
// For the updated and deleted tables, the id is assigned, but we do want to keep track
// of the ORDER of updates using an autoincrement primary key. We use the DATA column
// at this point; it has no other function
String altCreateString = " (" + EmailContent.RECORD_ID + " integer unique, "
String altCreateString = " (" + BaseColumns._ID + " integer unique, "
+ SyncColumns.SERVER_ID + " text, "
+ SyncColumns.SERVER_TIMESTAMP + " integer, "
+ messageColumns;
@ -351,7 +352,7 @@ public final class DBHelper {
// in a separate database, and trigger cannot operate on attached databases.
db.execSQL("create trigger message_delete before delete on " + Message.TABLE_NAME +
" begin delete from " + Attachment.TABLE_NAME +
" where " + AttachmentColumns.MESSAGE_KEY + "=old." + EmailContent.RECORD_ID +
" where " + AttachmentColumns.MESSAGE_KEY + "=old." + BaseColumns._ID +
"; end");
// Add triggers to keep unread count accurate per mailbox
@ -364,7 +365,7 @@ public final class DBHelper {
" when NEW." + MessageColumns.FLAG_READ + "=0" +
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.UNREAD_COUNT +
'=' + MailboxColumns.UNREAD_COUNT + "+1" +
" where " + EmailContent.RECORD_ID + "=NEW." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=NEW." + MessageColumns.MAILBOX_KEY +
"; end");
// Delete a message; if flagRead is zero, decrement the unread count of the msg's mailbox
@ -372,7 +373,7 @@ public final class DBHelper {
" when OLD." + MessageColumns.FLAG_READ + "=0" +
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.UNREAD_COUNT +
'=' + MailboxColumns.UNREAD_COUNT + "-1" +
" where " + EmailContent.RECORD_ID + "=OLD." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=OLD." + MessageColumns.MAILBOX_KEY +
"; end");
// Change a message's mailbox
@ -381,10 +382,10 @@ public final class DBHelper {
" when OLD." + MessageColumns.FLAG_READ + "=0" +
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.UNREAD_COUNT +
'=' + MailboxColumns.UNREAD_COUNT + "-1" +
" where " + EmailContent.RECORD_ID + "=OLD." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=OLD." + MessageColumns.MAILBOX_KEY +
"; update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.UNREAD_COUNT +
'=' + MailboxColumns.UNREAD_COUNT + "+1" +
" where " + EmailContent.RECORD_ID + "=NEW." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=NEW." + MessageColumns.MAILBOX_KEY +
"; end");
// Change a message's read state
@ -394,7 +395,7 @@ public final class DBHelper {
" begin update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.UNREAD_COUNT +
'=' + MailboxColumns.UNREAD_COUNT + "+ case OLD." + MessageColumns.FLAG_READ +
" when 0 then -1 else 1 end" +
" where " + EmailContent.RECORD_ID + "=OLD." + MessageColumns.MAILBOX_KEY +
" where " + BaseColumns._ID + "=OLD." + MessageColumns.MAILBOX_KEY +
"; end");
// Add triggers to maintain message_count.
@ -444,13 +445,13 @@ public final class DBHelper {
// Trigger to delete from the change log when a message is deleted.
db.execSQL("create trigger " + tableName + "_delete_message before delete on "
+ Message.TABLE_NAME + " for each row begin delete from " + tableName
+ " where " + MessageChangeLogTable.MESSAGE_KEY + "=old." + MessageColumns.ID
+ " where " + MessageChangeLogTable.MESSAGE_KEY + "=old." + MessageColumns._ID
+ "; end");
// Trigger to delete from the change log when an account is deleted.
db.execSQL("create trigger " + tableName + "_delete_account before delete on "
+ Account.TABLE_NAME + " for each row begin delete from " + tableName
+ " where " + MessageChangeLogTable.ACCOUNT_KEY + "=old." + AccountColumns.ID
+ " where " + MessageChangeLogTable.ACCOUNT_KEY + "=old." + AccountColumns._ID
+ "; end");
}
@ -488,7 +489,7 @@ public final class DBHelper {
@SuppressWarnings("deprecation")
static void createAccountTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + AccountColumns._ID + " integer primary key autoincrement, "
+ AccountColumns.DISPLAY_NAME + " text, "
+ AccountColumns.EMAIL_ADDRESS + " text, "
+ AccountColumns.SYNC_KEY + " text, "
@ -524,7 +525,7 @@ public final class DBHelper {
}
static void createPolicyTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + PolicyColumns._ID + " integer primary key autoincrement, "
+ PolicyColumns.PASSWORD_MODE + " integer, "
+ PolicyColumns.PASSWORD_MIN_LENGTH + " integer, "
+ PolicyColumns.PASSWORD_EXPIRATION_DAYS + " integer, "
@ -552,7 +553,7 @@ public final class DBHelper {
}
static void createHostAuthTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + HostAuthColumns._ID + " integer primary key autoincrement, "
+ HostAuthColumns.PROTOCOL + " text, "
+ HostAuthColumns.ADDRESS + " text, "
+ HostAuthColumns.PORT + " integer, "
@ -577,7 +578,7 @@ public final class DBHelper {
}
static void createMailboxTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + MailboxColumns._ID + " integer primary key autoincrement, "
+ MailboxColumns.DISPLAY_NAME + " text, "
+ MailboxColumns.SERVER_ID + " text, "
+ MailboxColumns.PARENT_SERVER_ID + " text, "
@ -622,7 +623,7 @@ public final class DBHelper {
}
static void createAttachmentTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + AttachmentColumns._ID + " integer primary key autoincrement, "
+ AttachmentColumns.FILENAME + " text, "
+ AttachmentColumns.MIME_TYPE + " text, "
+ AttachmentColumns.SIZE + " integer, "
@ -653,7 +654,7 @@ public final class DBHelper {
}
static void createQuickResponseTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + QuickResponseColumns._ID + " integer primary key autoincrement, "
+ QuickResponseColumns.TEXT + " text, "
+ QuickResponseColumns.ACCOUNT_KEY + " integer"
+ ");";
@ -661,7 +662,7 @@ public final class DBHelper {
}
static void createBodyTable(SQLiteDatabase db) {
String s = " (" + EmailContent.RECORD_ID + " integer primary key autoincrement, "
String s = " (" + BodyColumns._ID + " integer primary key autoincrement, "
+ BodyColumns.MESSAGE_KEY + " integer, "
+ BodyColumns.HTML_CONTENT + " text, "
+ BodyColumns.TEXT_CONTENT + " text, "
@ -736,8 +737,8 @@ public final class DBHelper {
static void recalculateMessageCount(SQLiteDatabase db) {
db.execSQL("update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.MESSAGE_COUNT +
"= (select count(*) from " + Message.TABLE_NAME +
" where " + Message.MAILBOX_KEY + " = " +
Mailbox.TABLE_NAME + "." + EmailContent.RECORD_ID + ")");
" where " + MessageColumns.MAILBOX_KEY + " = " +
Mailbox.TABLE_NAME + "." + MailboxColumns._ID + ")");
}
protected static class DatabaseHelper extends SQLiteOpenHelper {
@ -883,7 +884,7 @@ public final class DBHelper {
if (oldVersion <= 13) {
try {
db.execSQL("alter table " + Message.TABLE_NAME
+ " add column " + Message.SNIPPET
+ " add column " + MessageColumns.SNIPPET
+" text" + ";");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
@ -893,9 +894,9 @@ public final class DBHelper {
if (oldVersion <= 14) {
try {
db.execSQL("alter table " + Message.DELETED_TABLE_NAME
+ " add column " + Message.SNIPPET +" text" + ";");
+ " add column " + MessageColumns.SNIPPET +" text" + ";");
db.execSQL("alter table " + Message.UPDATED_TABLE_NAME
+ " add column " + Message.SNIPPET +" text" + ";");
+ " add column " + MessageColumns.SNIPPET +" text" + ";");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from 14 to 15 " + e);
@ -904,13 +905,13 @@ public final class DBHelper {
if (oldVersion <= 15) {
try {
db.execSQL("alter table " + Attachment.TABLE_NAME
+ " add column " + Attachment.ACCOUNT_KEY +" integer" + ";");
+ " add column " + AttachmentColumns.ACCOUNT_KEY +" integer" + ";");
// Update all existing attachments to add the accountKey data
db.execSQL("update " + Attachment.TABLE_NAME + " set " +
Attachment.ACCOUNT_KEY + "= (SELECT " + Message.TABLE_NAME + "." +
Message.ACCOUNT_KEY + " from " + Message.TABLE_NAME + " where " +
Message.TABLE_NAME + "." + Message.RECORD_ID + " = " +
Attachment.TABLE_NAME + "." + Attachment.MESSAGE_KEY + ")");
AttachmentColumns.ACCOUNT_KEY + "= (SELECT " + Message.TABLE_NAME +
"." + MessageColumns.ACCOUNT_KEY + " from " + Message.TABLE_NAME +
" where " + Message.TABLE_NAME + "." + MessageColumns._ID + " = " +
Attachment.TABLE_NAME + "." + AttachmentColumns.MESSAGE_KEY + ")");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from 15 to 16 " + e);
@ -931,7 +932,7 @@ public final class DBHelper {
if (oldVersion <= 18) {
try {
db.execSQL("alter table " + Account.TABLE_NAME
+ " add column " + Account.POLICY_KEY + " integer;");
+ " add column " + AccountColumns.POLICY_KEY + " integer;");
db.execSQL("drop trigger account_delete;");
db.execSQL(TRIGGER_ACCOUNT_DELETE);
createPolicyTable(db);
@ -991,11 +992,11 @@ public final class DBHelper {
if (oldVersion <= 26) {
try {
db.execSQL("alter table " + Message.TABLE_NAME
+ " add column " + Message.PROTOCOL_SEARCH_INFO + " text;");
+ " add column " + MessageColumns.PROTOCOL_SEARCH_INFO + " text;");
db.execSQL("alter table " + Message.DELETED_TABLE_NAME
+ " add column " + Message.PROTOCOL_SEARCH_INFO +" text" + ";");
+ " add column " + MessageColumns.PROTOCOL_SEARCH_INFO +" text" + ";");
db.execSQL("alter table " + Message.UPDATED_TABLE_NAME
+ " add column " + Message.PROTOCOL_SEARCH_INFO +" text" + ";");
+ " add column " + MessageColumns.PROTOCOL_SEARCH_INFO +" text" + ";");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from 26 to 27 " + e);
@ -1044,16 +1045,16 @@ public final class DBHelper {
if (oldVersion <= 32) {
try {
db.execSQL("alter table " + Attachment.TABLE_NAME
+ " add column " + Attachment.UI_STATE + " integer;");
+ " add column " + AttachmentColumns.UI_STATE + " integer;");
db.execSQL("alter table " + Attachment.TABLE_NAME
+ " add column " + Attachment.UI_DESTINATION + " integer;");
+ " add column " + AttachmentColumns.UI_DESTINATION + " integer;");
db.execSQL("alter table " + Attachment.TABLE_NAME
+ " add column " + Attachment.UI_DOWNLOADED_SIZE + " integer;");
+ " add column " + AttachmentColumns.UI_DOWNLOADED_SIZE + " integer;");
// If we have a contentUri then the attachment is saved
// uiDestination of 0 = "cache", so we don't have to set this
db.execSQL("update " + Attachment.TABLE_NAME + " set " + Attachment.UI_STATE +
"=" + UIProvider.AttachmentState.SAVED + " where " +
AttachmentColumns.CONTENT_URI + " is not null;");
db.execSQL("update " + Attachment.TABLE_NAME + " set " +
AttachmentColumns.UI_STATE + "=" + UIProvider.AttachmentState.SAVED +
" where " + AttachmentColumns.CONTENT_URI + " is not null;");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from 32 to 33 " + e);
@ -1091,10 +1092,10 @@ public final class DBHelper {
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 + "," +
"." + 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 + "='" +
HostAuthColumns._ID + " and " + HostAuthColumns.PROTOCOL + "='" +
LEGACY_SCHEME_EAS + "')");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
@ -1178,7 +1179,7 @@ public final class DBHelper {
if (oldVersion <= 107) {
try {
db.execSQL("alter table " + Attachment.TABLE_NAME
+ " add column " + Attachment.CACHED_FILE +" text" + ";");
+ " add column " + AttachmentColumns.CACHED_FILE +" text" + ";");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from v107 to v108", e);
@ -1274,10 +1275,11 @@ public final class DBHelper {
if (oldVersion <= 117) {
db.execSQL("update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.SYNC_INTERVAL
+ "=0 where " + MailboxColumns.ACCOUNT_KEY + " in (select "
+ Account.TABLE_NAME + "." + AccountColumns.ID + " from "
+ Account.TABLE_NAME + "." + AccountColumns._ID + " from "
+ Account.TABLE_NAME + " join " + HostAuth.TABLE_NAME + " where "
+ HostAuth.TABLE_NAME + "." + HostAuth.ID + "=" + Account.TABLE_NAME + "."
+ Account.HOST_AUTH_KEY_RECV + " and (" + HostAuth.TABLE_NAME + "."
+ HostAuth.TABLE_NAME + "." + HostAuthColumns._ID + "="
+ Account.TABLE_NAME + "." + AccountColumns.HOST_AUTH_KEY_RECV
+ " and (" + HostAuth.TABLE_NAME + "."
+ HostAuthColumns.PROTOCOL + "='"
+ mContext.getString(R.string.protocol_legacy_imap) + "' or "
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + "='"
@ -1304,7 +1306,7 @@ public final class DBHelper {
+ "(" + SyncColumns.SERVER_ID + " not null and "
+ SyncColumns.SERVER_ID + "!='') and "
+ MessageColumns.MAILBOX_KEY + " in (select "
+ MailboxColumns.ID + " from " + Mailbox.TABLE_NAME + " where "
+ MailboxColumns._ID + " from " + Mailbox.TABLE_NAME + " where "
+ MailboxColumns.TYPE + "=" + Mailbox.TYPE_DRAFTS + ")");
}
@ -1397,7 +1399,7 @@ public final class DBHelper {
@SuppressWarnings("deprecation")
static void convertPolicyFlagsToPolicyTable(SQLiteDatabase db) {
Cursor c = db.query(Account.TABLE_NAME,
new String[] {EmailContent.RECORD_ID /*0*/, AccountColumns.SECURITY_FLAGS /*1*/},
new String[] {BaseColumns._ID /*0*/, AccountColumns.SECURITY_FLAGS /*1*/},
AccountColumns.SECURITY_FLAGS + ">0", null, null, null, null);
try {
ContentValues cv = new ContentValues();
@ -1408,8 +1410,8 @@ public final class DBHelper {
long policyId = db.insert(Policy.TABLE_NAME, null, policy.toContentValues());
cv.put(AccountColumns.POLICY_KEY, policyId);
cv.putNull(AccountColumns.SECURITY_FLAGS);
args[0] = Long.toString(c.getLong(0 /*RECORD_ID*/));
db.update(Account.TABLE_NAME, cv, EmailContent.RECORD_ID + "=?", args);
args[0] = Long.toString(c.getLong(0 /*_ID*/));
db.update(Account.TABLE_NAME, cv, BaseColumns._ID + "=?", args);
}
} finally {
c.close();
@ -1435,8 +1437,8 @@ public final class DBHelper {
"UPDATE " + Mailbox.TABLE_NAME + " SET "
+ MailboxColumns.SERVER_ID + "=" + MailboxColumns.DISPLAY_NAME
+ " WHERE "
+ Mailbox.TABLE_NAME + "." + MailboxColumns.ID + " IN ( SELECT "
+ Mailbox.TABLE_NAME + "." + MailboxColumns.ID + " FROM "
+ Mailbox.TABLE_NAME + "." + MailboxColumns._ID + " IN ( SELECT "
+ Mailbox.TABLE_NAME + "." + MailboxColumns._ID + " FROM "
+ Mailbox.TABLE_NAME + "," + Account.TABLE_NAME + ","
+ HostAuth.TABLE_NAME + " WHERE "
+ "("
@ -1444,9 +1446,9 @@ public final class DBHelper {
+ Mailbox.TABLE_NAME + "." + MailboxColumns.PARENT_KEY + "=0 "
+ ") AND "
+ Mailbox.TABLE_NAME + "." + MailboxColumns.ACCOUNT_KEY + "="
+ Account.TABLE_NAME + "." + AccountColumns.ID + " AND "
+ Account.TABLE_NAME + "." + AccountColumns._ID + " AND "
+ Account.TABLE_NAME + "." + AccountColumns.HOST_AUTH_KEY_RECV + "="
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.ID + " AND ( "
+ HostAuth.TABLE_NAME + "." + HostAuthColumns._ID + " AND ( "
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + "='imap' OR "
+ HostAuth.TABLE_NAME + "." + HostAuthColumns.PROTOCOL + "='pop3' ) )");
} catch (SQLException e) {
@ -1525,7 +1527,7 @@ public final class DBHelper {
hostAuthArgs[0] = accountCursor.getString(V21_ACCOUNT_RECV);
// Get the "receive" HostAuth for this account
final Cursor hostAuthCursor = db.query(HostAuth.TABLE_NAME,
V21_HOSTAUTH_PROJECTION, HostAuth.RECORD_ID + "=?", hostAuthArgs,
V21_HOSTAUTH_PROJECTION, HostAuthColumns._ID + "=?", hostAuthArgs,
null, null, null);
try {
if (hostAuthCursor.moveToFirst()) {
@ -1584,7 +1586,7 @@ public final class DBHelper {
private static void upgradeFromVersion23ToVersion24(SQLiteDatabase db) {
try {
db.execSQL("alter table " + HostAuth.TABLE_NAME
+ " add column " + HostAuth.CLIENT_CERT_ALIAS + " text;");
+ " add column " + HostAuthColumns.CLIENT_CERT_ALIAS + " text;");
} catch (SQLException e) {
// Shouldn't be needed unless we're debugging and interrupt the process
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from 23 to 24 " + e);
@ -1602,7 +1604,7 @@ public final class DBHelper {
}
private static final String[] V25_ACCOUNT_PROJECTION =
new String[] {AccountColumns.ID, AccountColumns.FLAGS, AccountColumns.HOST_AUTH_KEY_RECV};
new String[] {AccountColumns._ID, AccountColumns.FLAGS, AccountColumns.HOST_AUTH_KEY_RECV};
private static final int V25_ACCOUNT_ID = 0;
private static final int V25_ACCOUNT_FLAGS = 1;
private static final int V25_ACCOUNT_RECV = 2;
@ -1623,7 +1625,7 @@ public final class DBHelper {
hostAuthArgs[0] = accountCursor.getString(V25_ACCOUNT_RECV);
// Get the "receive" HostAuth for this account
Cursor hostAuthCursor = db.query(HostAuth.TABLE_NAME,
V25_HOSTAUTH_PROJECTION, HostAuth.RECORD_ID + "=?", hostAuthArgs,
V25_HOSTAUTH_PROJECTION, HostAuthColumns._ID + "=?", hostAuthArgs,
null, null, null);
try {
if (hostAuthCursor.moveToFirst()) {
@ -1633,7 +1635,7 @@ public final class DBHelper {
String id = accountCursor.getString(V25_ACCOUNT_ID);
int flags = accountCursor.getInt(V25_ACCOUNT_FLAGS);
cv.put(AccountColumns.FLAGS, flags | Account.FLAGS_SUPPORTS_SEARCH);
db.update(Account.TABLE_NAME, cv, Account.RECORD_ID + "=?",
db.update(Account.TABLE_NAME, cv, AccountColumns._ID + "=?",
new String[] {id});
}
}
@ -1651,13 +1653,19 @@ public final class DBHelper {
}
/** Upgrades the database from v29 to v30 by updating all address fields in Message */
private static final int[] ADDRESS_COLUMN_INDICES = new int[] {
Message.CONTENT_BCC_LIST_COLUMN, Message.CONTENT_CC_LIST_COLUMN,
Message.CONTENT_FROM_LIST_COLUMN, Message.CONTENT_REPLY_TO_COLUMN,
Message.CONTENT_TO_LIST_COLUMN
private static final int[] ADDRESS_COLUMN_INDICES = {
Message.CONTENT_BCC_LIST_COLUMN,
Message.CONTENT_CC_LIST_COLUMN,
Message.CONTENT_FROM_LIST_COLUMN,
Message.CONTENT_REPLY_TO_COLUMN,
Message.CONTENT_TO_LIST_COLUMN
};
private static final String[] ADDRESS_COLUMN_NAMES = new String[] {
Message.BCC_LIST, Message.CC_LIST, Message.FROM_LIST, Message.REPLY_TO_LIST, Message.TO_LIST
private static final String[] ADDRESS_COLUMN_NAMES = {
MessageColumns.BCC_LIST,
MessageColumns.CC_LIST,
MessageColumns.FROM_LIST,
MessageColumns.REPLY_TO_LIST,
MessageColumns.TO_LIST
};
private static void upgradeFromVersion29ToVersion30(SQLiteDatabase db) {
@ -1730,7 +1738,7 @@ public final class DBHelper {
db.execSQL(
"UPDATE " + Account.TABLE_NAME + " SET " + AccountColumns.FLAGS + "=" +
AccountColumns.FLAGS + "|" + Long.toString(newFlags) + " WHERE " +
AccountColumns.ID + " IN (SELECT t1." + AccountColumns.ID + " FROM " +
AccountColumns._ID + " IN (SELECT t1." + AccountColumns._ID + " FROM " +
Account.TABLE_NAME + " t1 INNER JOIN " + HostAuth.TABLE_NAME +
" t2 ON t1." + AccountColumns.HOST_AUTH_KEY_RECV + "=t2._id WHERE t2." +
HostAuthColumns.PROTOCOL + "='" +
@ -1757,7 +1765,7 @@ public final class DBHelper {
// From 32->33 upgrade
try {
db.execSQL("update " + Attachment.TABLE_NAME + " set " + Attachment.UI_STATE +
db.execSQL("update " + Attachment.TABLE_NAME + " set " + AttachmentColumns.UI_STATE +
"=" + UIProvider.AttachmentState.SAVED + " where " +
AttachmentColumns.CONTENT_URI + " is not null;");
} catch (SQLException e) {
@ -1785,10 +1793,10 @@ public final class DBHelper {
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 + "," +
"." + 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 + "='" +
HostAuthColumns._ID + " and " + HostAuthColumns.PROTOCOL + "='" +
LEGACY_SCHEME_EAS + "')");
} catch (SQLException e) {
LogUtils.w(TAG, "Exception upgrading EmailProvider.db from 35/36 to 37/100 " + e);

View File

@ -82,6 +82,7 @@ import com.android.emailcommon.provider.EmailContent.MailboxColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
import com.android.emailcommon.provider.EmailContent.PolicyColumns;
import com.android.emailcommon.provider.EmailContent.QuickResponseColumns;
import com.android.emailcommon.provider.EmailContent.SyncColumns;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.provider.Mailbox;
@ -182,11 +183,11 @@ public class EmailProvider extends ContentProvider {
// Definitions for our queries looking for orphaned messages
private static final String[] ORPHANS_PROJECTION
= new String[] {MessageColumns.ID, MessageColumns.MAILBOX_KEY};
= new String[] {MessageColumns._ID, MessageColumns.MAILBOX_KEY};
private static final int ORPHANS_ID = 0;
private static final int ORPHANS_MAILBOX_KEY = 1;
private static final String WHERE_ID = EmailContent.RECORD_ID + "=?";
private static final String WHERE_ID = BaseColumns._ID + "=?";
private static final int ACCOUNT_BASE = 0;
private static final int ACCOUNT = ACCOUNT_BASE;
@ -304,18 +305,18 @@ public class EmailProvider extends ContentProvider {
*/
private static final String UPDATED_MESSAGE_INSERT = "insert or ignore into " +
Message.UPDATED_TABLE_NAME + " select * from " + Message.TABLE_NAME + " where " +
EmailContent.RECORD_ID + '=';
BaseColumns._ID + '=';
private static final String UPDATED_MESSAGE_DELETE = "delete from " +
Message.UPDATED_TABLE_NAME + " where " + EmailContent.RECORD_ID + '=';
Message.UPDATED_TABLE_NAME + " where " + BaseColumns._ID + '=';
private static final String DELETED_MESSAGE_INSERT = "insert or replace into " +
Message.DELETED_TABLE_NAME + " select * from " + Message.TABLE_NAME + " where " +
EmailContent.RECORD_ID + '=';
BaseColumns._ID + '=';
private static final String DELETE_ORPHAN_BODIES = "delete from " + Body.TABLE_NAME +
" where " + BodyColumns.MESSAGE_KEY + " in " + "(select " + BodyColumns.MESSAGE_KEY +
" from " + Body.TABLE_NAME + " except select " + EmailContent.RECORD_ID + " from " +
" from " + Body.TABLE_NAME + " except select " + BaseColumns._ID + " from " +
Message.TABLE_NAME + ')';
private static final String DELETE_BODY = "delete from " + Body.TABLE_NAME +
@ -428,7 +429,7 @@ public class EmailProvider extends ContentProvider {
// mailbox.parentServerId=b.serverId and mailbox.parentServerId not null and
// mailbox.accountKey=b.accountKey)
db.execSQL("update " + Mailbox.TABLE_NAME + " set " + MailboxColumns.PARENT_KEY + "="
+ "(select " + Mailbox.ID + " from " + Mailbox.TABLE_NAME + " as b where "
+ "(select " + Mailbox._ID + " from " + Mailbox.TABLE_NAME + " as b where "
+ Mailbox.TABLE_NAME + "." + MailboxColumns.PARENT_SERVER_ID + "="
+ "b." + MailboxColumns.SERVER_ID + " and "
+ Mailbox.TABLE_NAME + "." + MailboxColumns.PARENT_SERVER_ID + " not null and "
@ -475,10 +476,10 @@ public class EmailProvider extends ContentProvider {
deleteMessageOrphans(mDatabase, Message.DELETED_TABLE_NAME);
// Delete orphaned mailboxes/messages/policies (account no longer exists)
deleteUnlinked(mDatabase, Mailbox.TABLE_NAME, MailboxColumns.ACCOUNT_KEY,
AccountColumns.ID, Account.TABLE_NAME);
AccountColumns._ID, Account.TABLE_NAME);
deleteUnlinked(mDatabase, Message.TABLE_NAME, MessageColumns.ACCOUNT_KEY,
AccountColumns.ID, Account.TABLE_NAME);
deleteUnlinked(mDatabase, Policy.TABLE_NAME, PolicyColumns.ID,
AccountColumns._ID, Account.TABLE_NAME);
deleteUnlinked(mDatabase, Policy.TABLE_NAME, PolicyColumns._ID,
AccountColumns.POLICY_KEY, Account.TABLE_NAME);
fixParentKeys(mDatabase);
initUiProvider();
@ -700,7 +701,8 @@ public class EmailProvider extends ContentProvider {
// All attachments for the given message
id = uri.getPathSegments().get(2);
result = db.delete(tableName,
whereWith(Attachment.MESSAGE_KEY + "=" + id, selection), selectionArgs);
whereWith(AttachmentColumns.MESSAGE_KEY + "=" + id, selection),
selectionArgs);
break;
case BODY:
@ -853,11 +855,11 @@ public class EmailProvider extends ContentProvider {
resultUri = ContentUris.withAppendedId(uri, longId);
switch(match) {
case MESSAGE:
final long mailboxId = values.getAsLong(Message.MAILBOX_KEY);
final long mailboxId = values.getAsLong(MessageColumns.MAILBOX_KEY);
if (!uri.getBooleanQueryParameter(IS_UIPROVIDER, false)) {
notifyUIConversationMailbox(mailboxId);
}
notifyUIFolder(mailboxId, values.getAsLong(Message.ACCOUNT_KEY));
notifyUIFolder(mailboxId, values.getAsLong(MessageColumns.ACCOUNT_KEY));
break;
case MAILBOX:
if (values.containsKey(MailboxColumns.TYPE)) {
@ -885,11 +887,11 @@ public class EmailProvider extends ContentProvider {
throw new IllegalArgumentException("Unknown URL " + uri);
case ATTACHMENT:
int flags = 0;
if (values.containsKey(Attachment.FLAGS)) {
flags = values.getAsInteger(Attachment.FLAGS);
if (values.containsKey(AttachmentColumns.FLAGS)) {
flags = values.getAsInteger(AttachmentColumns.FLAGS);
}
// Report all new attachments to the download service
if (TextUtils.isEmpty(values.getAsString(Attachment.LOCATION))) {
if (TextUtils.isEmpty(values.getAsString(AttachmentColumns.LOCATION))) {
LogUtils.w(TAG, new Throwable(), "attachment with blank location");
}
mAttachmentService.attachmentChanged(getContext(), longId, flags);
@ -898,7 +900,7 @@ public class EmailProvider extends ContentProvider {
break;
case QUICK_RESPONSE_ACCOUNT_ID:
longId = Long.parseLong(uri.getPathSegments().get(2));
values.put(EmailContent.QuickResponseColumns.ACCOUNT_KEY, longId);
values.put(QuickResponseColumns.ACCOUNT_KEY, longId);
return insert(QuickResponse.CONTENT_URI, values);
case MAILBOX_ID:
// This implies adding a message to a mailbox
@ -1102,7 +1104,7 @@ public class EmailProvider extends ContentProvider {
sURIMatcher.addURI(EmailContent.AUTHORITY, "updatedMessage/#", UPDATED_MESSAGE_ID);
CONTENT_VALUES_RESET_NEW_MESSAGE_COUNT = new ContentValues();
CONTENT_VALUES_RESET_NEW_MESSAGE_COUNT.put(Account.NEW_MESSAGE_COUNT, 0);
CONTENT_VALUES_RESET_NEW_MESSAGE_COUNT.put(AccountColumns.NEW_MESSAGE_COUNT, 0);
sURIMatcher.addURI(EmailContent.AUTHORITY, "policy", POLICY);
sURIMatcher.addURI(EmailContent.AUTHORITY, "policy/#", POLICY_ID);
@ -1309,7 +1311,7 @@ public class EmailProvider extends ContentProvider {
// All attachments for the given message
id = uri.getPathSegments().get(2);
c = db.query(Attachment.TABLE_NAME, projection,
whereWith(Attachment.MESSAGE_KEY + "=" + id, selection),
whereWith(AttachmentColumns.MESSAGE_KEY + "=" + id, selection),
selectionArgs, null, null, sortOrder, limit);
break;
case QUICK_RESPONSE_ACCOUNT_ID:
@ -1380,7 +1382,7 @@ public class EmailProvider extends ContentProvider {
*/
private static HostAuth restoreHostAuth(SQLiteDatabase db, long id) {
Cursor c = db.query(HostAuth.TABLE_NAME, HostAuth.CONTENT_PROJECTION,
HostAuth.RECORD_ID + "=?", new String[] {Long.toString(id)}, null, null, null);
HostAuthColumns._ID + "=?", new String[] {Long.toString(id)}, null, null, null);
try {
if (c.moveToFirst()) {
HostAuth hostAuth = new HostAuth();
@ -1532,8 +1534,10 @@ public class EmailProvider extends ContentProvider {
+ MessageChangeLogTable.ACCOUNT_KEY + "," + MessageChangeLogTable.STATUS + ",";
private static final String MESSAGE_CHANGE_LOG_TABLE_VALUES_PREFIX = ") values (%s, "
+ "(select " + Message.SERVER_ID + " from " + Message.TABLE_NAME + " where _id=%s),"
+ "(select " + Message.ACCOUNT_KEY + " from " + Message.TABLE_NAME + " where _id=%s),"
+ "(select " + MessageColumns.SERVER_ID + " from " +
Message.TABLE_NAME + " where _id=%s),"
+ "(select " + MessageColumns.ACCOUNT_KEY + " from " +
Message.TABLE_NAME + " where _id=%s),"
+ MessageMove.STATUS_NONE_STRING + ",";
/**
@ -1546,10 +1550,10 @@ public class EmailProvider extends ContentProvider {
+ MessageMove.SRC_FOLDER_KEY + "," + MessageMove.DST_FOLDER_KEY + ","
+ MessageMove.SRC_FOLDER_SERVER_ID + "," + MessageMove.DST_FOLDER_SERVER_ID
+ MESSAGE_CHANGE_LOG_TABLE_VALUES_PREFIX
+ "(select " + Message.MAILBOX_KEY + " from " + Message.TABLE_NAME + " where _id=%s),"
+ "%d,"
+ "(select " + MessageColumns.MAILBOX_KEY +
" from " + Message.TABLE_NAME + " where _id=%s)," + "%d,"
+ "(select " + Mailbox.SERVER_ID + " from " + Mailbox.TABLE_NAME + " where _id=(select "
+ Message.MAILBOX_KEY + " from " + Message.TABLE_NAME + " where _id=%s)),"
+ MessageColumns.MAILBOX_KEY + " from " + Message.TABLE_NAME + " where _id=%s)),"
+ "(select " + Mailbox.SERVER_ID + " from " + Mailbox.TABLE_NAME + " where _id=%d))";
/**
@ -1574,10 +1578,10 @@ public class EmailProvider extends ContentProvider {
+ MessageStateChange.OLD_FLAG_READ + "," + MessageStateChange.NEW_FLAG_READ + ","
+ MessageStateChange.OLD_FLAG_FAVORITE + "," + MessageStateChange.NEW_FLAG_FAVORITE
+ MESSAGE_CHANGE_LOG_TABLE_VALUES_PREFIX
+ "(select " + Message.FLAG_READ + " from " + Message.TABLE_NAME + " where _id=%s),"
+ "%d,"
+ "(select " + Message.FLAG_FAVORITE + " from " + Message.TABLE_NAME + " where _id=%s),"
+ "%d)";
+ "(select " + MessageColumns.FLAG_READ +
" from " + Message.TABLE_NAME + " where _id=%s)," + "%d,"
+ "(select " + MessageColumns.FLAG_FAVORITE +
" from " + Message.TABLE_NAME + " where _id=%s)," + "%d)";
private void addToMessageStateChange(final SQLiteDatabase db, final String messageId,
final int newFlagRead, final int newFlagFavorite) {
@ -1597,14 +1601,14 @@ public class EmailProvider extends ContentProvider {
// behavior; should go away when IMAP gets converted.
private static final String GET_MESSAGE_DETAILS = "SELECT"
+ " h." + HostAuthColumns.PROTOCOL + ","
+ " m." + Message.MAILBOX_KEY + ","
+ " a." + AccountColumns.ID
+ " m." + MessageColumns.MAILBOX_KEY + ","
+ " a." + AccountColumns._ID
+ " FROM " + Message.TABLE_NAME + " AS m"
+ " INNER JOIN " + Account.TABLE_NAME + " AS a"
+ " ON m." + MessageColumns.ACCOUNT_KEY + "=a." + AccountColumns.ID
+ " ON m." + MessageColumns.ACCOUNT_KEY + "=a." + AccountColumns._ID
+ " INNER JOIN " + HostAuth.TABLE_NAME + " AS h"
+ " ON a." + AccountColumns.HOST_AUTH_KEY_RECV + "=h." + HostAuthColumns.ID
+ " WHERE m." + MessageColumns.ID + "=?";
+ " ON a." + AccountColumns.HOST_AUTH_KEY_RECV + "=h." + HostAuthColumns._ID
+ " WHERE m." + MessageColumns._ID + "=?";
private static final int INDEX_PROTOCOL = 0;
private static final int INDEX_MAILBOX_KEY = 1;
private static final int INDEX_ACCOUNT_KEY = 2;
@ -1619,8 +1623,8 @@ public class EmailProvider extends ContentProvider {
+ " a." + AccountColumns.SYNC_KEY
+ " FROM " + Account.TABLE_NAME + " AS a"
+ " INNER JOIN " + HostAuth.TABLE_NAME + " AS h"
+ " ON a." + AccountColumns.HOST_AUTH_KEY_RECV + "=h." + HostAuthColumns.ID
+ " WHERE a." + AccountColumns.ID + "=?";
+ " ON a." + AccountColumns.HOST_AUTH_KEY_RECV + "=h." + HostAuthColumns._ID
+ " WHERE a." + AccountColumns._ID + "=?";
private static final int INDEX_EMAIL_ADDRESS = 1;
private static final int INDEX_SYNC_KEY = 2;
@ -1864,8 +1868,8 @@ public class EmailProvider extends ContentProvider {
handleMessageUpdateNotifications(uri, id, values);
} else if (match == ATTACHMENT_ID) {
long attId = Integer.parseInt(id);
if (values.containsKey(Attachment.FLAGS)) {
int flags = values.getAsInteger(Attachment.FLAGS);
if (values.containsKey(AttachmentColumns.FLAGS)) {
int flags = values.getAsInteger(AttachmentColumns.FLAGS);
mAttachmentService.attachmentChanged(context, attId, flags);
}
// Notify UI if necessary; there are only two columns we can change that
@ -1899,8 +1903,8 @@ public class EmailProvider extends ContentProvider {
// is hokey at best.
LogUtils.i(TAG, "Body Update to non-existent row, morphing to insert");
final ContentValues insertValues = new ContentValues(values);
insertValues.put(EmailContent.Body.MESSAGE_KEY, selectionArgs[0]);
insert(EmailContent.Body.CONTENT_URI, insertValues);
insertValues.put(BodyColumns.MESSAGE_KEY, selectionArgs[0]);
insert(Body.CONTENT_URI, insertValues);
}
break;
case MESSAGE:
@ -1928,7 +1932,7 @@ public class EmailProvider extends ContentProvider {
Long set = values.getAsLong(EmailContent.SET_COLUMN_NAME);
if (set != null) {
newMessageCount = new ContentValues();
newMessageCount.put(Account.NEW_MESSAGE_COUNT, set);
newMessageCount.put(AccountColumns.NEW_MESSAGE_COUNT, set);
}
}
result = db.update(tableName, newMessageCount,
@ -2045,7 +2049,7 @@ public class EmailProvider extends ContentProvider {
case ATTACHMENTS_CACHED_FILE_ACCESS:
// Parse the cache file path out from the uri
final String cachedFilePath =
uri.getQueryParameter(EmailContent.Attachment.CACHED_FILE_QUERY_PARAM);
uri.getQueryParameter(Attachment.CACHED_FILE_QUERY_PARAM);
if (cachedFilePath != null) {
// clearCallingIdentity means that the download manager will
@ -2266,7 +2270,7 @@ public class EmailProvider extends ContentProvider {
" END";
private static final String ACCOUNT_COLOR =
"@CASE (" + AccountColumns.ID + " - 1) % " + ACCOUNT_COLORS.length +
"@CASE (" + AccountColumns._ID + " - 1) % " + ACCOUNT_COLORS.length +
" WHEN 0 THEN " + ACCOUNT_COLORS[0] +
" WHEN 1 THEN " + ACCOUNT_COLORS[1] +
" WHEN 2 THEN " + ACCOUNT_COLORS[2] +
@ -2285,7 +2289,7 @@ public class EmailProvider extends ContentProvider {
private static ProjectionMap getMessageListMap() {
if (sMessageListMap == null) {
sMessageListMap = ProjectionMap.builder()
.add(BaseColumns._ID, MessageColumns.ID)
.add(BaseColumns._ID, MessageColumns._ID)
.add(UIProvider.ConversationColumns.URI, uriWithId("uimessage"))
.add(UIProvider.ConversationColumns.MESSAGE_LIST_URI, uriWithId("uimessage"))
.add(UIProvider.ConversationColumns.SUBJECT, MessageColumns.SUBJECT)
@ -2339,36 +2343,34 @@ public class EmailProvider extends ContentProvider {
private static ProjectionMap getMessageViewMap() {
if (sMessageViewMap == null) {
sMessageViewMap = ProjectionMap.builder()
.add(BaseColumns._ID, Message.TABLE_NAME + "." + EmailContent.MessageColumns.ID)
.add(BaseColumns._ID, Message.TABLE_NAME + "." + MessageColumns._ID)
.add(UIProvider.MessageColumns.SERVER_ID, SyncColumns.SERVER_ID)
.add(UIProvider.MessageColumns.URI, uriWithFQId("uimessage", Message.TABLE_NAME))
.add(UIProvider.MessageColumns.CONVERSATION_ID,
uriWithFQId("uimessage", Message.TABLE_NAME))
.add(UIProvider.MessageColumns.SUBJECT, EmailContent.MessageColumns.SUBJECT)
.add(UIProvider.MessageColumns.SNIPPET, EmailContent.MessageColumns.SNIPPET)
.add(UIProvider.MessageColumns.FROM, EmailContent.MessageColumns.FROM_LIST)
.add(UIProvider.MessageColumns.TO, EmailContent.MessageColumns.TO_LIST)
.add(UIProvider.MessageColumns.CC, EmailContent.MessageColumns.CC_LIST)
.add(UIProvider.MessageColumns.BCC, EmailContent.MessageColumns.BCC_LIST)
.add(UIProvider.MessageColumns.REPLY_TO, EmailContent.MessageColumns.REPLY_TO_LIST)
.add(UIProvider.MessageColumns.DATE_RECEIVED_MS,
EmailContent.MessageColumns.TIMESTAMP)
.add(UIProvider.MessageColumns.BODY_HTML, Body.HTML_CONTENT)
.add(UIProvider.MessageColumns.BODY_TEXT, Body.TEXT_CONTENT)
.add(UIProvider.MessageColumns.SUBJECT, MessageColumns.SUBJECT)
.add(UIProvider.MessageColumns.SNIPPET, MessageColumns.SNIPPET)
.add(UIProvider.MessageColumns.FROM, MessageColumns.FROM_LIST)
.add(UIProvider.MessageColumns.TO, MessageColumns.TO_LIST)
.add(UIProvider.MessageColumns.CC, MessageColumns.CC_LIST)
.add(UIProvider.MessageColumns.BCC, MessageColumns.BCC_LIST)
.add(UIProvider.MessageColumns.REPLY_TO, MessageColumns.REPLY_TO_LIST)
.add(UIProvider.MessageColumns.DATE_RECEIVED_MS, MessageColumns.TIMESTAMP)
.add(UIProvider.MessageColumns.BODY_HTML, BodyColumns.HTML_CONTENT)
.add(UIProvider.MessageColumns.BODY_TEXT, BodyColumns.TEXT_CONTENT)
.add(UIProvider.MessageColumns.REF_MESSAGE_ID, "0")
.add(UIProvider.MessageColumns.DRAFT_TYPE, NOT_A_DRAFT_STRING)
.add(UIProvider.MessageColumns.APPEND_REF_MESSAGE_CONTENT, "0")
.add(UIProvider.MessageColumns.HAS_ATTACHMENTS,
EmailContent.MessageColumns.FLAG_ATTACHMENT)
.add(UIProvider.MessageColumns.HAS_ATTACHMENTS, MessageColumns.FLAG_ATTACHMENT)
.add(UIProvider.MessageColumns.ATTACHMENT_LIST_URI,
uriWithFQId("uiattachments", Message.TABLE_NAME))
.add(UIProvider.MessageColumns.MESSAGE_FLAGS, MESSAGE_FLAGS)
.add(UIProvider.MessageColumns.DRAFT_TYPE, MESSAGE_DRAFT_TYPE)
.add(UIProvider.MessageColumns.MESSAGE_ACCOUNT_URI,
uriWithColumn("uiaccount", MessageColumns.ACCOUNT_KEY))
.add(UIProvider.MessageColumns.STARRED, EmailContent.MessageColumns.FLAG_FAVORITE)
.add(UIProvider.MessageColumns.READ, EmailContent.MessageColumns.FLAG_READ)
.add(UIProvider.MessageColumns.SEEN, EmailContent.MessageColumns.FLAG_SEEN)
.add(UIProvider.MessageColumns.STARRED, MessageColumns.FLAG_FAVORITE)
.add(UIProvider.MessageColumns.READ, MessageColumns.FLAG_READ)
.add(UIProvider.MessageColumns.SEEN, MessageColumns.FLAG_SEEN)
.add(UIProvider.MessageColumns.SPAM_WARNING_STRING, null)
.add(UIProvider.MessageColumns.SPAM_WARNING_LEVEL,
Integer.toString(UIProvider.SpamWarningLevel.NO_WARNING))
@ -2431,7 +2433,7 @@ public class EmailProvider extends ContentProvider {
private static ProjectionMap getFolderListMap() {
if (sFolderListMap == null) {
sFolderListMap = ProjectionMap.builder()
.add(BaseColumns._ID, MailboxColumns.ID)
.add(BaseColumns._ID, MailboxColumns._ID)
.add(UIProvider.FolderColumns.PERSISTENT_ID, MailboxColumns.SERVER_ID)
.add(UIProvider.FolderColumns.URI, uriWithId("uifolder"))
.add(UIProvider.FolderColumns.NAME, "displayName")
@ -2462,7 +2464,7 @@ public class EmailProvider extends ContentProvider {
"(SELECT group_concat(" + MessageColumns.FROM_LIST + ") FROM " +
"(SELECT " + MessageColumns.FROM_LIST + " FROM " + Message.TABLE_NAME +
" WHERE " + MessageColumns.MAILBOX_KEY + "=" + Mailbox.TABLE_NAME + "." +
MailboxColumns.ID + " AND " + MessageColumns.FLAG_READ + "=0" +
MailboxColumns._ID + " AND " + MessageColumns.FLAG_READ + "=0" +
" GROUP BY " + MessageColumns.FROM_LIST + " ORDER BY " +
MessageColumns.TIMESTAMP + " DESC))")
.build();
@ -2478,7 +2480,7 @@ public class EmailProvider extends ContentProvider {
private static ProjectionMap getAccountListMap(Context context) {
if (sAccountListMap == null) {
final ProjectionMap.Builder builder = ProjectionMap.builder()
.add(BaseColumns._ID, AccountColumns.ID)
.add(BaseColumns._ID, AccountColumns._ID)
.add(UIProvider.AccountColumns.FOLDER_LIST_URI, uriWithId("uifolders"))
.add(UIProvider.AccountColumns.FULL_FOLDER_LIST_URI, uriWithId("uifullfolders"))
.add(UIProvider.AccountColumns.ALL_FOLDER_LIST_URI, uriWithId("uiallfolders"))
@ -2532,11 +2534,10 @@ public class EmailProvider extends ContentProvider {
private static ProjectionMap getQuickResponseMap() {
if (sQuickResponseMap == null) {
sQuickResponseMap = ProjectionMap.builder()
.add(UIProvider.QuickResponseColumns.TEXT,
EmailContent.QuickResponseColumns.TEXT)
.add(UIProvider.QuickResponseColumns.TEXT, QuickResponseColumns.TEXT)
.add(UIProvider.QuickResponseColumns.URI,
"'" + combinedUriString("quickresponse", "") + "'||"
+ EmailContent.QuickResponseColumns.ID)
+ QuickResponseColumns._ID)
.build();
}
return sQuickResponseMap;
@ -2635,7 +2636,7 @@ public class EmailProvider extends ContentProvider {
* @return a Uri string
*/
private static String uriWithId(String type) {
return uriWithColumn(type, EmailContent.RECORD_ID);
return uriWithColumn(type, BaseColumns._ID);
}
/**
@ -2768,9 +2769,10 @@ public class EmailProvider extends ContentProvider {
values.put(UIProvider.MessageColumns.ATTACHMENT_LIST_URI, attachmentListUri.toString());
}
StringBuilder sb = genSelect(getMessageViewMap(), uiProjection, values);
sb.append(" FROM " + Message.TABLE_NAME + " LEFT JOIN " + Body.TABLE_NAME + " ON " +
Body.MESSAGE_KEY + "=" + Message.TABLE_NAME + "." + Message.RECORD_ID + " WHERE " +
Message.TABLE_NAME + "." + Message.RECORD_ID + "=?");
sb.append(" FROM " + Message.TABLE_NAME + " LEFT JOIN " + Body.TABLE_NAME +
" ON " + BodyColumns.MESSAGE_KEY + "=" + Message.TABLE_NAME + "." +
MessageColumns._ID +
" WHERE " + Message.TABLE_NAME + "." + MessageColumns._ID + "=?");
String sql = sb.toString();
return new MessageQuery(sql, attachmentJson);
}
@ -2796,7 +2798,7 @@ public class EmailProvider extends ContentProvider {
appendConversationInfoColumns(sb);
sb.append(" FROM " + Message.TABLE_NAME + " WHERE " +
Message.FLAG_LOADED_SELECTION + " AND " +
Message.MAILBOX_KEY + "=? ");
MessageColumns.MAILBOX_KEY + "=? ");
if (unseenOnly) {
sb.append("AND ").append(MessageColumns.FLAG_SEEN).append(" = 0 ");
sb.append("AND ").append(MessageColumns.FLAG_READ).append(" = 0 ");
@ -2839,7 +2841,7 @@ public class EmailProvider extends ContentProvider {
}
switch (getVirtualMailboxType(mailboxId)) {
case Mailbox.TYPE_INBOX:
sb.append(MessageColumns.MAILBOX_KEY + " IN (SELECT " + MailboxColumns.ID +
sb.append(MessageColumns.MAILBOX_KEY + " IN (SELECT " + MailboxColumns._ID +
" FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.TYPE +
"=" + Mailbox.TYPE_INBOX + ")");
break;
@ -2848,7 +2850,7 @@ public class EmailProvider extends ContentProvider {
break;
case Mailbox.TYPE_UNREAD:
sb.append(MessageColumns.FLAG_READ + "=0 AND " + MessageColumns.MAILBOX_KEY +
" NOT IN (SELECT " + MailboxColumns.ID + " FROM " + Mailbox.TABLE_NAME +
" NOT IN (SELECT " + MailboxColumns._ID + " FROM " + Mailbox.TABLE_NAME +
" WHERE " + MailboxColumns.TYPE + "=" + Mailbox.TYPE_TRASH + ")");
break;
default:
@ -2866,7 +2868,7 @@ public class EmailProvider extends ContentProvider {
*/
private static String genQueryConversation(String[] uiProjection) {
StringBuilder sb = genSelect(getMessageListMap(), uiProjection);
sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + Message.RECORD_ID + "=?");
sb.append(" FROM " + Message.TABLE_NAME + " WHERE " + MessageColumns._ID + "=?");
return sb.toString();
}
@ -3026,7 +3028,7 @@ public class EmailProvider extends ContentProvider {
}
}
StringBuilder sb = genSelect(getFolderListMap(), uiProjection, values);
sb.append(" FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.ID + "=?");
sb.append(" FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns._ID + "=?");
return sb.toString();
}
@ -3288,7 +3290,7 @@ public class EmailProvider extends ContentProvider {
}
final StringBuilder sb = genSelect(getAccountListMap(getContext()), uiProjection, values);
sb.append(" FROM " + Account.TABLE_NAME + " WHERE " + AccountColumns.ID + "=?");
sb.append(" FROM " + Account.TABLE_NAME + " WHERE " + AccountColumns._ID + "=?");
return sb.toString();
}
@ -3523,7 +3525,7 @@ public class EmailProvider extends ContentProvider {
} else if (column.equals(UIProvider.FolderColumns.UNREAD_COUNT)) {
if (mailboxType == Mailbox.TYPE_INBOX && accountId == COMBINED_ACCOUNT_ID) {
final int unreadCount = EmailContent.count(getContext(), Message.CONTENT_URI,
MessageColumns.MAILBOX_KEY + " IN (SELECT " + MailboxColumns.ID
MessageColumns.MAILBOX_KEY + " IN (SELECT " + MailboxColumns._ID
+ " FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.TYPE
+ "=" + Mailbox.TYPE_INBOX + ") AND " + MessageColumns.FLAG_READ + "=0",
null);
@ -3540,7 +3542,7 @@ public class EmailProvider extends ContentProvider {
}
final int unreadCount = EmailContent.count(getContext(), Message.CONTENT_URI,
accountKeyClause + MessageColumns.FLAG_READ + "=0 AND "
+ MessageColumns.MAILBOX_KEY + " NOT IN (SELECT " + MailboxColumns.ID
+ MessageColumns.MAILBOX_KEY + " NOT IN (SELECT " + MailboxColumns._ID
+ " FROM " + Mailbox.TABLE_NAME + " WHERE " + MailboxColumns.TYPE + "="
+ Mailbox.TYPE_TRASH + ")", whereArgs);
values[i] = unreadCount;
@ -3628,7 +3630,7 @@ public class EmailProvider extends ContentProvider {
final SQLiteDatabase db = getDatabase(context);
final StringBuilder sb = genSelect(getQuickResponseMap(), uiProjection);
sb.append(" FROM " + QuickResponse.TABLE_NAME);
sb.append(" WHERE " + QuickResponse.ID + "=?");
sb.append(" WHERE " + QuickResponse._ID + "=?");
final String query = sb.toString();
return db.rawQuery(query, new String[] {id});
}
@ -3706,7 +3708,7 @@ public class EmailProvider extends ContentProvider {
sb.append(" FROM ")
.append(Attachment.TABLE_NAME)
.append(" WHERE ")
.append(AttachmentColumns.ID)
.append(AttachmentColumns._ID)
.append(" =? ");
return sb.toString();
}
@ -4522,7 +4524,8 @@ public class EmailProvider extends ContentProvider {
.build());
// Delete the body
ops.add(ContentProviderOperation.newDelete(Body.CONTENT_URI)
.withSelection(Body.MESSAGE_KEY + "=?", new String[] {Long.toString(msg.mId)})
.withSelection(BodyColumns.MESSAGE_KEY + "=?",
new String[] {Long.toString(msg.mId)})
.build());
// Add the ops for the message, atts, and body
msg.addSaveOps(ops);
@ -4553,7 +4556,7 @@ public class EmailProvider extends ContentProvider {
flags |= Message.FLAG_REPLIED_TO;
break;
}
cv.put(Message.FLAGS, flags);
cv.put(MessageColumns.FLAGS, flags);
context.getContentResolver().update(ContentUris.withAppendedId(
Message.CONTENT_URI, originalMsgId), cv, null, null);
}
@ -5017,7 +5020,7 @@ public class EmailProvider extends ContentProvider {
// Find the account ID (needed in a few calls)
final Cursor mailboxCursor = db.query(
Mailbox.TABLE_NAME, new String[] { MailboxColumns.ACCOUNT_KEY },
Mailbox.ID + "=" + mailboxId, null, null, null, null);
Mailbox._ID + "=" + mailboxId, null, null, null, null);
if (mailboxCursor == null || !mailboxCursor.moveToFirst()) {
LogUtils.wtf(LogUtils.TAG, "Null or empty cursor when trying to purge mailbox %d",
mailboxId);
@ -5028,7 +5031,7 @@ public class EmailProvider extends ContentProvider {
// Find all the messages in the mailbox
final String[] messageProjection =
new String[] { MessageColumns.ID };
new String[] { MessageColumns._ID };
final String messageWhere = MessageColumns.MAILBOX_KEY + "=" + mailboxId;
final Cursor messageCursor = db.query(Message.TABLE_NAME, messageProjection, messageWhere,
null, null, null, null);
@ -5037,7 +5040,7 @@ public class EmailProvider extends ContentProvider {
// Kill them with fire
while (messageCursor != null && messageCursor.moveToNext()) {
final long messageId = messageCursor.getLong(messageCursor.getColumnIndex(
MessageColumns.ID));
MessageColumns._ID));
AttachmentUtilities.deleteAllAttachmentFiles(context, accountId, messageId);
deletedCount += context.getContentResolver().delete(
ContentUris.withAppendedId(Message.SYNCED_CONTENT_URI, messageId), null, null);
@ -5487,7 +5490,7 @@ public class EmailProvider extends ContentProvider {
// Delete existing contents of search mailbox
ContentResolver resolver = context.getContentResolver();
resolver.delete(Message.CONTENT_URI, Message.MAILBOX_KEY + "=" + searchMailboxId,
resolver.delete(Message.CONTENT_URI, MessageColumns.MAILBOX_KEY + "=" + searchMailboxId,
null);
final ContentValues cv = new ContentValues(1);
// For now, use the actual query as the name of the mailbox
@ -5611,7 +5614,7 @@ public class EmailProvider extends ContentProvider {
// Delete account sync key.
final ContentValues cv = new ContentValues();
cv.putNull(Account.SYNC_KEY);
cv.putNull(AccountColumns.SYNC_KEY);
resolver.update(Account.CONTENT_URI, cv, Account.ID_SELECTION, accountIdArgs);
// Delete PIM data (contacts, calendar), stop syncs, etc. if applicable

View File

@ -278,8 +278,8 @@ public class AttachmentDownloadService extends Service implements Runnable {
private void markAttachmentAsFailed(final Attachment att) {
final ContentValues cv = new ContentValues();
final int flags = Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
cv.put(Attachment.FLAGS, att.mFlags &= ~flags);
cv.put(Attachment.UI_STATE, AttachmentState.FAILED);
cv.put(AttachmentColumns.FLAGS, att.mFlags &= ~flags);
cv.put(AttachmentColumns.UI_STATE, AttachmentState.FAILED);
att.update(mContext, cv);
}
@ -425,7 +425,7 @@ public class AttachmentDownloadService extends Service implements Runnable {
Cursor c = mContext.getContentResolver().query(lookupUri,
Attachment.CONTENT_PROJECTION,
EmailContent.Attachment.PRECACHE_INBOX_SELECTION,
null, Attachment.RECORD_ID + " DESC");
null, AttachmentColumns._ID + " DESC");
File cacheDir = mContext.getCacheDir();
try {
while (c.moveToNext()) {
@ -736,8 +736,8 @@ public class AttachmentDownloadService extends Service implements Runnable {
ContentValues cv = new ContentValues();
int flags =
Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
cv.put(Attachment.FLAGS, attachment.mFlags &= ~flags);
cv.put(Attachment.UI_STATE, AttachmentState.SAVED);
cv.put(AttachmentColumns.FLAGS, attachment.mFlags &= ~flags);
cv.put(AttachmentColumns.UI_STATE, AttachmentState.SAVED);
attachment.update(mContext, cv);
}
}
@ -1001,7 +1001,7 @@ public class AttachmentDownloadService extends Service implements Runnable {
// the queue
int mask = Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
Cursor c = getContentResolver().query(Attachment.CONTENT_URI,
EmailContent.ID_PROJECTION, "(" + Attachment.FLAGS + " & ?) != 0",
EmailContent.ID_PROJECTION, "(" + AttachmentColumns.FLAGS + " & ?) != 0",
new String[] {Integer.toString(mask)}, null);
try {
LogUtils.d(TAG, "Count: " + c.getCount());
@ -1060,7 +1060,7 @@ public class AttachmentDownloadService extends Service implements Runnable {
sRunningService = this;
}
if (intent != null && intent.hasExtra(EXTRA_ATTACHMENT)) {
Attachment att = (Attachment)intent.getParcelableExtra(EXTRA_ATTACHMENT);
Attachment att = intent.getParcelableExtra(EXTRA_ATTACHMENT);
onChange(att);
}
return Service.START_STICKY;

View File

@ -77,8 +77,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
private static final int MAILBOX_COLUMN_TYPE = 2;
/** Small projection for just the columns required for a sync. */
private static final String[] MAILBOX_PROJECTION = new String[] {
MailboxColumns.ID,
private static final String[] MAILBOX_PROJECTION = {
MailboxColumns._ID,
MailboxColumns.SERVER_ID,
MailboxColumns.TYPE,
};
@ -418,7 +418,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
final ContentResolver resolver = context.getContentResolver();
final Cursor c = resolver.query(EmailContent.Message.CONTENT_URI,
EmailContent.Message.ID_COLUMN_PROJECTION,
EmailContent.Message.MAILBOX_KEY + "=?", new String[] { Long.toString(outboxId) },
MessageColumns.MAILBOX_KEY + "=?", new String[] { Long.toString(outboxId) },
null);
try {
// 2. exit early

View File

@ -51,6 +51,7 @@ import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.HostAuthColumns;
import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.IEmailService;
@ -337,7 +338,7 @@ public class EmailServiceUtils {
// Change the HostAuth to reference the new protocol; this has to be done before
// trying to create the AccountManager account (below)
final ContentValues hostValues = new ContentValues();
hostValues.put(HostAuth.PROTOCOL, newProtocol);
hostValues.put(HostAuthColumns.PROTOCOL, newProtocol);
resolver.update(ContentUris.withAppendedId(HostAuth.CONTENT_URI, hostAuth.mId),
hostValues, null, null);
LogUtils.w(Logging.LOG_TAG, "Updated HostAuths");

View File

@ -204,10 +204,14 @@ public class ImapService extends Service {
private static final int COLUMN_SERVER_ID = 4;
private static final int COLUMN_FLAGS = 5;
private static final int COLUMN_TIMESTAMP = 6;
private static final String[] PROJECTION = new String[] {
EmailContent.RECORD_ID, MessageColumns.FLAG_READ, MessageColumns.FLAG_FAVORITE,
MessageColumns.FLAG_LOADED, SyncColumns.SERVER_ID, MessageColumns.FLAGS,
MessageColumns.TIMESTAMP
private static final String[] PROJECTION = {
MessageColumns._ID,
MessageColumns.FLAG_READ,
MessageColumns.FLAG_FAVORITE,
MessageColumns.FLAG_LOADED,
SyncColumns.SERVER_ID,
MessageColumns.FLAGS,
MessageColumns.TIMESTAMP
};
final long mId;
@ -887,9 +891,9 @@ public class ImapService extends Service {
// First handle the "new" messages (serverId == null)
Cursor upsyncs1 = resolver.query(EmailContent.Message.CONTENT_URI,
EmailContent.Message.ID_PROJECTION,
EmailContent.Message.MAILBOX_KEY + "=?"
+ " and (" + EmailContent.Message.SERVER_ID + " is null"
+ " or " + EmailContent.Message.SERVER_ID + "=''" + ")",
MessageColumns.MAILBOX_KEY + "=?"
+ " and (" + MessageColumns.SERVER_ID + " is null"
+ " or " + MessageColumns.SERVER_ID + "=''" + ")",
mailboxKeyArgs,
null);
try {
@ -1141,7 +1145,7 @@ public class ImapService extends Service {
@Override
public void onMessageUidChange(Message message, String newUid) {
ContentValues cv = new ContentValues();
cv.put(EmailContent.Message.SERVER_ID, newUid);
cv.put(MessageColumns.SERVER_ID, newUid);
// We only have one message, so, any updates _must_ be for it. Otherwise,
// we'd have to cycle through to find the one with the same server ID.
context.getContentResolver().update(ContentUris.withAppendedId(
@ -1239,7 +1243,7 @@ public class ImapService extends Service {
// update the UID in the local trash folder, because some stores will
// have to change it when copying to remoteTrashFolder
ContentValues cv = new ContentValues();
cv.put(EmailContent.Message.SERVER_ID, newUid);
cv.put(MessageColumns.SERVER_ID, newUid);
context.getContentResolver().update(newMessage.getUri(), cv, null, null);
}
@ -1425,8 +1429,8 @@ public class ImapService extends Service {
resolver.delete(uri, null, null);
} else if (updateMessage) {
ContentValues cv = new ContentValues();
cv.put(EmailContent.Message.SERVER_ID, message.mServerId);
cv.put(EmailContent.Message.SERVER_TIMESTAMP, message.mServerTimeStamp);
cv.put(MessageColumns.SERVER_ID, message.mServerId);
cv.put(MessageColumns.SERVER_TIMESTAMP, message.mServerTimeStamp);
resolver.update(uri, cv, null, null);
}
}

View File

@ -37,6 +37,7 @@ import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.EmailContent.AccountColumns;
import com.android.emailcommon.provider.EmailContent.Message;
import com.android.emailcommon.provider.EmailContent.MessageColumns;
import com.android.emailcommon.provider.Mailbox;
import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.EmailServiceStatus;
@ -112,7 +113,7 @@ public class PopImapSyncAdapterService extends Service {
!loadsFromServer(context, mailbox, protocol)) {
// This is an update to a message in a non-syncing mailbox; delete this from the
// updates table and return
resolver.delete(Message.UPDATED_CONTENT_URI, Message.MAILBOX_KEY + "=?",
resolver.delete(Message.UPDATED_CONTENT_URI, MessageColumns.MAILBOX_KEY + "=?",
new String[] {Long.toString(mailbox.mId)});
return;
}
@ -194,8 +195,8 @@ public class PopImapSyncAdapterService extends Service {
// See if any boxes have mail...
ArrayList<Long> mailboxesToUpdate;
Cursor updatesCursor = provider.query(Message.UPDATED_CONTENT_URI,
new String[] {Message.MAILBOX_KEY},
Message.ACCOUNT_KEY + "=?",
new String[] {MessageColumns.MAILBOX_KEY},
MessageColumns.ACCOUNT_KEY + "=?",
new String[] {Long.toString(acct.mId)},
null);
try {

View File

@ -416,7 +416,7 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
Cursor c = null;
try {
c = mMockContext.getContentResolver().query(EmailContent.Body.CONTENT_URI,
EmailContent.Body.CONTENT_PROJECTION, EmailContent.Body.MESSAGE_KEY + "=?",
EmailContent.Body.CONTENT_PROJECTION, BodyColumns.MESSAGE_KEY + "=?",
new String[] {String.valueOf(messageId)}, null);
int numBodies = c.getCount();
assertTrue("at most one body", numBodies < 2);
@ -2432,10 +2432,10 @@ public class ProviderTests extends ProviderTestCase2<EmailProvider> {
ContentCache.invalidateAllCaches();
// Delete orphaned mailboxes/messages/policies
EmailProvider.deleteUnlinked(db, Mailbox.TABLE_NAME, MailboxColumns.ACCOUNT_KEY,
AccountColumns.ID, Account.TABLE_NAME);
AccountColumns._ID, Account.TABLE_NAME);
EmailProvider.deleteUnlinked(db, Message.TABLE_NAME, MessageColumns.ACCOUNT_KEY,
AccountColumns.ID, Account.TABLE_NAME);
EmailProvider.deleteUnlinked(db, Policy.TABLE_NAME, PolicyColumns.ID,
AccountColumns._ID, Account.TABLE_NAME);
EmailProvider.deleteUnlinked(db, Policy.TABLE_NAME, PolicyColumns._ID,
AccountColumns.POLICY_KEY, Account.TABLE_NAME);
// Make sure the orphaned mailboxes are gone