Merge "Make sure protocol version is always set in sync services"
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index cd255ee..418b1ea 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -91,6 +91,9 @@
static private final String PING_COMMAND = "Ping";
static private final int COMMAND_TIMEOUT = 20*SECONDS;
+ // Define our default protocol version as 2.5 (Exchange 2003)
+ static private final String DEFAULT_PROTOCOL_VERSION = "2.5";
+
/**
* We start with an 8 minute timeout, and increase/decrease by 3 minutes at a time. There's
* no point having a timeout shorter than 5 minutes, I think; at that point, we can just let
@@ -119,7 +122,7 @@
static private final int PING_FALLBACK_PIM = 25;
// Reasonable default
- String mProtocolVersion = "2.5";
+ public String mProtocolVersion = DEFAULT_PROTOCOL_VERSION;
public Double mProtocolVersionDouble;
protected String mDeviceId = null;
private String mDeviceType = "Android";
@@ -557,7 +560,7 @@
SyncManager.kick("change ping boxes to push");
}
- // Determine our protocol version, if we haven't already
+ // Determine our protocol version, if we haven't already and save it in the Account
if (mAccount.mProtocolVersion == null) {
userLog("Determine EAS protocol version");
HttpResponse resp = sendHttpClientOptions();
@@ -574,6 +577,10 @@
}
mProtocolVersionDouble = Double.parseDouble(mProtocolVersion);
mAccount.mProtocolVersion = mProtocolVersion;
+ // Save the protocol version
+ cv.clear();
+ cv.put(Account.PROTOCOL_VERSION, mProtocolVersion);
+ mAccount.update(mContext, cv);
userLog(versions);
userLog("Using version ", mProtocolVersion);
} else {
@@ -588,7 +595,7 @@
// Change all pushable boxes to push when we start the account mailbox
if (mAccount.mSyncInterval == Account.CHECK_INTERVAL_PUSH) {
- cv = new ContentValues();
+ cv.clear();
cv.put(Mailbox.SYNC_INTERVAL, Mailbox.CHECK_INTERVAL_PUSH);
if (mContentResolver.update(Mailbox.CONTENT_URI, cv,
SyncManager.WHERE_IN_ACCOUNT_AND_PUSHABLE,
@@ -623,7 +630,7 @@
}
// Change all push/hold boxes to push
- cv = new ContentValues();
+ cv.clear();
cv.put(Mailbox.SYNC_INTERVAL, Account.CHECK_INTERVAL_PUSH);
if (mContentResolver.update(Mailbox.CONTENT_URI, cv,
WHERE_PUSH_HOLD_NOT_ACCOUNT_MAILBOX,
@@ -1101,11 +1108,13 @@
mUserName = ha.mLogin;
mPassword = ha.mPassword;
- // Set up our protocol version
+ // Set up our protocol version from the Account
mProtocolVersion = mAccount.mProtocolVersion;
- if (mProtocolVersion != null) {
- mProtocolVersionDouble = Double.parseDouble(mProtocolVersion);
+ // If it hasn't been set up, start with default version
+ if (mProtocolVersion == null) {
+ mProtocolVersion = DEFAULT_PROTOCOL_VERSION;
}
+ mProtocolVersionDouble = Double.parseDouble(mProtocolVersion);
return true;
}