Mobile applications must adapt their runtime operations according to device battery levels and charging states. For example, background sync services may defer network requests when battery power is critically low, video players may throttle resolution, and offline media caches may only download when the device is actively plugged into an AC wall charger. However, manually waiting for a physical smartphone battery to discharge or repeatedly connecting and disconnecting cables is tedious and impractical.
Android Debug Bridge (ADB) provides comprehensive battery emulation tools via the dumpsys battery service. Developers and QA engineers can mock battery discharge states, simulate custom battery percentages, test charger types, and trigger thermal alerts directly from the terminal without affecting physical hardware.
Inspecting Current Battery State and Hardware Telemetry
Connect your Android device with USB Debugging enabled, then query the battery subsystem:
adb shell dumpsys battery
The terminal outputs current real-time telemetry from the device’s battery management IC:
Current Battery Service state:
AC powered: false
USB powered: true
Wireless powered: false
Max charging current: 500000
Max charging voltage: 5000000
Charge counter: 2840000
status: 2
health: 2
present: true
level: 85
scale: 100
voltage: 4120
temperature: 295
technology: Li-ion
Simulating Battery Disconnection (Unplugging)
When connected to a development computer via a USB cable, Android automatically reports that the device is charging. To test battery-powered behaviour while keeping your ADB connection active, force the system to simulate being unplugged:
adb shell dumpsys battery unplug
Observe your device’s status bar: the charging lightning icon disappears, and Android begins reporting that it is running entirely on battery power.
Mocking Custom Battery Levels
To test how your application behaves under different battery levels, override the reported percentage using the set level parameter (accepts values from 0 to 100):
# Simulate low battery warning threshold (15%)
adb shell dumpsys battery set level 15
# Simulate critical battery threshold (5%)
adb shell dumpsys battery set level 5
# Simulate fully charged state (100%)
adb shell dumpsys battery set level 100
Setting the level to 15% or lower immediately triggers Android’s system-level Battery Saver prompts and dispatches standard ACTION_BATTERY_LOW broadcast intents to listening applications.
Simulating Specific Charger Types and Status Codes
You can simulate specific power sources and charging states:
# Simulate AC wall charger connection
adb shell dumpsys battery set ac 1
# Simulate USB charging port
adb shell dumpsys battery set usb 1
# Simulate Qi / Qi2 wireless charging pad
adb shell dumpsys battery set wireless 1
You can also simulate explicit charging status states using standard Android battery status integers:
# 1 = Unknown, 2 = Charging, 3 = Discharging, 4 = Not charging, 5 = Full
adb shell dumpsys battery set status 2
Simulating Battery Temperature and Thermal Throttling
Battery temperature is reported in tenths of a degree Celsius (e.g., a value of 295 corresponds to 29.5°C). To test how your application responds to thermal throttling and high-temperature safety cutoffs, simulate elevated temperatures:
# Simulate 48.0°C (thermal warning threshold)
adb shell dumpsys battery set temp 480
Resetting Battery Emulation to Real Hardware State
Once your testing is complete, restore the battery subsystem to read live hardware sensors:
adb shell dumpsys battery reset
Important: Always execute dumpsys battery reset after testing. If left in an emulated state, your device will not report genuine battery levels or recharge status until rebooted or reset.