From d4ba4c446b77bbc08da3e0990fd18cb8b2b0460b Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 1 Feb 2017 14:43:47 -0500 Subject: [PATCH] Respond to CR. // FREEBIE --- .../Speakerbox/CallKitCallUIAdaptee.swift | 11 +++----- .../call/UserInterface/CallUIAdapter.swift | 1 - .../src/call/WebRTCCallMessageHandler.swift | 25 ++++++++----------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift index 28b3807f5..90da51ed6 100644 --- a/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift +++ b/Signal/src/call/Speakerbox/CallKitCallUIAdaptee.swift @@ -261,16 +261,13 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate { // // Trigger the call to be ended via the underlying network service. // call.endSpeakerboxCall() - // Synchronous to ensure call is terminated before call is displayed as "ended" self.callService.handleLocalHungupCall(call) - DispatchQueue.main.async { - // Signal to the system that the action has been successfully performed. - action.fulfill() + // Signal to the system that the action has been successfully performed. + action.fulfill() - // Remove the ended call from the app's list of calls. - self.callManager.removeCall(call) - } + // Remove the ended call from the app's list of calls. + self.callManager.removeCall(call) } public func provider(_ provider: CXProvider, perform action: CXSetHeldCallAction) { diff --git a/Signal/src/call/UserInterface/CallUIAdapter.swift b/Signal/src/call/UserInterface/CallUIAdapter.swift index 4f4adcaf8..8dcfc9df3 100644 --- a/Signal/src/call/UserInterface/CallUIAdapter.swift +++ b/Signal/src/call/UserInterface/CallUIAdapter.swift @@ -42,7 +42,6 @@ extension CallUIAdaptee { notificationsAdapter.presentMissedCall(call, callerName: callerName) } - // TODO: who calls this? internal func callBack(recipientId: String) { AssertIsOnMainThread() diff --git a/Signal/src/call/WebRTCCallMessageHandler.swift b/Signal/src/call/WebRTCCallMessageHandler.swift index 5461b9719..bf9ad8438 100644 --- a/Signal/src/call/WebRTCCallMessageHandler.swift +++ b/Signal/src/call/WebRTCCallMessageHandler.swift @@ -28,24 +28,23 @@ class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler { // MARK: - Call Handlers public func receivedOffer(_ offer: OWSSignalServiceProtosCallMessageOffer, from callerId: String) { + AssertIsOnMainThread() Logger.verbose("\(TAG) handling offer from caller:\(callerId)") let thread = TSContactThread.getOrCreateThread(contactId: callerId) - DispatchQueue.main.async { - _ = self.callService.handleReceivedOffer(thread: thread, callId: offer.id, sessionDescription: offer.sessionDescription) - } + self.callService.handleReceivedOffer(thread: thread, callId: offer.id, sessionDescription: offer.sessionDescription) } public func receivedAnswer(_ answer: OWSSignalServiceProtosCallMessageAnswer, from callerId: String) { + AssertIsOnMainThread() Logger.verbose("\(TAG) handling answer from caller:\(callerId)") let thread = TSContactThread.getOrCreateThread(contactId: callerId) - DispatchQueue.main.async { - self.callService.handleReceivedAnswer(thread: thread, callId: answer.id, sessionDescription: answer.sessionDescription) - } + self.callService.handleReceivedAnswer(thread: thread, callId: answer.id, sessionDescription: answer.sessionDescription) } public func receivedIceUpdate(_ iceUpdate: OWSSignalServiceProtosCallMessageIceUpdate, from callerId: String) { + AssertIsOnMainThread() Logger.verbose("\(TAG) handling iceUpdates from caller:\(callerId)") let thread = TSContactThread.getOrCreateThread(contactId: callerId) @@ -54,29 +53,25 @@ class WebRTCCallMessageHandler: NSObject, OWSCallMessageHandler { // while the RTC iOS API requires a signed int. let lineIndex = Int32(iceUpdate.sdpMlineIndex) - DispatchQueue.main.async { - self.callService.handleRemoteAddedIceCandidate(thread: thread, callId: iceUpdate.id, sdp: iceUpdate.sdp, lineIndex: lineIndex, mid: iceUpdate.sdpMid) - } + self.callService.handleRemoteAddedIceCandidate(thread: thread, callId: iceUpdate.id, sdp: iceUpdate.sdp, lineIndex: lineIndex, mid: iceUpdate.sdpMid) } public func receivedHangup(_ hangup: OWSSignalServiceProtosCallMessageHangup, from callerId: String) { + AssertIsOnMainThread() Logger.verbose("\(TAG) handling 'hangup' from caller:\(callerId)") let thread = TSContactThread.getOrCreateThread(contactId: callerId) - DispatchQueue.main.async { - self.callService.handleRemoteHangup(thread: thread) - } + self.callService.handleRemoteHangup(thread: thread) } public func receivedBusy(_ busy: OWSSignalServiceProtosCallMessageBusy, from callerId: String) { + AssertIsOnMainThread() Logger.verbose("\(TAG) handling 'busy' from caller:\(callerId)") let thread = TSContactThread.getOrCreateThread(contactId: callerId) - DispatchQueue.main.async { - self.callService.handleRemoteBusy(thread: thread) - } + self.callService.handleRemoteBusy(thread: thread) } }