2

I have been developing an app to programmatically enable/disable Wi-Fi interface of my iphone. I have tried to use the Apple 80211( apple's private service) on my jail broken Iphone 4s (iOS 5.1.1) to make it work. However, thing does not work out as I expected. I can successfully scan and get the status of Wi-Fi connection however, the method Apple80211SetPower to enable/disable WiFi seems does not work on iOS 5.

As I found out from SBsetting's WiFi toggle, It might also require to change the system property of WiFi at "/var/preferences/systemconfiguration/com.apple.wifi.plist". However, my app is failed to change system property in that file, I suspected the problem resulted from file property and ownership. Therefore, I imitated the file property of SBsetting's WiFi toggle, Still, it did not change a thing. does anyone know how I could change the system property of this file? this is the code that I used. thanks and regards

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];
}
Nate
  • 31,017
  • 13
  • 83
  • 207
Nam Nguyen
  • 31
  • 1
  • 4

1 Answers1

0

On my phone (iOS 5.0.1, not 5.1.1), I see this in the SystemConfiguration directory:

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 .

So, it looks like the user mobile (which is the user the apps normally run as) would not be able to write that file, with only read privileges.

You can take a look here at how to give your app root privileges.

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207