I`m trying to implement interconnection with telecom service with this guide: https://developer.android.com/guide/topics/connectivity/telecom/
I'm are already can show my own fullscreen incoming call UI without Telecom service, make and receive video calls. All, that I want to do with Telecomservice, is just tell Android OS, that our application is starting/stopping video call in particular moment, and receive call holded/unholded events from other calling apps.
The main problems are:
1) addNewIncomingCall in case of incoming call does nothing: onCreateIncomingConnection callback not fired (even onCreate callback of mine ConnectionService not fired at all). Why connection service is not started?
2) in case of outgoing call placeCall tries to open system calling app with our user id, call it as phone or SIP number. Can I use placeCall without system UI?
Or, if I just want to inform system about video call, I can use other option than TelecomService?
Connection created as follows:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
connection?.connectionProperties = Connection.PROPERTY_SELF_MANAGED
}
connection?.connectionCapabilities = Connection.CAPABILITY_HOLD and Connection.CAPABILITY_SUPPORT_HOLD
connection?.setVideoState(VideoProfile.STATE_BIDIRECTIONAL)
Placing call:
val telecomService = context.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
try {
val uri = Uri.fromParts(PhoneAccount.SCHEME_SIP, teacherInfo.name, null)
telecomService.placeCall(uri, Bundle.EMPTY)
} catch (e: Throwable) {
e.printStackTrace()
}
Receiving call:
val telecomService = applicationContext.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
try {
Log.d("VideoCOnnection", "addNewIncomingCall")
telecomService.addNewIncomingCall(CallUtils.getAccountConnection(telecomService), Bundle.EMPTY)
} catch (e: Throwable) {
Log.d("VideoCOnnection", "crash")
e.printStackTrace()
}
@SuppressLint("MissingPermission")
fun getAccountConnection(teleconManager: TelecomManager) : PhoneAccountHandle? {
return if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val enabledAccounts = teleconManager.callCapablePhoneAccounts
for(account in enabledAccounts) {
if(account.componentName.className.equals(BindTelecomService::class.java.canonicalName)) {
return account
}
}
return null
} else
null
}