浏览代码

Fix 1911

Signed-off-by: Mario Danic <mario@lovelyhq.com>
Mario Danic 7 年之前
父节点
当前提交
8a865ee638

+ 2 - 1
src/main/java/com/owncloud/android/files/services/FileUploader.java

@@ -396,6 +396,7 @@ public class FileUploader extends Service
                         currentAccount = failedUpload.getAccount(context);
                         currentAccount = failedUpload.getAccount(context);
                     }
                     }
 
 
+                    charging = charging || Device.getBatteryStatus(context).getBatteryPercent() == 1;
                     if (!isPowerSaving && gotNetwork && checkIfUploadCanBeRetried(failedUpload, gotWifi, charging)) {
                     if (!isPowerSaving && gotNetwork && checkIfUploadCanBeRetried(failedUpload, gotWifi, charging)) {
                             retry(context, currentAccount, failedUpload);
                             retry(context, currentAccount, failedUpload);
                         }
                         }
@@ -942,7 +943,7 @@ public class FileUploader extends Service
                         cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
                         cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
                                 , ResultCode.DELAYED_FOR_WIFI);
                                 , ResultCode.DELAYED_FOR_WIFI);
                     } else if (mCurrentUpload.getIsChargingRequired() &&
                     } else if (mCurrentUpload.getIsChargingRequired() &&
-                            !Device.getBatteryStatus(MainApp.getAppContext()).isCharging()) {
+                            (!Device.getBatteryStatus(MainApp.getAppContext()).isCharging())) {
                         cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
                         cancel(mCurrentUpload.getAccount().name, mCurrentUpload.getFile().getRemotePath()
                                 , ResultCode.DELAYED_FOR_CHARGING);
                                 , ResultCode.DELAYED_FOR_CHARGING);
                     } else if (!mCurrentUpload.getIsIgnoringPowerSaveMode() &&
                     } else if (!mCurrentUpload.getIsIgnoringPowerSaveMode() &&

+ 2 - 1
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
             // 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());
                 Log_OC.d(TAG, "Upload delayed until the device is charging: " + getRemotePath());
                 return new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING);
                 return new RemoteOperationResult(ResultCode.DELAYED_FOR_CHARGING);
             }
             }