From 81d669e5cef3b260fb7563e6bdeea21192030d4a Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 8 Aug 2024 13:54:45 +0300 Subject: [PATCH] Fixes #3136 - Stop manually configuring ElementCall's AudioSession - CallKit decides what action to to take when pressing the hardware lock button based on where the audio is routed to. Using the speaker will make it lock the phone while using the headset will make it end the call. - Before the introduction of CallKit we had to manually setup the AudioSession to keep the audio live in the background. This is now clashing with CallKit making it bevelie the audio is not routed to the speaker and causing the call be terminated when pressing the lock button. --- .../Services/ElementCall/ElementCallService.swift | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ElementX/Sources/Services/ElementCall/ElementCallService.swift b/ElementX/Sources/Services/ElementCall/ElementCallService.swift index d096a34f9..43b84c596 100644 --- a/ElementX/Sources/Services/ElementCall/ElementCallService.swift +++ b/ElementX/Sources/Services/ElementCall/ElementCallService.swift @@ -105,13 +105,6 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe } catch { MXLog.error("Failed requesting start call action with error: \(error)") } - - do { // Setup the audio session even if setting up CallKit failed, ElementCall **is** running at this point - try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .videoChat, options: []) - try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation) - } catch { - MXLog.error("Failed setting up audio session with error: \(error)") - } } func tearDownCallSession() { @@ -181,6 +174,14 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe // MARK: - CXProviderDelegate + func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) { + MXLog.info("Call provider did activate audio session") + } + + func provider(_ provider: CXProvider, didDeactivate audioSession: AVAudioSession) { + MXLog.info("Call provider did deactivate audio session") + } + func providerDidReset(_ provider: CXProvider) { MXLog.info("Call provider did reset: \(provider)") }