Skip to content

Commit 21f8eca

Browse files
committed
ci: make Android adb priming resilient
1 parent 54ac44e commit 21f8eca

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

scripts/prime_android_lab_adb.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

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.
812
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
1115
fi
1216

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
1320
adb kill-server >/dev/null 2>&1 || true
14-
adb start-server >/dev/null
21+
pkill -f '(^|/)adb( |$).*server' >/dev/null 2>&1 || true
1522

1623
ready=0
24+
: > /tmp/niakvio-adb-error.txt
1725
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
1928
ready=1
2029
break
2130
fi
22-
sleep 1
31+
adb kill-server >/dev/null 2>&1 || true
32+
sleep 2
2333
done
2434

2535
if [ "$ready" -ne 1 ]; then
2636
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
2939
fi
3040

3141
echo "FIELD_NATIVE_ADB_PRIME status=ready port=5037 runtime_mutation=false"

0 commit comments

Comments
 (0)