目前,应用程序商店中有一些应用程序(所以不需要越狱)告诉您:
- **Current Maximum Capacity** vs **Manufacturer's Capacity**
- **Current Discharge Rate**
- **Lifetime Battery Cycle Count**


当UIDevice提供的电池健康信息如此之少,几乎没有电池健康和性能信息时,这些应用程序如何获得如此多的电池健康信息。
发布于 2016-03-22 08:21:53
这类应用程序很可能使用IOKit框架,该框架在OS上是公开的,而在iOS上是私有的(苹果不允许为apps应用程序使用私有框架,尽管有时在审查过程中可能会忽略它)。
您可以看到一个示例项目这里。
发布于 2016-04-29 07:15:22
我开发了一个解决方案,允许您在不调用任何私有API调用的情况下获取这些信息(尽管我肯定不能保证苹果会批准它)。
虽然所讨论的信息确实来自IOKit,但我已经找到了一种无需依赖IOKit就能获得它的方法。我的解决方案绝对不依赖任何类型的私有API。相反,我开发了一个名为UIDeviceListener的组件,它有效地劫持了来自UIDevice的IOKit数据。
试试看,我已经编写了一个简单的示例程序:https://github.com/eldoogy/PowerData
例如,它检索的IOKit字典看起来很像(请注意,它可能因iOS版本和设备模型、生成等而有所不同):
{
AdapterDetails = {
Amperage = 1000;
Description = "usb host";
FamilyCode = "-536854528";
PMUConfiguration = 1000;
Watts = 5;
};
AdapterInfo = 16384;
Amperage = 1000;
AppleRawCurrentCapacity = 1279;
AppleRawMaxCapacity = 1275;
AtCriticalLevel = 0;
AtWarnLevel = 0;
BatteryData = {
BatterySerialNumber = REDACTED;
ChemID = 355;
CycleCount = 524;
DesignCapacity = 1420;
Flags = 640;
FullAvailableCapacity = 1325;
ManufactureDate = REDACTED;
MaxCapacity = 1273;
MfgData = REDACTED;
QmaxCell0 = 1350;
StateOfCharge = 100;
Voltage = 4194;
};
BatteryInstalled = 1;
BatteryKey = "0003-default";
BootBBCapacity = 52;
BootCapacityEstimate = 2;
BootVoltage = 3518;
CFBundleIdentifier = "com.apple.driver.AppleD1815PMU";
ChargerConfiguration = 990;
CurrentCapacity = 1275;
CycleCount = 524;
DesignCapacity = 1420;
ExternalChargeCapable = 1;
ExternalConnected = 1;
FullyCharged = 1;
IOClass = AppleD1815PMUPowerSource;
IOFunctionParent64000000 = <>;
IOGeneralInterest = "IOCommand is not serializable";
IOInterruptControllers = (
IOInterruptController34000000,
IOInterruptController34000000,
IOInterruptController34000000,
IOInterruptController34000000
);
IOInterruptSpecifiers = (
<03000000>,
<26000000>,
<04000000>,
<24000000>
);
IOMatchCategory = AppleD1815PMUPowerSource;
IOPowerManagement = {
CurrentPowerState = 2;
DevicePowerState = 2;
MaxPowerState = 2;
};
IOProbeScore = 0;
IOProviderClass = AppleD1815PMU;
InstantAmperage = 0;
IsCharging = 0;
Location = 0;
Manufacturer = A;
MaxCapacity = 1275;
Model = "0003-A";
Serial = REDACTED;
Temperature = 2590;
TimeRemaining = 0;
UpdateTime = 1461830702;
Voltage = 4182;
"battery-data" = {
"0003-default" = <...>;
"0004-default" = <...>;
"0005-default" = <...};
"built-in" = 1;
}发布于 2016-03-29 05:50:53
这个项目可以帮助你找出电池信息。
https://stackoverflow.com/questions/36024247
复制相似问题