Make sure Core exists when TelecomManager service is created & destroyed

This commit is contained in:
Sylvain Berfini 2022-05-27 11:47:39 +02:00
parent 90c7528540
commit 8d5d344c2c

View file

@ -23,7 +23,9 @@ import android.content.ComponentName
import android.content.Intent
import android.net.Uri
import android.telecom.*
import org.linphone.LinphoneApplication
import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.ensureCoreExists
import org.linphone.core.Call
import org.linphone.core.Core
import org.linphone.core.CoreListenerStub
@ -70,12 +72,15 @@ class TelecomConnectionService : ConnectionService() {
super.onCreate()
Log.i("[Telecom Connection Service] onCreate()")
ensureCoreExists(applicationContext)
coreContext.core.addListener(listener)
}
override fun onUnbind(intent: Intent?): Boolean {
Log.i("[Telecom Connection Service] onUnbind()")
coreContext.core.removeListener(listener)
if (LinphoneApplication.contextExists()) {
Log.i("[Telecom Connection Service] onUnbind()")
coreContext.core.removeListener(listener)
}
return super.onUnbind(intent)
}