Files
SoulStream/src-tauri/android/deploy.sh
T
KeelrLeek a44b4422fd android: the same SIGPIPE race, in the two focus checks it has not lost yet
deploy.sh and dev.sh both ask which app is on screen with
`echo "$FOCUS" | grep -qi`, under the same `set -o pipefail`. $FOCUS is one
line, so echo has always finished writing before grep -q exits and the race
has never been lost — but it is the identical shape that made verify-icon.sh
report a missing file in an APK that contained it. Herestrings, so there is no
writer to kill.
2026-09-15 07:48:09 -05:00

35 lines
1.8 KiB
Bash

#!/usr/bin/env bash
# frontend → detour build → install on the connected phone → launch → screenshot
set -euo pipefail
cd /f/Coding/SoulStream
export MSYS_NO_PATHCONV=1
ADB="$(cygpath -u "$LOCALAPPDATA")/Android/Sdk/platform-tools/adb.exe"
echo "== vite $(date +%T)"
npx vite build 2>&1 | grep -i "error\|built in" || true
bash src-tauri/android/build.sh
APK=src-tauri/gen/android/app/build/outputs/apk/arm64/debug/app-arm64-debug.apk
echo "== install $(date +%T)"
"$ADB" install -r "$APK" 2>&1 | tail -2
# the media card is a notification; a debug install grants the permission up
# front so the first play never stops on the system's dialog
"$ADB" shell pm grant com.soulstream.app android.permission.POST_NOTIFICATIONS 2>/dev/null || true
"$ADB" shell am force-stop com.soulstream.app
# launch and screenshot only when the phone is ours to drive: SoulStream or
# the launcher on screen. Never take the screen from another app.
FOCUS=$("$ADB" shell dumpsys window 2>/dev/null | grep -a "mCurrentFocus" | head -1)
# herestring, not `echo | grep -q`: grep -q exits on its match while echo is
# still writing, echo takes SIGPIPE, and the `pipefail` above promotes the
# dead writer's 141 to the pipeline — so the test reports "not focused" having
# just found SoulStream. $FOCUS is one line so it has never lost the race here,
# but it is the same bug that made verify-icon.sh answer fail/pass/fail to one
# unchanged APK.
if grep -qi "soulstream\|launcher" <<< "$FOCUS"; then
"$ADB" shell am start -n com.soulstream.app/.MainActivity >/dev/null
sleep 5
OUT="${SS_SHOT_DIR:-$(cygpath -u "$TEMP")}"
"$ADB" exec-out screencap -p > "$OUT/px-1.png"
echo "== shot $(date +%T) -> $OUT/px-1.png"
else
echo "== installed; not launched (the phone is in use: $FOCUS)"
fi