private void importSms(final Message message) throws IOException, MessagingException { if (LOCAL_LOGV) Log.v(TAG, "importSms(" + message + ")"); final ContentValues values = converter.messageToContentValues(message); final Integer type = values.getAsInteger(Telephony.TextBasedSmsColumns.TYPE); // only restore inbox messages and sent messages - otherwise sms might get sent on restore if (type != null && (type == Telephony.TextBasedSmsColumns.MESSAGE_TYPE_INBOX || type == Telephony.TextBasedSmsColumns.MESSAGE_TYPE_SENT) && !smsExists(values)) { final Uri uri = resolver.insert(Consts.SMS_PROVIDER, values); if (uri != null) { smsIds.add(uri.getLastPathSegment()); Long timestamp = values.getAsLong(Telephony.TextBasedSmsColumns.DATE); if (timestamp != null && preferences.getDataTypePreferences().getMaxSyncedDate(SMS) < timestamp) { preferences.getDataTypePreferences().setMaxSyncedDate(SMS, timestamp); } if (LOCAL_LOGV) Log.v(TAG, "inserted " + uri); } } else { if (LOCAL_LOGV) Log.d(TAG, "ignoring sms"); } }
private BackupState skip(Iterable<DataType> types) { appLog(R.string.app_log_skip_backup_skip_messages); for (DataType type : types) { try { preferences.getDataTypePreferences().setMaxSyncedDate(type, fetcher.getMostRecentTimestamp(type)); } catch (SecurityException e ) { return new BackupState(ERROR, 0, 0, MANUAL, type, e); } } Log.i(TAG, "All messages skipped."); return new BackupState(FINISHED_BACKUP, 0, 0, MANUAL, null, null); }
@Test public void shouldSkipItems() throws Exception { when(fetcher.getMostRecentTimestamp(any(DataType.class))).thenReturn(-23L); BackupState finalState = task.doInBackground(new BackupConfig( store, 0, 100, new ContactGroup(-1), BackupType.SKIP, EnumSet.of(SMS), false ) ); verify(dataTypePreferences).setMaxSyncedDate(DataType.SMS, -23); verifyZeroInteractions(dataTypePreferences); assertThat(finalState).isNotNull(); assertThat(finalState.isFinished()).isTrue(); }
@Test public void shouldTestForFirstBackupCallLog() throws Exception { preferences.getDataTypePreferences().setMaxSyncedDate(CALLLOG, 1234); assertThat(preferences.isFirstBackup()).isFalse(); } }
@Test public void shouldTestForFirstBackupMMS() throws Exception { preferences.getDataTypePreferences().setMaxSyncedDate(MMS, 1234); assertThat(preferences.isFirstBackup()).isFalse(); }
@Test public void shouldTestForFirstBackupSMS() throws Exception { preferences.getDataTypePreferences().setMaxSyncedDate(SMS, 1234); assertThat(preferences.isFirstBackup()).isFalse(); }
calendarSyncer.syncCalendar(result); preferences.getDataTypePreferences().setMaxSyncedDate(cursor.type, result.getMaxDate()); backedUpItems += messages.size(); } else {
preferences.getDataTypePreferences().setMaxSyncedDate(SMS, MAX_SYNCED_DATE); preferences.getDataTypePreferences().setMaxSyncedDate(MMS, MAX_SYNCED_DATE);