mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 18:26:57 +00:00
Improve network reliability.
This commit is contained in:
@@ -132,7 +132,8 @@ public class BackgroundMessageRetriever {
|
||||
* care of it.
|
||||
*/
|
||||
public static boolean shouldIgnoreFetch() {
|
||||
return ApplicationDependencies.getAppForegroundObserver().isForegrounded();
|
||||
return ApplicationDependencies.getAppForegroundObserver().isForegrounded() &&
|
||||
ApplicationDependencies.getSignalServiceNetworkAccess().supportsWebsockets();
|
||||
}
|
||||
|
||||
private static String logSuffix(long startTime) {
|
||||
|
||||
@@ -132,7 +132,7 @@ public class IncomingMessageObserver {
|
||||
}
|
||||
|
||||
public boolean isDecryptionDrained() {
|
||||
return decryptionDrained;
|
||||
return decryptionDrained || !networkAccess.supportsWebsockets();
|
||||
}
|
||||
|
||||
public void notifyDecryptionsDrained() {
|
||||
@@ -174,12 +174,13 @@ public class IncomingMessageObserver {
|
||||
Log.d(TAG, "Removed old keep web socket open requests.");
|
||||
}
|
||||
|
||||
Log.d(TAG, String.format("Network: %s, Foreground: %s, FCM: %s, Stay open requests: [%s], Censored: %s, Registered: %s, Proxy: %s, Force websocket: %s",
|
||||
hasNetwork, appVisible, fcmEnabled, Util.join(keepAliveTokens.entrySet(), ","), networkAccess.isCensored(), registered, hasProxy, forceWebsocket));
|
||||
Log.d(TAG, String.format("Network: %s, Foreground: %s, FCM: %s, Stay open requests: [%s], Censored: %s, Supports websockets: %s, Registered: %s, Proxy: %s, Force websocket: %s",
|
||||
hasNetwork, appVisible, fcmEnabled, Util.join(keepAliveTokens.entrySet(), ","), networkAccess.isCensored(), networkAccess.supportsWebsockets(), registered, hasProxy, forceWebsocket));
|
||||
|
||||
return registered &&
|
||||
(appVisible || !fcmEnabled || forceWebsocket || Util.hasItems(keepAliveTokens)) &&
|
||||
hasNetwork;
|
||||
hasNetwork &&
|
||||
networkAccess.supportsWebsockets();
|
||||
}
|
||||
|
||||
private synchronized void waitForConnectionNecessary() {
|
||||
|
||||
@@ -173,7 +173,8 @@ open class SignalServiceNetworkAccess(context: Context) {
|
||||
interceptors,
|
||||
Optional.of(DNS),
|
||||
Optional.empty(),
|
||||
zkGroupServerPublicParams
|
||||
zkGroupServerPublicParams,
|
||||
false
|
||||
)
|
||||
|
||||
private val censorshipConfiguration: Map<Int, SignalServiceConfiguration> = mapOf(
|
||||
@@ -224,7 +225,8 @@ open class SignalServiceNetworkAccess(context: Context) {
|
||||
interceptors,
|
||||
Optional.of(DNS),
|
||||
if (SignalStore.proxy().isProxyEnabled) Optional.ofNullable(SignalStore.proxy().proxy) else Optional.empty(),
|
||||
zkGroupServerPublicParams
|
||||
zkGroupServerPublicParams,
|
||||
true
|
||||
)
|
||||
|
||||
open fun getConfiguration(): SignalServiceConfiguration {
|
||||
@@ -267,6 +269,10 @@ open class SignalServiceNetworkAccess(context: Context) {
|
||||
return defaultCensoredCountryCodes.contains(countryCode)
|
||||
}
|
||||
|
||||
fun supportsWebsockets(): Boolean {
|
||||
return !isCensored() || getConfiguration().supportsWebSockets()
|
||||
}
|
||||
|
||||
private fun buildGConfiguration(
|
||||
hostConfigs: List<HostConfig>
|
||||
): SignalServiceConfiguration {
|
||||
@@ -291,7 +297,8 @@ open class SignalServiceNetworkAccess(context: Context) {
|
||||
interceptors,
|
||||
Optional.of(DNS),
|
||||
Optional.empty(),
|
||||
zkGroupServerPublicParams
|
||||
zkGroupServerPublicParams,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user