mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-01 06:38:29 +02:00
Check if account thread is alive
This commit is contained in:
@@ -3503,6 +3503,10 @@ class Core {
|
||||
join(thread);
|
||||
}
|
||||
|
||||
boolean isAlive() {
|
||||
return thread.isAlive();
|
||||
}
|
||||
|
||||
boolean isRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
@@ -236,15 +236,16 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
|
||||
// Some networks disallow email server connections:
|
||||
// - reload on network type change when disconnected
|
||||
boolean isRunning = (state != null && state.isAlive());
|
||||
if (reload ||
|
||||
prev.canRun() != current.canRun() ||
|
||||
isRunning != current.canRun() ||
|
||||
!prev.accountState.equals(current.accountState) ||
|
||||
(!"connected".equals(current.accountState.state) &&
|
||||
!Objects.equals(prev.networkState.getType(), current.networkState.getType()))) {
|
||||
if (prev.canRun() || current.canRun())
|
||||
if (isRunning || current.canRun())
|
||||
EntityLog.log(ServiceSynchronize.this, "### changed " + current +
|
||||
" reload=" + reload +
|
||||
" stop=" + prev.canRun() +
|
||||
" stop=" + isRunning +
|
||||
" start=" + current.canRun() +
|
||||
" sync=" + current.accountState.isEnabled(current.enabled) + "/" + sync +
|
||||
" changed=" + !prev.accountState.equals(current.accountState) +
|
||||
@@ -255,7 +256,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
" tbd=" + current.accountState.tbd +
|
||||
" state=" + current.accountState.state +
|
||||
" type=" + prev.networkState.getType() + "/" + current.networkState.getType());
|
||||
if (prev.canRun())
|
||||
if (isRunning)
|
||||
stop(prev);
|
||||
if (current.canRun())
|
||||
start(current, current.accountState.isEnabled(current.enabled) || sync);
|
||||
|
||||
Reference in New Issue
Block a user