需求: 使用Cycript调用SBWiFiManager可以控制WiFi,但是通过Hook SpringBoard进程时调用SBWiFiManager却不能控制WiFi
日志:
代码:
- (void)switchWifi:(BOOL)enable {
[WDUtility toast:enable ? @“开启Wifi” : @“关闭Wifi”];
Class class_SBWiFiManager = NSClassFromString(@“SBWiFiManager”);
id wifiManager = [class_SBWiFiManager performSelector:NSSelectorFromString(@“sharedInstance”)];
[wifiManager performSelector:NSSelectorFromString(@“setWiFiEnabled:”) withObject:@(enable)];
// 可以通过[[wifiManager valueForKey:@"_powered"] boolValue]来校验
}
操作步骤:
1.用crycript跟踪SpringBoard
2.调用[WDHookAppSpringBoard switchWifi:YES]可以打开Wifi
3.接着调用[WDHookAppSpringBoard switchWifi:NO],却无法关闭wifi
4.接着调用[[SBWiFiManager sharedInstance] setWiFiEnabled:NO]却可以关闭wifi