- 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:
|
stopped:
|
||||||
|
|
||||||
LOGD("tell app about baresip stop");
|
LOGD("tell main that baresip has stopped");
|
||||||
jmethodID stoppedId = (*env)->GetMethodID(env, pctx->mainActivityClz, "stopped", "()V");
|
jmethodID stoppedId = (*env)->GetMethodID(env, pctx->mainActivityClz, "stopped", "()V");
|
||||||
(*env)->CallVoidMethod(env, pctx->mainActivityObj, stoppedId);
|
(*env)->CallVoidMethod(env, pctx->mainActivityObj, stoppedId);
|
||||||
|
|
||||||
|
|||||||
@@ -179,12 +179,15 @@ class BaresipService: Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"Stop", "Stop Force" -> {
|
"Stop", "Stop Force" -> {
|
||||||
if (action == "Stop") cleanService()
|
if (!isServiceClean) cleanService()
|
||||||
if (isServiceRunning) baresipStop(action == "Stop Force")
|
if (isServiceRunning) baresipStop(action == "Stop Force")
|
||||||
}
|
}
|
||||||
|
|
||||||
"Kill" -> {
|
"Kill" -> {
|
||||||
stopped()
|
if (!isServiceClean) cleanService()
|
||||||
|
isServiceRunning = false
|
||||||
|
stopForeground(true)
|
||||||
|
stopSelf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +511,7 @@ class BaresipService: Service() {
|
|||||||
|
|
||||||
@Keep
|
@Keep
|
||||||
fun stopped() {
|
fun stopped() {
|
||||||
Log.d(LOG_TAG, "'stopped' from baresip or 'Kill' from MainActivity")
|
Log.d(LOG_TAG, "'stopped' from baresip")
|
||||||
isServiceRunning = false
|
isServiceRunning = false
|
||||||
val intent = Intent("service event")
|
val intent = Intent("service event")
|
||||||
intent.putExtra("event", "stopped")
|
intent.putExtra("event", "stopped")
|
||||||
@@ -618,6 +621,7 @@ class BaresipService: Service() {
|
|||||||
if (this::nm.isInitialized) nm.cancelAll()
|
if (this::nm.isInitialized) nm.cancelAll()
|
||||||
if (this::wl.isInitialized && wl.isHeld) wl.release()
|
if (this::wl.isInitialized && wl.isHeld) wl.release()
|
||||||
if (this::fl.isInitialized && fl.isHeld) fl.release()
|
if (this::fl.isInitialized && fl.isHeld) fl.release()
|
||||||
|
isServiceClean = true
|
||||||
}
|
}
|
||||||
|
|
||||||
external fun baresipStart(path: String)
|
external fun baresipStart(path: String)
|
||||||
@@ -635,6 +639,7 @@ class BaresipService: Service() {
|
|||||||
var isServiceRunning = false
|
var isServiceRunning = false
|
||||||
var disconnected = false
|
var disconnected = false
|
||||||
var libraryLoaded = false
|
var libraryLoaded = false
|
||||||
|
var isServiceClean = false
|
||||||
|
|
||||||
var uas = ArrayList<UserAgent>()
|
var uas = ArrayList<UserAgent>()
|
||||||
var status = ArrayList<Int>()
|
var status = ArrayList<Int>()
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"force" -> {
|
"force" -> {
|
||||||
baresipService.setAction("Kill");
|
baresipService.setAction("Kill");
|
||||||
startService(baresipService)
|
startService(baresipService)
|
||||||
|
finishAndRemoveTask()
|
||||||
|
System.exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user