Fix providers.xml alternate diversion

b/17048013

Change-Id: If2bc857266a6ba1445bf1fabbaed179c1b13a14f
This commit is contained in:
Tony Mantler 2014-08-15 11:18:10 -07:00
parent 6d165bca6b
commit 486e971066
2 changed files with 16 additions and 6 deletions

View File

@ -562,6 +562,13 @@ public class HostAuth extends EmailContent implements Parcelable {
setConnection(protocol, host, port, flags, clientCertAlias); setConnection(protocol, host, port, flags, clientCertAlias);
} }
public static String getProtocolFromString(String uriString) {
final Uri uri = Uri.parse(uriString);
final String scheme = uri.getScheme();
final String[] schemeParts = scheme.split("\\+");
return schemeParts[0];
}
@Override @Override
public String toString() { public String toString() {
return "[protocol " + mProtocol + "]"; return "[protocol " + mProtocol + "]";

View File

@ -857,18 +857,21 @@ public class AccountSetupFinal extends AccountSetupActivity
try { try {
mProvider.expandTemplates(email); mProvider.expandTemplates(email);
final Account account = mSetupData.getAccount(); final String primaryProtocol = HostAuth.getProtocolFromString(mProvider.incomingUri);
final HostAuth recvAuth = account.getOrCreateHostAuthRecv(this); EmailServiceUtils.EmailServiceInfo info =
recvAuth.setHostAuthFromString(mProvider.incomingUri); EmailServiceUtils.getServiceInfo(this, primaryProtocol);
final EmailServiceUtils.EmailServiceInfo info = mSetupData.getIncomingServiceInfo(this);
// If the protocol isn't one we can use, and we're not diverting to gmail, try the alt // If the protocol isn't one we can use, and we're not diverting to gmail, try the alt
if (!info.isGmailStub && !EmailServiceUtils.isServiceAvailable(this, info.protocol)) { if (!info.isGmailStub && !EmailServiceUtils.isServiceAvailable(this, info.protocol)) {
LogUtils.d(LogUtils.TAG, "Protocol %s not available, using alternate", LogUtils.d(LogUtils.TAG, "Protocol %s not available, using alternate",
info.protocol); info.protocol);
mProvider.expandAlternateTemplates(email); mProvider.expandAlternateTemplates(email);
recvAuth.setHostAuthFromString(mProvider.incomingUri); final String alternateProtocol = HostAuth.getProtocolFromString(
mProvider.incomingUri);
info = EmailServiceUtils.getServiceInfo(this, alternateProtocol);
} }
final Account account = mSetupData.getAccount();
final HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
recvAuth.setHostAuthFromString(mProvider.incomingUri);
recvAuth.setUserName(mProvider.incomingUsername); recvAuth.setUserName(mProvider.incomingUsername);
recvAuth.mPort = recvAuth.mPort =