mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Do not use CoreService as it will attempt to use the Core on the main thread, TODO : disable activity monitor in SDK
This commit is contained in:
parent
ca080b2dcc
commit
3d5ca3313b
6 changed files with 30 additions and 18 deletions
|
|
@ -76,7 +76,7 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
state: Call.State?,
|
||||
message: String
|
||||
) {
|
||||
Log.i("$TAG Call state changed [$state]")
|
||||
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
|
||||
when (state) {
|
||||
Call.State.OutgoingProgress, Call.State.Connected -> {
|
||||
postOnMainThread {
|
||||
|
|
|
|||
|
|
@ -19,12 +19,15 @@
|
|||
*/
|
||||
package org.linphone.core
|
||||
|
||||
import android.app.Service
|
||||
import android.content.Intent
|
||||
import android.os.IBinder
|
||||
import androidx.annotation.MainThread
|
||||
import org.linphone.LinphoneApplication.Companion.coreContext
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.core.tools.service.CoreService
|
||||
|
||||
class CoreForegroundService : CoreService() {
|
||||
@MainThread
|
||||
class CoreForegroundService : Service() {
|
||||
companion object {
|
||||
private const val TAG = "[Core Foreground Service]"
|
||||
}
|
||||
|
|
@ -42,18 +45,6 @@ class CoreForegroundService : CoreService() {
|
|||
return super.onStartCommand(intent, flags, startId)
|
||||
}
|
||||
|
||||
override fun createServiceNotificationChannel() {
|
||||
// Done elsewhere
|
||||
}
|
||||
|
||||
override fun showForegroundServiceNotification() {
|
||||
// Done elsewhere
|
||||
}
|
||||
|
||||
override fun hideForegroundServiceNotification() {
|
||||
// Done elsewhere
|
||||
}
|
||||
|
||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||
Log.i("$TAG Task removed, doing nothing")
|
||||
|
||||
|
|
@ -66,4 +57,8 @@ class CoreForegroundService : CoreService() {
|
|||
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onBind(p0: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,12 +117,22 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
fun onServiceStarted(service: CoreForegroundService) {
|
||||
Log.i("$TAG Service has been started")
|
||||
coreService = service
|
||||
startCallForeground()
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
if (core.callsNb == 0) {
|
||||
Log.w("$TAG No call anymore, stopping service")
|
||||
stopCallForeground()
|
||||
} else {
|
||||
startCallForeground()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
fun onServiceDestroyed() {
|
||||
Log.i("$TAG Service has been destroyed")
|
||||
coreService = null
|
||||
|
|
@ -355,6 +365,7 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
return builder.build()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun dismissCallNotification(call: Call) {
|
||||
val address = call.remoteAddress.asStringUriOnly()
|
||||
val notifiable: Notifiable? = callNotificationsMap[address]
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class TelecomCallControlCallback constructor(
|
|||
|
||||
private val callListener = object : CallListenerStub() {
|
||||
override fun onStateChanged(call: Call, state: Call.State?, message: String) {
|
||||
Log.i("$TAG Call state changed [$state]")
|
||||
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
|
||||
if (state == Call.State.Connected) {
|
||||
if (call.dir == Call.Dir.Incoming) {
|
||||
scope.launch {
|
||||
|
|
@ -137,7 +137,9 @@ class TelecomCallControlCallback constructor(
|
|||
|
||||
callControl.isMuted.onEach { muted ->
|
||||
Log.i("$TAG We're asked to ${if (muted) "mute" else "unmute"} the call")
|
||||
call.microphoneMuted = muted
|
||||
coreContext.postOnCoreThread {
|
||||
call.microphoneMuted = muted
|
||||
}
|
||||
}.launchIn(scope)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,9 @@ class CallsViewModel @UiThread constructor() : ViewModel() {
|
|||
message: String
|
||||
) {
|
||||
if (call == core.currentCall || core.currentCall == null) {
|
||||
Log.i(
|
||||
"$TAG Current call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]"
|
||||
)
|
||||
when (call.state) {
|
||||
Call.State.Connected -> {
|
||||
goToActiveCallEvent.postValue(Event(true))
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
if (CurrentCallViewModel@call != call) {
|
||||
return
|
||||
}
|
||||
Log.i("$TAG Call [${call.remoteAddress.asStringUriOnly()}] state changed [$state]")
|
||||
|
||||
if (LinphoneUtils.isCallOutgoing(call.state)) {
|
||||
isVideoEnabled.postValue(call.params.isVideoEnabled)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue