private RestoreState handleAuthError(RestoreConfig config, int currentRestoredItem, XOAuth2AuthenticationFailedException e) {
if (e.getStatus() == 400) {
Log.d(TAG, "need to perform xoauth2 token refresh");
if (config.tries < 1) {
try {
tokenRefresher.refreshOAuth2Token();
return restore(config.retryWithStore(currentRestoredItem, service.getBackupImapStore()));
} catch (MessagingException ignored) {
Log.w(TAG, ignored);
} catch (TokenRefreshException refreshException) {
Log.w(TAG, refreshException);
}
} else {
Log.w(TAG, "no new token obtained, giving up");
}
} else {
Log.w(TAG, "unexpected xoauth status code " + e.getStatus());
}
return transition(SmsSyncState.ERROR, e);
}