Add more checks to avoid unnecessary websocket connects.
This commit is contained in:
parent
e877f43dde
commit
4c1555bc7b
@ -143,6 +143,7 @@ class BackupSubscriptionCheckJobTest {
|
||||
@Test
|
||||
fun givenUserIsNotRegistered_whenIRun_thenIExpectSuccessAndEarlyExit() {
|
||||
mockkObject(SignalStore.account) {
|
||||
every { SignalStore.account.e164 } returns "+15555550101"
|
||||
every { SignalStore.account.isRegistered } returns false
|
||||
|
||||
val job = BackupSubscriptionCheckJob.create()
|
||||
@ -155,6 +156,7 @@ class BackupSubscriptionCheckJobTest {
|
||||
@Test
|
||||
fun givenIsLinkedDevice_whenIRun_thenIExpectSuccessAndEarlyExit() {
|
||||
mockkObject(SignalStore.account) {
|
||||
every { SignalStore.account.e164 } returns "+15555550101"
|
||||
every { SignalStore.account.isLinkedDevice } returns true
|
||||
|
||||
val job = BackupSubscriptionCheckJob.create()
|
||||
|
||||
@ -399,7 +399,7 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
};
|
||||
|
||||
SignalWebSocket.AuthenticatedWebSocket webSocket = new SignalWebSocket.AuthenticatedWebSocket(authFactory,
|
||||
() -> !SignalStore.misc().isClientDeprecated() && !DeviceTransferBlockingInterceptor.getInstance().isBlockingNetwork() && !Environment.IS_INSTRUMENTATION,
|
||||
() -> !SignalStore.misc().isClientDeprecated() && SignalStore.account().isRegistered() && !TextSecurePreferences.isUnauthorizedReceived(context) && !DeviceTransferBlockingInterceptor.getInstance().isBlockingNetwork() && !Environment.IS_INSTRUMENTATION,
|
||||
sleepTimer,
|
||||
TimeUnit.SECONDS.toMillis(30));
|
||||
if (AppForegroundObserver.isForegrounded()) {
|
||||
|
||||
@ -271,7 +271,7 @@ class IncomingMessageObserver(
|
||||
}
|
||||
|
||||
private fun isConnectionAvailable(): Boolean {
|
||||
return SignalStore.account.isRegistered && (authWebSocket.stateSnapshot == WebSocketConnectionState.CONNECTED || (authWebSocket.shouldSendKeepAlives() && NetworkConstraint.isMet(context)))
|
||||
return !TextSecurePreferences.isUnauthorizedReceived(context) && SignalStore.account.isRegistered && (authWebSocket.stateSnapshot == WebSocketConnectionState.CONNECTED || (authWebSocket.shouldSendKeepAlives() && NetworkConstraint.isMet(context)))
|
||||
}
|
||||
|
||||
private fun waitForConnectionNecessary() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user