- baresip service now lets main activity to die on its own after

receiving kill intent from it
- small logging edits
This commit is contained in:
Juha Heinanen
2019-02-26 03:37:07 +02:00
parent c0b75a16c6
commit 5c476efea6
3 changed files with 11 additions and 4 deletions
@@ -179,12 +179,15 @@ class BaresipService: Service() {
}
"Stop", "Stop Force" -> {
if (action == "Stop") cleanService()
if (!isServiceClean) cleanService()
if (isServiceRunning) baresipStop(action == "Stop Force")
}
"Kill" -> {
stopped()
if (!isServiceClean) cleanService()
isServiceRunning = false
stopForeground(true)
stopSelf()
}
}
@@ -508,7 +511,7 @@ class BaresipService: Service() {
@Keep
fun stopped() {
Log.d(LOG_TAG, "'stopped' from baresip or 'Kill' from MainActivity")
Log.d(LOG_TAG, "'stopped' from baresip")
isServiceRunning = false
val intent = Intent("service event")
intent.putExtra("event", "stopped")
@@ -618,6 +621,7 @@ class BaresipService: Service() {
if (this::nm.isInitialized) nm.cancelAll()
if (this::wl.isInitialized && wl.isHeld) wl.release()
if (this::fl.isInitialized && fl.isHeld) fl.release()
isServiceClean = true
}
external fun baresipStart(path: String)
@@ -635,6 +639,7 @@ class BaresipService: Service() {
var isServiceRunning = false
var disconnected = false
var libraryLoaded = false
var isServiceClean = false
var uas = ArrayList<UserAgent>()
var status = ArrayList<Int>()
@@ -110,6 +110,8 @@ class MainActivity : AppCompatActivity() {
"force" -> {
baresipService.setAction("Kill");
startService(baresipService)
finishAndRemoveTask()
System.exit(0)
}
}
}