Skip to content

Commit

Permalink
fix: removed starting service manually
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremynorman89 committed Sep 5, 2024
1 parent 4c1c45c commit b0f407f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ internal class NotificationButtonReceiver : BroadcastReceiver() {

pil.notifications.dismissStale()

// We need to start the VoIP service here, or we don't have access to the microphone.
// See: https://developer.android.com/guide/components/foreground-services#bg-access-restriction-exemptions
context.startService(Intent(context, VoIPService::class.java))

try {
val action = valueOf(intent.action ?: "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.os.Build
import android.os.Handler
import android.os.Looper
import android.os.PowerManager
import org.linphone.core.tools.Log
import org.linphone.core.tools.service.CoreService
import org.openvoipalliance.androidphoneintegration.PIL
import org.openvoipalliance.androidphoneintegration.call.CallDirection
Expand Down Expand Up @@ -62,7 +63,12 @@ internal class VoIPService : CoreService(), PILEventListener {
FOREGROUND_SERVICE_TYPE_PHONE_CALL
}

startForeground(id, notification, types)
try {
startForeground(id, notification, types)
} catch (e: Exception) {
pil.writeLog("Can't start service as foreground! $e")
}

} else {
startForeground(id, notification)
}
Expand Down

0 comments on commit b0f407f

Please sign in to comment.