Passing through initializing -> inititalized -> dialling more stable

Stephen Paul Weber created

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.

Change summary

src/cheogram/java/com/cheogram/android/ConnectionService.java | 26 ++--
1 file changed, 15 insertions(+), 11 deletions(-)

Detailed changes

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();