scripts: emulator-seed.sh — seed a fresh emulated device with the test account

This commit is contained in:
Jeena 2026-10-11 07:47:06 +00:00
parent b8893172d4
commit 28f0751e48

32
scripts/emulator-seed.sh Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# emulator-seed.sh — (container-side) log the freshly booted emulated device into the
# JTube test account via the debug-only seed intent. Usage:
# ./emulator-seed.sh emulator-5568 [serial]
set -euo pipefail
SERIAL="${1:-emulator-5568}"
ADB="${ANDROID_HOME:-$HOME/Android/Sdk}/platform-tools/adb"
[ -x "$ADB" ] && ADB="$ADB" || ADB="$(which adb)"
# credentials from the encrypted store
eval "$(sops -d --output-type dotenv "$HOME/.agents/secrets/jtube.env" | sed 's/^/export /')"
# kill + cold start so onCreate (the debug seeder) actually runs
"$ADB" -s "$SERIAL" shell am force-stop net.jeena.jtubetv 2>/dev/null || true
"$ADB" -s "$SERIAL" install -r "$HOME/Projects/jtube-tv/app/build/outputs/apk/debug/app-debug.apk" 2>&1 | tail -1
"$ADB" -s "$SERIAL" shell am start -a android.intent.action.MAIN \
-n net.jeena.jtubetv/.MainActivity \
--es jtube_url "$JTUBE_URL" \
--es jtube_user "$JTUBE_USER" \
--es jtube_pass "$JTUBE_PASS"
sleep 12
"$ADB" -s "$SERIAL" shell uiautomator dump /sdcard/ui.xml > /dev/null 2>&1
"$ADB" -s "$SERIAL" shell cat /sdcard/ui.xml | python3 -c "
import sys, re
xml = sys.stdin.read()
texts = [m.group(1) for m in re.finditer(r'text=\"([^\"]{2,40})\"', xml)]
foc = re.search(r'<node[^>]*focused=\"true\"[^>]*>', xml)
print('logged in as:', texts[0] if texts else '?')
print('rows/screens:', texts[1:8])"