---
name: android_shell
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "android_shell([--serial <S>], cmd ...args)"
description: "Execute arbitrary shell command on Android device. Multi-emulator via --serial."
tags: [android, adb, shell, exec, pendiente-usar]
params:
  - name: "--serial <S>"
    desc: "Optional target device serial. Omit to auto-pick (single device) or use ADB_SERIAL env."
  - name: "cmd ...args"
    desc: "Shell command + args to run on device. Variadic."
output: "Passthrough stdout/stderr de adb shell. Exit code = shell command exit."
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_shell.sh"
notes: "Para comandos complejos con pipes/redirects mejor `adb_s $serial shell 'cmd | other'` directo via adb_run."
---

## Ejemplo

```bash
android_shell pm list packages
android_shell --serial emulator-5554 getprop ro.product.model
android_shell df -h /sdcard
android_shell ls -la /data/local/tmp
```

## Notas

Sourcea `adb_wsl.sh` para resolver `adb_pick_serial` (maneja `--serial`, `ADB_SERIAL`, y auto-detect de dispositivo unico) y `adb_s` (wrapper de `adb -s`). El array `ADB_PICK_REST` contiene los args restantes tras consumir `--serial`.

Para comandos con pipes o redirects que bash interpretaria localmente, mejor pasar como string unico: `adb_s "$serial" shell 'cmd | grep foo'`.
