- Tried to improve baresip quit/restart process
This commit is contained in:
@ -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()
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user