diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 0f371f5b..fe23648a 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -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() } diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt index a1ae63cd..6454a4a5 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainActivity.kt @@ -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) }