mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Generalize preventing WebSocket from connecting in various app states.
This commit is contained in:
committed by
Michelle Tang
parent
ecb040ce98
commit
fcc6032ee0
@@ -5,7 +5,6 @@ import androidx.annotation.NonNull;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.whispersystems.signalservice.api.websocket.SignalWebSocket;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -49,15 +48,17 @@ public final class DeviceTransferBlockingInterceptor implements Interceptor {
|
||||
.build();
|
||||
}
|
||||
|
||||
public boolean isBlockingNetwork() {
|
||||
return blockNetworking;
|
||||
}
|
||||
|
||||
public void blockNetwork() {
|
||||
blockNetworking = true;
|
||||
SignalWebSocket.setCanConnect(false);
|
||||
AppDependencies.resetNetwork();
|
||||
}
|
||||
|
||||
public void unblockNetwork() {
|
||||
blockNetworking = false;
|
||||
SignalWebSocket.setCanConnect(true);
|
||||
AppDependencies.startNetwork();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,15 @@ class SignalWebSocketHealthMonitor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMessageError(status: Int, isIdentifiedWebSocket: Boolean) = Unit
|
||||
override fun onMessageError(status: Int, isIdentifiedWebSocket: Boolean) {
|
||||
executor.execute {
|
||||
if (status == 499 && !SignalStore.misc.isClientDeprecated) {
|
||||
Log.w(TAG, "Received 499. Client version is deprecated.", true)
|
||||
SignalStore.misc.isClientDeprecated = true
|
||||
webSocket?.forceNewWebSocket()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateKeepAliveSenderStatus() {
|
||||
if (keepAliveSender == null && sendKeepAlives()) {
|
||||
|
||||
Reference in New Issue
Block a user