diff --git a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java index 9427681ab..c41065c47 100755 --- a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java +++ b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java @@ -562,8 +562,8 @@ public abstract class EmailContent { public static final Uri CONTENT_URI_LIMIT_1 = uriWithLimit(CONTENT_URI, 1); public static final Uri SYNCED_CONTENT_URI = Uri.parse(EmailContent.CONTENT_URI + "/syncedMessage"); - public static final Uri SYNCED_SELECTION_CONTENT_URI = - Uri.parse(EmailContent.CONTENT_URI + "/syncedMessageSelection"); + public static final Uri SELECTED_MESSAGE_CONTENT_URI = + Uri.parse(EmailContent.CONTENT_URI + "/messageBySelection"); public static final Uri DELETED_CONTENT_URI = Uri.parse(EmailContent.CONTENT_URI + "/deletedMessage"); public static final Uri UPDATED_CONTENT_URI = diff --git a/imap2/src/com/android/imap2/Imap2SyncManager.java b/imap2/src/com/android/imap2/Imap2SyncManager.java index 51d72cef4..62c25395c 100644 --- a/imap2/src/com/android/imap2/Imap2SyncManager.java +++ b/imap2/src/com/android/imap2/Imap2SyncManager.java @@ -196,7 +196,7 @@ public class Imap2SyncManager extends SyncManager { @Override public int getCapabilities(long accountId) throws RemoteException { return AccountCapabilities.SYNCABLE_FOLDERS | - AccountCapabilities.FOLDER_SERVER_SEARCH | + //AccountCapabilities.FOLDER_SERVER_SEARCH | AccountCapabilities.UNDO; } }; diff --git a/imap2/src/com/android/imap2/Imap2SyncService.java b/imap2/src/com/android/imap2/Imap2SyncService.java index a9e162427..0cdaae889 100644 --- a/imap2/src/com/android/imap2/Imap2SyncService.java +++ b/imap2/src/com/android/imap2/Imap2SyncService.java @@ -1343,10 +1343,25 @@ public class Imap2SyncService extends AbstractSyncService { } } - + private static final int BATCH_SIZE = 100; private void applyBatch(ArrayList ops) { try { - mResolver.applyBatch(EmailContent.AUTHORITY, ops); + int len = ops.size(); + if (len == 0) { + return; + } else if (len < BATCH_SIZE) { + mResolver.applyBatch(EmailContent.AUTHORITY, ops); + } else { + ArrayList batchOps = + new ArrayList(); + for (int i = 0; i < len; i+=BATCH_SIZE) { + batchOps.clear(); + for (int j = 0; (j < BATCH_SIZE) && ((i+j) < len); j++) { + batchOps.add(ops.get(i+j)); + } + mResolver.applyBatch(EmailContent.AUTHORITY, batchOps); + } + } } catch (RemoteException e) { // Nothing to be done } catch (OperationApplicationException e) { @@ -1362,7 +1377,7 @@ public class Imap2SyncService extends AbstractSyncService { for (int i = 0; i < cnt; i++) { MAILBOX_SERVER_ID_ARGS[1] = Long.toString(deleteList.get(i)); Builder b = ContentProviderOperation.newDelete( - Message.SYNCED_SELECTION_CONTENT_URI); + Message.SELECTED_MESSAGE_CONTENT_URI); b.withSelection(MessageColumns.MAILBOX_KEY + "=? AND " + SyncColumns.SERVER_ID + "=?", MAILBOX_SERVER_ID_ARGS); ops.add(b.build()); @@ -1379,7 +1394,7 @@ public class Imap2SyncService extends AbstractSyncService { for (int i = 0; i < cnt; i++) { MAILBOX_SERVER_ID_ARGS[1] = Long.toString(deleteList.get(i)); Builder b = ContentProviderOperation.newUpdate( - Message.SYNCED_SELECTION_CONTENT_URI); + Message.SELECTED_MESSAGE_CONTENT_URI); b.withSelection(MessageColumns.MAILBOX_KEY + "=? AND " + SyncColumns.SERVER_ID + "=?", MAILBOX_SERVER_ID_ARGS); b.withValues(values); @@ -2032,6 +2047,8 @@ public class Imap2SyncService extends AbstractSyncService { @Override public void run() { try { + TAG = Thread.currentThread().getName(); + // Check for Outbox (special "sync") and stopped if (mMailbox.mType == Mailbox.TYPE_OUTBOX) { sendMail(); diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 841241cac..38c7757d1 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -196,7 +196,7 @@ public class EmailProvider extends ContentProvider { private static final int MESSAGE = MESSAGE_BASE; private static final int MESSAGE_ID = MESSAGE_BASE + 1; private static final int SYNCED_MESSAGE_ID = MESSAGE_BASE + 2; - private static final int SYNCED_MESSAGE_SELECTION = MESSAGE_BASE + 3; + private static final int MESSAGE_SELECTION = MESSAGE_BASE + 3; private static final int ATTACHMENT_BASE = 0x3000; private static final int ATTACHMENT = ATTACHMENT_BASE; @@ -415,8 +415,7 @@ public class EmailProvider extends ContentProvider { * TO A SERVER VIA A SYNC ADAPTER */ matcher.addURI(EmailContent.AUTHORITY, "syncedMessage/#", SYNCED_MESSAGE_ID); - matcher.addURI(EmailContent.AUTHORITY, "syncedMessageSelection", - SYNCED_MESSAGE_SELECTION); + matcher.addURI(EmailContent.AUTHORITY, "messageBySelection", MESSAGE_SELECTION); /** * THE URIs BELOW THIS POINT ARE INTENDED TO BE USED BY SYNC ADAPTERS ONLY @@ -791,13 +790,13 @@ public class EmailProvider extends ContentProvider { return uiDeleteAccountData(uri); case UI_ACCOUNT: return uiDeleteAccount(uri); - case SYNCED_MESSAGE_SELECTION: + case MESSAGE_SELECTION: Cursor findCursor = db.query(tableName, Message.ID_COLUMN_PROJECTION, selection, selectionArgs, null, null, null); try { if (findCursor.moveToFirst()) { return delete(ContentUris.withAppendedId( - Message.SYNCED_CONTENT_URI, + Message.CONTENT_URI, findCursor.getLong(Message.ID_COLUMNS_ID_COLUMN)), null, null); } else { @@ -1727,13 +1726,13 @@ outer: } } break; - case SYNCED_MESSAGE_SELECTION: + case MESSAGE_SELECTION: Cursor findCursor = db.query(tableName, Message.ID_COLUMN_PROJECTION, selection, selectionArgs, null, null, null); try { if (findCursor.moveToFirst()) { return update(ContentUris.withAppendedId( - Message.SYNCED_CONTENT_URI, + Message.CONTENT_URI, findCursor.getLong(Message.ID_COLUMNS_ID_COLUMN)), values, null, null); } else { diff --git a/src/com/android/email/service/ImapService.java b/src/com/android/email/service/ImapService.java index c18f2e57d..1debd4104 100644 --- a/src/com/android/email/service/ImapService.java +++ b/src/com/android/email/service/ImapService.java @@ -1186,15 +1186,6 @@ public class ImapService extends Service { } } - public int searchMailbox(Context context, long accountId, SearchParams searchParams, - long destMailboxId) throws MessagingException { - try { - return searchMailboxImpl(context, accountId, searchParams, destMailboxId); - } finally { - // Tell UI - } - } - private int searchMailboxImpl(final Context context, long accountId, SearchParams searchParams, final long destMailboxId) throws MessagingException { final Account account = Account.restoreAccountWithId(context, accountId);