Increase EmailServiceProxy timeout for validation attempts
* Use 90 seconds (instead of 45 seconds)
Bug: 3008626
Change-Id: I31258a5fbcca1f489c8bf6fb2ed8f3dcad5d2e26
diff --git a/src/com/android/email/mail/store/ExchangeStore.java b/src/com/android/email/mail/store/ExchangeStore.java
index 9935d50..4eaab24 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.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 @@
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 1feaf01..f09be95 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -410,7 +410,7 @@
// 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 @@
// 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) {