如何改变"呼叫等待"以编程方式在iOS(越狱设备)?

时间:2014-07-03 08:04:19

标签: ios iphone jailbreak cydia-substrate

我不想以编程方式打开/关闭iPhone的呼叫等待功能(可以在Settings > Phone > Call Waiting找到)。

我的想法是,手机设置从找到的-setCallWaitingEnabled:specifier:班级here调用PhoneSettingsCallWaitingController方法。我在/System/Library/PreferenceBundles/MobilePhoneSettings.bundle/Call Waiting.plist

中找到了它
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>id</key>
    <string>com.apple.preferences.phone.call-waiting</string>
    <key>items</key>
    <array>
        <dict>
            <key>cell</key>
            <string>PSGroupCell</string>
        </dict>
        <dict>
            <key>cell</key>
            <string>PSSwitchCell</string>
            <key>get</key>
            <string>callWaitingEnabled:</string>
            <key>label</key>
            <string>Call Waiting</string>
            <key>set</key>
            <string>setCallWaitingEnabled:specifier:</string>
        </dict>
    </array>
    <key>title</key>
    <string>Call Waiting</string>
</dict>
</plist>

我手动加载了包并初始化了上面的类并调用了我说的方法,但没有任何反应。这是代码:

NSBundle *b = [NSBundle bundleWithPath:@"/System/Library/PreferenceBundles/MobilePhoneSettings.bundle"];
BOOL success = [b load];
if (success)
{

    NSLog(@"\n\n\n\n Bundle load successfull! \n\n\n\n ");
    Class PhoneSettingsCallWaitingController = NSClassFromString(@"PhoneSettingsCallWaitingController");
    id tc = [[PhoneSettingsCallWaitingController alloc] init];

    [tc setCallWaitingEnabled:0 specifier:0];

} else NSLog(@"\n\n\n\n Bundle load failure! \n\n\n\n ");

我不知道我是否走在正确的道路上。是否有其他方法可以打开/关闭呼叫等待设置?

1 个答案:

答案 0 :(得分:1)

CoreTelephony.framework私有API的声明

CF_EXTERN_C_BEGIN

CF_EXPORT CFNotificationCenterRef CTTelephonyCenterGetDefault();
CF_EXPORT void CTTelephonyCenterAddObserver(CFNotificationCenterRef center, const void *observer, CFNotificationCallback callBack, CFStringRef name, const void *object, CFNotificationSuspensionBehavior suspensionBehavior);

CF_EXPORT void CTSettingRequest(NSDictionary* dict);
CF_EXPORT void CTSettingSave(NSDictionary* dict);

CF_EXPORT NSString* kCTSettingCallClassVoice;
CF_EXPORT NSString* kCTSettingTypeCallWaiting;
CF_EXPORT NSString* kCTSettingType;
CF_EXPORT NSString* kCTSettingCallClass;
CF_EXPORT NSString* kCTSettingEnabled;

CF_EXTERN_C_END

设置请求和保存是异步完成的。结果将发送到电话中心回拨:

void SettingCallback(CFNotificationCallback center, void* observer, NSString* name, const void* objec, NSDictionary* userInfo)
{
    if ([name isEqualToString:@"kCTSettingRequestSuccessNotification"])
    {
        //Setting request results are in 'userInfo' argument
    }
    else if ([name isEqualToString:@"kCTSettingRequestErrorNotification"])
    {
        //Setting request error
    }
    else if ([name isEqualToString:@"kCTSettingSaveSuccessNotification"])
    {
        //Setting saved
    }
    else if ([name isEqualToString:@"kCTSettingSaveErrorNotification"])
    {
        //Setting save error
    }
}

...

CTTelephonyCenterAddObserver(CTTelephonyCenterGetDefault(), NULL, SettingCallback, NULL, NULL, CFNotificationSuspensionBehaviorHold);

请求呼叫等待设置:

CTSettingRequest(@{@"STSettingTypeUniqueIdentifier" : kCTSettingTypeCallWaiting,
                   kCTSettingCallClass : kCTSettingCallClassVoice, 
                   kCTSettingType : kCTSettingTypeCallWaiting});

保存呼叫等待设置(在这种情况下,已启用):

CTSettingSave(@{@"STSettingTypeUniqueIdentifier" : kCTSettingTypeCallWaiting,
                kCTSettingCallClass : kCTSettingCallClassVoice, 
                kCTSettingType : kCTSettingTypeCallWaiting, 
                kCTSettingEnabled : @YES});