---
name: android_app_info
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "android_app_info([--serial <S>], package, [--json]) -> stdout"
description: "Inspect installed app: version, target SDK, activities via dumpsys package."
tags: [android, adb, app, info, dumpsys, pendiente-usar]
params:
  - name: "--serial <S>"
    desc: "Optional ADB serial to target a specific device/emulator. Auto-detected if omitted."
  - name: "package"
    desc: "Android package name to inspect (e.g. com.example.myapp)."
  - name: "--json"
    desc: "Emit parsed JSON with versionName, versionCode, targetSdk, launcherActivity instead of raw dumpsys output."
output: "Raw dumpsys package output, or JSON object {package, versionName, versionCode, targetSdk, launcherActivity}. Outputs JSON null if package not installed (--json mode). Exit 2 if package not found in raw mode, exit 3 if no device."
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_app_info.sh"
---

## Ejemplo

```bash
# Raw dumpsys (full output)
source bash/functions/infra/android_app_info.sh
android_app_info com.example.myapp

# Target specific device
android_app_info --serial emulator-5554 com.example.myapp

# Parsed JSON
android_app_info com.example.myapp --json
# {"package":"com.example.myapp","versionName":"2.1.0","versionCode":210,"targetSdk":34,"launcherActivity":"com.example.myapp/.MainActivity"}

# Package not installed → JSON null
android_app_info com.not.installed --json
# null
```

## Notas

- Sources `adb_wsl.sh` para resolver el binario ADB Windows desde WSL2 y las helpers `adb_pick_serial` / `adb_s`.
- `--serial` se consume via `adb_pick_serial`; el resto de los args quedan en `ADB_PICK_REST` y se re-asignan con `set --`.
- JSON parsing usa `grep`/`sed`/`awk` sobre la salida de `dumpsys package`. Campos faltantes se emiten como string vacío o 0; no se usa `jq` para no requerir dependencias externas.
- `launcherActivity` se extrae buscando el bloque `android.intent.action.MAIN` / `android.intent.category.LAUNCHER` en el listado de intent filters.
- Exit codes: 0 = OK, 1 = arg/adb error, 2 = package not found (raw mode), 3 = no device.
---
