From b40110f919a59ee7a198849c3fa5114211a5b6c2 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Mon, 13 Jan 2025 14:34:18 +0100 Subject: [PATCH] Trigger onEnterBackground if we are in background when all calls are terminated --- Linphone/Core/CoreContext.swift | 9 +++++++++ Linphone/UI/Call/ViewModel/PIPViewModel.swift | 0 2 files changed, 9 insertions(+) create mode 100644 Linphone/UI/Call/ViewModel/PIPViewModel.swift diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index 42c61c6f7..0b83749d2 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -218,6 +218,15 @@ final class CoreContext: ObservableObject { } }, onCallStateChanged: { (core: Core, call: Call, cstate: Call.State, message: String) in TelecomManager.shared.onCallStateChanged(core: core, call: call, state: cstate, message: message) + + if core.calls.isEmpty { + DispatchQueue.main.asyncAfter(deadline: .now() + 2) { + if UIApplication.shared.applicationState == .background { + Log.info("[CoreContext] core is currently in background with no calls, triggering onEnterBackground procedure") + self.onEnterBackground() + } + } + } }, onAuthenticationRequested: { (_: Core, authInfo: AuthInfo, method: AuthMethod) in guard let username = authInfo.username, let server = authInfo.authorizationServer, !server.isEmpty else { Log.error("Authentication requested but either username [\(String(describing: authInfo.username))], domain [\(String(describing: authInfo.domain))] or server [\(String(describing: authInfo.authorizationServer))] is nil or empty!") diff --git a/Linphone/UI/Call/ViewModel/PIPViewModel.swift b/Linphone/UI/Call/ViewModel/PIPViewModel.swift new file mode 100644 index 000000000..e69de29bb