set_battery
Set battery level (0-100) and charging state for deterministic testing of low-battery UI and charging-only logic. Use reset to restore automatic reporting.
Instructions
Set the battery level (0-100) and/or charging state — test low-battery UI and charging-only logic deterministically. On an emulator it uses the console (adb emu power); on a PHYSICAL device it forces the values via dumpsys battery, which persist until you call this again with reset=true (or the device reboots). Provide level, charging, or both — or reset=true to restore automatic reporting. (For a fake battery in a clean SCREENSHOT status bar only, use set_status_bar instead.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| level | No | Battery charge level 0-100. Omit to leave the level unchanged. | |
| reset | No | Restore automatic battery reporting (dumpsys battery reset) and ignore level/charging. On a physical device the forced values persist until this (or a reboot); use it to clean up after testing. | |
| serial | No | Target device serial (adb -s). Optional when exactly one device is attached. | |
| charging | No | true = plugged into AC, false = on battery. Omit to leave the charging state unchanged. |