mirror of https://github.com/M66B/FairEmail.git
Reduced battery usage on connection failures
This commit is contained in:
parent
19942fe339
commit
8881cb5b24
|
@ -100,7 +100,7 @@ public class EmailService implements AutoCloseable {
|
||||||
static final int PURPOSE_USE = 2;
|
static final int PURPOSE_USE = 2;
|
||||||
static final int PURPOSE_SEARCH = 3;
|
static final int PURPOSE_SEARCH = 3;
|
||||||
|
|
||||||
final static int DEFAULT_CONNECT_TIMEOUT = 20; // seconds
|
final static int DEFAULT_CONNECT_TIMEOUT = 15; // seconds
|
||||||
|
|
||||||
private final static int SEARCH_TIMEOUT = 2 * 60 * 1000; // milliseconds
|
private final static int SEARCH_TIMEOUT = 2 * 60 * 1000; // milliseconds
|
||||||
private final static int FETCH_SIZE = 1024 * 1024; // bytes, default 16K
|
private final static int FETCH_SIZE = 1024 * 1024; // bytes, default 16K
|
||||||
|
@ -386,7 +386,6 @@ public class EmailService implements AutoCloseable {
|
||||||
InetAddress[] iaddrs = InetAddress.getAllByName(host);
|
InetAddress[] iaddrs = InetAddress.getAllByName(host);
|
||||||
boolean ip4 = (main instanceof Inet4Address);
|
boolean ip4 = (main instanceof Inet4Address);
|
||||||
boolean ip6 = (main instanceof Inet6Address);
|
boolean ip6 = (main instanceof Inet6Address);
|
||||||
boolean vpn = ConnectionHelper.vpnActive(context);
|
|
||||||
|
|
||||||
boolean has4 = false;
|
boolean has4 = false;
|
||||||
boolean has6 = false;
|
boolean has6 = false;
|
||||||
|
@ -408,8 +407,7 @@ public class EmailService implements AutoCloseable {
|
||||||
EntityLog.log(context, "Address main=" + main +
|
EntityLog.log(context, "Address main=" + main +
|
||||||
" count=" + iaddrs.length +
|
" count=" + iaddrs.length +
|
||||||
" ip4=" + ip4 + "/" + has4 +
|
" ip4=" + ip4 + "/" + has4 +
|
||||||
" ip6=" + ip6 + "/" + has6 +
|
" ip6=" + ip6 + "/" + has6);
|
||||||
" vpn=" + vpn);
|
|
||||||
|
|
||||||
for (InetAddress iaddr : iaddrs) {
|
for (InetAddress iaddr : iaddrs) {
|
||||||
EntityLog.log(context, "Address resolved=" + iaddr);
|
EntityLog.log(context, "Address resolved=" + iaddr);
|
||||||
|
@ -418,17 +416,13 @@ public class EmailService implements AutoCloseable {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iaddr instanceof Inet4Address) {
|
if (iaddr instanceof Inet4Address) {
|
||||||
if (!has4)
|
if (!has4 || ip4)
|
||||||
continue;
|
|
||||||
if (!vpn && ip4)
|
|
||||||
continue;
|
continue;
|
||||||
ip4 = true;
|
ip4 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iaddr instanceof Inet6Address) {
|
if (iaddr instanceof Inet6Address) {
|
||||||
if (!has6)
|
if (!has6 || ip6)
|
||||||
continue;
|
|
||||||
if (!vpn && ip6)
|
|
||||||
continue;
|
continue;
|
||||||
ip6 = true;
|
ip6 = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue