diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsPresenter.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsPresenter.java index ca5cf440e8..5dc4b71279 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsPresenter.java +++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsPresenter.java @@ -79,9 +79,20 @@ public void saveContribution(Contribution contribution) { .save(contribution) .subscribeOn(ioThreadScheduler) .subscribe(() -> { + /* Set backoff criteria for the updated upload work request + The default backoff policy is EXPONENTIAL, but while testing we found that it + too long for the uploads to finish. So, set the backoff policy as LINEAR with the + minimum backoff delay value of 10 seconds. + + More details on when exactly it is retried: + https://developer.android.com/guide/background/persistent/getting-started/define-work#retries_backoff + */ OneTimeWorkRequest updatedUploadRequest = new OneTimeWorkRequest .Builder(UploadWorker.class) - .setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.SECONDS) + .setBackoffCriteria( + BackoffPolicy.LINEAR, + OneTimeWorkRequest.MIN_BACKOFF_MILLIS, + TimeUnit.MILLISECONDS) .build(); WorkManager.getInstance(view.getContext().getApplicationContext()) .enqueueUniqueWork( diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java b/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java index 5bcbe838fb..56ba5e930f 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/contributions/MainActivity.java @@ -371,9 +371,20 @@ public void toggleLimitedConnectionMode() { viewUtilWrapper .showShortToast(getBaseContext(), getString(R.string.limited_connection_enabled)); } else { + /* Set backoff criteria for the restart upload request + The default backoff policy is EXPONENTIAL, but while testing we found that it + too long for the uploads to finish. So, set the backoff policy as LINEAR with the + minimum backoff delay value of 10 seconds. + + More details on when exactly it is retried: + https://developer.android.com/guide/background/persistent/getting-started/define-work#retries_backoff + */ OneTimeWorkRequest restartUploadsRequest = new OneTimeWorkRequest .Builder(UploadWorker.class) - .setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.SECONDS) + .setBackoffCriteria( + BackoffPolicy.LINEAR, + OneTimeWorkRequest.MIN_BACKOFF_MILLIS, + TimeUnit.MILLISECONDS) .build(); WorkManager.getInstance(getApplicationContext()).enqueueUniqueWork( UploadWorker.class.getSimpleName(), diff --git a/app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java b/app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java index ce957e4b46..6f509f0a62 100644 --- a/app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/upload/UploadActivity.java @@ -319,9 +319,20 @@ public void updateTopCardTitle() { @Override public void makeUploadRequest() { + /* Set backoff criteria for the upload work request + The default backoff policy is EXPONENTIAL, but while testing we found that it + too long for the uploads to finish. So, set the backoff policy as LINEAR with the + minimum backoff delay value of 10 seconds. + + More details on when exactly it is retried: + https://developer.android.com/guide/background/persistent/getting-started/define-work#retries_backoff + */ OneTimeWorkRequest uploadRequest = new OneTimeWorkRequest .Builder(UploadWorker.class) - .setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.SECONDS) + .setBackoffCriteria( + BackoffPolicy.LINEAR, + OneTimeWorkRequest.MIN_BACKOFF_MILLIS, + TimeUnit.MILLISECONDS) .build(); WorkManager.getInstance(getApplicationContext()).enqueueUniqueWork( UploadWorker.class.getSimpleName(),