Fix GAL search in EAS 12.1

* We weren't sending the proper protocol version to GAL search, which
  causes errors when using 12.1
* The simple fix is to send the agreed upon protocol version, instead
  of the default (which is 2.5)
* Replace parsing of protocol version with lookup

Bug: 2793588
Change-Id: Ib2a255d8467004ce985d2d688b37066e1e09d78a
This commit is contained in:
Marc Blank 2010-06-23 14:57:53 -07:00
parent 9b4988de43
commit 663b57daa7
3 changed files with 33 additions and 4 deletions

View File

@ -93,5 +93,16 @@ public class Eas {
Log.d("Eas Debug", "Logging: " + (USER_LOG ? "User " : "") +
(PARSER_LOG ? "Parser " : "") + (FILE_LOG ? "File" : ""));
}
}
}
static public Double getProtocolVersionDouble(String version) {
if (SUPPORTED_PROTOCOL_EX2003.equals(version)) {
return SUPPORTED_PROTOCOL_EX2003_DOUBLE;
} else if (SUPPORTED_PROTOCOL_EX2007.equals(version)) {
return SUPPORTED_PROTOCOL_EX2007_DOUBLE;
} if (SUPPORTED_PROTOCOL_EX2007_SP1.equals(version)) {
return SUPPORTED_PROTOCOL_EX2007_SP1_DOUBLE;
}
throw new IllegalArgumentException("illegal protocol version");
}
}

View File

@ -369,7 +369,7 @@ public class EasSyncService extends AbstractSyncService {
throw new MessagingException(MessagingException.PROTOCOL_VERSION_UNSUPPORTED);
} else {
service.mProtocolVersion = ourVersion;
service.mProtocolVersionDouble = Double.parseDouble(ourVersion);
service.mProtocolVersionDouble = Eas.getProtocolVersionDouble(ourVersion);
if (service.mAccount != null) {
service.mAccount.mProtocolVersion = ourVersion;
}
@ -779,7 +779,7 @@ public class EasSyncService extends AbstractSyncService {
* @param context caller's context
* @param accountId the account Id to search
* @param filter the characters entered so far
* @return a result record
* @return a result record or null
*
* TODO: shorter timeout for interactive lookup
* TODO: make watchdog actually work (it doesn't understand our service w/Mailbox == 0)
@ -791,6 +791,15 @@ public class EasSyncService extends AbstractSyncService {
HostAuth ha = HostAuth.restoreHostAuthWithId(context, acct.mHostAuthKeyRecv);
EasSyncService svc = new EasSyncService("%GalLookupk%");
try {
// If there's no protocol version set up, we haven't successfully started syncing
// so we can't use GAL yet
String protocolVersion = acct.mProtocolVersion;
if (protocolVersion == null) {
return null;
} else {
svc.mProtocolVersion = protocolVersion;
svc.mProtocolVersionDouble = Eas.getProtocolVersionDouble(protocolVersion);
}
svc.mContext = context;
svc.mHostAddress = ha.mAddress;
svc.mUserName = ha.mLogin;
@ -2126,7 +2135,7 @@ public class EasSyncService extends AbstractSyncService {
if (mProtocolVersion == null) {
mProtocolVersion = Eas.DEFAULT_PROTOCOL_VERSION;
}
mProtocolVersionDouble = Double.parseDouble(mProtocolVersion);
mProtocolVersionDouble = Eas.getProtocolVersionDouble(mProtocolVersion);
return true;
}

View File

@ -121,4 +121,13 @@ public class EasSyncServiceTests extends AndroidTestCase {
assertEquals(1, headers.length);
assertEquals("key", headers[0].getValue());
}
public void testGetProtocolVersionDouble() {
assertEquals(Eas.SUPPORTED_PROTOCOL_EX2003_DOUBLE,
Eas.getProtocolVersionDouble(Eas.SUPPORTED_PROTOCOL_EX2003));
assertEquals(Eas.SUPPORTED_PROTOCOL_EX2007_DOUBLE,
Eas.getProtocolVersionDouble(Eas.SUPPORTED_PROTOCOL_EX2007));
assertEquals(Eas.SUPPORTED_PROTOCOL_EX2007_SP1_DOUBLE,
Eas.getProtocolVersionDouble(Eas.SUPPORTED_PROTOCOL_EX2007_SP1));
}
}