emu: Stop silent early exits in the emulator start script
The script's set -euo pipefail made it die without any visible error in two places: an empty /tmp/jtube-adbkeys/ failed the glob cat (the error itself was discarded, so the output just stopped mid-script — this hits any host after a reboot), and the boot-wait loop was killed on its first iteration because adb exits non-zero while the device is still booting. Both were swallowing the whole && chain (adb connect, scrcpy), making it look like the emulator was broken when it was fine or about to be. The stale bridge-emulator.sh duplicate (different port, broken vendor keys path) is removed in the same spirit — keeping it invites running the wrong script. Docs updated to match the one script.
This commit is contained in:
parent
c19024355c
commit
a71de07969
3 changed files with 22 additions and 49 deletions
|
|
@ -62,11 +62,13 @@ if [ "$MODE" = windowed ]; then
|
|||
else
|
||||
echo "JTUBE_EMU_MODE=windowed but no display detected — falling back to headless"
|
||||
WINDOWED=0
|
||||
ACCEL+=(-no-window)
|
||||
ACCEL+=(-no-window -gpu swiftshader_indirect)
|
||||
fi
|
||||
else
|
||||
WINDOWED=0
|
||||
ACCEL+=(-no-window)
|
||||
# Headless has no X display, so -gpu host/GLX can't init EGL ("Failed to get EGL
|
||||
# display") and the emulator dies on launch — fall back to software rendering.
|
||||
ACCEL+=(-no-window -gpu swiftshader_indirect)
|
||||
echo "headless (default; JTUBE_EMU_MODE=windowed for a window) — no emulator window"
|
||||
fi
|
||||
if [ -e /dev/kvm ]; then
|
||||
|
|
@ -79,21 +81,27 @@ fi
|
|||
# blocked, so remote keys are trusted via ADB_VENDOR_KEYS at launch instead.
|
||||
# Drop extra public keys into /tmp/jtube-adbkeys/ (one per file), e.g. from the
|
||||
# agent container: docker exec <ctr> sh -c 'cat ~/.android/adbkey.pub' > /tmp/jtube-adbkeys/agent-container.pub
|
||||
mkdir -p /tmp/jtube-adbkeys
|
||||
VKEYS=/tmp/jtube-adbkeys-combined
|
||||
{
|
||||
cat "$HOME/.android/adbkey.pub"
|
||||
cat /tmp/jtube-adbkeys/*.pub 2>/dev/null
|
||||
# Optional extra keys — must not fail the script under `set -e` when absent.
|
||||
shopt -s nullglob
|
||||
for k in /tmp/jtube-adbkeys/*.pub; do cat "$k"; done
|
||||
shopt -u nullglob
|
||||
} > "$VKEYS"
|
||||
chmod 600 "$VKEYS"
|
||||
|
||||
echo "Booting AVD '$AVD' …"
|
||||
ADB_VENDOR_KEYS="$VKEYS" setsid nohup "$EMU" -avd "$AVD" -port "$PORT" -gpu host "${ACCEL[@]:-}" \
|
||||
ADB_VENDOR_KEYS="$VKEYS" setsid nohup "$EMU" -avd "$AVD" -port "$PORT" "${ACCEL[@]:-}" \
|
||||
-no-snapshot > /tmp/jtube-emu.log 2>&1 < /dev/null &
|
||||
echo "emulator PID $! — log: /tmp/jtube-emu.log"
|
||||
|
||||
for i in $(seq 1 90); do
|
||||
ok=$("$ADB" -s "emulator-$PORT" shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')
|
||||
[ "$ok" = "1" ] && { echo "BOOTED"; break; }
|
||||
# adb exits non-zero while the device is still booting — don't let
|
||||
# pipefail+set -e kill the wait loop.
|
||||
ok=$( ("$ADB" -s "emulator-$PORT" shell getprop sys.boot_completed 2>/dev/null || true) | tr -d '\r')
|
||||
if [ "$ok" = "1" ]; then echo "BOOTED"; break; fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue