Erdal
Erdal

Reputation: 1502

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.

Upvotes: 14

Views: 3080

Answers (2)

hackbod
hackbod

Reputation: 91351

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.)

Upvotes: 8

Flow
Flow

Reputation: 24083

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.

Upvotes: 5

Related Questions