Tried to simplify Quit/Restart process

This commit is contained in:
Juha Heinanen
2022-09-15 16:56:53 +03:00
parent f1ba8db207
commit 2f53b89386
2 changed files with 6 additions and 15 deletions

View File

@ -325,11 +325,6 @@ class BaresipService: Service() {
"force" -> {
cleanService()
isServiceRunning = false
if (VERSION.SDK_INT < 33)
@Suppress("DEPRECATION")
stopForeground(true)
else
stopForeground(STOP_FOREGROUND_REMOVE)
stopSelf()
// exitProcess(0)
}
@ -543,14 +538,16 @@ class BaresipService: Service() {
override fun onDestroy() {
super.onDestroy()
Log.d(TAG, "At Baresip Service onDestroy")
Log.d(TAG, "onDestroy at Baresip Service")
this.unregisterReceiver(bluetoothReceiver)
this.unregisterReceiver(hotSpotReceiver)
if (am.isBluetoothScoOn) am.stopBluetoothSco()
if (am.isBluetoothScoOn)
am.stopBluetoothSco()
cleanService()
if (isServiceRunning) {
if (isServiceRunning)
sendBroadcast(Intent("com.tutpro.baresip.Restart"))
}
else
exitProcess(0)
}
@SuppressLint("UnspecifiedImmutableFlag")
@ -1097,11 +1094,6 @@ class BaresipService: Service() {
quitTimer.cancel()
isServiceRunning = false
postServiceEvent(ServiceEvent("stopped", arrayListOf(error), System.nanoTime()))
if (VERSION.SDK_INT < 33)
@Suppress("DEPRECATION")
stopForeground(true)
else
stopForeground(STOP_FOREGROUND_REMOVE)
stopSelf()
}

View File

@ -1185,7 +1185,6 @@ class MainActivity : AppCompatActivity() {
Log.d(TAG, "Trigger restart")
val pm = applicationContext.packageManager
val intent = pm.getLaunchIntentForPackage(this.packageName)
this.finishAffinity()
this.startActivity(intent)
exitProcess(0)
}