Auto-disable CallKit privacy in iOS 11 and later.

This commit is contained in:
Matthew Chen 2018-02-23 10:52:46 -05:00 committed by Michael Kirk
parent 775682052c
commit 5b9ab0cf5d
4 changed files with 35 additions and 4 deletions

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "PrivacySettingsTableViewController.h"
@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
isOn:[Environment.preferences isCallKitEnabled]
target:weakSelf
selector:@selector(didToggleEnableCallKitSwitch:)]];
if (Environment.preferences.isCallKitEnabled) {
if (Environment.preferences.isCallKitEnabled && !Environment.preferences.isCallKitPrivacyAutoDisabled) {
[callKitSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE",
@"Label for 'CallKit privacy' preference")

View File

@ -50,6 +50,10 @@ final class CallKitCallUIAdaptee: NSObject, CallUIAdaptee, CXProviderDelegate {
// default iOS ringtone OR the custom ringtone associated with this user's
// system contact, if possible (iOS 11 or later).
if #available(iOS 11.0, *) {
providerConfiguration.includesCallsInRecents = false
}
return providerConfiguration
}

View File

@ -68,6 +68,7 @@ extern NSString *const OWSPreferencesKeyEnableDebugLog;
- (void)setIsCallKitPrivacyEnabled:(BOOL)flag;
// Returns YES IFF isCallKitPrivacyEnabled has been set by user.
- (BOOL)isCallKitPrivacySet;
- (BOOL)isCallKitPrivacyAutoDisabled;
#pragma mark direct call connectivity (non-TURN)

View File

@ -190,10 +190,36 @@ NSString *const OWSPreferencesKey_IsReadyForAppExtensions = @"isReadyForAppExten
return preference != nil;
}
- (BOOL)isCallKitPrivacyAutoDisabled
{
// In iOS 10.2.1, Apple fixed a bug wherein call history was backed up to iCloud.
//
// See: https://support.apple.com/en-us/HT207482
//
// In iOS 11, Apple introduced a property CXProviderConfiguration.includesCallsInRecents
// that allows us to prevent Signal calls made with CallKit from showing up in the device's
// call history.
//
// Therefore in versions of iOS after 11, we have no need of call privacy.
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 0)) {
return YES;
} else {
return NO;
}
}
- (BOOL)isCallKitPrivacyEnabled
{
NSNumber *preference = [self tryGetValueForKey:OWSPreferencesKeyCallKitPrivacyEnabled];
return preference ? [preference boolValue] : YES;
if ([self isCallKitPrivacyAutoDisabled]) {
return NO;
}
NSNumber *_Nullable preference = [self tryGetValueForKey:OWSPreferencesKeyCallKitPrivacyEnabled];
if (preference) {
return [preference boolValue];
} else {
// Private by default.
return YES;
}
}
- (void)setIsCallKitPrivacyEnabled:(BOOL)flag