mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-15 08:29:24 +00:00
Restart send on active network change
This commit is contained in:
parent
f30157ee6f
commit
d26d9b3cac
1 changed files with 16 additions and 0 deletions
|
@ -51,6 +51,7 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
|
@ -67,6 +68,7 @@ import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
|||
|
||||
public class ServiceSend extends ServiceBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private TupleUnsent lastUnsent = null;
|
||||
private Network lastActive = null;
|
||||
private boolean lastSuitable = false;
|
||||
|
||||
private PowerManager.WakeLock wlOutbox;
|
||||
|
@ -290,6 +292,20 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
|
|||
}
|
||||
|
||||
private void _checkConnectivity() {
|
||||
Network active = ConnectionHelper.getActiveNetwork(this);
|
||||
boolean restart = !Objects.equals(lastActive, active);
|
||||
if (restart) {
|
||||
lastActive = active;
|
||||
EntityLog.log(this, "Service send active=" + active);
|
||||
|
||||
if (lastSuitable) {
|
||||
EntityLog.log(this, "Service send restart");
|
||||
lastSuitable = false;
|
||||
owner.stop();
|
||||
handling.clear();
|
||||
}
|
||||
}
|
||||
|
||||
boolean suitable = ConnectionHelper.getNetworkState(this).isSuitable();
|
||||
if (lastSuitable != suitable) {
|
||||
lastSuitable = suitable;
|
||||
|
|
Loading…
Add table
Reference in a new issue