scripts: bridge-emulator.sh (host) + image prefetching
Perf work for the TV FPS complaint: every page that loads from the API also warms Coil's disk/memory caches (video thumbnails at the same 480x270 the card renders, channel banners/avatars) so rows scroll without popping in over the network. Prefetch keys match render keys exactly so cache hits are guaranteed. bridge-emulator.sh runs OUTSIDE the container on the emulator host: boots jtubesc if needed (ADB_VENDOR_KEYS whitelists the host adb key), installs/starts JTube TV and binds :5557 -> adbd 5601 so the container and LAN can drive it. Run it once in your rutherford shell.
This commit is contained in:
parent
0d583c9660
commit
cc1c1d1c9d
7 changed files with 122 additions and 1 deletions
42
scripts/bridge-emulator.sh
Executable file
42
scripts/bridge-emulator.sh
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# bridge-emulator.sh — (host-side) expose the emulator's adbd to the LAN so agents
|
||||
# inside the container/other machines can use it: binds :5557 -> 127.0.0.1:5601.
|
||||
# The emulator console transport (emulator-5600) stays local-only; this bridges the
|
||||
# adbd TCP port 5601.
|
||||
set -euo pipefail
|
||||
ADBD_PORT=5601
|
||||
BRIDGE_PORT=5557
|
||||
|
||||
# start emulator if not running
|
||||
ADB="${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}/platform-tools/adb"
|
||||
if ! "$ADB" devices | grep -q "emulator-5600.*device"; then
|
||||
echo "emulator-5600 not running — starting it…"
|
||||
ADB_VENDOR_KEYS="$HOME/.android/adbkey" setsid nohup \
|
||||
"${ANDROID_SDK_ROOT:-$HOME/Android/Sdk}/emulator/emulator" -avd jtubesc -port 5600 \
|
||||
-no-window -gpu swiftshader_indirect -no-snapshot -no-audio -no-boot-anim \
|
||||
> /tmp/jtube-emu.log 2>&1 < /dev/null &
|
||||
echo "waiting for boot (log: /tmp/jtube-emu.log)…"
|
||||
for i in $(seq 1 60); do
|
||||
ok=$("$ADB" -s emulator-5600 shell getprop sys.boot_completed 2>/dev/null | tr -d '\r')
|
||||
[ "$ok" = "1" ] && { echo "BOOTED"; break; }
|
||||
sleep 5
|
||||
done
|
||||
fi
|
||||
|
||||
# keep JTube TV installed + running
|
||||
APK="$HOME/Projects/jtube-tv/app/build/outputs/apk/debug/app-debug.apk"
|
||||
if [ -f "$APK" ]; then
|
||||
"$ADB" -s emulator-5600 install -r "$APK" >/dev/null && echo "JTube TV installed"
|
||||
"$ADB" -s emulator-5600 shell am start -n net.jeena.jtubetv/.MainActivity && echo "app started"
|
||||
fi
|
||||
|
||||
# the bridge (bind all LAN addresses)
|
||||
if ! ss -tln 2>/dev/null | grep -q ":$BRIDGE_PORT"; then
|
||||
setsid nohup socat TCP-LISTEN:$BRIDGE_PORT,bind=0.0.0.0,fork,reuseaddr \
|
||||
TCP:127.0.0.1:$ADBD_PORT > /tmp/jtube-bridge.log 2>&1 < /dev/null &
|
||||
echo "bridge: :$BRIDGE_PORT -> 127.0.0.1:$ADBD_PORT (pid $!)"
|
||||
fi
|
||||
|
||||
echo "From this host: adb connect localhost:$BRIDGE_PORT"
|
||||
echo "From other machines: adb connect rutherford:$BRIDGE_PORT"
|
||||
Loading…
Add table
Add a link
Reference in a new issue