Belphegor
Belphegor

Reputation: 1843

Android: How to interpret pwi (Power Use Item) from battery stats dumpsys

I am currently trying to understand the output of my batterystats after following the instructions listed here by Google: https://developer.android.com/studio/command-line/dumpsys#inspect_machine-friendly_output

In the identifiers section there is something call "pwi" or Power Use Item and it mentions that it can be read as label/mAh, but when I look at my output I do not seem to understand what it is telling me.

10254   l   pwi uid 84.8    0   51.0    112

Is 84.8 the label and 0 is the mAh? What kind of information can I learn from this?

Upvotes: 0

Views: 85

Answers (1)

Morrison Chang
Morrison Chang

Reputation: 12121

So what I've been able to find is that the line is being printed in: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/os/BatteryStats.java

search for POWER_USE_ITEM_DATA using the search webpage Find button tool. I think what you are seeing is dumpLine on line #4563,

private static final String POWER_USE_ITEM_DATA = "pwi";

final ProportionalAttributionCalculator proportionalAttributionCalculator =
        new ProportionalAttributionCalculator(context, stats);

final List<UidBatteryConsumer> uidBatteryConsumers = stats.getUidBatteryConsumers();
for (int i = 0; i < uidBatteryConsumers.size(); i++) {
    UidBatteryConsumer consumer = uidBatteryConsumers.get(i);
    dumpLine(pw, consumer.getUid(), category, POWER_USE_ITEM_DATA, "uid",
            formatCharge(consumer.getConsumedPower()),
            proportionalAttributionCalculator.isSystemBatteryConsumer(consumer) ? 1 : 0,
            formatCharge(consumer.getConsumedPower(BatteryConsumer.POWER_COMPONENT_SCREEN)),
            formatCharge(
                    proportionalAttributionCalculator.getProportionalPowerMah(consumer)));
}

which appears to have the right number of fields and the '0' you are referring to is a boolean flag (system process==1 perhaps), otherwise the later items represent mAh. In the code search site, you can click on ProportionalAttributionCalculator class to see the method's source code. I believe that file is where the other battery stats are output, so your output may require context values displayed elsewhere.

Upvotes: 0

Related Questions