Remove unused code; rename some constants
* Also handle large batch operations in chunks Change-Id: Ie566cb8d8bb73e8edd663de5228e905c223f031b
This commit is contained in:
parent
51d4370b77
commit
00287c4d8f
@ -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 =
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -1343,10 +1343,25 @@ public class Imap2SyncService extends AbstractSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final int BATCH_SIZE = 100;
|
||||
private void applyBatch(ArrayList<ContentProviderOperation> 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<ContentProviderOperation> batchOps =
|
||||
new ArrayList<ContentProviderOperation>();
|
||||
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();
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user