diff --git a/app/src/main/kotlin/com/tutpro/baresip/InCallService.kt b/app/src/main/kotlin/com/tutpro/baresip/InCallService.kt index 19199d0f..40970583 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/InCallService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/InCallService.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.os.IBinder import android.telecom.Call import android.telecom.InCallService +import java.lang.ref.WeakReference class InCallService : InCallService() { @@ -21,8 +22,7 @@ class InCallService : InCallService() { if (handle == baresipHandle) { Log.d(TAG, "InCallService: Identified as SIP call") - // The SIP call is already managed by ConnectionService/BaresipService. - // We just need to ensure the InCallService stays bound. + // SIP call is already managed by ConnectionService/BaresipService } else { Log.d(TAG, "InCallService: Identified as PSTN call from $handle") val aor = call.details.intentExtras?.getString("aor") @@ -43,6 +43,11 @@ class InCallService : InCallService() { companion object { private const val TAG = "Baresip" - var instance: InCallService? = null + private var _instance = WeakReference(null) + var instance: InCallService? + get() = _instance.get() + set(value) { + _instance = WeakReference(value) + } } }