Add another test for "incomplete" accounts

* We have been erroneously marking some accounts "incomplete" and
  this can cause reconciliation to fail after deleting the
  accounts in Settings.
* Still need to investigate why the flag isn't cleared at times...

Bug: 7148506
Bug: 7166598
Change-Id: I0059580a6e4b6a5c54c09b8409c4358ff707ff77
This commit is contained in:
Marc Blank 2012-09-21 11:27:19 -07:00
parent 733a11467c
commit 78b8c04898

View File

@ -26,6 +26,8 @@ import android.util.Log;
import com.android.emailcommon.Logging; import com.android.emailcommon.Logging;
import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.Account;
import com.android.emailcommon.provider.EmailContent;
import com.android.emailcommon.provider.Mailbox;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import java.io.IOException; import java.io.IOException;
@ -108,9 +110,20 @@ public class AccountReconciler {
} }
if (!found) { if (!found) {
if ((providerAccount.mFlags & Account.FLAGS_INCOMPLETE) != 0) { if ((providerAccount.mFlags & Account.FLAGS_INCOMPLETE) != 0) {
Log.w(Logging.LOG_TAG, // Do another test before giving up; an incomplete account shouldn't have
"Account reconciler noticed incomplete account; ignoring"); // any mailboxes (the incomplete flag is used to prevent reconciliation
continue; // between the time the EP account is created and when the AM account is
// asynchronously created)
if (EmailContent.count(providerContext, Mailbox.CONTENT_URI,
Mailbox.ACCOUNT_KEY + "=?",
new String[] { Long.toString(providerAccount.mId) } ) > 0) {
Log.w(Logging.LOG_TAG,
"Account reconciler found wrongly incomplete account");
} else {
Log.w(Logging.LOG_TAG,
"Account reconciler noticed incomplete account; ignoring");
continue;
}
} }
needsReconciling = true; needsReconciling = true;