|  |  | @ -51,6 +51,8 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  |     init(callService: CallService, notificationsAdapter: CallNotificationsAdapter) { |  |  |  |     init(callService: CallService, notificationsAdapter: CallNotificationsAdapter) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.callManager = CallKitCallManager() |  |  |  |         self.callManager = CallKitCallManager() | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.callService = callService |  |  |  |         self.callService = callService | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.notificationsAdapter = notificationsAdapter |  |  |  |         self.notificationsAdapter = notificationsAdapter | 
			
		
	
	
		
		
			
				
					|  |  | @ -65,6 +67,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func startOutgoingCall(handle: String) -> SignalCall { |  |  |  |     func startOutgoingCall(handle: String) -> SignalCall { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         let call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: handle) |  |  |  |         let call = SignalCall.outgoingCall(localId: UUID(), remotePhoneNumber: handle) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -79,6 +82,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  |     // Called from CallService after call has ended to clean up any remaining CallKit call state. |  |  |  |     // Called from CallService after call has ended to clean up any remaining CallKit call state. | 
			
		
	
		
		
			
				
					
					|  |  |  |     func failCall(_ call: SignalCall, error: CallError) { |  |  |  |     func failCall(_ call: SignalCall, error: CallError) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         provider.reportCall(with: call.localId, endedAt: Date(), reason: CXCallEndedReason.failed) |  |  |  |         provider.reportCall(with: call.localId, endedAt: Date(), reason: CXCallEndedReason.failed) | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.callManager.removeCall(call) |  |  |  |         self.callManager.removeCall(call) | 
			
		
	
	
		
		
			
				
					|  |  | @ -86,6 +90,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func reportIncomingCall(_ call: SignalCall, callerName: String) { |  |  |  |     func reportIncomingCall(_ call: SignalCall, callerName: String) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         // 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() | 
			
		
	
	
		
		
			
				
					|  |  | @ -110,30 +115,35 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func answerCall(localId: UUID) { |  |  |  |     func answerCall(localId: UUID) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         assertionFailure("CallKit should answer calls via system call screen, not via notifications.") |  |  |  |         assertionFailure("CallKit should answer calls via system call screen, not via notifications.") | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func answerCall(_ call: SignalCall) { |  |  |  |     func answerCall(_ call: SignalCall) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         callManager.answer(call: call) |  |  |  |         callManager.answer(call: call) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func declineCall(localId: UUID) { |  |  |  |     func declineCall(localId: UUID) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         assertionFailure("CallKit should decline calls via system call screen, not via notifications.") |  |  |  |         assertionFailure("CallKit should decline calls via system call screen, not via notifications.") | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func declineCall(_ call: SignalCall) { |  |  |  |     func declineCall(_ call: SignalCall) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         callManager.localHangup(call: call) |  |  |  |         callManager.localHangup(call: call) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func recipientAcceptedCall(_ call: SignalCall) { |  |  |  |     func recipientAcceptedCall(_ call: SignalCall) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.provider.reportOutgoingCall(with: call.localId, connectedAt: nil) |  |  |  |         self.provider.reportOutgoingCall(with: call.localId, connectedAt: nil) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -145,24 +155,35 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func localHangupCall(_ call: SignalCall) { |  |  |  |     func localHangupCall(_ call: SignalCall) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         callManager.localHangup(call: call) |  |  |  |         callManager.localHangup(call: call) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func remoteDidHangupCall(_ call: SignalCall) { |  |  |  |     func remoteDidHangupCall(_ call: SignalCall) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         provider.reportCall(with: call.localId, endedAt: nil, reason: CXCallEndedReason.remoteEnded) |  |  |  |         provider.reportCall(with: call.localId, endedAt: nil, reason: CXCallEndedReason.remoteEnded) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     func remoteBusy(_ call: SignalCall) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         provider.reportCall(with: call.localId, endedAt: nil, reason: CXCallEndedReason.unanswered) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func setIsMuted(call: SignalCall, isMuted: Bool) { |  |  |  |     func setIsMuted(call: SignalCall, isMuted: Bool) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         callManager.setIsMuted(call: call, isMuted: isMuted) |  |  |  |         callManager.setIsMuted(call: call, isMuted: isMuted) | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func setHasLocalVideo(call: SignalCall, hasLocalVideo: Bool) { |  |  |  |     func setHasLocalVideo(call: SignalCall, hasLocalVideo: Bool) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         let update = CXCallUpdate() |  |  |  |         let update = CXCallUpdate() | 
			
		
	
		
		
			
				
					
					|  |  |  |         update.remoteHandle = CXHandle(type: .phoneNumber, value: call.remotePhoneNumber) |  |  |  |         update.remoteHandle = CXHandle(type: .phoneNumber, value: call.remotePhoneNumber) | 
			
		
	
	
		
		
			
				
					|  |  | @ -178,8 +199,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     func providerDidReset(_ provider: CXProvider) { |  |  |  |     func providerDidReset(_ provider: CXProvider) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         AssertIsOnMainThread() |  |  |  |         AssertIsOnMainThread() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |         Logger.debug("\(self.TAG) \(#function)") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         Logger.debug("\(TAG) in \(#function)") |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         // TODO |  |  |  |         // TODO | 
			
		
	
		
		
			
				
					
					|  |  |  |         // copied from Speakerbox, but is there a corallary with peerconnection, since peer connection starts the audio |  |  |  |         // copied from Speakerbox, but is there a corallary with peerconnection, since peer connection starts the audio | 
			
		
	
	
		
		
			
				
					|  |  | 
 |