use of com.owncloud.android.datamodel.UploadsStorageManager in project android by owncloud.
the class FileUploader method onCreate.
/**
* Service initialization
*/
@Override
public void onCreate() {
super.onCreate();
Timber.d("Creating service");
mNotificationBuilder = NotificationUtils.newNotificationBuilder(this, UPLOAD_NOTIFICATION_CHANNEL_ID);
HandlerThread thread = new HandlerThread("FileUploaderThread", Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper, this);
mBinder = new FileUploaderBinder();
mUploadsStorageManager = new UploadsStorageManager(getContentResolver());
int failedCounter = mUploadsStorageManager.failInProgressUploads(// Add UploadResult.KILLED?
UploadResult.SERVICE_INTERRUPTED);
if (failedCounter > 0) {
resurrection();
}
// add AccountsUpdatedListener
AccountManager am = AccountManager.get(getApplicationContext());
am.addOnAccountsUpdatedListener(this, null, false);
// create manager for local broadcasts
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
}
use of com.owncloud.android.datamodel.UploadsStorageManager in project android by owncloud.
the class TransferRequester method getRequiredNetworkType.
/**
* Retrieve the type of network connection required to schedule the last upload for an account
*
* @param context
* @param accountName
* @param remotePath to upload the file
* @return 2 if only wifi is required, 1 if any internet connection is required (wifi or cellular)
*/
private int getRequiredNetworkType(Context context, String accountName, String remotePath) {
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(context.getContentResolver());
// Get last upload to be retried
OCUpload ocUpload = uploadsStorageManager.getLastUploadFor(new OCFile(remotePath), accountName);
// Wifi by default
int networkType = JobInfo.NETWORK_TYPE_UNMETERED;
return networkType;
}
Aggregations