From d375262dd8f224d849e06cd144a31e24e9cf5bed Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 23 Feb 2022 23:02:47 -0500 Subject: [PATCH 1/2] Passing through initializing -> inititalized -> dialling more stable Rather than starting right at dialling, which seemed to cause sometimes delays in the in call screen appearing and also a different behaviour when a post dial string was present, passing through all the states with some time in between seems to result in a more stable and consistent UX with no change to functionality. --- .../cheogram/android/ConnectionService.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/cheogram/java/com/cheogram/android/ConnectionService.java b/src/cheogram/java/com/cheogram/android/ConnectionService.java index a8208be048f0c0c7259e18608902f8ebab950c8f..82ad0f4c2cd48bb8019dd7a2ff9383dd3b4f272b 100644 --- a/src/cheogram/java/com/cheogram/android/ConnectionService.java +++ b/src/cheogram/java/com/cheogram/android/ConnectionService.java @@ -126,20 +126,11 @@ public class ConnectionService extends android.telecom.ConnectionService { } }); + connection.setInitializing(); connection.setAddress( Uri.fromParts("tel", tel, null), // Normalized tel as tel: URI TelecomManager.PRESENTATION_ALLOWED ); - connection.setCallerDisplayName( - account.getDisplayName(), - TelecomManager.PRESENTATION_ALLOWED - ); - connection.setAudioModeIsVoip(true); - connection.setRingbackRequested(true); - connection.setDialing(); - connection.setConnectionCapabilities( - Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION - ); xmppConnectionService.setOnRtpConnectionUpdateListener( (XmppConnectionService.OnJingleRtpConnectionUpdate) connection @@ -172,6 +163,15 @@ public class ConnectionService extends android.telecom.ConnectionService { postDial.push("" + postDialString.charAt(i)); } } + + setCallerDisplayName( + account.getDisplayName(), + TelecomManager.PRESENTATION_ALLOWED + ); + setAudioModeIsVoip(true); + setConnectionCapabilities( + Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION + ); } public void setSessionId(final String sessionId) { @@ -188,7 +188,11 @@ public class ConnectionService extends android.telecom.ConnectionService { setStatusHints(new StatusHints(null, gatewayIcon, null)); - if (state == RtpEndUserState.CONNECTED) { + if (state == RtpEndUserState.FINDING_DEVICE) { + setInitialized(); + } else if (state == RtpEndUserState.RINGING) { + setDialing(); + } else if (state == RtpEndUserState.CONNECTED) { xmppConnectionService.setDiallerIntegrationActive(true); setActive(); From 751206adc5ba97cf063c89aac3d3a273770817e8 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 23 Feb 2022 23:09:32 -0500 Subject: [PATCH 2/2] Unify phone number normalization with Quicksy Uses phone location and libphonenumber to normalize. --- .../com/cheogram/android/ConnectionService.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cheogram/java/com/cheogram/android/ConnectionService.java b/src/cheogram/java/com/cheogram/android/ConnectionService.java index 82ad0f4c2cd48bb8019dd7a2ff9383dd3b4f272b..57915a668215fbe4d76f55c0740308f51a10b9fb 100644 --- a/src/cheogram/java/com/cheogram/android/ConnectionService.java +++ b/src/cheogram/java/com/cheogram/android/ConnectionService.java @@ -34,6 +34,7 @@ import android.util.Log; import com.intentfilter.androidpermissions.PermissionManager; import com.intentfilter.androidpermissions.models.DeniedPermissions; +import io.michaelrocks.libphonenumber.android.NumberParseException; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.services.AppRTCAudioManager; @@ -41,6 +42,7 @@ import eu.siacs.conversations.services.AvatarService; import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.RtpSessionActivity; +import eu.siacs.conversations.utils.PhoneNumberUtilWrapper; import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection; import eu.siacs.conversations.xmpp.jingle.Media; @@ -89,12 +91,13 @@ public class ConnectionService extends android.telecom.ConnectionService { String rawTel = request.getAddress().getSchemeSpecificPart(); String postDial = PhoneNumberUtils.extractPostDialPortion(rawTel); - // TODO: jabber:iq:gateway String tel = PhoneNumberUtils.extractNetworkPortion(rawTel); - if (tel.startsWith("1")) { - tel = "+" + tel; - } else if (!tel.startsWith("+")) { - tel = "+1" + tel; + try { + tel = PhoneNumberUtilWrapper.normalize(this, tel); + } catch (NumberParseException e) { + return Connection.createFailedConnection( + new DisconnectCause(DisconnectCause.ERROR) + ); } if (xmppConnectionService.getJingleConnectionManager().isBusy() != null) {