是否可以在未越狱的 iOS 7 设备上获取 Wi-Fi RSSI 值?我读到了 MobileWiFi.framework 和Apple80211
功能,如果我理解正确的话,它们在没有越狱的情况下无法工作。
我不想在 App Store 上发布我的应用程序,因此允许使用私有 API。
我找不到原始帖子的来源,但它在运行 iOS 7.1 的被监禁设备上对我有用(在 iOS 8 上不起作用):
#include <dlfcn.h>
-(NSDictionary *)currentWiFiInfo
{
void *libHandle;
void *airportHandle;
int (*apple80211Open)(void *);
int (*apple80211Bind)(void *, NSString *);
int (*apple80211Close)(void *);
int (*apple80211GetInfoCopy)(void *, CFDictionaryRef *);
NSMutableDictionary *infoDict = [NSMutableDictionary new];
NSDictionary * tempDictionary;
libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);
char *error;
if (libHandle == NULL && (error = dlerror()) != NULL) {
NSLog(@"%s", error);
}
apple80211Open = dlsym(libHandle, "Apple80211Open");
apple80211Bind = dlsym(libHandle, "Apple80211BindToInterface");
apple80211Close = dlsym(libHandle, "Apple80211Close");
apple80211GetInfoCopy = dlsym(libHandle, "Apple80211GetInfoCopy");
apple80211Open(&airportHandle);
apple80211Bind(airportHandle, @"en0");
CFDictionaryRef info = NULL;
apple80211GetInfoCopy(airportHandle, &info);
tempDictionary = (__bridge NSDictionary *)info;
apple80211Close(airportHandle);
[infoDict setObject:(tempDictionary[@"RSSI"])[@"RSSI_CTL_AGR"] ? (tempDictionary[@"RSSI"])[@"RSSI_CTL_AGR"] : @"0" forKey:@"RSSI"];
[infoDict setObject:tempDictionary[@"BSSID"] ? tempDictionary[@"BSSID"] : @"null" forKey:@"BSSID"];
[infoDict setObject:tempDictionary[@"SSID_STR"] ? tempDictionary[@"SSID_STR"] : @"null" forKey:@"SSID"];
[infoDict setObject:tempDictionary[@"RATE"] ? tempDictionary[@"RATE"] : @"0" forKey:@"SPEED"];
return infoDict;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)