- Tried to improve baresip quit/restart process

This commit is contained in:
Juha Heinanen
2023-01-18 02:49:56 +02:00
parent abcf37dca2
commit 755b8edb51
2 changed files with 8 additions and 9 deletions

View File

@ -325,6 +325,7 @@ class BaresipService: Service() {
"force" -> {
cleanService()
isServiceRunning = false
postServiceEvent(ServiceEvent("stopped", arrayListOf(""), System.nanoTime()))
stopSelf()
// exitProcess(0)
}
@ -539,15 +540,9 @@ class BaresipService: Service() {
override fun onDestroy() {
super.onDestroy()
Log.d(TAG, "onDestroy at Baresip Service")
this.unregisterReceiver(bluetoothReceiver)
this.unregisterReceiver(hotSpotReceiver)
if (am.isBluetoothScoOn)
am.stopBluetoothSco()
cleanService()
if (isServiceRunning)
sendBroadcast(Intent("com.tutpro.baresip.Restart"))
else
exitProcess(0)
}
@SuppressLint("UnspecifiedImmutableFlag")
@ -1100,8 +1095,8 @@ class BaresipService: Service() {
@Keep
fun stopped(error: String) {
Log.d(TAG, "Received 'stopped' from baresip with start error '$error'")
if (error == "")
quitTimer.cancel()
quitTimer.cancel()
cleanService()
isServiceRunning = false
postServiceEvent(ServiceEvent("stopped", arrayListOf(error), System.nanoTime()))
stopSelf()
@ -1486,6 +1481,10 @@ class BaresipService: Service() {
private fun cleanService() {
if (!isServiceClean) {
this.unregisterReceiver(bluetoothReceiver)
this.unregisterReceiver(hotSpotReceiver)
if (am.isBluetoothScoOn)
am.stopBluetoothSco()
am.mode = AudioManager.MODE_NORMAL
abandonAudioFocus()
stopRinging()

View File

@ -1188,7 +1188,7 @@ class MainActivity : AppCompatActivity() {
val pm = applicationContext.packageManager
val intent = pm.getLaunchIntentForPackage(this.packageName)
this.startActivity(intent)
// exitProcess(0)
exitProcess(0)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {