Fixed quit button not killing app when background mode is enabled

This commit is contained in:
Sylvain Berfini 2022-02-10 10:08:11 +01:00
parent 69d7bff9a5
commit 4226dd6d5c
2 changed files with 4 additions and 8 deletions

View file

@ -31,7 +31,6 @@ import androidx.lifecycle.lifecycleScope
import java.io.File import java.io.File
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.coreContext
import org.linphone.LinphoneApplication.Companion.corePreferences
import org.linphone.R import org.linphone.R
import org.linphone.activities.GenericFragment import org.linphone.activities.GenericFragment
import org.linphone.activities.assistant.AssistantActivity import org.linphone.activities.assistant.AssistantActivity
@ -113,12 +112,9 @@ class SideMenuFragment : GenericFragment<SideMenuFragmentBinding>() {
Log.i("[Side Menu] Quitting app") Log.i("[Side Menu] Quitting app")
requireActivity().finishAndRemoveTask() requireActivity().finishAndRemoveTask()
if (!corePreferences.keepServiceAlive) { Log.i("[Side Menu] Stopping Core Context")
Log.i("[Side Menu] Stopping Core") coreContext.notificationsManager.stopForegroundNotification()
coreContext.stop() coreContext.stop()
} else {
Log.w("[Side Menu] Keep Service alive setting enabled, don't destroy the Core")
}
} }
onBackPressedCallback.isEnabled = false onBackPressedCallback.isEnabled = false

View file

@ -342,7 +342,7 @@ class NotificationsManager(private val context: Context) {
} }
} }
private fun stopForegroundNotification() { fun stopForegroundNotification() {
if (service != null) { if (service != null) {
Log.i("[Notifications Manager] Stopping service as foreground [$currentForegroundServiceNotificationId]") Log.i("[Notifications Manager] Stopping service as foreground [$currentForegroundServiceNotificationId]")
service?.stopForeground(true) service?.stopForeground(true)