onHold and onUnhold functions won't get triggered when I receive a GSM call and pick it up while I'm on an active call through my app. onDisconnect callback gets triggered when I answer the GSM call. Am I missing something in my implementation?
So, I've integrated the telecom subsystem into my app. I've also set the capabilities for the connection and included CAPABILITY_SUPPORT_HOLD, like shown below,
class VoiceConnectionService : ConnectionService() {
var activeConnection: Connection? = null
override fun onCreateIncomingConnection(
connectionManagerPhoneAccount: PhoneAccountHandle,
request: ConnectionRequest
): Connection? {
val incomingCallConnection = createConnection(request)
incomingCallConnection?.setRinging()
return incomingCallConnection
}
private fun createConnection(request: ConnectionRequest): Connection? {
activeConnection = TelecomConnection()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
(activeConnection as TelecomTwilioConnection).connectionProperties = Connection.PROPERTY_SELF_MANAGED
}
(activeConnection as TelecomTwilioConnection).connectionCapabilities = Connection.CAPABILITY_MUTE
(activeConnection as TelecomTwilioConnection).connectionCapabilities = Connection.CAPABILITY_SUPPORT_HOLD
return activeConnection
}
}
But the callback functions in TelecomConnection class won't get triggered when I'm on an active call through this app and then I receive a GSM call and if I answer it, onHold and onUnhold won't get called.
class TelecomConnection : Connection() {
override onHold() { }
override onUnhold() { }
}
<service android:name=".twilio.telecom.VoiceConnectionService"
android:label="VoiceConnectionService"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
android:exported="false">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>
I was able to get it working by adding the capabilities in the following way,