execute all account state managments on ping thread
This commit is contained in:
parent
86b733e159
commit
00f52226d8
|
@ -83,6 +83,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -879,7 +880,12 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
manageAccountConnectionStates(action, intent == null ? null : intent.getExtras());
|
||||
final var extras = intent == null ? null : intent.getExtras();
|
||||
try {
|
||||
internalPingExecutor.execute(() -> manageAccountConnectionStates(action, extras));
|
||||
} catch (final RejectedExecutionException e) {
|
||||
Log.e(Config.LOGTAG, "can not schedule connection states manager");
|
||||
}
|
||||
if (SystemClock.elapsedRealtime() - mLastExpiryRun.get() >= Config.EXPIRY_INTERVAL) {
|
||||
expireOldMessages();
|
||||
}
|
||||
|
@ -959,7 +965,7 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean processAccountState(Account account, boolean interactive, boolean isUiAction, boolean isAccountPushed, HashSet<Account> pingCandidates) {
|
||||
private boolean processAccountState(final Account account, final boolean interactive, final boolean isUiAction, final boolean isAccountPushed, final HashSet<Account> pingCandidates) {
|
||||
if (!account.getStatus().isAttemptReconnect()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -36,15 +36,15 @@ import eu.siacs.conversations.Config;
|
|||
|
||||
public class WakeLockHelper {
|
||||
|
||||
public static void acquire(PowerManager.WakeLock wakeLock) {
|
||||
public static void acquire(final PowerManager.WakeLock wakeLock) {
|
||||
try {
|
||||
wakeLock.acquire(2000);
|
||||
} catch (RuntimeException e) {
|
||||
} catch (final RuntimeException e) {
|
||||
Log.d(Config.LOGTAG, "unable to acquire wake lock", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void release(PowerManager.WakeLock wakeLock) {
|
||||
public static void release(final PowerManager.WakeLock wakeLock) {
|
||||
if (wakeLock == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class WakeLockHelper {
|
|||
if (wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
} catch (final RuntimeException e) {
|
||||
Log.d(Config.LOGTAG, "unable to release wake lock", e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue