mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-15 05:23:48 +02:00
Suppress connection errors in airplane mode
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user