When you develop or test Android apps that react to battery conditions, you quickly discover that waiting for the real battery to drain or charge is impractical. Android provides a hidden ADB interface that lets you override the system‑reported battery level, charge state, and even temperature. This tutorial walks you through the entire process—pre‑flight checks, command syntax, verification, and troubleshooting—so you can reliably simulate any battery scenario without rooting the device.
Many apps change their behavior based on power availability: video players may lower bitrate, location services may pause, or background sync may be deferred. Testing those pathways manually is tedious because you would need to:
Using the ADB shell dumpsys battery interface lets you set these values instantly, giving you deterministic, repeatable test cases.
Make sure the device is charged above 30 % before you begin. Although the simulation does not affect the actual charge, a low‑battery device may power‑off during the session, interrupting the test.
Build number seven times).If you are on Windows, ensure the adb.exe directory is added to your PATH variable so you can call adb from any command prompt.
adb devices. You should see a line with your device’s serial number and the word device.
adb devices
List of devices attached
FA6B12345678 device
unauthorized, check the phone for a dialog asking to allow USB debugging and tap Allow.Successful connection is the foundation; all following commands depend on it.
Android’s battery service only accepts overrides when it is explicitly placed in “test mode”. This is a one‑time command per session.
adb shell dumpsys battery set status 1
Explanation: status 1 tells the system the battery is UNKNOWN, which unlocks the override fields.
adb shell dumpsys battery
Look for a line that reads Battery Status: UNKNOWN. If you see Battery Status: CHARGING or DISCHARGING, repeat step 2.
Battery level is expressed as an integer from 0 to 100 representing the percentage of charge.
15 for a low‑battery scenario.adb shell dumpsys battery set level 15
adb shell dumpsys battery | grep "level"
The output should be level: 15.
Repeat the command with any value between 0 and 100 to test different thresholds.
Charging state influences how the system reports Battery Status. The valid values are:
| Value | Status |
|---|---|
| 1 | UNKNOWN (used for test mode) |
| 2 | CHARGING |
| 3 | DISCHARGING |
| 4 | NOT CHARGING |
| 5 | FULL |
adb shell dumpsys battery set status 2
adb shell dumpsys battery set status 3
adb shell dumpsys battery | grep "Battery Status"
Combine the level and status commands to mimic, for example, a 5 % battery that is still charging (a rare but possible edge case).
Temperature is reported in tenths of a degree Celsius (e.g., 300 = 30.0 °C). Extreme temperatures trigger thermal throttling or safety shutdowns, which some apps monitor.
420 for 42 °C.adb shell dumpsys battery set temperature 420
adb shell dumpsys battery | grep "temperature"
Expected output: temperature: 420.
Typical safe operating ranges are 20 °C – 45 °C (200 – 450). Values outside this range may cause the system to display a warning, which you can use to test your app’s response.
Most developers prefer to see the simulated values inside the OS UI rather than only via ADB. You can do this with the built‑in Developer options > Battery usage screen or a simple third‑party app that reads BatteryManager values.
Now that the system reports the values you need, launch the app you are testing. Observe how it reacts:
Battery Status: CHARGING = false?Because the override is global, any app on the device will see the same fake values, making it easy to compare behaviors side‑by‑side.
When you finish testing, you must return the system to its natural state. Failing to do so can cause the UI to display an incorrect percentage for days.
adb shell dumpsys battery reset
adb shell dumpsys battery now shows Battery Status: CHARGING/DISCHARGING and a realistic level value.
After a reset, the phone will again report the true battery level, temperature, and charge state.
Ensure the Platform‑Tools folder is in your system PATH. On Windows, you can add it via System > Advanced system settings > Environment Variables. On macOS/Linux, edit ~/.bash_profile or ~/.zshrc to include export PATH=$PATH:/path/to/platform-tools.
Battery Status: UNKNOWN after resetSome OEM skins (e.g., Samsung One UI) keep the battery service in test mode until a full reboot. Power‑cycle the device and run adb shell dumpsys battery again.
Android may re‑initialize the battery service when entering deep sleep. To keep the override active, you can keep the device awake using adb shell svc power stayon true or enable Stay awake while charging in Developer options. Remember to disable it after testing.
Older Android versions (< 6.0) ignore the temperature field in test mode. In that case, you can only test level and status. For newer versions, make sure you are using at least Android 7.0 (API 24) where the field is honored.
Apps that query the hardware directly via the BatteryManager API will see the overridden values, but apps that read the sysfs path /sys/class/power_supply/battery/ may bypass the override. In such rare cases, you need root to change those files, which is outside the scope of this no‑root tutorial.
#!/bin/bash
adb shell dumpsys battery set status 2
adb shell dumpsys battery set level $1
adb shell dumpsys battery set temperature $2
Run with ./simulate.sh 30 350 to set 30 % and 35.0 °C.
dumpsys battery commands to your Gradle or Fastlane scripts, ensuring every test run starts from a known power state.adb shell dumpsys batterystats --reset && adb shell dumpsys batterystats --history) and feed it to Battery Historian to see how the system would have behaved with a real battery drain.While the ADB interface is part of the Android Open Source Project, manufacturers sometimes add custom battery managers that ignore the test mode. Here are a few observations:
reset to clear the test flag.temperature field is capped at 500 (50 °C) even in test mode.If you encounter a device that simply does not accept the commands, verify the Android version with adb shell getprop ro.build.version.release and consult the device’s developer forum for any known quirks.
Do not leave the battery service in test mode on a daily‑use device. The UI will display inaccurate percentages, which can lead to missed low‑battery warnings and unexpected shutdowns.
Reserve this method for development machines, test phones, or emulators that are not your primary communication device.
By following the six straightforward ADB commands—setting the service to test mode, adjusting level, status, and temperature, and finally resetting—you gain full control over how Android reports its power state. This empowers you to:
The technique works on any non‑rooted device running Android 7.0 or newer, with only a USB cable and the free Platform‑Tools package. Remember to reset the service when you’re done, and you’ll have a reliable, repeatable testing workflow that any Android developer can adopt.









