Compare commits

..

6 commits

Author SHA1 Message Date
Peter Cai 437002d189 ConnectionService: handle disconnected state correctly
onDisconnect() will only be called when the user manually requests a
disconnect. When the call is disconnected by the rtp connection itself,
the call won't be cleaned up and the system will be stuck in an in-call
state. Handle this correctly by moving the clean-up code to a close()
function, and calling that function instead when we disconnect.

Note that we cannot call the cleanup routine destroy() from the
onStateChanged() function, because it seems that this triggers a
deadlock somewhere down the line, probably in the calling
account-related telephony code. Doing a close() function mirrors what is
done in the default TelephonyConnection implementation for RIL-based
calls.
2022-03-12 23:29:14 -05:00
Peter Cai d8d49e03a0 ConnectionService: implement onReject()
Forgot this for incoming calls
2022-03-12 13:08:42 -05:00
Peter Cai 6ca2ffd6ea ConnectionService: miscellaneous fixes
* Fix a few potential errors due to the use of newer APIs (minSDK is
  still only 24)
* Fix one remaining case of raw usage of generic types.
2022-03-12 12:50:29 -05:00
Peter Cai 788818fdda ConnectionService: Dialer UI integration for incoming calls
For incoming calls, we fall back to the built-in call UI if the
microphone permission is not granted. The reason is that if the Dialer
UI is displayed over keyguard, then the user may not even be able to see
the notification that we show in order for them to grant the permission.
Having a small annoyance for the first incoming call is better than
having the in-call UI hang.
2022-03-12 12:50:29 -05:00
Peter Cai b218b57c94 ConnectionService: fix unchecked type assignments 2022-03-12 12:50:29 -05:00
Stephen Paul Weber e02dee8c01
Bad number can also cause IllegalArgumentException 2022-03-11 23:00:49 -05:00
2 changed files with 24 additions and 11 deletions

View file

@ -136,7 +136,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
@Override
public void onPermissionDenied(DeniedPermissions deniedPermissions) {
connection.setDisconnected(new DisconnectCause(DisconnectCause.ERROR));
connection.close(new DisconnectCause(DisconnectCause.ERROR));
}
});
@ -237,13 +237,13 @@ public class ConnectionService extends android.telecom.ConnectionService {
postDial();
} else if (state == RtpEndUserState.DECLINED_OR_BUSY) {
setDisconnected(new DisconnectCause(DisconnectCause.BUSY));
close(new DisconnectCause(DisconnectCause.BUSY));
} else if (state == RtpEndUserState.ENDED) {
setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
close(new DisconnectCause(DisconnectCause.LOCAL));
} else if (state == RtpEndUserState.RETRACTED) {
setDisconnected(new DisconnectCause(DisconnectCause.CANCELED));
close(new DisconnectCause(DisconnectCause.CANCELED));
} else if (RtpSessionActivity.END_CARD.contains(state)) {
setDisconnected(new DisconnectCause(DisconnectCause.ERROR));
close(new DisconnectCause(DisconnectCause.ERROR));
}
}
@ -274,18 +274,31 @@ public class ConnectionService extends android.telecom.ConnectionService {
rtpConnection.get().acceptCall();
}
@Override
public void onReject() {
this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
rtpConnection.get().rejectCall();
close(new DisconnectCause(DisconnectCause.LOCAL));
}
// Set the connection to the disconnected state and clean up the resources
// Note that we cannot do this from onStateChanged() because calling destroy
// there seems to trigger a deadlock somewhere in the telephony stack.
public void close(DisconnectCause reason) {
setDisconnected(reason);
destroy();
xmppConnectionService.setDiallerIntegrationActive(false);
xmppConnectionService.removeRtpConnectionUpdateListener(this);
}
@Override
public void onDisconnect() {
if (rtpConnection == null || rtpConnection.get() == null) {
xmppConnectionService.getJingleConnectionManager().retractSessionProposal(account, with.asBareJid());
close(new DisconnectCause(DisconnectCause.LOCAL));
} else {
rtpConnection.get().endCall();
}
destroy();
xmppConnectionService.setDiallerIntegrationActive(false);
xmppConnectionService.removeRtpConnectionUpdateListener(
(XmppConnectionService.OnJingleRtpConnectionUpdate) this
);
}
@Override

View file

@ -276,7 +276,7 @@ public class EnterJidDialog extends DialogFragment implements OnBackendConnected
if (type != null && (type.equals("pstn") || type.equals("sms"))) {
try {
binding.jid.setText(PhoneNumberUtilWrapper.normalize(getActivity(), binding.jid.getText().toString()));
} catch (NumberParseException | NullPointerException e) { }
} catch (NumberParseException | IllegalArgumentException | NullPointerException e) { }
}
if (p == null) {