diff --git a/owncloudApp/src/main/java/com/owncloud/android/broadcastreceivers/ConnectivityActionReceiver.java b/owncloudApp/src/main/java/com/owncloud/android/broadcastreceivers/ConnectivityActionReceiver.java index ddc1b142ee6..3530310a14d 100755 --- a/owncloudApp/src/main/java/com/owncloud/android/broadcastreceivers/ConnectivityActionReceiver.java +++ b/owncloudApp/src/main/java/com/owncloud/android/broadcastreceivers/ConnectivityActionReceiver.java @@ -194,4 +194,4 @@ private void wifiConnected(Context context) { ); } } -} \ No newline at end of file +} diff --git a/owncloudApp/src/main/java/com/owncloud/android/files/services/CameraUploadsSyncJobService.java b/owncloudApp/src/main/java/com/owncloud/android/files/services/CameraUploadsSyncJobService.java index fec357186ec..fd563f3a602 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/files/services/CameraUploadsSyncJobService.java +++ b/owncloudApp/src/main/java/com/owncloud/android/files/services/CameraUploadsSyncJobService.java @@ -45,8 +45,6 @@ import java.util.Date; import java.util.Locale; -import androidx.annotation.RequiresApi; - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public class CameraUploadsSyncJobService extends JobService { diff --git a/owncloudApp/src/main/java/com/owncloud/android/files/services/FileUploader.java b/owncloudApp/src/main/java/com/owncloud/android/files/services/FileUploader.java index f3f9e0a6b4c..df6b831530b 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/owncloudApp/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -97,7 +97,6 @@ * fatal error occured. *
* Every file passed to this service is uploaded. No filtering is performed. - * However, Intent keys (e.g., KEY_WIFI_ONLY) are obeyed. */ public class FileUploader extends Service implements OnDatatransferProgressListener, OnAccountsUpdateListener, @@ -292,7 +291,6 @@ public int onStartCommand(Intent intent, int flags, int startId) { if ((isCameraUploadFile || isAvailableOfflineFile || isRequestedFromWifiBackEvent) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Log_OC.d(TAG, "Starting FileUploader service in foreground"); mNotificationBuilder .setChannelId(UPLOAD_NOTIFICATION_CHANNEL_ID) @@ -884,32 +882,42 @@ public void uploadFile(String uploadKey) { ); } - if (!uploadResult.isSuccess() && uploadResult.getException() != null) { - - // if failed due to lack of connectivity, schedule an automatic retry + if (!uploadResult.isSuccess()) { TransferRequester requester = new TransferRequester(); - if (requester.shouldScheduleRetry(this, uploadResult.getException())) { - int jobId = mPendingUploads.buildKey( - mCurrentAccount.name, - mCurrentUpload.getRemotePath() - ).hashCode(); + int jobId = mPendingUploads.buildKey( + mCurrentAccount.name, + mCurrentUpload.getRemotePath() + ).hashCode(); + + if (uploadResult.getException() != null) { + // if failed due to lack of connectivity, schedule an automatic retry + if (requester.shouldScheduleRetry(this, uploadResult.getException())) { + requester.scheduleUpload( + this, + jobId, + mCurrentAccount.name, + mCurrentUpload.getRemotePath() + ); + uploadResult = new RemoteOperationResult( + ResultCode.NO_NETWORK_CONNECTION); + } else { + Log_OC.v( + TAG, + String.format( + "Exception in upload, network is OK, no retry scheduled for %1s in %2s", + mCurrentUpload.getRemotePath(), + mCurrentAccount.name + ) + ); + } + } else if (uploadResult.getCode() == ResultCode.DELAYED_FOR_WIFI) { + // if failed due to the upload is delayed for wifi, schedule automatic retry as well requester.scheduleUpload( this, jobId, mCurrentAccount.name, mCurrentUpload.getRemotePath() ); - uploadResult = new RemoteOperationResult( - ResultCode.NO_NETWORK_CONNECTION); - } else { - Log_OC.v( - TAG, - String.format( - "Exception in upload, network is OK, no retry scheduled for %1s in %2s", - mCurrentUpload.getRemotePath(), - mCurrentAccount.name - ) - ); } } else { Log_OC.v(