- Get complete information about the battery
adb shell dumpsys battery - Check the current battery level
adb shell cmd battery get level - Set custom battery level
adb shell dumpsys battery set level <value>
Modern smartphones are sophisticated machines that can handle hundreds of processes and multiple apps running simultaneously. Despite processors getting more powerful and power-efficient, poor battery life has always been a serious concern for Android users. Android offers settings to extend battery life. Still, the OS doesn’t let users check the status of battery health, its current capacity, charge cycles, manufacturing date, etc. from its regular interface. Here is how to check the battery’s health and detailed technical information using ADB commands.
If it’s your first encounter with ADB and you don’t know how to use commands on Android, try one of the following methods to harness the power of ADB:
- Set up ADB on your computer
- Set up ADB over Wi-Fi to use commands wirelessly
- Use aShell Terminal app on your device
The first 2 methods require USB debugging enabled via Developer options. Also, do not forget to extend the screen timeout to 5-10 minutes from the Display settings.
Battery-related ADB Commands for Android
Now that you are ready to use ADB commands, let’s check out how to check battery health, charge cycle count, charge level, and so on.
1. Check Battery Health, Capacity, and Charge Cycle
Open a PowerShell or Command Prompt window and execute the following command for a detailed overview of your battery health and status.
adb shell dumpsys battery
The screenshot above shows the technical information about the battery of my 2-month-old Samsung Galaxy S24 Ultra. I attempted to decipher the info I got using the dumpsys
battery command.
- The first 4 entries in the report tell about the current power source. The
true
value for ‘USB powered’ means the device is connected to a computer. - Charge counter: The first 4 digits in the Charge counter display the exact battery capacity in mAh (milliampere-hour). The value is relative to the current charging level. Thus, if the value of the charging counter is 4937000 at 100% charge, it means my S24 Ultra’s battery’s capacity is 4937mAh which is in line with Samsung’s rated capacity of 4855mAh for the device. Suppose your Android device is currently charged 62% and its capacity is 3051 mAh, you can use the following formula to get its total remaining capacity.
-
3051÷62%= 4920 (approx. 5000mAh)
-
- Level: It shows the current battery level which is 100%.
- Temperature: The value for this item is 10 times the temperature of the battery in Celcius. Thus, if the value is 334, the temperature is 33.4° Celcius.
- LLB CAL: Li-ion battery calibration date. The date represents the day (YYYY-MM-DD) the battery was first installed on the phone or tablet. This might also indicate the manufacturing date of your Android device. The date when the battery was fitted and calibrated in my Galaxy S24 is 20240118 (January 18, 2024).
- LLB Current: This item shows the date (year, month, and date) when your device was fully charged or completed one charge cycle. YEAR2024M3D21 means my phone was fully charged on 21-03-2024.
- mSavedBatteryAsoc: Li-ion batteries’ charging capacity dwindles over time. The ASoC (absolute state of charge) value displays the energy the battery can hold compared to its original rated capacity. If the health score is 100, your battery will charge at full capacity. However, the ASoC score may decrease over months. A score between 90 and 100% is considered good.
- mSavedBatteryUsage: The first three digits of this item’s value show the number of charging cycles. My Galaxy 24 Ultra has completed 350 charging cycles in just two months, which doesn’t make sense. The mSavedBatteryUsage value doesn’t tell about the charging cycle but the number of times the device was plugged into a power source.
2. Check Battery Level with ADB
Android allows users to show the current battery level percentage in the status bar. However, if you want to check the battery level of your Android device using an ADB command, try one of the following.
adb shell dumpsys battery | grep level
adb shell cmd battery get level
adb shell dumpsys battery get level
ADB will print a numerical value as output to show the battery level in percentage.
3. Check Battery Usage Time for Apps and Processes
Using the next ADB command, you can check the timestamps for app battery usage. It also prints the statistics of device CPU wake-up, wake lock, charge, discharge, device idle, and screen on time. You can use this data to analyze battery activities and stop apps and processes running in the background to save the battery.
adb shell dumpsys batterystats
You can use the following command to reset the battery stats.
adb shell dumpsys batterystats --reset
Other battery stats dump options or parameters:
- –history: Show only history data.
- –charged: Only output data since last charged.
- –daily: Only output full daily data.
- –reset: Reset the stats, clearing all current data.
- –reset-all: Reset the stats, clearing all current and past data.
- –settings: Dump the settings key/values related to batterystats.
- –cpu: Dump CPU stats for debugging purposes.
- –wakeups: Dump CPU wakeup history and attribution.
- –-power-profile: Dump the power profile constants.
- –usage: Write battery usage stats.
For example, if you want to check the battery usage stats for a specific app, you can use the following command followed by the package name of the Android app.
adb shell dumpsys batterystats --charged <package-name>
4. Settings Battery Custom Level using ADB
Can a phone’s battery charge beyond 100%? Certainly not but the screenshot showing a 150% battery level is not fake. An ADB command allows you to set a custom battery level on your Android device. You can prank your friends with this ADB trick.
Connect your phone or tablet to your computer, launch a command window, and execute the following.
adb shell dumpsys battery set level <value>
To reset the battery level to the original, use the following command.
adb shell dumpsys battery reset
5. Enable or Disable Battery Optimizations for Specific Apps
Putting unused or battery-draining apps can extend the battery life on Android devices. However, if your phone doesn’t have the feature, you can use ADB commands to enable or disable battery optimizations for apps and services. Let’s see how to do this.
- Execute the following command to get a list of whitelisted apps with permission to bypass battery optimization settings. You’ll find the apps under Whitelist system apps.
adb shell dumpsys deviceidle or adb shell dumpsys deviceidle whitelist
- Note down the package names of the apps or services you want to remove from the whitelist.
adb shell dumpsys deviceidle sys-whitelist -<package-name>
- To restore the app to the whitelist, use-
adb shell dumpsys deviceidle sys-whitelist +<package-name>
- To verify that the app was successfully removed from the battery whitelist and put to sleep, use the following command again and check the whitelisted system apps.
adb shell dumpsys deviceidle whitelist
- If you’re a Samsung user, navigate to Settings > Battery > Background usage limits and check Sleeping apps and Deep sleeping apps.
6. Forcing Sleep Mode on Android with ADB
Android offers a feature called Sleep Mode that stops most background activities when the device is not used to prevent battery drain. You can configure the Sleep Mode from the device settings. However, if you’re looking for a way to do the same via ADB, it is possible.
To force Sleep Mode, use-
adb shell dumpsys deviceidle force-idle
adb shell dumpsys deviceidle enable
This will activate the Sleep Mode which will remain active until you disable it using one of the following commands or restarting the device.
adb shell dumpsys deviceidle unforce
adb shell dumpsys deviceidle disable
7. Using Termux to Check Battery Charge Cycle and Capacity
You can also ADB commands on your phone without a computer with the aShell Terminal app. Users with a rooted Android device should follow the steps below to check battery capacity and charge cycle via Termux.
- Open Termux, type the following command and press Enter.
su
- Termux will prompt you to grant root privilege. Tap Grant.
- To check the charge cycle count of your phone’s battery, type or paste the following command and press Enter.
cat /sys/class/power_supply/battery/cycle_count
- Now execute the following command to check the battery capacity in mAh.
cat /sys/class/power_supply/battery/charge_full
- Please note that the mAh value depends on the current charge level. To get the full capacity, ensure your Android device is fully charged. The battery capacity of my S24 Ultra at 79% charge level is 3958mAh.
Using ADB, you can check battery health, charging level, battery capacity, set charging level, and enable or disable Sleep Mode for apps.
Read Next: List of Battery Optimization Commands for Android