获取iOS上的电池健康信息

arknldoa  于 2023-03-31  发布在  iOS
关注(0)|答案(2)|浏览(163)

目前有应用程序在应用程序商店(所以它不需要越狱),告诉你:
1.你的iPhone上的电池电量的确切百分比值.我试过苹果的官方Code Sample,虽然它会告诉你当你的iPhone充电和放电,但它给我的值在5%的步骤.这些应用程序如何获得确切的值电池百分比

  • Battery Health等应用程序显示
    *当前最大容量vs制造商容量
    *电流放电率
    *电池寿命周期计数
  • 同一应用程序还提供了有关手机充电时的充电率(单位:瓦)(检查图像)和当前充电器的额定功率的信息。

第一节第一节第一节第一节第一次

  • 当[UIDevice]提供如此少的电池健康信息,几乎没有电池健康和性能信息时,这些应用程序如何获得如此多的电池健康信息。*
a1o7rhls

a1o7rhls1#

我已经开发了一个解决方案,可以让你在不调用任何私有API调用的情况下获得这些信息(尽管我肯定不能保证Apple会批准它)。
虽然这些信息确实来自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;
}
nkoocmlb

nkoocmlb2#

这类应用程序很可能使用IOKit框架,该框架在OS X上是公共的,但在iOS上是私有的(苹果不允许对App Store应用程序使用私有框架,尽管有时在审查过程中可能会被忽略)。
您可以看到一个示例项目here

相关问题