# Android Control Matrix Orchestrator

`scripts/adb_control_matrix_orchestrator.mjs` is the batch runner for:

1. Discovering ADB devices (USB + wireless)
2. Deduplicating transports for one physical phone
3. Installing APK
4. Launching app
5. Mapping ADB device to server `deviceId`
6. Running control-panel smoke test
7. Applying ROM-specific recovery actions and retrying

## Quick start

Run with defaults:

```bash
npm run autotest:android-control
```

Dry run:

```bash
npm run autotest:android-control -- --dry-run --max-devices 2
```

Single device:

```bash
npm run autotest:android-control -- --only-serials 271d9738
```

## Common options

- `--build-apk`: build debug APK before testing
- `--apk <path>`: custom APK path
- `--server-http <url>`: override server HTTP endpoint
- `--socket-url <url>`: override socket endpoint for smoke script
- `--max-devices <n>`: limit tested devices
- `--attempts <n>`: override retry attempts
- `--skip-install`: skip APK install stage
- `--report <path>`: save matrix JSON to custom path

## ROM profile strategy

Built-in rule profiles:

- `oppo_family`
- `vivo_iqoo`
- `xiaomi_hyperos`
- `huawei_honor`
- `default`

Each profile controls:

- max attempts
- warning tolerance
- settle/wait timeout
- recovery action sequence

## Output

The matrix report contains:

- selected serial and deduped transports
- resolved `deviceId` mapping logic
- per-attempt install/launch/online/smoke details
- final pass/fail summary

