Fix NPE when answering a call that has already gone away

This commit is contained in:
Stephen Paul Weber 2022-03-22 09:14:52 -05:00
parent 4d011016db
commit 38450896d1
No known key found for this signature in database
GPG Key ID: D11C2911CE519CDE
1 changed files with 17 additions and 6 deletions

View File

@ -220,7 +220,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
if (sessionId == null || !sessionId.equals(this.sessionId)) return;
if (rtpConnection == null) {
this.with = with; // Store full JID of connection
rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
findRtpConnection();
}
setStatusHints(new StatusHints(null, gatewayIcon, null));
@ -269,15 +269,20 @@ public class ConnectionService extends android.telecom.ConnectionService {
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);
rtpConnection.get().acceptCall();
findRtpConnection();
if (rtpConnection == null || rtpConnection.get() == null) {
close(new DisconnectCause(DisconnectCause.CANCELED));
} else {
rtpConnection.get().acceptCall();
}
}
@Override
public void onReject() {
this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
rtpConnection.get().rejectCall();
findRtpConnection();
if (rtpConnection != null && rtpConnection.get() != null) {
rtpConnection.get().rejectCall();
}
close(new DisconnectCause(DisconnectCause.LOCAL));
}
@ -316,6 +321,12 @@ public class ConnectionService extends android.telecom.ConnectionService {
if (c) postDial();
}
protected void findRtpConnection() {
if (rtpConnection != null) return;
rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
}
protected void sleep(int ms) {
try {
Thread.sleep(ms);