Revert "offline presences aborts session proposals. fixes #3943"

This reverts commit f23016c967.
This commit is contained in:
Daniel Gultsch 2021-01-06 09:03:42 +01:00
parent 17c697eed9
commit 372ddbfb49
2 changed files with 27 additions and 49 deletions

View File

@ -206,26 +206,23 @@ public class XmppConnectionService extends Service {
} }
}; };
public DatabaseBackend databaseBackend; public DatabaseBackend databaseBackend;
private final ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor("ContactMerger"); private ReplacingSerialSingleThreadExecutor mContactMergerExecutor = new ReplacingSerialSingleThreadExecutor("ContactMerger");
private long mLastActivity = 0; private long mLastActivity = 0;
private final FileBackend fileBackend = new FileBackend(this); private FileBackend fileBackend = new FileBackend(this);
private MemorizingTrustManager mMemorizingTrustManager; private MemorizingTrustManager mMemorizingTrustManager;
private final NotificationService mNotificationService = new NotificationService(this); private NotificationService mNotificationService = new NotificationService(this);
private final ChannelDiscoveryService mChannelDiscoveryService = new ChannelDiscoveryService(this); private ChannelDiscoveryService mChannelDiscoveryService = new ChannelDiscoveryService(this);
private final ShortcutService mShortcutService = new ShortcutService(this); private ShortcutService mShortcutService = new ShortcutService(this);
private final AtomicBoolean mInitialAddressbookSyncCompleted = new AtomicBoolean(false); private AtomicBoolean mInitialAddressbookSyncCompleted = new AtomicBoolean(false);
private final AtomicBoolean mForceForegroundService = new AtomicBoolean(false); private AtomicBoolean mForceForegroundService = new AtomicBoolean(false);
private final AtomicBoolean mForceDuringOnCreate = new AtomicBoolean(false); private AtomicBoolean mForceDuringOnCreate = new AtomicBoolean(false);
private final AtomicReference<OngoingCall> ongoingCall = new AtomicReference<>(); private AtomicReference<OngoingCall> ongoingCall = new AtomicReference<>();
private final OnMessagePacketReceived mMessageParser = new MessageParser(this); private OnMessagePacketReceived mMessageParser = new MessageParser(this);
private final OnPresencePacketReceived mPresenceParser = new PresenceParser(this); private OnPresencePacketReceived mPresenceParser = new PresenceParser(this);
private final IqParser mIqParser = new IqParser(this); private IqParser mIqParser = new IqParser(this);
private final MessageGenerator mMessageGenerator = new MessageGenerator(this); private MessageGenerator mMessageGenerator = new MessageGenerator(this);
public OnContactStatusChanged onContactStatusChanged = (contact, online) -> { public OnContactStatusChanged onContactStatusChanged = (contact, online) -> {
if (!online) { Conversation conversation = find(getConversations(), contact);
getJingleConnectionManager().failProposedSessions(contact.getAccount(), contact.getJid().asBareJid());
}
final Conversation conversation = find(getConversations(), contact);
if (conversation != null) { if (conversation != null) {
if (online) { if (online) {
if (contact.getPresences().size() == 1) { if (contact.getPresences().size() == 1) {
@ -234,14 +231,14 @@ public class XmppConnectionService extends Service {
} }
} }
}; };
private final PresenceGenerator mPresenceGenerator = new PresenceGenerator(this); private PresenceGenerator mPresenceGenerator = new PresenceGenerator(this);
private List<Account> accounts; private List<Account> accounts;
private final JingleConnectionManager mJingleConnectionManager = new JingleConnectionManager(this); private JingleConnectionManager mJingleConnectionManager = new JingleConnectionManager(this);
private final HttpConnectionManager mHttpConnectionManager = new HttpConnectionManager(this); private HttpConnectionManager mHttpConnectionManager = new HttpConnectionManager(this);
private final AvatarService mAvatarService = new AvatarService(this); private AvatarService mAvatarService = new AvatarService(this);
private final MessageArchiveService mMessageArchiveService = new MessageArchiveService(this); private MessageArchiveService mMessageArchiveService = new MessageArchiveService(this);
private final PushManagementService mPushManagementService = new PushManagementService(this); private PushManagementService mPushManagementService = new PushManagementService(this);
private final QuickConversationsService mQuickConversationsService = new QuickConversationsService(this); private QuickConversationsService mQuickConversationsService = new QuickConversationsService(this);
private final ConversationsFileObserver fileObserver = new ConversationsFileObserver( private final ConversationsFileObserver fileObserver = new ConversationsFileObserver(
Environment.getExternalStorageDirectory().getAbsolutePath() Environment.getExternalStorageDirectory().getAbsolutePath()
) { ) {

View File

@ -361,7 +361,7 @@ public class JingleConnectionManager extends AbstractConnectionManager {
} }
} }
} else { } else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retrieved out of order jingle message" + message); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retrieved out of order jingle message"+message);
} }
} }
@ -681,30 +681,11 @@ public class JingleConnectionManager extends AbstractConnectionManager {
Log.d(Config.LOGTAG, "session proposal already at discovered. not going to fall back"); Log.d(Config.LOGTAG, "session proposal already at discovered. not going to fall back");
return; return;
} }
updateProposedSessionDiscovered(sessionProposal, target); this.rtpSessionProposals.put(sessionProposal, target);
} final RtpEndUserState endUserState = target.toEndUserState();
} toneManager.transition(endUserState, sessionProposal.media);
mXmppConnectionService.notifyJingleRtpConnectionUpdate(account, sessionProposal.with, sessionProposal.sessionId, endUserState);
public void updateProposedSessionDiscovered(RtpSessionProposal sessionProposal, final DeviceDiscoveryState target) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": flagging session " + sessionId + " as " + target);
this.rtpSessionProposals.put(sessionProposal, target);
final RtpEndUserState endUserState = target.toEndUserState();
toneManager.transition(endUserState, sessionProposal.media);
mXmppConnectionService.notifyJingleRtpConnectionUpdate(sessionProposal.account, sessionProposal.with, sessionProposal.sessionId, endUserState);
Log.d(Config.LOGTAG, sessionProposal.account.getJid().asBareJid() + ": flagging session " + sessionProposal.sessionId + " as " + target);
}
public void failProposedSessions(final Account account, Jid from) {
synchronized (this.rtpSessionProposals) {
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry : rtpSessionProposals.entrySet()) {
final RtpSessionProposal rtpSessionProposal = entry.getKey();
final DeviceDiscoveryState state = entry.getValue();
if (state != DeviceDiscoveryState.DISCOVERED) {
continue;
}
if (rtpSessionProposal.with.equals(from) && rtpSessionProposal.account.getJid().equals(account.getJid())) {
updateProposedSessionDiscovered(rtpSessionProposal, JingleConnectionManager.DeviceDiscoveryState.FAILED);
}
}
} }
} }