Compare commits

..

3 commits

Author SHA1 Message Date
5e8d51db9f 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-11 22:44:21 -05:00
faab2d5799 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-11 22:44:17 -05:00
b7b2bb0cdd ConnectionService: fix unchecked type assignments 2022-03-11 21:44:57 -05:00
2 changed files with 11 additions and 24 deletions

View file

@ -136,7 +136,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
@Override @Override
public void onPermissionDenied(DeniedPermissions deniedPermissions) { public void onPermissionDenied(DeniedPermissions deniedPermissions) {
connection.close(new DisconnectCause(DisconnectCause.ERROR)); connection.setDisconnected(new DisconnectCause(DisconnectCause.ERROR));
} }
}); });
@ -237,13 +237,13 @@ public class ConnectionService extends android.telecom.ConnectionService {
postDial(); postDial();
} else if (state == RtpEndUserState.DECLINED_OR_BUSY) { } else if (state == RtpEndUserState.DECLINED_OR_BUSY) {
close(new DisconnectCause(DisconnectCause.BUSY)); setDisconnected(new DisconnectCause(DisconnectCause.BUSY));
} else if (state == RtpEndUserState.ENDED) { } else if (state == RtpEndUserState.ENDED) {
close(new DisconnectCause(DisconnectCause.LOCAL)); setDisconnected(new DisconnectCause(DisconnectCause.LOCAL));
} else if (state == RtpEndUserState.RETRACTED) { } else if (state == RtpEndUserState.RETRACTED) {
close(new DisconnectCause(DisconnectCause.CANCELED)); setDisconnected(new DisconnectCause(DisconnectCause.CANCELED));
} else if (RtpSessionActivity.END_CARD.contains(state)) { } else if (RtpSessionActivity.END_CARD.contains(state)) {
close(new DisconnectCause(DisconnectCause.ERROR)); setDisconnected(new DisconnectCause(DisconnectCause.ERROR));
} }
} }
@ -274,31 +274,18 @@ public class ConnectionService extends android.telecom.ConnectionService {
rtpConnection.get().acceptCall(); 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 @Override
public void onDisconnect() { public void onDisconnect() {
if (rtpConnection == null || rtpConnection.get() == null) { if (rtpConnection == null || rtpConnection.get() == null) {
xmppConnectionService.getJingleConnectionManager().retractSessionProposal(account, with.asBareJid()); xmppConnectionService.getJingleConnectionManager().retractSessionProposal(account, with.asBareJid());
close(new DisconnectCause(DisconnectCause.LOCAL));
} else { } else {
rtpConnection.get().endCall(); rtpConnection.get().endCall();
} }
destroy();
xmppConnectionService.setDiallerIntegrationActive(false);
xmppConnectionService.removeRtpConnectionUpdateListener(
(XmppConnectionService.OnJingleRtpConnectionUpdate) this
);
} }
@Override @Override

View file

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