ConnectionService: handle disconnection correctly
onDisconnect() is only called when the user *requests* to hang up. If the state is changed by setDisconnected(), then only onStateChanged() will be called. Handle this correctly, otherwise the connection state could be inconsistent (e.g. call is ended by the other side but the Connection object is still around)
This commit is contained in:
parent
5e39d45d9a
commit
259b0e69ad
|
@ -290,6 +290,17 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChanged(int state) {
|
||||
if (state == STATE_DISCONNECTED) {
|
||||
mHandler.post(() -> {
|
||||
destroy();
|
||||
xmppConnectionService.setDiallerIntegrationActive(false);
|
||||
xmppConnectionService.removeRtpConnectionUpdateListener(this);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
mHandler.post(() -> {
|
||||
|
@ -298,11 +309,8 @@ public class ConnectionService extends android.telecom.ConnectionService {
|
|||
} else {
|
||||
rtpConnection.get().endCall();
|
||||
}
|
||||
destroy();
|
||||
xmppConnectionService.setDiallerIntegrationActive(false);
|
||||
xmppConnectionService.removeRtpConnectionUpdateListener(
|
||||
(XmppConnectionService.OnJingleRtpConnectionUpdate) this
|
||||
);
|
||||
|
||||
setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue