Merge branch 'charlesmchen/callStateEdgeCases'

pull/1/head
Matthew Chen 7 years ago
commit 58ee518b26

@ -244,10 +244,11 @@ private class SignalCallData: NSObject {
if let oldValue = oldValue { if let oldValue = oldValue {
DeviceSleepManager.sharedInstance.removeBlock(blockObject: oldValue) DeviceSleepManager.sharedInstance.removeBlock(blockObject: oldValue)
} }
stopAnyCallTimer()
if let callData = callData { if let callData = callData {
DeviceSleepManager.sharedInstance.addBlock(blockObject: callData) DeviceSleepManager.sharedInstance.addBlock(blockObject: callData)
self.startCallTimer() self.startCallTimer()
} else {
stopAnyCallTimer()
} }
} }
@ -1233,10 +1234,9 @@ private class SignalCallData: NSObject {
SwiftAssertIsOnMainThread(#function) SwiftAssertIsOnMainThread(#function)
guard let call = self.call else { guard let call = self.call else {
// This should never happen; return to a known good state. // This can happen if you toggle local video right after
owsFail("\(self.logTag) call was unexpectedly nil in \(#function)") // the other user ends the call.
OWSProdError(OWSAnalyticsEvents.callServiceCallMissing(), file: #file, function: #function, line: #line) Logger.debug("\(self.logTag) \(#function) Ignoring event from obsolete call")
handleFailedCurrentCall(error: CallError.assertionError(description: "\(self.logTag) call unexpectedly nil in \(#function)"))
return return
} }
@ -1666,11 +1666,8 @@ private class SignalCallData: NSObject {
func startCallTimer() { func startCallTimer() {
SwiftAssertIsOnMainThread(#function) SwiftAssertIsOnMainThread(#function)
if self.activeCallTimer != nil { stopAnyCallTimer()
owsFail("\(self.logTag) activeCallTimer should only be set once per call") assert(self.activeCallTimer == nil)
self.activeCallTimer!.invalidate()
self.activeCallTimer = nil
}
self.activeCallTimer = WeakTimer.scheduledTimer(timeInterval: 1, target: self, userInfo: nil, repeats: true) { [weak self] timer in self.activeCallTimer = WeakTimer.scheduledTimer(timeInterval: 1, target: self, userInfo: nil, repeats: true) { [weak self] timer in
guard let strongSelf = self else { guard let strongSelf = self else {
@ -1688,6 +1685,15 @@ private class SignalCallData: NSObject {
} }
func ensureCallScreenPresented(call: SignalCall) { func ensureCallScreenPresented(call: SignalCall) {
guard let currentCall = self.call else {
owsFail("\(self.logTag) obsolete call: \(call.identifiersForLogs) in \(#function)")
return
}
guard currentCall == call else {
owsFail("\(self.logTag) obsolete call: \(call.identifiersForLogs) in \(#function)")
return
}
guard let connectedDate = call.connectedDate else { guard let connectedDate = call.connectedDate else {
// Ignore; call hasn't connected yet. // Ignore; call hasn't connected yet.
return return

@ -67,8 +67,7 @@ extension CallUIAdaptee {
SwiftAssertIsOnMainThread(#function) SwiftAssertIsOnMainThread(#function)
guard self.callService.call == nil else { guard self.callService.call == nil else {
Logger.info("unexpectedly found an existing call when trying to start outgoing call: \(recipientId)") owsFail("unexpectedly found an existing call when trying to start outgoing call: \(recipientId)")
//TODO terminate existing call.
return return
} }

Loading…
Cancel
Save