Capture and Analyze Android Battery Usage with Battery Historian

12 min read Learn a step‑by‑step, no‑root method to record Android battery stats, run Battery Historian locally, and interpret the results to pinpoint power‑hungry apps. October 11, 2026 08:30 How to Capture and Analyze Android Battery Usage with Battery Historian (No Root)

Most Android users notice a sudden dip in battery life but have no concrete way to know which app or system component is the culprit. Android records low‑level power metrics in a hidden batterystats file, but the raw dump is unreadable to humans. Battery Historian converts that dump into an interactive timeline that highlights wake‑locks, CPU usage, network activity, and more.

This tutorial assumes you have a Windows, macOS, or Linux PC with adb installed and a USB cable or Wi‑Fi ADB connection to your phone. No root access is required.

Before you start

  • Charge your device to at least 80 % – the capture process may last 30 minutes to an hour.
  • Back up important data. The procedure only reads system logs, but it’s good practice before any deep‑diagnostic work.
  • Ensure Developer options are enabled (Settings > About phone > Tap Build number seven times). Then enable USB debugging (Settings > System > Developer options > USB debugging).
  • Install the latest Platform‑Tools on your PC. Verify with adb version in a terminal.

Overview of the workflow

  1. Reset the device’s battery stats to start with a clean slate.
  2. Use adb bugreport or dumpsys batterystats to capture a period of usage.
  3. Install Battery Historian locally (Python or Docker).
  4. Feed the captured file into Historian and open the generated HTML report.
  5. Interpret the timeline to locate the offending app or hardware component.

Step 1 – Resetting battery statistics

Resetting ensures that the next capture reflects only the activity you will monitor, eliminating noise from previous days.

adb shell dumpsys batterystats --reset

After running the command, you should see no output. If you get permission denied, double‑check that USB debugging is enabled and that the device trusts your PC.

Step 2 – Capture real‑world usage

There are two common ways to collect data. Choose the one that matches your workflow.

Method A – Full bugreport (recommended for beginners)

A bugreport bundles batterystats together with logs, making it easy to hand over to Battery Historian.

# Start the capture – this will run until you stop it.
adb bugreport > bugreport.zip

Leave the phone in its normal usage pattern for at least 30 minutes. You can browse the web, watch a video, or let background apps run. When you feel the period is representative, press Ctrl+C on the PC to stop the capture.

The resulting bugreport.zip may be 30‑100 MB depending on activity.

Method B – Manual batterystats dump (for shorter sessions)

If you only need a few minutes of data, you can dump the stats directly.

# Start a background dump that writes every 30 seconds.
adb shell "while true; do dumpsys batterystats > /sdcard/batterystats.txt; sleep 30; done" &

After the desired interval, stop the loop with Ctrl+C on the PC, then pull the file:

adb pull /sdcard/batterystats.txt

Rename the file to batterystats.txt for consistency.

Step 3 – Install Battery Historian locally

Battery Historian is an open‑source web app written in Python. Running it locally guarantees that your usage data never leaves your machine.

Option 1 – Python virtual environment (cross‑platform)

  1. Install Python 3.8+ and pip if they are not already present.
  2. Open a terminal and create a virtual environment:
    python3 -m venv bh-env
    source bh-env/bin/activate   # macOS/Linux
    bh-env\Scripts\activate    # Windows
  3. Clone the Battery Historian repository:
    git clone https://github.com/google/battery-historian.git
    cd battery-historian
  4. Install dependencies:
    pip install -r requirements.txt
  5. Start the server on port 9999:
    python3 historian.py --port 9999
  6. Open a browser and navigate to http://localhost:9999. You should see the Historian upload page.

Option 2 – Docker (quick, isolated)

docker pull ghcr.io/google/battery-historian:latest
docker run -p 9999:9999 ghcr.io/google/battery-historian:latest

Docker handles all dependencies. Once the container is running, open http://localhost:9999 in a browser.

Running Battery Historian as a public web service (e.g., on a remote server) exposes detailed usage patterns. Always keep the tool local unless you fully trust the host.

Step 4 – Load the captured data into Historian

Depending on the capture method you used, the upload steps differ slightly.

Uploading a bugreport

  1. On the Historian web page, click Choose file and select bugreport.zip.
  2. Press Upload. The tool extracts the batterystats protobuf and renders a timeline.

Uploading a raw batterystats dump

  1. Rename the file to batterystats.txt if it isn’t already.
  2. On the upload page, choose Upload file and select the text file.
  3. Historian will parse the plain‑text format and generate the same visual output.

Step 5 – Understanding the Historian UI

The default view is a stacked timeline with several layers. Hover over any block to see a tooltip with exact timestamps and metrics.

  • Wake locks – Indicates when an app or system service prevented the CPU from sleeping. Long wake‑locks are a common drain.
  • CPU usage – Shows active CPU cores. Spikes often correlate with heavy processing.
  • Network activity – Separate rows for Wi‑Fi, mobile data, and Bluetooth. Unexpected background traffic can be a red flag.
  • Location requests – GPS usage is power‑hungry; frequent requests suggest a misbehaving app.
  • Screen state – When the screen is on, the battery naturally drains faster. Use this as a baseline.

To isolate a suspect, click the Filter dropdown and select a specific app package name. The timeline will then highlight only that app’s contributions.

Practical example

Suppose you notice a 2‑hour battery drop after a morning commute. In Historian you see a continuous wake‑lock from com.example.news that starts at 08:15 and ends at 10:45. The tooltip reads “Wake lock held for 150 seconds”. This suggests the news app is keeping the device awake even when the screen is off, likely due to a background service.

Troubleshooting common issues

1. No data appears after upload

  • Make sure you uploaded the correct file type (.zip for bugreport, .txt for raw dump).
  • Check the console where Historian is running – any parsing errors will be printed.
  • If the bugreport is corrupted (e.g., incomplete download), re‑run the capture.

2. "Permission denied" when resetting stats

  • Reconnect the device and accept the RSA fingerprint prompt.
  • On some OEMs (e.g., Xiaomi, Huawei), you must also enable USB debugging (Security settings) in the developer options.

3. Browser shows a blank page after upload

  • Ensure JavaScript is enabled.
  • If you’re using Docker, confirm the container’s port mapping is correct (host 9999 → container 9999).

4. The timeline is full of "unknown" entries

  • This usually happens on Android 13+ where the batterystats protobuf version changed. Update Battery Historian to the latest commit (pull the repo again) and restart the server.

Advanced tips and edge cases

  • Split‑tunneling analysis: If you use a VPN, enable the Show network activity per UID filter to see whether the VPN app itself is the drain.
  • Battery health check: Historian also displays the Battery level line. Sudden drops may indicate a hardware issue rather than software.
  • Long‑term monitoring: Automate periodic dumps with a simple shell script and schedule them via adb shell crontab (requires a rooted device). For non‑root, you can use Tasker to trigger adb shell dumpsys batterystats over Wi‑Fi.
  • Exporting the report: Click the Export as CSV button to download raw event data. This is handy for sharing with developers when filing bug reports.

Safety and privacy considerations

The bugreport contains a snapshot of all running processes, installed apps, and sometimes even logcat output that may include personal identifiers (e.g., email addresses). Treat the file as sensitive data. Delete it securely after you finish analysis, or keep it in an encrypted folder.

Wrapping up

By resetting the stats, capturing real‑world usage, and feeding the data into Battery Historian, you gain a visual, data‑driven view of what’s draining your Android battery. The process requires only ADB and a local Python (or Docker) installation, so it works on any device without rooting.

Once you identify the offending wake‑lock or network spike, you can take concrete action: disable background sync, force‑stop the app, adjust its battery‑optimisation settings, or report a bug to the developer. Re‑run the capture after making changes to verify the improvement – a reduced wake‑lock duration or lower network usage is a good sign.

Regularly repeating this workflow (e.g., once a month) helps you keep your device’s power profile healthy, especially after installing new apps or system updates.

User Comments (0)

Add Comment
We'll never share your email with anyone else.