update UI with correct state after UI gets invoked with ACTION_VIEW
This commit is contained in:
parent
d20cc87bda
commit
a44ad6015d
|
@ -29,6 +29,7 @@ import eu.siacs.conversations.xmpp.Jid;
|
||||||
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
|
||||||
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
|
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
|
||||||
import eu.siacs.conversations.xmpp.jingle.Media;
|
import eu.siacs.conversations.xmpp.jingle.Media;
|
||||||
|
import eu.siacs.conversations.xmpp.jingle.RtpEndUserState;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -83,6 +84,7 @@ public class CallIntegrationConnectionService extends ConnectionService {
|
||||||
}
|
}
|
||||||
final Account account = service.findAccountByUuid(phoneAccountHandle.getId());
|
final Account account = service.findAccountByUuid(phoneAccountHandle.getId());
|
||||||
final Intent intent = new Intent(this, RtpSessionActivity.class);
|
final Intent intent = new Intent(this, RtpSessionActivity.class);
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, account.getJid().toEscapedString());
|
intent.putExtra(RtpSessionActivity.EXTRA_ACCOUNT, account.getJid().toEscapedString());
|
||||||
intent.putExtra(RtpSessionActivity.EXTRA_WITH, jid.toEscapedString());
|
intent.putExtra(RtpSessionActivity.EXTRA_WITH, jid.toEscapedString());
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
@ -93,10 +95,17 @@ public class CallIntegrationConnectionService extends ConnectionService {
|
||||||
service.getJingleConnectionManager()
|
service.getJingleConnectionManager()
|
||||||
.proposeJingleRtpSession(account, jid, media);
|
.proposeJingleRtpSession(account, jid, media);
|
||||||
|
|
||||||
|
intent.putExtra(
|
||||||
|
RtpSessionActivity.EXTRA_LAST_REPORTED_STATE,
|
||||||
|
RtpEndUserState.FINDING_DEVICE.toString());
|
||||||
if (Media.audioOnly(media)) {
|
if (Media.audioOnly(media)) {
|
||||||
intent.setAction(RtpSessionActivity.ACTION_MAKE_VOICE_CALL);
|
intent.putExtra(
|
||||||
|
RtpSessionActivity.EXTRA_LAST_ACTION,
|
||||||
|
RtpSessionActivity.ACTION_MAKE_VOICE_CALL);
|
||||||
} else {
|
} else {
|
||||||
intent.setAction(RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
|
intent.putExtra(
|
||||||
|
RtpSessionActivity.EXTRA_LAST_ACTION,
|
||||||
|
RtpSessionActivity.ACTION_MAKE_VIDEO_CALL);
|
||||||
}
|
}
|
||||||
callIntegration = proposal.getCallIntegration();
|
callIntegration = proposal.getCallIntegration();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -467,8 +467,7 @@ public class RtpSessionActivity extends XmppActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putProximityWakeLockInProperState(
|
private void putProximityWakeLockInProperState(final CallIntegration.AudioDevice audioDevice) {
|
||||||
final CallIntegration.AudioDevice audioDevice) {
|
|
||||||
if (audioDevice == CallIntegration.AudioDevice.EARPIECE) {
|
if (audioDevice == CallIntegration.AudioDevice.EARPIECE) {
|
||||||
acquireProximityWakeLock();
|
acquireProximityWakeLock();
|
||||||
} else {
|
} else {
|
||||||
|
@ -583,7 +582,8 @@ public class RtpSessionActivity extends XmppActivity
|
||||||
.getJingleConnectionManager()
|
.getJingleConnectionManager()
|
||||||
.proposeJingleRtpSession(account, with, media);
|
.proposeJingleRtpSession(account, with, media);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("We should not be initializing direct calls from the RtpSessionActivity. Go through CallIntegrationConnectionService.placeCall instead!");
|
throw new IllegalStateException(
|
||||||
|
"We should not be initializing direct calls from the RtpSessionActivity. Go through CallIntegrationConnectionService.placeCall instead!");
|
||||||
}
|
}
|
||||||
putScreenInCallMode(media);
|
putScreenInCallMode(media);
|
||||||
}
|
}
|
||||||
|
@ -1312,7 +1312,7 @@ public class RtpSessionActivity extends XmppActivity
|
||||||
final Set<Media> media = actionToMedia(lastAction == null ? action : lastAction);
|
final Set<Media> media = actionToMedia(lastAction == null ? action : lastAction);
|
||||||
this.rtpConnectionReference = null;
|
this.rtpConnectionReference = null;
|
||||||
Log.d(Config.LOGTAG, "attempting retry with " + with.toEscapedString());
|
Log.d(Config.LOGTAG, "attempting retry with " + with.toEscapedString());
|
||||||
CallIntegrationConnectionService.placeCall(this,account,with,media);
|
CallIntegrationConnectionService.placeCall(this, account, with, media);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exit(final View view) {
|
private void exit(final View view) {
|
||||||
|
|
|
@ -636,17 +636,16 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean fireJingleRtpConnectionStateUpdates() {
|
public boolean fireJingleRtpConnectionStateUpdates() {
|
||||||
boolean firedUpdates = false;
|
|
||||||
for (final AbstractJingleConnection connection : this.connections.values()) {
|
for (final AbstractJingleConnection connection : this.connections.values()) {
|
||||||
if (connection instanceof JingleRtpConnection jingleRtpConnection) {
|
if (connection instanceof JingleRtpConnection jingleRtpConnection) {
|
||||||
if (jingleRtpConnection.isTerminated()) {
|
if (jingleRtpConnection.isTerminated()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
jingleRtpConnection.fireStateUpdate();
|
jingleRtpConnection.fireStateUpdate();
|
||||||
firedUpdates = true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return firedUpdates;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retractSessionProposal(final Account account, final Jid with) {
|
public void retractSessionProposal(final Account account, final Jid with) {
|
||||||
|
@ -745,8 +744,16 @@ public class JingleConnectionManager extends AbstractConnectionManager {
|
||||||
synchronized (this.rtpSessionProposals) {
|
synchronized (this.rtpSessionProposals) {
|
||||||
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry :
|
for (Map.Entry<RtpSessionProposal, DeviceDiscoveryState> entry :
|
||||||
this.rtpSessionProposals.entrySet()) {
|
this.rtpSessionProposals.entrySet()) {
|
||||||
|
final var state = entry.getValue();
|
||||||
final RtpSessionProposal proposal = entry.getKey();
|
final RtpSessionProposal proposal = entry.getKey();
|
||||||
if (proposal.account == account && with.asBareJid().equals(proposal.with)) {
|
if (proposal.account == account && with.asBareJid().equals(proposal.with)) {
|
||||||
|
// CallIntegrationConnectionService starts RtpSessionActivity with ACTION_VIEW
|
||||||
|
// and an EXTRA_LAST_REPORTED_STATE of DISCOVERING devices. however due to
|
||||||
|
// possible race conditions the state might have already moved on so we are going
|
||||||
|
// to update the UI
|
||||||
|
final RtpEndUserState endUserState = state.toEndUserState();
|
||||||
|
mXmppConnectionService.notifyJingleRtpConnectionUpdate(
|
||||||
|
account, proposal.with, proposal.sessionId, endUserState);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue