From 6c6c38728c1363ef71c7c02b2e7520feaea80ecd Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sat, 18 Sep 2010 11:50:47 -0700 Subject: [PATCH] Increase EmailServiceProxy timeout for validation attempts * Use 90 seconds (instead of 45 seconds) Bug: 3008626 Change-Id: I31258a5fbcca1f489c8bf6fb2ed8f3dcad5d2e26 --- src/com/android/email/mail/store/ExchangeStore.java | 12 ++++++++++-- src/com/android/exchange/EasSyncService.java | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/android/email/mail/store/ExchangeStore.java b/src/com/android/email/mail/store/ExchangeStore.java index 9935d50ea..4eaab2496 100644 --- a/src/com/android/email/mail/store/ExchangeStore.java +++ b/src/com/android/email/mail/store/ExchangeStore.java @@ -25,6 +25,8 @@ import com.android.email.mail.Store; import com.android.email.mail.StoreSynchronizer; import com.android.email.provider.EmailContent.Account; import com.android.email.service.EasAuthenticatorService; +import com.android.email.service.EmailServiceProxy; +import com.android.email.service.IEmailService; import android.accounts.AccountManager; import android.accounts.AccountManagerCallback; @@ -238,8 +240,14 @@ public class ExchangeStore extends Store { boolean tssl = uri.getScheme().contains("+trustallcerts"); try { int port = ssl ? 443 : 80; - int result = ExchangeUtils.getExchangeEmailService(mContext, null) - .validate("eas", mHost, mUsername, mPassword, port, ssl, tssl); + + IEmailService svc = ExchangeUtils.getExchangeEmailService(mContext, null); + // Use a longer timeout for the validate command. Note that the instanceof check + // shouldn't be necessary; we'll do it anyway, just to be safe + if (svc instanceof EmailServiceProxy) { + ((EmailServiceProxy)svc).setTimeout(90); + } + int result = svc.validate("eas", mHost, mUsername, mPassword, port, ssl, tssl); if (result != MessagingException.NO_ERROR) { if (result == MessagingException.AUTHENTICATION_FAILED) { throw new AuthenticationFailedException("Authentication failed."); diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index 1feaf01f6..f09be95f9 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -410,7 +410,7 @@ public class EasSyncService extends AbstractSyncService { // Run second test here for provisioning failures... Serializer s = new Serializer(); - userLog("Try folder sync"); + userLog("Validate: try folder sync"); s.start(Tags.FOLDER_FOLDER_SYNC).start(Tags.FOLDER_SYNC_KEY).text("0") .end().end().done(); resp = svc.sendHttpClientPost("FolderSync", s.toByteArray()); @@ -418,14 +418,18 @@ public class EasSyncService extends AbstractSyncService { // We'll get one of the following responses if policies are required by the server if (code == HttpStatus.SC_FORBIDDEN || code == HTTP_NEED_PROVISIONING) { // Get the policies and see if we are able to support them + userLog("Validate: provisioning required"); if (svc.canProvision() != null) { // If so, send the advisory Exception (the account may be created later) + userLog("Validate: provisioning is possible"); throw new MessagingException(MessagingException.SECURITY_POLICIES_REQUIRED); } else + userLog("Validate: provisioning not possible"); // If not, send the unsupported Exception (the account won't be created) throw new MessagingException( MessagingException.SECURITY_POLICIES_UNSUPPORTED); } else if (code == HttpStatus.SC_NOT_FOUND) { + userLog("Wrong address or bad protocol version"); // We get a 404 from OWA addresses (which are NOT EAS addresses) throw new MessagingException(MessagingException.PROTOCOL_VERSION_UNSUPPORTED); } else if (code != HttpStatus.SC_OK) {