|
|
@ -73,13 +73,19 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
// MARK: - Report calls
|
|
|
|
// MARK: - Report calls
|
|
|
|
|
|
|
|
|
|
|
|
public static func reportFakeCall(info: String) {
|
|
|
|
public static func reportFakeCall(info: String) {
|
|
|
|
SessionCallManager.sharedProvider(useSystemCallLog: false)
|
|
|
|
let callId = UUID()
|
|
|
|
.reportNewIncomingCall(
|
|
|
|
let provider = SessionCallManager.sharedProvider(useSystemCallLog: false)
|
|
|
|
with: UUID(),
|
|
|
|
provider.reportNewIncomingCall(
|
|
|
|
|
|
|
|
with: callId,
|
|
|
|
update: CXCallUpdate()
|
|
|
|
update: CXCallUpdate()
|
|
|
|
) { _ in
|
|
|
|
) { _ in
|
|
|
|
SNLog("[Calls] Reported fake incoming call to CallKit due to: \(info)")
|
|
|
|
SNLog("[Calls] Reported fake incoming call to CallKit due to: \(info)")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
provider.reportCall(
|
|
|
|
|
|
|
|
with: callId,
|
|
|
|
|
|
|
|
endedAt: nil,
|
|
|
|
|
|
|
|
reason: .failed
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public func reportOutgoingCall(_ call: SessionCall) {
|
|
|
|
public func reportOutgoingCall(_ call: SessionCall) {
|
|
|
@ -100,7 +106,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
public func reportIncomingCall(_ call: SessionCall, callerName: String, completion: @escaping (Error?) -> Void) {
|
|
|
|
public func reportIncomingCall(_ call: SessionCall, callerName: String, completion: @escaping (Error?) -> Void) {
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
|
|
if let provider = provider {
|
|
|
|
let provider = provider ?? Self.sharedProvider(useSystemCallLog: false)
|
|
|
|
// Construct a CXCallUpdate describing the incoming call, including the caller.
|
|
|
|
// Construct a CXCallUpdate describing the incoming call, including the caller.
|
|
|
|
let update = CXCallUpdate()
|
|
|
|
let update = CXCallUpdate()
|
|
|
|
update.localizedCallerName = callerName
|
|
|
|
update.localizedCallerName = callerName
|
|
|
@ -120,12 +126,6 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
completion(nil)
|
|
|
|
completion(nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
SessionCallManager.reportFakeCall(info: "No CXProvider instance")
|
|
|
|
|
|
|
|
UserDefaults.sharedLokiProject?.set(true, forKey: "isCallOngoing")
|
|
|
|
|
|
|
|
completion(nil)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public func reportCurrentCallEnded(reason: CXCallEndedReason?) {
|
|
|
|
public func reportCurrentCallEnded(reason: CXCallEndedReason?) {
|
|
|
|
guard Thread.isMainThread else {
|
|
|
|
guard Thread.isMainThread else {
|
|
|
@ -135,7 +135,11 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
guard let call = currentCall else { return }
|
|
|
|
guard let call = currentCall else {
|
|
|
|
|
|
|
|
WebRTCSession.current = nil
|
|
|
|
|
|
|
|
UserDefaults.sharedLokiProject?.set(false, forKey: "isCallOngoing")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if let reason = reason {
|
|
|
|
if let reason = reason {
|
|
|
|
self.provider?.reportCall(with: call.callId, endedAt: nil, reason: reason)
|
|
|
|
self.provider?.reportCall(with: call.callId, endedAt: nil, reason: reason)
|
|
|
|