iphone privateapi - Private iOS Framework Returning NULL -
i'm trying use batterycenter
, commonutilities
private frameworks under ios 9.1 of nst's ios runtime headers. it's research purposes , won't make appstore.
here respective codes:
- (void)batterycenter { nsbundle *bundle = [nsbundle bundlewithpath:@"/system/library/privateframeworks/batterycenter.framework"]; bool success = [bundle load]; if(success) { class bcbatterydevice = nsclassfromstring(@"bcbatterydevice"); id si = [[bcbatterydevice alloc] init]; nslog(@"charging: %@", [si valueforkey:@"charging"]); } } - (void)commonutilities { nsbundle *bundle = [nsbundle bundlewithpath:@"/system/library/privateframeworks/commonutilities.framework"]; bool success = [bundle load]; if(success) { class commonutilities = nsclassfromstring(@"cutwifimanager"); id si = [commonutilities valueforkey:@"sharedinstance"]; nslog(@"is wi-fi enabled: %@", [si valueforkey:@"iswifienabled"]); nslog(@"wi-fi scaled rssi: %@", [si valueforkey:@"wifiscaledrssi"]); nslog(@"wi-fi scaled rssi: %@", [si valueforkey:@"lastwifipowerinfo"]); } }
although classes back, of respected values null weird since must true, e.g. i'm connected wi-fi iswifienabled
should yes
.
what missing code doesn't return whats expected? need entitlement(s)? if exactly?
in swift, managed working without batterycenter
headers. i'm still looking way access list of attached batteries without using bcbatterydevicecontroller
, have working far:
swift 3:
guard case let batterycenterhandle = dlopen("/system/library/privateframeworks/batterycenter.framework/batterycenter", rtld_lazy), batterycenterhandle != nil else { fatalerror("batterycenter not found") } guard let batterydevicecontrollerclass = nsclassfromstring("bcbatterydevicecontroller") as? nsobjectprotocol else { fatalerror("bcbatterydevicecontroller not found") } let instance = batterydevicecontrollerclass.perform(selector(("sharedinstance"))).takeunretainedvalue() if let devices = instance.value(forkey: "connecteddevices") as? [anyobject] { // have more 1 battery in connecteddevices if device using smart case battery in devices { print(battery) } }
swift 2.2:
guard case let batterycenterhandle = dlopen("/system/library/privateframeworks/batterycenter.framework/batterycenter", rtld_lazy) batterycenterhandle != nil else { fatalerror("batterycenter not found") } guard let c = nsclassfromstring("bcbatterydevicecontroller") as? nsobjectprotocol else { fatalerror("bcbatterydevicecontroller not found") } let instance = c.performselector("sharedinstance").takeunretainedvalue() if let devices = instance.valueforkey("connecteddevices") as? [anyobject] { // have more 1 battery in connecteddevices if device using smart case battery in devices { print(battery) } }
this logs:
<bcbatterydevice: 0x15764a3d0; vendor = apple; productidentifier = 0; parts = (null); matchidentifier = (null); baseidentifier = internalbattery-0; name = iphone; percentcharge = 63; lowbattery = no; connected = yes; charging = yes; internal = yes; powersource = yes; poweredsourestate = ac power; transporttype = 1 >
Comments
Post a Comment