|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -euo pipefail |
3 | 3 |
|
4 | | -# Hosted Android readers occasionally enter the emulator action with no adb |
5 | | -# daemon listening on 5037. Prime the production SDK bridge before an AVD is |
6 | | -# launched. This is Lab-only orchestration: it never changes Nuvio runtime code, |
7 | | -# app manifests, provider JS or player/network behavior. |
| 4 | +# Hosted Android readers can enter the emulator action while the SDK bridge is |
| 5 | +# absent, stale, or temporarily unable to bind port 5037. This preflight is |
| 6 | +# deliberately best-effort: the emulator runner remains the authority for ADB |
| 7 | +# availability once an AVD is launched. A transient host-side ADB failure must |
| 8 | +# therefore never prevent the real native reader from being attempted. |
| 9 | +# |
| 10 | +# Lab-only orchestration: this never changes Nuvio runtime code, app manifests, |
| 11 | +# provider JS, player behavior, or network behavior. |
8 | 12 | if ! command -v adb >/dev/null 2>&1; then |
9 | | - echo "FIELD_NATIVE_ADB_PRIME status=missing_adb runtime_mutation=false" >&2 |
10 | | - exit 1 |
| 13 | + echo "FIELD_NATIVE_ADB_PRIME status=missing_adb fallback=emulator_runner runtime_mutation=false" >&2 |
| 14 | + exit 0 |
11 | 15 | fi |
12 | 16 |
|
| 17 | +# A hosted runner may inherit a custom server socket or a stale daemon. Force |
| 18 | +# the normal local SDK bridge and clean up only host-side adb state. |
| 19 | +unset ADB_SERVER_SOCKET || true |
13 | 20 | adb kill-server >/dev/null 2>&1 || true |
14 | | -adb start-server >/dev/null |
| 21 | +pkill -f '(^|/)adb( |$).*server' >/dev/null 2>&1 || true |
15 | 22 |
|
16 | 23 | ready=0 |
| 24 | +: > /tmp/niakvio-adb-error.txt |
17 | 25 | for _attempt in 1 2 3 4 5; do |
18 | | - if adb devices >/tmp/niakvio-adb-devices.txt 2>/tmp/niakvio-adb-error.txt; then |
| 26 | + if adb start-server >/tmp/niakvio-adb-start.txt 2>>/tmp/niakvio-adb-error.txt \ |
| 27 | + && adb devices >/tmp/niakvio-adb-devices.txt 2>>/tmp/niakvio-adb-error.txt; then |
19 | 28 | ready=1 |
20 | 29 | break |
21 | 30 | fi |
22 | | - sleep 1 |
| 31 | + adb kill-server >/dev/null 2>&1 || true |
| 32 | + sleep 2 |
23 | 33 | done |
24 | 34 |
|
25 | 35 | if [ "$ready" -ne 1 ]; then |
26 | 36 | cat /tmp/niakvio-adb-error.txt >&2 || true |
27 | | - echo "FIELD_NATIVE_ADB_PRIME status=unavailable runtime_mutation=false" >&2 |
28 | | - exit 1 |
| 37 | + echo "FIELD_NATIVE_ADB_PRIME status=degraded fallback=emulator_runner runtime_mutation=false" >&2 |
| 38 | + exit 0 |
29 | 39 | fi |
30 | 40 |
|
31 | 41 | echo "FIELD_NATIVE_ADB_PRIME status=ready port=5037 runtime_mutation=false" |
0 commit comments