From a7e2ebb6004367c45c3fd839c0ea0b1acf6562f5 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Thu, 4 Sep 2025 16:40:34 +0200 Subject: [PATCH] Ensure core is On before stopping it on background entry --- Linphone/Core/CoreContext.swift | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index 3c2711d0c..9d1cf6dc3 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -424,26 +424,24 @@ class CoreContext: ObservableObject { func onEnterForeground() { coreQueue.async { - // We can't rely on defaultAccount?.params?.isPublishEnabled - // as it will be modified by the SDK when changing the presence status + Log.info("[onEnterForegroundOrBackground] Entering foreground") try? self.mCore.start() } } - + func onEnterBackground() { coreQueue.async { - // We can't rely on defaultAccount?.params?.isPublishEnabled - // as it will be modified by the SDK when changing the presence status - Log.info("App is in background, un-PUBLISHING presence info") + Log.info("[onEnterForegroundOrBackground] Entering background, un-PUBLISHING presence info") - // We don't use ConsolidatedPresence.Busy but Offline to do an unsubscribe, - // Flexisip will handle the Busy status depending on other devices - self.updatePresence(core: self.mCore, presence: ConsolidatedPresence.Offline) + self.updatePresence(core: self.mCore, presence: .Offline) self.mCore.iterate() - if self.mCore.currentCall == nil { + if self.mCore.currentCall == nil && self.mCore.globalState == .On { + Log.info("[onEnterForegroundOrBackground] Stopping core because no active calls") self.mCore.stop() + } else { + Log.info("[onEnterForegroundOrBackground] Skipped stop: core not fully On or active call in progress") } } }