14

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.

jimmym715
  • 1,512
  • 1
  • 16
  • 25
Erdal
  • 1,472
  • 3
  • 16
  • 33
  • 2
    Wake Locks? Use `adb shell dumpsys power` or on rooted devices look at https://market.android.com/details?id=me.kennydude.dev.urlopener&e -Anything else like on the web would be an invasion on the user's privacy :) – Joe Simpson Aug 27 '11 at 19:34

2 Answers2

8

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

hackbod
  • 90,665
  • 16
  • 140
  • 154
  • 1
    Indeed it is not available to developers; I tested this last week by writing a CPU-hogging app, then reporting the battery usage. I saw an ANR report I sent in the Market Developer Console, but not the battery report. Certainly this info would be useful for developers to receive, to corroborate Market comments complaining of high battery usage and to improve their apps in general. – Christopher Orr Aug 30 '11 at 17:44
  • thanks for the answer! I hope in the near future we will be able to see both wake lock and running services reports. sorry about the bounty I was out of internet area and couldn't login :( – Erdal Aug 30 '11 at 18:23
  • 2 years have passed. Has anything changed? Can developers measure the impact of specific code on the battery? – AlikElzin-kilaka Aug 04 '13 at 08:45
5

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.

Flow
  • 23,572
  • 15
  • 99
  • 156
  • that's interesting but it answers a little different question. This is probably how they collected those stats, but my question was, after the user submits those stats to Google, is there any place where us, developers can see them? – Erdal Aug 23 '11 at 19:33
  • Are you sure that what you understand under "report" does report the battery usage? Isn't that just the bug and log collector feature that also appears on "Force Closes" of an App. These reports are reported directly to the owner of the app via market. – Flow Aug 24 '11 at 19:10
  • 1
    I'm pretty sure it's battery usage data because I looked at the preview of what I am sending. You can try it yourself if you have a phone running gingerbread. – Erdal Aug 25 '11 at 03:16