---
name: android_emu_battery
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "android_emu_battery([--serial <S>], level: int, [--charging <true|false>]) -> void"
description: "Simulate battery state on emulator (level + charging). Emulator-only."
tags: [android, emulator, battery, power, pendiente-usar]
params:
  - name: "--serial <S>"
    desc: "Optional emulator serial (e.g. emulator-5554). Auto-detected if omitted."
  - name: "level"
    desc: "Battery level 0-100 to set via 'emu power capacity'."
  - name: "--charging <true|false>"
    desc: "AC charging state: true maps to 'on', false maps to 'off'. Omit to leave unchanged."
output: "Stdout 'battery: <N>% [charging=...] on <serial>'. Exit 3 if no device found, exit 1 on other errors."
uses_functions: [adb_wsl_bash_infra]
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/android_emu_battery.sh"
notes: "Util para tests bateria baja, modo ahorro energia. Solo funciona con emuladores (serial emulator-*), no con devices fisicos."
---

## Ejemplo

```bash
# Nivel al 15%, sin cambiar estado de carga
android_emu_battery 15

# Nivel al 5%, forzar descarga (AC off)
android_emu_battery 5 --charging false

# Nivel al 80%, forzar carga (AC on), emulador concreto
android_emu_battery --serial emulator-5554 80 --charging true
```

## Notas

Util para tests de bateria baja y modo ahorro de energia. Solo funciona con emuladores Android
(serial debe empezar con `emulator-`). No aplica a dispositivos fisicos.

Requiere que `adb_wsl.sh` este en el mismo directorio. El ADB se resuelve via
`ANDROID_SDK_WIN` o la ruta por defecto de la instalacion Windows SDK.
