From 646180a856feec1c226e1fe993c072c7c1c2ae19 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Dec 2018 13:59:55 +0100 Subject: [PATCH] Fixed no suitable network --- .../main/java/eu/faircode/email/ServiceSynchronize.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 8d4a18bbdd..ae52cb7d2c 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -81,7 +81,6 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import javax.mail.Address; import javax.mail.AuthenticationFailedException; @@ -704,7 +703,7 @@ public class ServiceSynchronize extends LifecycleService { } } - private void monitorAccount(final EntityAccount account, final ServiceState state) throws NoSuchProviderException, TimeoutException { + private void monitorAccount(final EntityAccount account, final ServiceState state) throws NoSuchProviderException { final PowerManager pm = getSystemService(PowerManager.class); final PowerManager.WakeLock wl0 = pm.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, @@ -2321,8 +2320,11 @@ public class ServiceSynchronize extends LifecycleService { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this); boolean metered = prefs.getBoolean("metered", true); + boolean suitable = (network != null && (metered || unmetered)); + EntityLog.log(ServiceSynchronize.this, "suitable=" + suitable + " active=" + cm.getActiveNetworkInfo()); + // The connected state is deliberately ignored - return (metered || unmetered); + return suitable; } private boolean isEnabled() {