Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android battery usage report for developers

On Gingerbread users can report apps for their battery usage, by going to Settings -> About phone -> Battery use, and then tap on a specific app.

My question is, as a developer where can I see these reports?

They seem very useful because they contain information on what type of wake locks you might be leaking.

like image 796
Erdal Avatar asked Aug 21 '11 00:08

Erdal


People also ask

What is battery historian?

The Battery Historian tool provides insight into a device's battery consumption over time. At a system-wide level, the tool visualizes power-related events from the system logs in an HTML representation.


2 Answers

Sorry I don't think this information is currently available. It is being collected, but at this point there is no UI for developers to retrieve it. (This is also true for reports coming about running services.)

like image 136
hackbod Avatar answered Sep 21 '22 15:09

hackbod


Check out PowerUsageSummary and PowerUsageDetail from the subdir fuelgauge in the Settings package. The relevant methods are reportBatteryUse() in PowerUsageDetail and processAppUsage() in PowerUsageSummary.

Most of the information comes from an mstats object which is created by an internal API call:

import com.android.internal.os.BatteryStatsImpl;
...
mStats = com.android.internal.os.BatteryStatsImpl.CREATOR
         .createFromParcel(parcel);
mStats.distributeWorkLocked(BatteryStats.STATS_SINCE_CHARGED);

I never tried to call these methods from your own non-system app, so you have to find out if it works.

like image 38
Flow Avatar answered Sep 20 '22 15:09

Flow