ConnectionService: initialize rtpConnection for incoming calls
Removes the need for repetitve findJingleRtpConnection() calls for onAnswer() and onReject()
This commit is contained in:
parent
1f2420b38b
commit
a50b50938e
|
@ -117,7 +117,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
|
||||
Account account = xmppConnectionService.findAccountByJid(Jid.of(gateway[0]));
|
||||
Jid with = Jid.ofLocalAndDomain(tel, gateway[1]);
|
||||
CheogramConnection connection = new CheogramConnection(account, with, postDial);
|
||||
CheogramConnection connection = new CheogramConnection(account, with, postDial, null);
|
||||
|
||||
PermissionManager permissionManager = PermissionManager.getInstance(this);
|
||||
permissionManager.setNotificationSettings(
|
||||
|
@ -167,7 +167,10 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
Account account = xmppConnectionService.findAccountByJid(Jid.of(accountJid));
|
||||
Jid with = Jid.of(withJid);
|
||||
|
||||
CheogramConnection connection = new CheogramConnection(account, with, null);
|
||||
CheogramConnection connection = new CheogramConnection(
|
||||
account, with, null,
|
||||
xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId)
|
||||
);
|
||||
connection.setSessionId(sessionId);
|
||||
connection.setAddress(
|
||||
Uri.fromParts("tel", with.getLocal(), null),
|
||||
|
@ -186,12 +189,13 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
protected String sessionId = null;
|
||||
protected Stack<String> postDial = new Stack<>();
|
||||
protected Icon gatewayIcon;
|
||||
protected WeakReference<JingleRtpConnection> rtpConnection = null;
|
||||
protected WeakReference<JingleRtpConnection> rtpConnection;
|
||||
|
||||
CheogramConnection(Account account, Jid with, String postDialString) {
|
||||
CheogramConnection(Account account, Jid with, String postDialString, WeakReference<JingleRtpConnection> rtpConnection) {
|
||||
super();
|
||||
this.account = account;
|
||||
this.with = with;
|
||||
this.rtpConnection = rtpConnection;
|
||||
|
||||
gatewayIcon = Icon.createWithBitmap(xmppConnectionService.getAvatarService().get(
|
||||
account.getRoster().getContact(Jid.of(with.getDomain())),
|
||||
|
@ -271,10 +275,6 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
|
||||
@Override
|
||||
public void onAnswer() {
|
||||
// For incoming calls, a connection update may not have been triggered before answering
|
||||
// so we have to acquire the rtp connection object here
|
||||
this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
|
||||
|
||||
mHandler.post(() -> {
|
||||
rtpConnection.get().acceptCall();
|
||||
});
|
||||
|
@ -282,8 +282,6 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
|
||||
@Override
|
||||
public void onReject() {
|
||||
this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
|
||||
|
||||
mHandler.post(() -> {
|
||||
rtpConnection.get().rejectCall();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue