From e41cc0cccf7d3673478f46a9f89c2e84dfe0d574 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 30 Sep 2018 13:49:01 +0000 Subject: [PATCH] Fixed race condition --- app/src/main/java/eu/faircode/email/ServiceSynchronize.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index e3ed2dfcc1..5b2173b4ed 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -214,7 +214,7 @@ public class ServiceSynchronize extends LifecycleService { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); cm.unregisterNetworkCallback(serviceManager); - serviceManager.stop(); + serviceManager.onLost(null); stopForeground(true); @@ -1864,7 +1864,7 @@ public class ServiceSynchronize extends LifecycleService { if (running) { ConnectivityManager cm = getSystemService(ConnectivityManager.class); - NetworkInfo ani = cm.getActiveNetworkInfo(); + NetworkInfo ani = (network == null ? null : cm.getActiveNetworkInfo()); EntityLog.log(ServiceSynchronize.this, "Network active=" + (ani == null ? null : ani.toString())); if (ani == null || !ani.isConnected()) { EntityLog.log(ServiceSynchronize.this, "Network disconnected=" + ani);