我一直在开发一个应用程序,以编程方式启用/禁用我的iPhone的Wi-Fi接口。我曾试图在我的监狱破坏Iphone 4s(iOS 5.1.1)上使用Apple 80211(苹果的私人服务)来使其正常工作。然而,事情并没有像我预期的那样成功。
我可以成功扫描并获取Wi-Fi连接的状态,但启用/禁用WiFi的方法Apple80211SetPower
似乎无法在iOS 5上运行。
正如我从SBsetting的WiFi切换中发现的那样,它可能还需要在"/var/preferences/systemconfiguration/com.apple.wifi.plist"
更改WiFi的系统属性。但是,我的应用程序无法更改该文件中的系统属性,我怀疑该问题是由文件属性和所有权引起的。因此,我模仿了SBsetting的WiFi切换的文件属性,但是,它没有改变一件事。
有谁知道如何更改此文件的系统属性?这是我使用的代码。谢谢和问候
NSMutableDictionary *plistDict =
[NSMutableDictionary dictionaryWithContentsOfFile:@"/var/preferences/SystemConfiguration/com.apple.wifi.plist"];
BOOL wifiState = [[plistDict objectForKey:@"AllowEnable"] boolValue];
NSLog(wifiState ? @"Yes" : @"No");
if (value == YES)
{
[plistDict setValue:[NSNumber numberWithBool:YES] forKey:@"AllowEnable"];
[plistDict writeToFile:@"/var/preferences/SystemConfiguration/com.apple.wifi.plist"
atomically: YES];
}
else if (value== NO)
{
[plistDict setValue:[NSNumber numberWithBool:NO] forKey:@"AllowEnable"];
[plistDict writeToFile:@"/var/preferences/SystemConfiguration/com.apple.wifi.plist"
atomically: YES];
}
答案 0 :(得分:0)
在我的手机上(iOS 5.0.1,而不是5.1.1),我在SystemConfiguration目录中看到了这一点:
iPhone4:/var/preferences/SystemConfiguration mobile$ ls -altr
total 144
drwxr-xr-x 3 root wheel 136 Dec 25 2007 ..
-rw-r--r-- 1 root wheel 181 Jul 26 2009 OSThermalStatus.plist
-rw-r--r-- 1 root wheel 79 Jan 10 2012 com.apple.mobilegestalt.plist
-rw-r--r-- 1 root wheel 60 Sep 30 00:47 com.apple.radios.plist
-rw-r--r-- 1 root wheel 1162 Sep 30 15:50 NetworkInterfaces.plist
-rw-r--r-- 1 root wheel 57087 Sep 30 15:51 com.apple.network.identification.plist
-rw-r--r-- 1 root wheel 127 Oct 1 01:04 com.apple.PowerManagement.plist
-rw-r--r-- 1 root wheel 7323 Oct 1 01:18 preferences.plist
-rw-r--r-- 1 root wheel 31648 Oct 1 01:18 com.apple.wifi.plist
-rw-r--r-- 1 root wheel 1223 Oct 1 01:18 com.apple.AutoWake.plist
drwxr-xr-x 2 root wheel 374 Oct 1 01:18 .
因此,看起来用户mobile
(应用程序通常运行的用户)将无法使用只读权限来编写该文件。