mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-12 16:57:18 +01:00
Add handling for AppExpiredConnection in LibSignalChatConnection:connect.
Co-authored-by: Cody Henthorne <cody@signal.org>
This commit is contained in:
committed by
Greyson Parrelli
parent
defe94c4fa
commit
88fd8fb36b
@@ -310,7 +310,9 @@ class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_f
|
||||
when (state) {
|
||||
WebSocketConnectionState.CONNECTING, WebSocketConnectionState.DISCONNECTING, WebSocketConnectionState.DISCONNECTED -> proxyStatus.setImageResource(R.drawable.ic_proxy_connecting_24)
|
||||
WebSocketConnectionState.CONNECTED -> proxyStatus.setImageResource(R.drawable.ic_proxy_connected_24)
|
||||
WebSocketConnectionState.AUTHENTICATION_FAILED, WebSocketConnectionState.FAILED -> proxyStatus.setImageResource(R.drawable.ic_proxy_failed_24)
|
||||
WebSocketConnectionState.AUTHENTICATION_FAILED,
|
||||
WebSocketConnectionState.REMOTE_DEPRECATED,
|
||||
WebSocketConnectionState.FAILED -> proxyStatus.setImageResource(R.drawable.ic_proxy_failed_24)
|
||||
else -> proxyStatus.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.reactivex.rxjava3.kotlin.subscribeBy
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.whispersystems.signalservice.api.util.SleepTimer
|
||||
import org.whispersystems.signalservice.api.websocket.HealthMonitor
|
||||
@@ -17,7 +18,6 @@ import org.whispersystems.signalservice.api.websocket.WebSocketConnectionState
|
||||
import org.whispersystems.signalservice.internal.websocket.OkHttpWebSocketConnection
|
||||
import java.util.concurrent.Executor
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.concurrent.Volatile
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
@@ -80,6 +80,12 @@ class SignalWebSocketHealthMonitor(
|
||||
TextSecurePreferences.setUnauthorizedReceived(AppDependencies.application, true)
|
||||
}
|
||||
}
|
||||
WebSocketConnectionState.REMOTE_DEPRECATED -> {
|
||||
if (!SignalStore.misc.isClientDeprecated) {
|
||||
Log.w(TAG, "Received remote deprecation. Client version is deprecated.", true)
|
||||
SignalStore.misc.isClientDeprecated = true
|
||||
}
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ public class EditProxyFragment extends Fragment {
|
||||
proxyStatus.setTextColor(getResources().getColor(R.color.signal_accent_green));
|
||||
break;
|
||||
case AUTHENTICATION_FAILED:
|
||||
case REMOTE_DEPRECATED:
|
||||
case FAILED:
|
||||
proxyStatus.setText(R.string.preferences_connection_failed);
|
||||
proxyStatus.setTextColor(getResources().getColor(R.color.signal_alert_primary));
|
||||
|
||||
+2
-1
@@ -10,9 +10,10 @@ public enum WebSocketConnectionState {
|
||||
RECONNECTING,
|
||||
DISCONNECTING,
|
||||
AUTHENTICATION_FAILED,
|
||||
REMOTE_DEPRECATED,
|
||||
FAILED;
|
||||
|
||||
public boolean isFailure() {
|
||||
return this == AUTHENTICATION_FAILED || this == FAILED;
|
||||
return this == AUTHENTICATION_FAILED || this == REMOTE_DEPRECATED || this == FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-5
@@ -14,6 +14,7 @@ import okio.ByteString
|
||||
import okio.ByteString.Companion.toByteString
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.libsignal.internal.CompletableFuture
|
||||
import org.signal.libsignal.net.AppExpiredException
|
||||
import org.signal.libsignal.net.AuthenticatedChatConnection
|
||||
import org.signal.libsignal.net.ChatConnection
|
||||
import org.signal.libsignal.net.ChatConnectionListener
|
||||
@@ -192,10 +193,17 @@ class LibSignalChatConnection(
|
||||
// request returns HTTP 403.
|
||||
// The chat service currently does not return HTTP 401 on /v1/websocket.
|
||||
// Thus, this currently matches the implementation in OkHttpWebSocketConnection.
|
||||
if (throwable is DeviceDeregisteredException) {
|
||||
state.onNext(WebSocketConnectionState.AUTHENTICATION_FAILED)
|
||||
} else {
|
||||
state.onNext(WebSocketConnectionState.FAILED)
|
||||
when (throwable) {
|
||||
is DeviceDeregisteredException -> {
|
||||
state.onNext(WebSocketConnectionState.AUTHENTICATION_FAILED)
|
||||
}
|
||||
is AppExpiredException -> {
|
||||
state.onNext(WebSocketConnectionState.REMOTE_DEPRECATED)
|
||||
}
|
||||
else -> {
|
||||
Log.w(TAG, "Unknown connection failure reason", throwable)
|
||||
state.onNext(WebSocketConnectionState.FAILED)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,7 +218,8 @@ class LibSignalChatConnection(
|
||||
WebSocketConnectionState.DISCONNECTED,
|
||||
WebSocketConnectionState.DISCONNECTING,
|
||||
WebSocketConnectionState.FAILED,
|
||||
WebSocketConnectionState.AUTHENTICATION_FAILED -> true
|
||||
WebSocketConnectionState.AUTHENTICATION_FAILED,
|
||||
WebSocketConnectionState.REMOTE_DEPRECATED -> true
|
||||
|
||||
WebSocketConnectionState.CONNECTING,
|
||||
WebSocketConnectionState.CONNECTED,
|
||||
|
||||
Reference in New Issue
Block a user