When you develop or test apps that react to low‑battery warnings, power‑saving modes, or temperature throttling, you often need a reliable way to reproduce those conditions without waiting for the device to actually drain. Android provides a hidden set of commands that let you simulate battery level, health, and temperature directly from a computer. This tutorial walks you through the entire process – from enabling the required developer settings to verifying that the simulated values are being used by the system.
Why this matters: USB debugging opens a secure channel between your PC and the device, allowing adb to issue system‑level commands. Without it, the simulation commands will be rejected.
adb devices. You should see a line with your device’s serial number followed by device.
adb devices
List of devices attached
1234567890ABCDEF device
unauthorized, unlock the phone and accept the “Allow USB debugging?” dialog.Tip: If no devices appear, try reconnecting the USB cable or installing the appropriate USB driver (Windows) or enabling adb permissions (macOS/Linux).
Android’s battery information is exposed through the BatteryManager service. The adb shell dumpsys battery command can both read and write simulated values. The relevant fields are:
When you issue a set command, the system replaces the real sensor values with the ones you provide until you reset the service.
adb shell dumpsys battery set level 10
discharging so the UI shows the battery icon without a charging bolt:
adb shell dumpsys battery set status 3
adb shell dumpsys battery
You should see something like:
Current Battery Service state:
AC powered: false
USB powered: false
Wireless powered: false
Max charging current: 0
Max charging voltage: 0
Charge counter: 0
status: 3
health: 2
present: true
level: 10
scale: 100
voltage: 3800
temperature: 300
What to expect: Most Android UI elements (low‑battery warning, adaptive battery throttling, etc.) will now behave as if the device truly has 10 % charge.
adb shell dumpsys battery set temperature 450
overheat (value 3) to trigger thermal throttling dialogs:
adb shell dumpsys battery set health 3
adb shell dumpsys battery as before. Look for the new temperature and health values.Why this matters: Some apps, especially games and video‑players, lower their performance when the system reports an over‑heat condition. Testing under these simulated values helps you verify that your app handles thermal events gracefully.
Real‑world scenarios often involve multiple constraints. For example, a device might be at 15 % battery and simultaneously overheating. To simulate this:
adb shell dumpsys battery set level 15
adb shell dumpsys battery set temperature 460
adb shell dumpsys battery set health 3
adb shell dumpsys battery set status 3
After issuing the four commands, run adb shell dumpsys battery to confirm all fields are set correctly.
adb shell dumpsys battery reset
adb reboot
Important: Forgetting to reset can leave the system thinking it is still low on power, which may cause unexpected shutdowns or reduced performance.
dumpsys battery set command may be restricted for security reasons. In that case, you can use the adb shell am broadcast workaround described below.Some manufacturers (e.g., Samsung, Xiaomi) run a background service that periodically refreshes the battery status from the hardware sensor, overwriting the simulated values. To keep the simulation active:
set commands in a loop. Create a simple batch or shell script:
# Windows batch example
:loop
adb shell dumpsys battery set level 10
adb shell dumpsys battery set temperature 300
timeout /t 30 >nul
goto loop
adb shell settings put global battery_estimate_charging_time -1 trick to silence the auto‑refresh (works on Android 10‑11).If the dumpsys battery set command is blocked, you can still influence the system by broadcasting an intent that mimics a battery change event. This method does not change the underlying BatteryManager values, but many apps listen for the broadcast and react accordingly.
adb shell am broadcast -a android.intent.action.BATTERY_CHANGED \
--ei level 10 \
--ei scale 100 \
--ei status 3 \
--ei temperature 300 \
--ei health 2
Use this approach when you only need to test your own app’s BroadcastReceiver for ACTION_BATTERY_CHANGED. System‑wide UI changes (like the low‑battery icon) will not be affected.
Suppose you are developing a fitness tracker that stops GPS updates when the battery falls below 20 % to preserve charge. Using the steps above, you can:
This quick feedback loop replaces the hours‑long process of actually draining the battery.
By enabling Developer Options, connecting via ADB, and using the dumpsys battery set command (or the broadcast fallback), you can reliably simulate any battery charge level, temperature, health, and charging status on an Android device without rooting. The method is fast, reversible, and works across most Android versions, making it an essential tool for developers, QA engineers, and power‑conscious users who need to see how their device behaves under extreme conditions.









