From 0afc34cfb145692fce9d6d052ba89b0d5489449f Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 22 May 2019 15:44:10 +0200 Subject: [PATCH] Suppress connection errors in airplane mode --- app/src/main/java/eu/faircode/email/ConnectionHelper.java | 5 +++++ app/src/main/java/eu/faircode/email/ServiceSynchronize.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/ConnectionHelper.java b/app/src/main/java/eu/faircode/email/ConnectionHelper.java index 9ed10e2f9e..17c4ab86b2 100644 --- a/app/src/main/java/eu/faircode/email/ConnectionHelper.java +++ b/app/src/main/java/eu/faircode/email/ConnectionHelper.java @@ -11,6 +11,7 @@ import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.os.Build; +import android.provider.Settings; import android.telephony.TelephonyManager; import androidx.preference.PreferenceManager; @@ -300,4 +301,8 @@ public class ConnectionHelper { return null; } + static boolean airplaneMode(Context context) { + return Settings.System.getInt(context.getContentResolver(), + Settings.Global.AIRPLANE_MODE_ON, 0) != 0; + } } diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index c83160c2da..3ce86520ae 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -665,7 +665,7 @@ public class ServiceSynchronize extends LifecycleService { ConnectionHelper.connect(this, istore, account); } catch (Throwable ex) { // Report account connection error - if (account.last_connected != null) { + if (account.last_connected != null && !ConnectionHelper.airplaneMode(this)) { EntityLog.log(this, account.name + " last connected: " + new Date(account.last_connected)); long now = new Date().getTime(); long delayed = now - account.last_connected - account.poll_interval * 60 * 1000L;