Instrument calls to ensure audio session is maintained

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent abb51b565a
commit 4dd1c7813a

@ -1501,6 +1501,8 @@ protocol CallServiceObserver: class {
self.call?.removeAllObservers()
self.call = nil
self.callUIAdapter.didTerminateCall(self.call)
self.sendIceUpdatesImmediately = true
Logger.info("\(self.logTag) clearing pendingIceUpdateMessages")
self.pendingIceUpdateMessages = []

@ -37,6 +37,9 @@ class NonCallKitCallUIAdaptee: NSObject, CallUIAdaptee {
let call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: handle)
// make sure we don't terminate audio session during call
OWSAudioSession.shared.startAudioActivity(call.audioActivity)
self.callService.handleOutgoingCall(call).then {
Logger.debug("\(self.TAG) handleOutgoingCall succeeded")
}.catch { error in

@ -106,6 +106,8 @@ protocol CallObserver: class {
}
}
let audioActivity: AudioActivity
var audioSource: AudioSource? = nil {
didSet {
AssertIsOnMainThread()
@ -149,6 +151,7 @@ protocol CallObserver: class {
self.state = state
self.remotePhoneNumber = remotePhoneNumber
self.thread = TSContactThread.getOrCreateThread(contactId: remotePhoneNumber)
self.audioActivity = AudioActivity(audioDescription: "[SignalCall] with \(remotePhoneNumber)")
}
// A string containing the three identifiers for this call.

@ -78,6 +78,9 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
let call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: handle)
// make sure we don't terminate audio session during call
OWSAudioSession.shared.startAudioActivity(call.audioActivity)
// Add the new outgoing call to the app's list of calls.
// So we can find it in the provider delegate callbacks.
callManager.addCall(call)

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
@ -111,6 +111,9 @@ extension CallUIAdaptee {
internal func reportIncomingCall(_ call: SignalCall, thread: TSContactThread) {
AssertIsOnMainThread()
// make sure we don't terminate audio session during call
OWSAudioSession.shared.startAudioActivity(call.audioActivity)
let callerName = self.contactsManager.displayName(forPhoneIdentifier: call.remotePhoneNumber)
adaptee.reportIncomingCall(call, callerName: callerName)
}
@ -153,6 +156,14 @@ extension CallUIAdaptee {
adaptee.declineCall(call)
}
internal func didTerminateCall(_ call: SignalCall?) {
AssertIsOnMainThread()
if let call = call {
OWSAudioSession.shared.endAudioActivity(call.audioActivity)
}
}
internal func startAndShowOutgoingCall(recipientId: String) {
AssertIsOnMainThread()

@ -70,7 +70,7 @@ public class OWSAudioSession: NSObject {
}
}
private func startAudioActivity(_ audioActivity: AudioActivity) {
public func startAudioActivity(_ audioActivity: AudioActivity) {
Logger.debug("\(logTag) in \(#function) with \(audioActivity)")
self.currentActivities.append(Weak(value: audioActivity))

Loading…
Cancel
Save