Update messaging when autodiscover fails due to an auth error

b/11538085

Change-Id: I76689cbd89eef233588804edeb3893f1ad36bebe
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9a50298..334a9f3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -390,6 +390,15 @@
     <!-- "Setup could not finish" dialog text; e.g., Username or password incorrect\n(ERR01 Account does not exist) -->
     <string name="account_setup_failed_dlg_auth_message_fmt">Login failed.\n(<xliff:g id="error">%s</xliff:g>)</string>
 
+    <!-- Account setup autodiscover auth failure dialog title. This is shown when autodiscover hits
+        an "access denied" server error, which could imply incorrect username/password or that no
+        autodiscover service has been configured for the domain [CHAR LIMIT=40] -->
+    <string name="account_setup_autodiscover_dlg_authfail_title">Problem with account setup</string>
+    <!-- Account setup autodiscover auth failure dialog message. This is shown when autodiscover hits
+        an "access denied" server error, which could imply incorrect username/password or that no
+        autodiscover service has been configured for the domain [CHAR LIMIT=NONE] -->
+    <string name="account_setup_autodiscover_dlg_authfail_message">Confirm username, password, and account settings are correct.</string>
+
     <!-- An error message presented to the user when the server's identity
          cannot be established or trusted [CHAR LIMIT=NONE] -->
     <string name="account_setup_failed_dlg_certificate_message"
diff --git a/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java b/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java
index 1309dff..e7ea824 100644
--- a/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java
+++ b/src/com/android/email/activity/setup/AccountCheckSettingsFragment.java
@@ -581,7 +581,7 @@
     }
 
     private static String getErrorString(Context context, MessagingException ex) {
-        int id;
+        final int id;
         String message = ex.getMessage();
         if (message != null) {
             message = message.trim();
@@ -595,8 +595,10 @@
                         : R.string.account_setup_failed_dlg_certificate_message_fmt;
                 break;
             case MessagingException.AUTHENTICATION_FAILED:
+                id = R.string.account_setup_failed_dlg_auth_message;
+                break;
             case MessagingException.AUTODISCOVER_AUTHENTICATION_FAILED:
-                id = R.string.account_settings_login_dialog_title;
+                id = R.string.account_setup_autodiscover_dlg_authfail_message;
                 break;
             case MessagingException.AUTHENTICATION_FAILED_OR_SERVER_ERROR:
                 id = R.string.account_setup_failed_check_credentials_message;
@@ -811,8 +813,11 @@
                 .setMessage(message)
                 .setCancelable(true);
 
-            // Hide title when we get MessagingException.AUTODISCOVER_AUTHENTICATION_FAILED
-            if (exceptionId != MessagingException.AUTODISCOVER_AUTHENTICATION_FAILED) {
+            // Use a different title when we get
+            // MessagingException.AUTODISCOVER_AUTHENTICATION_FAILED
+            if (exceptionId == MessagingException.AUTODISCOVER_AUTHENTICATION_FAILED) {
+                builder.setTitle(R.string.account_setup_autodiscover_dlg_authfail_title);
+            } else {
                 builder.setIconAttribute(android.R.attr.alertDialogIcon)
                     .setTitle(context.getString(R.string.account_setup_failed_dlg_title));
             }