Merge pull request #2373 from nextcloud/check-wifi-on-offline-sync

Check if we’re on unmetered wifi
This commit is contained in:
Andy Scherzinger 2018-03-19 18:43:12 +01:00 committed by GitHub
commit 1f64297dc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,8 @@ import android.support.annotation.NonNull;
import com.evernote.android.job.Job;
import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest;
import com.evernote.android.job.util.Device;
import com.owncloud.android.MainApp;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.FileDataStorageManager;
@ -55,7 +57,9 @@ public class OfflineSyncJob extends Job {
final Context context = MainApp.getAppContext();
PowerManager.WakeLock wakeLock = null;
if (!PowerUtils.isPowerSaveMode(context) && !ConnectivityUtils.isInternetWalled(context)) {
if (!PowerUtils.isPowerSaveMode(context) &&
Device.getNetworkType(context).equals(JobRequest.NetworkType.UNMETERED) &&
!ConnectivityUtils.isInternetWalled(context)) {
Set<Job> jobs = JobManager.instance().getAllJobsForTag(TAG);
for (Job job : jobs) {
if (!job.isFinished() && !job.equals(this)) {