I'm developing a liblinphone app for android and am
having trouble interacting with incoming cell calls while the
app is on a call. When an incoming cell call comes in while the
app is in an active call and I choose 'Answer', android puts my
app's call on hold and answers the cell call.
Fine so far, but there's no audio in the cell call. If I
put the cell call on hold and resume it, the audio works.
This is true for vice versa too -- on a cell call and
incoming app call. Answering the app call puts the cell call
on hold, but no audio in the answered app call. Putting the
app call on hold and resuming fixes the audio.
These scenarios work properly:
- Place outgoing cell call while on app call
- Place outgoing app call while on cell call
Any idea what I'm doing wrong?
Here's some code:
Core initialization:
fun initLinphone(appContext: Context) {
this.appContext = appContext
initAndroidAccount()
val config = factory.createConfigFromString(linphoneConfig)
lcore = factory.createCoreWithConfig(config, appContext)
coreVersion = lcore.version
lcore.addListener(this)
uoLog("CoreContext.initLinphone: starting liblinphone core, version $coreVersion")
lcore.start()
login()
}
fun initAndroidAccount() {
uoLog("CoreContext.initAndroidAccount: connection service class name: ${UOConnectionService::class.java.name}")
val compName = ComponentName(appContext, UOConnectionService::class.java.name)
phoneAccountHandle = PhoneAccountHandle(compName, "UOPhone")
val builder = PhoneAccount.builder(phoneAccountHandle, "UOPhone")
builder.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
phoneAccount = builder.build()
telecomManager = appContext.getSystemService(Context.TELECOM_SERVICE) as TelecomManager
telecomManager.registerPhoneAccount(phoneAccount)
}
fun login() {
if (UOSettings.tcn == "") return
uoLog("CoreContext.login: Registering...")
domain = "${UOSettings.tcn}-proxy.uotcn.net:5090"
val authInfo = factory.createAuthInfo(UOSettings.deviceid, null, UOSettings.secret, null, null, domain, null)
val accountParams = lcore.createAccountParams()
val identity = factory.createAddress("sip:${UOSettings.deviceid}@${domain}")
accountParams.setIdentityAddress(identity)
val address = factory.createAddress("sip:${domain}")
address?.setTransport(TransportType.Udp)
accountParams.setServerAddress(address)
accountParams.pushNotificationAllowed = true
accountParams.isRegisterEnabled = true
val account = lcore.createAccount(accountParams)
lcore.addAuthInfo(authInfo)
lcore.addAccount(account)
lcore.defaultAccount = account
lcore.setUserAgent("Unified Office UOPhone Android", BuildConfig.VERSION_NAME)
}