Merge change 7552

* changes:
  Fix push bug, minor changes to logging and removal of debug code
This commit is contained in:
Android (Google) Code Review 2009-07-16 13:14:55 -07:00
commit 0dba37ec51
9 changed files with 35 additions and 21 deletions

View File

@ -332,9 +332,8 @@ public class ExchangeStore extends Store {
// service (EasAuthenticatorService)
AccountManager.get(mContext).addAccount(Eas.ACCOUNT_MANAGER_TYPE, null, null,
options, null, callback, null);
}
svc.loadAttachment(0, new Attachment(), mCallback);
} catch (RemoteException e) {
}
} catch (RemoteException e) {
throw new MessagingException("Call to validate generated an exception", e);
}
}

View File

@ -31,6 +31,8 @@ public class Eas {
public static final String ACCOUNT_MANAGER_TYPE = "com.android.exchange";
public static final String ACCOUNT_MAILBOX = "__eas";
// From EAS spec
// Mail Cal
// 0 No filter Yes Yes

View File

@ -76,9 +76,10 @@ public class EasSyncService extends InteractiveSyncService {
MailboxColumns.ACCOUNT_KEY + "=? and " + MailboxColumns.SERVER_ID + "=?";
private static final String WHERE_SYNC_FREQUENCY_PING =
Mailbox.SYNC_FREQUENCY + '=' + Account.CHECK_INTERVAL_PING;
private static final String SYNC_FREQUENCY_PING =
private static final String AND_FREQUENCY_PING_PUSH_AND_NOT_ACCOUNT_MAILBOX = " AND " +
MailboxColumns.SYNC_FREQUENCY + " IN (" + Account.CHECK_INTERVAL_PING +
',' + Account.CHECK_INTERVAL_PUSH + ')';
',' + Account.CHECK_INTERVAL_PUSH + ") AND " + MailboxColumns.SERVER_ID + "!=\"" +
Eas.ACCOUNT_MAILBOX + '\"';
static private final int CHUNK_SIZE = 16 * 1024;
@ -469,8 +470,8 @@ public class EasSyncService extends InteractiveSyncService {
HttpURLConnection uc;
int code;
Cursor c = mContentResolver.query(Mailbox.CONTENT_URI, Mailbox.CONTENT_PROJECTION,
MailboxColumns.ACCOUNT_KEY + '=' + mAccount.mId + " and " + SYNC_FREQUENCY_PING,
null, null);
MailboxColumns.ACCOUNT_KEY + '=' + mAccount.mId +
AND_FREQUENCY_PING_PUSH_AND_NOT_ACCOUNT_MAILBOX, null, null);
try {
// Loop through our pushed boxes seeing what is available to push
@ -495,13 +496,19 @@ public class EasSyncService extends InteractiveSyncService {
.data("PingId", c.getString(Mailbox.CONTENT_SERVER_ID_COLUMN))
.data("PingClass", folderClass)
.end("PingFolder");
userLog("Ping ready for: " + folderClass + ", " +
c.getString(Mailbox.CONTENT_SERVER_ID_COLUMN) + " (" +
c.getString(Mailbox.CONTENT_DISPLAY_NAME_COLUMN) + ')');
} else {
userLog(c.getString(Mailbox.CONTENT_DISPLAY_NAME_COLUMN) +
" not ready for ping");
}
}
} finally {
c.close();
}
if (canPushCount > 0) {
if (canPushCount > 0 && (canPushCount == pushCount)) {
// If we have some number that are ready for push, send Ping to the server
s.end("PingFolders").end("Ping").end();
uc = sendEASPostCommand("Ping", s.toString());
@ -531,6 +538,7 @@ public class EasSyncService extends InteractiveSyncService {
}
} else if (pushCount > 0) {
// If we want to Ping, but can't just yet, wait 10 seconds and try again
userLog("pingLoop waiting for " + (pushCount - canPushCount) + " box(es)");
sleep(10*SECS);
} else {
// We've got nothing to do, so let's hang out for a while
@ -787,7 +795,7 @@ public class EasSyncService extends InteractiveSyncService {
mPassword = ha.mPassword;
try {
if (mMailbox.mServerId.equals("_main")) {
if (mMailbox.mServerId.equals(Eas.ACCOUNT_MAILBOX)) {
runMain();
} else {
EasSyncAdapter target;

View File

@ -181,7 +181,7 @@ public class SyncManager extends Service implements Runnable {
int cnt = Mailbox.count(context, Mailbox.CONTENT_URI, "accountKey=" + accountId,
null);
if (cnt == 0) {
initializeAccount(accountId);
addAccountMailbox(accountId);
}
}
}
@ -203,7 +203,7 @@ public class SyncManager extends Service implements Runnable {
for (long accountId : currentIds) {
if (!mAccountIds.contains(accountId)) {
// This is an addition; create our magic hidden mailbox...
initializeAccount(accountId);
addAccountMailbox(accountId);
mAccountIds.add(accountId);
}
}
@ -228,11 +228,11 @@ public class SyncManager extends Service implements Runnable {
}
}
void initializeAccount(long acctId) {
void addAccountMailbox(long acctId) {
Account acct = Account.restoreAccountWithId(getContext(), acctId);
Mailbox main = new Mailbox();
main.mDisplayName = "_main";
main.mServerId = "_main";
main.mDisplayName = Eas.ACCOUNT_MAILBOX;
main.mServerId = Eas.ACCOUNT_MAILBOX;
main.mAccountKey = acct.mId;
main.mType = Mailbox.TYPE_NOT_EMAIL;
main.mSyncFrequency = Account.CHECK_INTERVAL_PUSH;
@ -371,7 +371,7 @@ public class SyncManager extends Service implements Runnable {
if (INSTANCE != null) {
AccountObserver obs = INSTANCE.mAccountObserver;
obs.accountDeleted(acctId);
obs.initializeAccount(acctId);
obs.addAccountMailbox(acctId);
}
}

View File

@ -369,7 +369,7 @@ public class EasContactsSyncAdapter extends EasSyncAdapter {
// // There is nothing to be done here; fail by returning null
// }
mService.userLog("SyncKey confirmed as: " + mMailbox.mSyncKey);
mService.userLog("Contacts SyncKey confirmed as: " + mMailbox.mSyncKey);
}
}

View File

@ -119,7 +119,7 @@ public abstract class EasContentParser extends EasParser {
if (mMailbox.mSyncKey.equals("0"))
moreAvailable = true;
String newKey = getValue();
mService.userLog("New sync key: " + newKey);
mService.userLog("Parsed key for " + mMailbox.mDisplayName + ": " + newKey);
mMailbox.mSyncKey = newKey;
// If we were pushing (i.e. auto-start), now we'll become ping-triggered
if (mMailbox.mSyncFrequency == Account.CHECK_INTERVAL_PUSH) {
@ -132,7 +132,7 @@ public abstract class EasContentParser extends EasParser {
// Make sure we save away the new syncKey, syncFrequency, etc.
mMailbox.saveOrUpdate(mContext);
mService.userLog(mMailbox.mDisplayName + " SyncKey saved as: " + mMailbox.mSyncKey);
// Let the caller know that there's more to do
return moreAvailable;
}

View File

@ -359,7 +359,7 @@ public class EasEmailSyncAdapter extends EasSyncAdapter {
// There is nothing to be done here; fail by returning null
}
mService.userLog("SyncKey confirmed as: " + mMailbox.mSyncKey);
mService.userLog(mMailbox.mDisplayName + " SyncKey saved as: " + mMailbox.mSyncKey);
}
}

View File

@ -49,6 +49,8 @@ import android.util.Log;
public class EasFolderSyncParser extends EasParser {
private static boolean DEBUG_LOGGING = false;
public static final String TAG = "FolderSyncParser";
// These are defined by the EAS protocol
@ -107,7 +109,9 @@ public class EasFolderSyncParser extends EasParser {
if (in instanceof MockParserStream) {
mMock = (MockParserStream)in;
}
setDebug(true);
if (DEBUG_LOGGING) {
setDebug(true);
}
}
public boolean parse() throws IOException {
@ -298,7 +302,7 @@ public class EasFolderSyncParser extends EasParser {
try {
mService.mContext.getContentResolver()
.applyBatch(EmailProvider.EMAIL_AUTHORITY, ops);
mService.userLog("New syncKey: " + mAccount.mSyncKey);
mService.userLog("New Account SyncKey: " + mAccount.mSyncKey);
} catch (RemoteException e) {
// There is nothing to be done here; fail by returning null
} catch (OperationApplicationException e) {

View File

@ -68,6 +68,7 @@ public class EasPingParser extends EasParser {
mService.userLog("Ping completed, status = " + status);
if (status == 2) {
// Status = 2 indicates changes in one folder or other
mService.userLog("Changes found");
res = true;
} else if (status == 7 || status == 4) {
// Status of 7 or 4 indicate a stale folder list