diff --git a/src/com/android/email/activity/setup/AccountSetupCheckSettings.java b/src/com/android/email/activity/setup/AccountSetupCheckSettings.java index b73d83d1b..44c093274 100644 --- a/src/com/android/email/activity/setup/AccountSetupCheckSettings.java +++ b/src/com/android/email/activity/setup/AccountSetupCheckSettings.java @@ -11,6 +11,8 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Process; + +import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; @@ -18,6 +20,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import com.android.email.Account; +import com.android.email.Email; import com.android.email.R; import com.android.email.mail.AuthenticationFailedException; import com.android.email.mail.MessagingException; @@ -124,14 +127,17 @@ public class AccountSetupCheckSettings extends Activity implements OnClickListen setResult(RESULT_OK); finish(); } catch (final AuthenticationFailedException afe) { + Log.e(Email.LOG_TAG, "Error while testing settings", afe); showErrorDialog( R.string.account_setup_failed_dlg_auth_message_fmt, afe.getMessage() == null ? "" : afe.getMessage()); } catch (final CertificateValidationException cve) { + Log.e(Email.LOG_TAG, "Error while testing settings", cve); acceptKeyDialog( R.string.account_setup_failed_dlg_certificate_message_fmt, cve); } catch (final Throwable t) { + Log.e(Email.LOG_TAG, "Error while testing settings", t); showErrorDialog( R.string.account_setup_failed_dlg_server_message_fmt, (t.getMessage() == null ? "" : t.getMessage())); diff --git a/src/com/android/email/mail/store/Pop3Store.java b/src/com/android/email/mail/store/Pop3Store.java index 97aaca2ca..5db009614 100644 --- a/src/com/android/email/mail/store/Pop3Store.java +++ b/src/com/android/email/mail/store/Pop3Store.java @@ -217,7 +217,10 @@ public class Pop3Store extends Store { } mSocket.setSoTimeout(Store.SOCKET_READ_TIMEOUT); - + if (!isOpen()) + { + throw new MessagingException("Unable to connect socket"); + } // Eat the banner executeSimpleCommand(null); @@ -239,6 +242,10 @@ public class Pop3Store extends Store { mSocket.setSoTimeout(Store.SOCKET_READ_TIMEOUT); mIn = new BufferedInputStream(mSocket.getInputStream(), 1024); mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512); + if (!isOpen()) + { + throw new MessagingException("Unable to connect socket"); + } } else if (mConnectionSecurity == CONNECTION_SECURITY_TLS_REQUIRED) { throw new MessagingException("TLS not supported but required"); } @@ -269,8 +276,8 @@ public class Pop3Store extends Store { } public boolean isOpen() { - return (mIn != null && mOut != null && mSocket != null && mSocket.isConnected() && !mSocket - .isClosed()); + return (mIn != null && mOut != null && mSocket != null + && mSocket.isConnected() && !mSocket.isClosed()); } @Override @@ -838,6 +845,10 @@ public class Pop3Store extends Store { return response; } + catch (MessagingException me) + { + throw me; + } catch (Exception e) { closeIO(); throw new MessagingException("Unable to execute POP3 command", e);