/** * Gets the most recent timestamp for given datatype. * @param dataType the data type * @return timestamp * @throws SecurityException if app does not hold necessary permissions */ public long getMostRecentTimestamp(DataType dataType) { return getMostRecentTimestampForQuery(queryBuilder.buildMostRecentQueryForDataType(dataType)); }
private BackupState acquireLocksAndBackup(BackupConfig config) { try { service.acquireLocks(); return fetchAndBackupItems(config); } finally { service.releaseLocks(); } }
private void publish(SmsSyncState state) { publishProgress(service.transition(state, null)); } }
@Test public void shouldAcquireAndReleaseLocksDuringBackup() throws Exception { mockAllFetchEmpty(); task.doInBackground(config); verify(service).acquireLocks(); verify(service).releaseLocks(); verify(service).transition(SmsSyncState.FINISHED_BACKUP, null); }
public static CursorAndType empty() { return new CursorAndType(DataType.SMS, emptyCursor()); } }
@Override public void onCreate() { super.onCreate(); asyncClearCache(); BinaryTempFileBody.setTempDirectory(getCacheDir()); service = this; }
RestoreTask(SmsRestoreService service, MessageConverter converter, ContentResolver resolver, TokenRefresher tokenRefresher) { this.service = service; this.converter = converter; this.resolver = resolver; this.tokenRefresher = tokenRefresher; this.preferences = service.getPreferences(); }
public BackupConfig retryWithStore(BackupImapStore store) { return new BackupConfig(store, currentTry + 1, maxItemsPerSync, groupToBackup, backupType, typesToBackup, debug); }
public RestoreConfig retryWithStore(int currentItem, BackupImapStore backupImapStore) { return new RestoreConfig( backupImapStore, tries + 1, restoreSms, restoreCallLog, restoreOnlyStarred, maxRestore, currentItem ); }
@Override protected void onProgressUpdate(BackupState... progress) { if (progress != null && progress.length > 0 && !isCancelled()) { post(progress[0]); } }
boolean isConnectedViaWifi() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return isConnectedViaWifi_SDK21(); } else { return isConnectedViaWifi_pre_SDK21(); } }
@Override protected void onProgressUpdate(RestoreState... progress) { if (progress != null && progress.length > 0 && !isCancelled()) { post(progress[0]); } }
private void asyncClearCache() { new Thread("clearCache") { @Override public void run() { clearCache(); } }.start(); }
@SuppressWarnings("deprecation") @Override protected int wakeLockType() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // hold a full wake lock when restoring on newer version of Android, since // the user needs to switch back the sms app afterwards return PowerManager.FULL_WAKE_LOCK; } else { return super.wakeLockType(); } }
@Override public void run() { clearCache(); } }.start();
@Override public int onStartCommand(final Intent intent, int flags, int startId) { handleIntent(intent); return START_NOT_STICKY; }