Fix NPE when answering a call that has already gone away
This commit is contained in:
parent
4d011016db
commit
38450896d1
|
@ -220,7 +220,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
||||||
if (sessionId == null || !sessionId.equals(this.sessionId)) return;
|
if (sessionId == null || !sessionId.equals(this.sessionId)) return;
|
||||||
if (rtpConnection == null) {
|
if (rtpConnection == null) {
|
||||||
this.with = with; // Store full JID of connection
|
this.with = with; // Store full JID of connection
|
||||||
rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
|
findRtpConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatusHints(new StatusHints(null, gatewayIcon, null));
|
setStatusHints(new StatusHints(null, gatewayIcon, null));
|
||||||
|
@ -269,15 +269,20 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
||||||
public void onAnswer() {
|
public void onAnswer() {
|
||||||
// For incoming calls, a connection update may not have been triggered before answering
|
// For incoming calls, a connection update may not have been triggered before answering
|
||||||
// so we have to acquire the rtp connection object here
|
// so we have to acquire the rtp connection object here
|
||||||
this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
|
findRtpConnection();
|
||||||
|
if (rtpConnection == null || rtpConnection.get() == null) {
|
||||||
rtpConnection.get().acceptCall();
|
close(new DisconnectCause(DisconnectCause.CANCELED));
|
||||||
|
} else {
|
||||||
|
rtpConnection.get().acceptCall();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReject() {
|
public void onReject() {
|
||||||
this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
|
findRtpConnection();
|
||||||
rtpConnection.get().rejectCall();
|
if (rtpConnection != null && rtpConnection.get() != null) {
|
||||||
|
rtpConnection.get().rejectCall();
|
||||||
|
}
|
||||||
close(new DisconnectCause(DisconnectCause.LOCAL));
|
close(new DisconnectCause(DisconnectCause.LOCAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +321,12 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
||||||
if (c) postDial();
|
if (c) postDial();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void findRtpConnection() {
|
||||||
|
if (rtpConnection != null) return;
|
||||||
|
|
||||||
|
rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
protected void sleep(int ms) {
|
protected void sleep(int ms) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(ms);
|
Thread.sleep(ms);
|
||||||
|
|
Loading…
Reference in a new issue