Prevent starting of baresip service more than once
This commit is contained in:
@@ -363,6 +363,8 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
"Start" -> {
|
"Start" -> {
|
||||||
|
|
||||||
|
isStartReceived = true
|
||||||
|
|
||||||
if (VERSION.SDK_INT < 31) {
|
if (VERSION.SDK_INT < 31) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
allNetworks = cm.allNetworks.toMutableSet()
|
allNetworks = cm.allNetworks.toMutableSet()
|
||||||
@@ -1476,6 +1478,7 @@ class BaresipService: Service() {
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
var isServiceRunning = false
|
var isServiceRunning = false
|
||||||
|
var isStartReceived = false
|
||||||
var isConfigInitialized = false
|
var isConfigInitialized = false
|
||||||
var libraryLoaded = false
|
var libraryLoaded = false
|
||||||
var callVolume = 0
|
var callVolume = 0
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val event = it.getContentIfNotHandled()
|
val event = it.getContentIfNotHandled()
|
||||||
Log.d(TAG, "Observed event $event")
|
Log.d(TAG, "Observed event $event")
|
||||||
if (event != null && BaresipService.serviceEvents.isNotEmpty()) {
|
if (event != null && BaresipService.serviceEvents.isNotEmpty()) {
|
||||||
val first = BaresipService.serviceEvents.first()
|
val first = BaresipService.serviceEvents.removeFirst()
|
||||||
handleServiceEvent(first.event, first.params)
|
handleServiceEvent(first.event, first.params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -989,11 +989,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
if (logMessage != null)
|
if (logMessage != null)
|
||||||
Log.w(TAG, logMessage)
|
Log.w(TAG, logMessage)
|
||||||
if (BaresipService.serviceEvents.isNotEmpty()) {
|
if (BaresipService.serviceEvents.isNotEmpty()) {
|
||||||
BaresipService.serviceEvents.removeFirst()
|
val first = BaresipService.serviceEvents.removeFirst()
|
||||||
if (BaresipService.serviceEvents.isNotEmpty()) {
|
handleServiceEvent(first.event, first.params)
|
||||||
val e = BaresipService.serviceEvents.first()
|
|
||||||
handleServiceEvent(e.event, e.params)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1679,10 +1676,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun startBaresip() {
|
private fun startBaresip() {
|
||||||
baresipService.action = "Start"
|
if (!BaresipService.isStartReceived) {
|
||||||
startService(baresipService)
|
baresipService.action = "Start"
|
||||||
if (atStartup)
|
startService(baresipService)
|
||||||
moveTaskToBack(true)
|
if (atStartup)
|
||||||
|
moveTaskToBack(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun backup(password: String) {
|
private fun backup(password: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user