use of com.zegoggles.smssync.contacts.ContactGroupIds in project sms-backup-plus by jberkel.
the class BackupTask method fetchAndBackupItems.
private BackupState fetchAndBackupItems(BackupConfig config) {
BackupCursors cursors = null;
try {
final ContactGroupIds groupIds = contactAccessor.getGroupContactIds(service.getContentResolver(), config.groupToBackup);
cursors = new BulkFetcher(fetcher).fetch(config.typesToBackup, groupIds, config.maxItemsPerSync);
final int itemsToSync = cursors.count();
if (itemsToSync > 0) {
appLog(R.string.app_log_backup_messages, cursors.count(SMS), cursors.count(MMS), cursors.count(CALLLOG));
if (config.debug) {
appLog(R.string.app_log_backup_messages_with_config, config);
}
return backupCursors(cursors, config.imapStore, config.backupType, itemsToSync);
} else {
appLog(R.string.app_log_skip_backup_no_items);
if (preferences.isFirstBackup()) {
// If this is the first backup we need to write something to MAX_SYNCED_DATE
// such that we know that we've performed a backup before.
preferences.getDataTypePreferences().setMaxSyncedDate(SMS, MAX_SYNCED_DATE);
preferences.getDataTypePreferences().setMaxSyncedDate(MMS, MAX_SYNCED_DATE);
}
Log.i(TAG, "Nothing to do.");
return transition(FINISHED_BACKUP, null);
}
} catch (XOAuth2AuthenticationFailedException e) {
return handleAuthError(config, e);
} catch (AuthenticationFailedException e) {
return transition(ERROR, e);
} catch (MessagingException e) {
return transition(ERROR, e);
} catch (SecurityException e) {
return transition(ERROR, e);
} finally {
if (cursors != null) {
cursors.close();
}
}
}
use of com.zegoggles.smssync.contacts.ContactGroupIds in project sms-backup-plus by jberkel.
the class BackupQueryBuilderTest method shouldBuildQueryForSMSIncludingContactGroup.
@Test
public void shouldBuildQueryForSMSIncludingContactGroup() throws Exception {
ContactGroupIds ids = new ContactGroupIds();
ids.add(1L, 20L);
BackupQueryBuilder.Query query = builder.buildQueryForDataType(SMS, ids, 200);
assertThat(query.uri).isEqualTo(Uri.parse("content://sms"));
assertThat(query.projection).isNull();
assertThat(query.selection).isEqualTo("date > ? AND type <> ? AND (type = 2 OR person IN (20))");
assertThat(query.selectionArgs).asList().containsExactly("-1", "3");
assertThat(query.sortOrder).isEqualTo("date LIMIT 200");
}
Aggregations