Battery life is the single most visible metric of a phone’s health, yet many users never know why their device suddenly starts dying after a few hours. The culprit is almost always a misbehaving app or a system service that keeps the device awake, performs network syncs, or triggers frequent alarms. Android ships with a powerful diagnostic utility called Battery Historian that can turn raw power‑usage logs into a visual timeline, letting you spot the exact moment an app starts draining power.
adb folder to your PATH.Settings > About phone > Build number and tap seven times. Then enable USB debugging under Settings > System > Developer options.Battery Historian works on Android 5.0 (Lollipop) and newer. Older devices may not expose the needed bugreport data.
When you request a bugreport or a dumpsys batterystats snapshot, Android writes a detailed log that includes:
Battery Historian parses that log and draws a timeline where each colored bar represents a specific power‑use source. By reading the timeline you can answer questions such as:
LocationManagerService the real drain?adb version. You should see something like Android Debug Bridge version 1.0.41. If you get “command not found”, add the platform‑tools folder to your PATH.adb devices. The device serial number should be listed under List of devices attached.Battery Historian needs a log that covers a realistic usage period – typically 30 minutes to an hour of normal activity (unlocking, browsing, messaging, etc.). The easiest way is to record a full bugreport while you use the phone.
adb shell dumpsys batterystats --reset
This clears any previous statistics so the next capture reflects only the upcoming session.
adb bugreport bugreport.zip
The command creates a bugreport.zip file in the current folder. It contains the raw log plus a text version.
Why we reset the stats first: Android keeps cumulative counters that grow over weeks. Resetting guarantees the timeline you see belongs to the short test window, making it easier to spot spikes.
Battery Historian is a small Java program that runs a local web server. It does not require root and works offline.
batteryhistorian.jar from the official GitHub repository (e.g., GitHub releases). Save it to a convenient folder, e.g., ~/battery.java -jar batteryhistorian.jar
The console will show something like Running on http://127.0.0.1:9999/. Leave the process running.
http://localhost:9999/).bugreport.zip you generated earlier.The main view consists of several stacked rows:
Hover over any bar to see a tooltip with precise timestamps and duration. The tooltip also shows the UID, which you can map to an app name using the adb shell pm list packages -U command if needed.
Once you have identified a suspicious bar, note the package name (e.g., com.example.social). Verify the app’s identity on the phone:
adb shell dumpsys package com.example.social | grep -i "application-label" to see the human‑readable app name.Settings > Apps & notifications > See all apps and scroll to the name.If the package belongs to a system component (e.g., com.android.systemui), proceed with caution – disabling it may break core functionality. In most cases, the culprit will be a third‑party app that you can safely modify.
Depending on the nature of the drain, you have several safe options.
Settings > Apps & notifications > See all apps.Android 9+ provides a per‑app “Background restriction” toggle.
Location, microphone, and sensor permissions are common wake‑lock triggers.
If the app continues to misbehave after restrictions, uninstall it. Often a lighter alternative exists (e.g., a news reader that respects Doze).
Developers frequently fix battery‑drain bugs in newer releases. Open the Play Store, check for updates, and install them. Also ensure your device runs the latest stable Android version for your model.
Repeat the capture process to confirm the fix.
adb shell dumpsys batterystats --reset again.bugreport.zip and load it in Battery Historian.If the timeline still shows unexpected spikes, revisit the earlier steps – there may be multiple apps contributing to the drain.
bugreport.zip may be corrupted. Delete it and repeat the capture. Also verify that Java 8 or newer is installed (run java -version).adb shell dumpsys power to list active wake‑locks and cross‑reference timestamps.dumpsys batterystats snapshot instead:
adb shell dumpsys batterystats > batterystats.txt
java -jar batteryhistorian.jar batterystats.txt
Some manufacturers (e.g., Xiaomi, Huawei) apply aggressive proprietary power‑saving layers that hide wake‑locks from the standard API. If Battery Historian shows no activity yet you still experience rapid drain, try the following:
Settings > Battery > Battery usage) to see a high‑level breakdown. It may list “Android System” as a top consumer; in that case, a system update is often the only remedy.Never disable or force‑stop core system packages such as com.android.systemui, com.google.android.gms, or android. Doing so can render the UI unusable, break push notifications, or cause the device to boot loops. If you are unsure, create a full ADB backup first (see our “How to Back Up and Restore Your Android Phone Using ADB” tutorial).
Imagine a user reports that their Pixel 5 drops from 100 % to 70 % in under an hour of light usage. Following the steps above, the captured timeline reveals a 12‑minute wake‑lock held by com.whatsapp every time the screen turns off. The user disables background activity for WhatsApp, revokes the “Location – Always” permission, and restarts the phone. A second capture shows the wake‑lock bar reduced to a few seconds, and the battery now lasts close to the advertised 24 hours.
By using Battery Historian you gain a data‑driven view of power consumption, avoid guesswork, and can apply targeted fixes rather than blanket “battery‑saver” toggles that often hide the real problem.
Keep this workflow handy: capture → analyse → act → verify. Over time you’ll develop an intuition for the patterns that indicate a rogue app, and your Android device will stay alive longer between charges.









