Add and honor the “CallKit Privacy” setting.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-02-22 09:23:56 -05:00
parent 065d383c15
commit f5004b27ab
2 changed files with 11 additions and 2 deletions

View File

@ -18,12 +18,13 @@ final class CallKitCallManager: NSObject {
let TAG = "[CallKitCallManager]"
let callController = CXCallController()
static let kAnonymousCallHandlePrefix = "Signal:"
// MARK: Actions
func startCall(_ call: SignalCall) {
let handle = (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
? CXHandle(type: .generic, value: call.localId.uuidString)
? CXHandle(type: .generic, value: CallKitCallManager.kAnonymousCallHandlePrefix + call.localId.uuidString)
: CXHandle(type: .phoneNumber, value: call.remotePhoneNumber))
let startCallAction = CXStartCallAction(call: call.localId, handle: handle)

View File

@ -101,7 +101,7 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
// Construct a CXCallUpdate describing the incoming call, including the caller.
let update = CXCallUpdate()
update.remoteHandle = (Environment.getCurrent().preferences.isCallKitPrivacyEnabled()
? CXHandle(type: .generic, value: call.localId.uuidString)
? CXHandle(type: .generic, value: CallKitCallManager.kAnonymousCallHandlePrefix + call.localId.uuidString)
: CXHandle(type: .phoneNumber, value: call.remotePhoneNumber))
update.hasVideo = call.hasLocalVideo
// Update the name used in the CallKit UI for incoming calls.
@ -237,7 +237,15 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
_ = self.callService.handleOutgoingCall(call)
action.fulfill()
self.provider.reportOutgoingCall(with: call.localId, startedConnectingAt: nil)
ensureCallName(call:call)
}
func ensureCallName(call : SignalCall) {
guard Environment.getCurrent().preferences.isCallKitPrivacyEnabled() else {
return;
}
// Update the name used in the CallKit UI for outgoing calls.
let update = CXCallUpdate()
update.localizedCallerName = NSLocalizedString("CALLKIT_ANONYMOUS_CONTACT_NAME", comment: "The generic name used for calls if CallKit privacy is enabled")