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.
adb version in a terminal.adb bugreport or dumpsys batterystats to capture a period of usage.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.
There are two common ways to collect data. Choose the one that matches your workflow.
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.
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.
Battery Historian is an open‑source web app written in Python. Running it locally guarantees that your usage data never leaves your machine.
pip if they are not already present.python3 -m venv bh-env
source bh-env/bin/activate # macOS/Linux
bh-env\Scripts\activate # Windows
git clone https://github.com/google/battery-historian.git
cd battery-historian
pip install -r requirements.txt
python3 historian.py --port 9999
http://localhost:9999. You should see the Historian upload page.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.
Depending on the capture method you used, the upload steps differ slightly.
bugreport.zip.batterystats protobuf and renders a timeline.batterystats.txt if it isn’t already.The default view is a stacked timeline with several layers. Hover over any block to see a tooltip with exact timestamps and metrics.
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.
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.
.zip for bugreport, .txt for raw dump).batterystats protobuf version changed. Update Battery Historian to the latest commit (pull the repo again) and restart the server.Battery level line. Sudden drops may indicate a hardware issue rather than software.adb shell crontab (requires a rooted device). For non‑root, you can use Tasker to trigger adb shell dumpsys batterystats over Wi‑Fi.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.
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.









