am 065d5c62: Merge branch \'eclair-plus-aosp\' of ssh://android-git.corp.google.com:29418/platform/packages/apps/Email into eclair-mr2-plus-aosp

Merge commit '065d5c6292b080f3f0e1507fc70e94a74ee9c9c2'

* commit '065d5c6292b080f3f0e1507fc70e94a74ee9c9c2':
  Fix problem with timeouts and sending attachments (#2178288)
This commit is contained in:
Mike Cleron 2009-10-13 16:52:25 -07:00 committed by Android Git Automerger
commit 741ebcddd4
3 changed files with 23 additions and 3 deletions

View File

@ -52,6 +52,12 @@ public class EasOutboxService extends EasSyncService {
new String[] {BodyColumns.SOURCE_MESSAGE_KEY};
public static final String WHERE_MESSAGE_KEY = Body.MESSAGE_KEY + "=?";
// This needs to be long enough to send the longest reasonable message, without being so long
// as to effectively "hang" sending of mail. The standard 30 second timeout isn't long enough
// for pictures and the like. For now, we'll use 15 minutes, in the knowledge that any socket
// failure would probably generate an Exception before timing out anyway
public static final int SEND_MAIL_TIMEOUT = 15*MINUTES;
public EasOutboxService(Context _context, Mailbox _mailbox) {
super(_context, _mailbox);
}
@ -129,7 +135,7 @@ public class EasOutboxService extends EasSyncService {
cmd += "&ItemId=" + itemId + "&CollectionId=" + collectionId + "&SaveInSent=T";
}
userLog("Send cmd: " + cmd);
HttpResponse resp = sendHttpClientPost(cmd, inputEntity);
HttpResponse resp = sendHttpClientPost(cmd, inputEntity, SEND_MAIL_TIMEOUT);
inputStream.close();
int code = resp.getStatusLine().getStatusCode();
@ -167,7 +173,6 @@ public class EasOutboxService extends EasSyncService {
@Override
public void run() {
setupService();
File cacheDir = mContext.getCacheDir();
try {
mDeviceId = SyncManager.getDeviceId();

View File

@ -111,7 +111,6 @@ public class EasSyncService extends AbstractSyncService {
static private final int PING_HEARTBEAT_INCREMENT = 3*PING_MINUTES;
static private final int PING_FORCE_HEARTBEAT = 2*PING_MINUTES;
static private final int PROTOCOL_PING_STATUS_UNAVAILABLE = -1;
static private final int PROTOCOL_PING_STATUS_COMPLETED = 1;
// Fallbacks (in minutes) for ping loop failures

View File

@ -292,6 +292,11 @@ public class SyncManager extends Service implements Runnable {
cv, WHERE_MAILBOX_KEY, new String[] {Long.toString(mailboxId)});
kick("start outbox");
// Outbox can't be synced in EAS
return;
} else if (m.mType == Mailbox.TYPE_DRAFTS) {
// Drafts can't be synced in EAS
return;
}
startManualSync(mailboxId, SyncManager.SYNC_SERVICE_START_SYNC, null);
}
@ -1139,6 +1144,11 @@ public class SyncManager extends Service implements Runnable {
if (service != null) {
Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, id);
if (m != null) {
// We ignore drafts completely (doesn't sync). Changes in Outbox are handled
// in the checkMailboxes loop, so we can ignore these pings.
if (m.mType == Mailbox.TYPE_DRAFTS || m.mType == Mailbox.TYPE_OUTBOX) {
return;
}
service.mAccount = Account.restoreAccountWithId(INSTANCE, m.mAccountKey);
service.mMailbox = m;
service.ping();
@ -1629,6 +1639,12 @@ public class SyncManager extends Service implements Runnable {
static public void serviceRequest(long mailboxId, long ms, int reason) {
if (INSTANCE == null) return;
Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, mailboxId);
// Never allow manual start of Drafts or Outbox via serviceRequest
if (m == null || m.mType == Mailbox.TYPE_DRAFTS || m.mType == Mailbox.TYPE_OUTBOX) {
INSTANCE.log("Ignoring serviceRequest for drafts/outbox");
return;
}
try {
AbstractSyncService service = INSTANCE.mServiceMap.get(mailboxId);
if (service != null) {