public RestoreConfig retryWithStore(int currentItem, BackupImapStore backupImapStore) { return new RestoreConfig( backupImapStore, tries + 1, restoreSms, restoreCallLog, restoreOnlyStarred, maxRestore, currentItem ); }
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(); // we got a new token, let's retry one more time - we need to pass in a new store object // since the auth params on it are immutable 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); }
@Before public void before() throws MessagingException { initMocks(this); config = new RestoreConfig(store, 0, true, false, false, -1, 0); when(service.getApplicationContext()).thenReturn(RuntimeEnvironment.application); when(service.getState()).thenReturn(state); when(service.getPreferences()).thenReturn(new Preferences(RuntimeEnvironment.application)); when(store.getFolder(any(DataType.class), any(DataTypePreferences.class))).thenReturn(folder); task = new RestoreTask(service, converter, resolver, tokenRefresher); }
); RestoreConfig config = new RestoreConfig( getBackupImapStore(), 0,