From 8a865ee6382b05ffaca9ccd2b7e90e415befc686 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Thu, 4 Jan 2018 22:22:30 +0100 Subject: [PATCH] Fix 1911 Signed-off-by: Mario Danic --- .../java/com/owncloud/android/files/services/FileUploader.java | 3 ++- .../com/owncloud/android/operations/UploadFileOperation.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/owncloud/android/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java index 8a15397597..0a5c1630ec 100644 --- a/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -396,6 +396,7 @@ public class FileUploader extends Service currentAccount = failedUpload.getAccount(context); } + charging = charging || Device.getBatteryStatus(context).getBatteryPercent() == 1; if (!isPowerSaving && gotNetwork && checkIfUploadCanBeRetried(failedUpload, gotWifi, charging)) { retry(context, currentAccount, failedUpload); } @@ -942,7 +943,7 @@ public class FileUploader extends Service cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath() , ResultCode.DELAYED_FOR_WIFI); } else if (mCurrentUpload.getIsChargingRequired() && - !Device.getBatteryStatus(MainApp.getAppContext()).isCharging()) { + (!Device.getBatteryStatus(MainApp.getAppContext()).isCharging())) { cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath() , ResultCode.DELAYED_FOR_CHARGING); } else if (!mCurrentUpload.getIsIgnoringPowerSaveMode() && diff --git a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java index ed7bd68487..65e6969512 100644 --- a/src/main/java/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/main/java/com/owncloud/android/operations/UploadFileOperation.java @@ -354,7 +354,8 @@ public class UploadFileOperation extends SyncOperation { } // Check if charging conditions are met and delays the upload otherwise - if (mWhileChargingOnly && !Device.getBatteryStatus(mContext).isCharging()) { + if (mWhileChargingOnly && (!Device.getBatteryStatus(mContext).isCharging() && Device.getBatteryStatus + (mContext).getBatteryPercent() < 1)) { Log_OC.d(TAG, "Upload delayed until the device is charging: " + getRemotePath()); return new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING); }