2

iPhoneのWi-Fiインターフェイスをプログラムで有効/無効にするアプリを開発しています。ジェイルが壊れたIphone 4s(iOS 5.1.1)でApple 80211(アップルのプライベートサービス)を使用して動作させようとしました。しかし、思い通りにいかない。Wi-Fi 接続の状態をスキャンして取得することはできますが、Apple80211SetPowerWiFi を有効/無効にする方法は iOS 5 では機能しないようです。

SBsetting の WiFi トグルからわかったように、WiFi at のシステム プロパティも変更する必要があるかもしれません"/var/preferences/systemconfiguration/com.apple.wifi.plist"。ただし、私のアプリはそのファイルのシステム プロパティを変更できませんでした。ファイルのプロパティと所有権に問題があると思われます。そこで、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];
}
4

1 に答える 1

0

私の電話 (5.1.1 ではなく iOS 5.0.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(アプリが通常実行されるユーザー) は、読み取り権限のみでそのファイルを書き込むことができないようです。

アプリにroot権限を付与する方法については、こちらをご覧ください。

于 2012-10-01T08:24:54.107 に答える