mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 16:19:33 +01:00
Only deauthorize on identified connection.
This commit is contained in:
@@ -4,11 +4,8 @@ import android.app.Application;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.signal.core.util.ThreadUtil;
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.signalservice.api.SignalWebSocket;
|
||||
@@ -66,26 +63,30 @@ public final class SignalWebSocketHealthMonitor implements HealthMonitor {
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(Schedulers.computation())
|
||||
.distinctUntilChanged()
|
||||
.subscribe(s -> onStateChange(s, identified));
|
||||
.subscribe(s -> onStateChange(s, identified, true));
|
||||
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
signalWebSocket.getUnidentifiedWebSocketState()
|
||||
.subscribeOn(Schedulers.computation())
|
||||
.observeOn(Schedulers.computation())
|
||||
.distinctUntilChanged()
|
||||
.subscribe(s -> onStateChange(s, unidentified));
|
||||
.subscribe(s -> onStateChange(s, unidentified, false));
|
||||
});
|
||||
}
|
||||
|
||||
private void onStateChange(WebSocketConnectionState connectionState, HealthState healthState) {
|
||||
private void onStateChange(WebSocketConnectionState connectionState, HealthState healthState, boolean isIdentified) {
|
||||
executor.execute(() -> {
|
||||
switch (connectionState) {
|
||||
case CONNECTED:
|
||||
TextSecurePreferences.setUnauthorizedReceived(context, false);
|
||||
break;
|
||||
if (isIdentified) {
|
||||
TextSecurePreferences.setUnauthorizedReceived(context, false);
|
||||
break;
|
||||
}
|
||||
case AUTHENTICATION_FAILED:
|
||||
TextSecurePreferences.setUnauthorizedReceived(context, true);
|
||||
break;
|
||||
if (isIdentified) {
|
||||
TextSecurePreferences.setUnauthorizedReceived(context, true);
|
||||
break;
|
||||
}
|
||||
case FAILED:
|
||||
if (SignalStore.proxy().isProxyEnabled()) {
|
||||
Log.w(TAG, "Encountered an error while we had a proxy set! Terminating the connection to prevent retry spam.");
|
||||
|
||||
Reference in New Issue
Block a user