- 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:
@ -465,7 +465,7 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
|
||||
stopped:
|
||||
|
||||
LOGD("tell app about baresip stop");
|
||||
LOGD("tell main that baresip has stopped");
|
||||
jmethodID stoppedId = (*env)->GetMethodID(env, pctx->mainActivityClz, "stopped", "()V");
|
||||
(*env)->CallVoidMethod(env, pctx->mainActivityObj, stoppedId);
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user