It seems that annotating the lambda makes the thread check works

This commit is contained in:
Sylvain Berfini 2023-10-27 17:50:24 +02:00
parent 61bd3978a4
commit 325feb5637
3 changed files with 9 additions and 2 deletions

View file

@ -214,14 +214,18 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
}
@AnyThread
fun postOnCoreThread(lambda: (core: Core) -> Unit) {
fun postOnCoreThread(
@WorkerThread lambda: (core: Core) -> Unit
) {
coreThread.post {
lambda.invoke(core)
}
}
@AnyThread
fun postOnMainThread(lambda: () -> Unit) {
fun postOnMainThread(
@UiThread lambda: () -> Unit
) {
mainThread.post {
lambda.invoke()
}

View file

@ -20,6 +20,7 @@
package org.linphone.telecom
import android.telecom.DisconnectCause
import androidx.annotation.WorkerThread
import androidx.core.telecom.CallAttributesCompat
import androidx.core.telecom.CallControlResult
import androidx.core.telecom.CallControlScope
@ -48,6 +49,7 @@ class TelecomCallControlCallback constructor(
private var availableEndpoints: List<CallEndpointCompat> = arrayListOf()
private val callListener = object : CallListenerStub() {
@WorkerThread
override fun onStateChanged(call: Call, state: Call.State?, message: String) {
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
if (state == Call.State.Connected) {

View file

@ -47,6 +47,7 @@ class CallModel @WorkerThread constructor(val call: Call) {
val contact = MutableLiveData<ContactAvatarModel>()
private val callListener = object : CallListenerStub() {
@WorkerThread
override fun onStateChanged(call: Call, state: Call.State, message: String) {
this@CallModel.state.postValue(LinphoneUtils.callStateToString(state))
isPaused.postValue(LinphoneUtils.isCallPaused(state))