English 中文(简体)
电池组
原标题:Getting iPhone s battery level

我有一个简单的问题。 如何达到电池级?

[UIDevice currentDevice] batteryLevel]

足够简单? 但是,有水面捕获量<>-><>>。 我可以使用IDKit。 这里是我迄今为止所写的,但我认为这行不通:

    // notification port
IONotificationPortRef nport = IONotificationPortCreate(kIOMasterPortDefault);

CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(nport), kCFRunLoopDefaultMode);

CFMutableDictionaryRef matching = IOServiceMatching("IOPMPowerSource");

kern_return_t kr = IOServiceAddMatchingNotification(nport, kIOFirstMatchNotification, matching, (IOServiceMatchingCallback)power, self, &powerIterator);

NSLog(@"Kernel said %d",kr);

power((void*)nport,powerIterator);

我仍然相信,为了找回电池水平,你必须依靠IOKit。 我的申请并不使用家庭调查,因为这是一个低层次的申请,无法使用家庭调查。 这里是我利用的框架:

alt text http://img837.imageshack.us/img837/1829/ Screenshot20100718at211.png

最佳回答

此前,我撰写了一个称为“iox”的方案,与“ioreg”相似,但使我更容易向“IOKit”电话翻译。 当我用手提电脑操作时,我看到以下电池级。

AppleSmartBattery - IOService:/AppleACPIPlatformExpert/SMB0/AppleECSMBusController/AppleSmartBatteryManager/AppleSmartBattery
        CurrentCapacity = 11678
        FullyCharged = YES
        DesignCapacity = 13000
        MaxCapacity = 11910
        ...

在法典中,即

IOServiceNameMatching( "AppleSmartBattery" );

我没有想法,如果这个名字在SOS上是一样的,但我会试图找到像你可以操作的Oreg那样的方案,或撰写一些简单的文件,以记录相应的内容。

http://www. opensource.apple.com/source/IOKitTools/IOKitTools/IOKitTools-78/“rel=“noreferer”>IOKitTools,它只应汇编成册。

Edit:

CFMutableDictionaryRef matching , properties = NULL;
io_registry_entry_t entry = 0;
matching = IOServiceMatching( "IOPMPowerSource" );
//matching = IOServiceNameMatching( "AppleSmartBattery" );
entry = IOServiceGetMatchingService( kIOMasterPortDefault , matching );
IORegistryEntryCreateCFProperties( entry , &properties , NULL , 0 );
NSLog( @"%@" , properties );
CFRelease( properties );
IOObjectRelease( entry );

增加一些安全检查。 一旦发现你想要的具体财产,你就能够直接获得这些财产,而不是利用IORegistryCreateCFProperties来一劳永逸地获得这些财产。

IOKit是一个大树。 IOPM Power 来源可能无法直接掌握你想要的属性,在这种情况下,你需要通过子女来生育。 利用像奥雷格这样的东西可以告诉你,在你开始编码之前,你会想什么。

问题回答

我没有监狱经纪人发展的经验,但 这份指南可能有用。

页: 1

你可能知道,你真的可以“而不是在“i”上使用“IDKit”,因此我不敢肯定你对什么。





相关问题
Write and test sub func

I m trying to write sub func for nachOS but when I combines it doesn t work. Don t know the reason. Details: In ../userprog/syscall.h Add : #define SC_Sub 11 int Sub(int a, int b); In ../test/ ....

Current Linux Kernel debugging techniques

A linux machine freezes few hours after booting and running software (including custom drivers). I m looking a method to debug such problem. Recently, there has been significant progress in Linux ...

How to debug driver load error?

I ve made a driver for Windows, compiled it and tried to start it via SC manager, but I get the system error from the SC manager API: ERROR_PROC_NOT_FOUND The specified procedure could not be found. ...

Configuring kernel

After create a new system call, how to update the kernel? I tried these lines, make-kpkg clean fakeroot make-kpkg -initrd -append-to-version=-custom kernel_image kernel_headers But Ubuntu asked me ...

What is the exact architecture/components of MinWin?

I ve always wanted a minimal windows NT build . Sounds like one s already there : MinWin. Can anyone tell me the exact design or architecture of MinWin and is it used in Windows 7 ? Windows Server ...

uniprocessor or multiprocessor

On unix, how could we know whether the system is multiprocessor or uniprocessor?

热门标签