Increase EmailServiceProxy timeout for validation attempts

* Use 90 seconds (instead of 45 seconds)

Bug: 3008626
Change-Id: I31258a5fbcca1f489c8bf6fb2ed8f3dcad5d2e26
This commit is contained in:
Marc Blank 2010-09-18 11:50:47 -07:00 committed by android-build SharedAccount
parent febba5bba6
commit 6c6c38728c
2 changed files with 15 additions and 3 deletions

View File

@ -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.");

View File

@ -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) {