am ab841bb5
: am 05629b29
: am e811c774
: am 40236a89
: Display sync errors using snackbar and not as a TL footer
* commit 'ab841bb5548dbf40ff896ad2e2ad128db676af72': Display sync errors using snackbar and not as a TL footer
This commit is contained in:
commit
bb8efd3583
@ -35,10 +35,10 @@ import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.BaseColumns;
|
||||
|
||||
import com.android.emailcommon.utility.TextUtilities;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.R;
|
||||
import com.android.emailcommon.utility.TextUtilities;
|
||||
import com.android.emailcommon.utility.Utility;
|
||||
import com.android.mail.providers.UIProvider;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@ -101,6 +101,7 @@ public abstract class EmailContent {
|
||||
|
||||
public static final int LAST_SYNC_RESULT_SUCCESS = UIProvider.LastSyncResult.SUCCESS;
|
||||
public static final int LAST_SYNC_RESULT_AUTH_ERROR = UIProvider.LastSyncResult.AUTH_ERROR;
|
||||
public static final int LAST_SYNC_RESULT_SERVER_ERROR = UIProvider.LastSyncResult.SERVER_ERROR;
|
||||
public static final int LAST_SYNC_RESULT_SECURITY_ERROR =
|
||||
UIProvider.LastSyncResult.SECURITY_ERROR;
|
||||
public static final int LAST_SYNC_RESULT_CONNECTION_ERROR =
|
||||
|
@ -33,6 +33,7 @@ import android.os.Bundle;
|
||||
public abstract class EmailServiceStatus {
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int IN_PROGRESS = 1;
|
||||
public static final int FAILURE = 2;
|
||||
|
||||
public static final int MESSAGE_NOT_FOUND = 0x10;
|
||||
public static final int ATTACHMENT_NOT_FOUND = 0x11;
|
||||
|
@ -72,8 +72,6 @@ public class EmailConversationCursor extends CursorWrapper implements
|
||||
if (mailbox != null) {
|
||||
mMailboxTypeId = mailbox.mType;
|
||||
|
||||
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_ERROR,
|
||||
mailbox.mUiLastSyncResult);
|
||||
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT, mailbox.mTotalCount);
|
||||
if (mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_BACKGROUND
|
||||
|| mailbox.mUiSyncStatus == EmailContent.SYNC_STATUS_USER
|
||||
@ -106,8 +104,6 @@ public class EmailConversationCursor extends CursorWrapper implements
|
||||
} else {
|
||||
mMailboxTypeId = -1;
|
||||
// TODO for virtual mailboxes, we may want to do something besides just fake it
|
||||
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_ERROR,
|
||||
UIProvider.LastSyncResult.SUCCESS);
|
||||
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_TOTAL_COUNT,
|
||||
cursor != null ? cursor.getCount() : 0);
|
||||
mExtras.putInt(UIProvider.CursorExtraKeys.EXTRA_STATUS,
|
||||
|
@ -65,10 +65,10 @@ import android.util.SparseArray;
|
||||
|
||||
import com.android.common.content.ProjectionMap;
|
||||
import com.android.email.DebugUtils;
|
||||
import com.android.email.NotificationController;
|
||||
import com.android.email.NotificationControllerCreatorHolder;
|
||||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
import com.android.email.NotificationControllerCreatorHolder;
|
||||
import com.android.email.NotificationController;
|
||||
import com.android.email.SecurityPolicy;
|
||||
import com.android.email.activity.setup.AccountSecurity;
|
||||
import com.android.email.activity.setup.AccountSettingsUtils;
|
||||
@ -5751,13 +5751,13 @@ public class EmailProvider extends ContentProvider
|
||||
.monitorRefreshStatus(mailbox.mId, new RefreshStatusMonitor.Callback() {
|
||||
@Override
|
||||
public void onRefreshCompleted(long mailboxId, int result) {
|
||||
// all calls to this method assumed to be started by a user action
|
||||
final int syncValue = UIProvider.createSyncValue(EmailContent.SYNC_STATUS_USER,
|
||||
result);
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.NO_SYNC);
|
||||
values.put(Mailbox.UI_LAST_SYNC_RESULT, result);
|
||||
mDatabase.update(
|
||||
Mailbox.TABLE_NAME,
|
||||
values,
|
||||
WHERE_ID,
|
||||
values.put(Mailbox.UI_LAST_SYNC_RESULT, syncValue);
|
||||
mDatabase.update(Mailbox.TABLE_NAME, values, WHERE_ID,
|
||||
new String[] { String.valueOf(mailboxId) });
|
||||
notifyUIFolder(mailbox.mId, mailbox.mAccountKey);
|
||||
}
|
||||
|
@ -122,17 +122,21 @@ public class PopImapSyncAdapterService extends Service {
|
||||
Uri mailboxUri = ContentUris.withAppendedId(Mailbox.CONTENT_URI, mailboxId);
|
||||
ContentValues values = new ContentValues();
|
||||
// Set mailbox sync state
|
||||
values.put(Mailbox.UI_SYNC_STATUS,
|
||||
uiRefresh ? EmailContent.SYNC_STATUS_USER : EmailContent.SYNC_STATUS_BACKGROUND);
|
||||
final int syncStatus = uiRefresh ? EmailContent.SYNC_STATUS_USER :
|
||||
EmailContent.SYNC_STATUS_BACKGROUND;
|
||||
values.put(Mailbox.UI_SYNC_STATUS, syncStatus);
|
||||
resolver.update(mailboxUri, values, null, null);
|
||||
try {
|
||||
int lastSyncResult;
|
||||
try {
|
||||
String legacyImapProtocol = context.getString(R.string.protocol_legacy_imap);
|
||||
if (mailbox.mType == Mailbox.TYPE_OUTBOX) {
|
||||
EmailServiceStub.sendMailImpl(context, account.mId);
|
||||
} else {
|
||||
lastSyncResult = UIProvider.createSyncValue(syncStatus,
|
||||
EmailContent.LAST_SYNC_RESULT_SUCCESS);
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
|
||||
EmailServiceStatus.IN_PROGRESS, 0, UIProvider.LastSyncResult.SUCCESS);
|
||||
EmailServiceStatus.IN_PROGRESS, 0, lastSyncResult);
|
||||
final int status;
|
||||
if (protocol.equals(legacyImapProtocol)) {
|
||||
status = ImapService.synchronizeMailboxSynchronous(context, account,
|
||||
@ -142,30 +146,38 @@ public class PopImapSyncAdapterService extends Service {
|
||||
mailbox, deltaMessageCount);
|
||||
}
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, status, 0,
|
||||
UIProvider.LastSyncResult.SUCCESS);
|
||||
lastSyncResult);
|
||||
}
|
||||
} catch (MessagingException e) {
|
||||
final int type = e.getExceptionType();
|
||||
// type must be translated into the domain of values used by EmailServiceStatus
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case MessagingException.IOERROR:
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0,
|
||||
UIProvider.LastSyncResult.CONNECTION_ERROR);
|
||||
lastSyncResult = UIProvider.createSyncValue(syncStatus,
|
||||
EmailContent.LAST_SYNC_RESULT_CONNECTION_ERROR);
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
|
||||
EmailServiceStatus.FAILURE, 0, lastSyncResult);
|
||||
syncResult.stats.numIoExceptions++;
|
||||
break;
|
||||
case MessagingException.AUTHENTICATION_FAILED:
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0,
|
||||
UIProvider.LastSyncResult.AUTH_ERROR);
|
||||
lastSyncResult = UIProvider.createSyncValue(syncStatus,
|
||||
EmailContent.LAST_SYNC_RESULT_AUTH_ERROR);
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
|
||||
EmailServiceStatus.FAILURE, 0, lastSyncResult);
|
||||
syncResult.stats.numAuthExceptions++;
|
||||
break;
|
||||
case MessagingException.SERVER_ERROR:
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0,
|
||||
UIProvider.LastSyncResult.SERVER_ERROR);
|
||||
lastSyncResult = UIProvider.createSyncValue(syncStatus,
|
||||
EmailContent.LAST_SYNC_RESULT_SERVER_ERROR);
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
|
||||
EmailServiceStatus.FAILURE, 0, lastSyncResult);
|
||||
break;
|
||||
|
||||
default:
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId, type, 0,
|
||||
UIProvider.LastSyncResult.INTERNAL_ERROR);
|
||||
lastSyncResult = UIProvider.createSyncValue(syncStatus,
|
||||
EmailContent.LAST_SYNC_RESULT_INTERNAL_ERROR);
|
||||
EmailServiceStatus.syncMailboxStatus(resolver, extras, mailboxId,
|
||||
EmailServiceStatus.FAILURE, 0, lastSyncResult);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user