gpt4 book ai didi

ios - 更改 com.apple.wifi.plist 中的系统属性

转载 作者:行者123 更新时间:2023-12-01 16:54:44 25 4
gpt4 key购买 nike

我一直在开发一个应用程序来以编程方式启用/禁用我的 iphone 的 Wi-Fi 接口(interface)。我曾尝试在我越狱的 Iphone 4s(iOS 5.1.1)上使用 Apple 80211(苹果的私有(private)服务)来使其工作。然而,事情并没有像我预期的那样顺利。
我可以成功扫描并获取 Wi-Fi 连接状态,但是方法 Apple80211SetPower启用/禁用 WiFi 似乎不适用于 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];
}

最佳答案

在我的手机(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 (这是应用程序通常运行的用户)将无法写入该文件,只有读取权限。

您可以在这里查看 how to give your app root privileges .

关于ios - 更改 com.apple.wifi.plist 中的系统属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12661737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com